Last active
September 22, 2022 21:41
-
-
Save gabrieljoelc/f01f2eef6cff4a751261fff97ae6be0a to your computer and use it in GitHub Desktop.
Mac vim config
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" GistID: f01f2eef6cff4a751261fff97ae6be0a | |
set number | |
syntax on | |
let base16colorspace=256 | |
colorscheme base16-tomorrow-night-eighties | |
"set termguicolors | |
filetype plugin indent on | |
" show existing tab with 2 spaces width | |
set tabstop=2 | |
" when indenting with '>', use 2 spaces width | |
set shiftwidth=2 | |
" On pressing tab, insert 2 spaces | |
set expandtab | |
" see https://www.johnhawthorn.com/2012/09/vi-escape-delays/ | |
set timeoutlen=1000 ttimeoutlen=0 | |
" soft wrapping http://vim.wikia.com/wiki/Automatic_word_wrapping | |
set wrap linebreak nolist | |
" use this: https://stackoverflow.com/a/18553778/34315 | |
" and then this: | |
" macOS clipboard sharing http://www.alecjacobson.com/weblog/?p=1162 and | |
" http://vim.wikia.com/wiki/Mac_OS_X_clipboard_sharing. Doesn't work right now | |
set clipboard=unnamed | |
set runtimepath^=~/.vim/bundle/ctrlp.vim | |
"set runtimepath^=~/.vim/bundle/ultisnips | |
"set runtimepath^=~/.vim/bundle/asyncomplete.vim | |
"set runtimepath^=~/.vim/bundle/omnisharp-vim | |
set runtimepath^=~/.vim/bundle/limelight.vim | |
set runtimepath^=~/.vim/bundle/goyo.vim | |
set runtimepath^=~/.vim/bundle/webapi-vim | |
set runtimepath^=~/.vim/bundle/gist-vim | |
set runtimepath^=~/.vim/bundle/typescript-vim | |
set runtimepath^=~/.vim/bundle/coc.nvim | |
"set runtimepath^=~/.vim/bundle/dart-vim-plugin/plugin | |
"set runtimepath^=~/.vim/bundle/rust.vim | |
"set runtimepath^=~/.vim/bundle/vim-jsx-typescript/ftdetect/typescript.vim | |
" this repo is deprecated | |
"set runtimepath^=~/.vim/colors/Tomorrow-Night-Eighties.vim | |
" uses git's cache of files and includes unstaged files (see https://news.ycombinator.com/item?id=4470283) | |
"let g:ctrlp_user_command = ['.git/', 'cd %s && git ls-files --exclude-standard -co'] | |
" Don't autoselect first omnicomplete option, show options even if there is only | |
" one (so the preview documentation is accessible). Remove 'preview' if you | |
" don't want to see any documentation whatsoever. | |
set completeopt=longest,menuone,preview | |
" Set desired preview window height for viewing documentation. | |
" You might also want to look at the echodoc plugin. | |
set previewheight=5 | |
" Opens quickfix in newtab https://stackoverflow.com/a/6853779/34315 | |
set switchbuf+=newtab | |
" CoC extensions | |
let g:coc_global_extensions = ['coc-tsserver'] | |
" Remap keys for applying codeAction to the current line. | |
nmap <leader>ac <Plug>(coc-codeaction) | |
" Apply AutoFix to problem on the current line. | |
nmap <leader>qf <Plug>(coc-fix-current) | |
" GoTo code navigation. | |
nmap <silent> gd <Plug>(coc-definition) | |
nmap <silent> gy <Plug>(coc-type-definition) | |
nmap <silent> gi <Plug>(coc-implementation) | |
nmap <silent> gr <Plug>(coc-references) | |
" Use tab for trigger completion with characters ahead and navigate. | |
" NOTE: Use command ':verbose imap <tab>' to make sure tab is not mapped by | |
" other plugin before putting this into your config. | |
inoremap <silent><expr> <TAB> | |
\ pumvisible() ? "\<C-n>" : | |
\ <SID>check_back_space() ? "\<TAB>" : | |
\ coc#refresh() | |
inoremap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<C-h>" | |
" i downloaded https://github.com/OmniSharp/omnisharp-roslyn/releases/download/v1.36.1/omnisharp-osx.tar.gz for the mac | |
let g:OmniSharp_server_path = '/Users/gabe/.omnisharp/omnisharp-roslyn/run' | |
"let g:OmniSharp_server_use_mono = 1 | |
let g:OmniSharp_selector_ui = 'ctrlp' | |
let g:OmniSharp_server_stdio = 1 | |
"let g:OmniSharp_proc_debug = 1 | |
"let g:OmniSharp_loglevel = 'debug' | |
"let g:OmniSharp_timeout=3 | |
" Update semantic highlighting on BufEnter and InsertLeave | |
let g:OmniSharp_highlight_types = 2 | |
augroup omnisharp_commands | |
autocmd! | |
" Show type information automatically when the cursor stops moving | |
" deprecated version | |
" autocmd CursorHold *.cs call OmniSharp#TypeLookupWithoutDocumentation() | |
autocmd CursorHold *.cs OmniSharpTypeLookup | |
" The following commands are contextual, based on the cursor position. | |
autocmd FileType cs nnoremap <buffer> gd :OmniSharpGotoDefinition<CR> | |
autocmd FileType cs nnoremap <buffer> <Leader>fi :OmniSharpFindImplementations<CR> | |
autocmd FileType cs nnoremap <buffer> <Leader>fs :OmniSharpFindSymbol<CR> | |
autocmd FileType cs nnoremap <buffer> <Leader>fu :OmniSharpFindUsages<CR> | |
" Finds members in the current buffer | |
autocmd FileType cs nnoremap <buffer> <Leader>fm :OmniSharpFindMembers<CR> | |
autocmd FileType cs nnoremap <buffer> <Leader>fx :OmniSharpFixUsings<CR> | |
autocmd FileType cs nnoremap <buffer> <Leader>tt :OmniSharpTypeLookup<CR> | |
autocmd FileType cs nnoremap <buffer> <Leader>dc :OmniSharpDocumentation<CR> | |
autocmd FileType cs nnoremap <buffer> <C-\> :OmniSharpSignatureHelp<CR> | |
autocmd FileType cs inoremap <buffer> <C-\> <C-o>:OmniSharpSignatureHelp<CR> | |
" Navigate up and down by method/property/field | |
autocmd FileType cs nnoremap <buffer> <C-k> :OmniSharpNavigateUp<CR> | |
autocmd FileType cs nnoremap <buffer> <C-j> :OmniSharpNavigateDown<CR> | |
" Find all code errors/warnings for the current solution and populate the quickfix window | |
autocmd FileType cs nnoremap <buffer> <Leader>cc :OmniSharpGlobalCodeCheck<CR> | |
autocmd FileType cs nnoremap <buffer> <Leader>u :OmniSharpRunTest<CR> | |
autocmd FileType cs nnoremap <buffer> <Leader>ua :OmniSharpRunTestsInFile<CR> | |
augroup END | |
" Contextual code actions (uses fzf, CtrlP or unite.vim when available) | |
nnoremap <Leader><Space> :OmniSharpGetCodeActions<CR> | |
" Run code actions with text selected in visual mode to extract method | |
xnoremap <Leader><Space> :call OmniSharp#GetCodeActions('visual')<CR> | |
" Rename with dialog | |
nnoremap <Leader>nm :OmniSharpRename<CR> | |
nnoremap <F2> :OmniSharpRename<CR> | |
" Rename without dialog - with cursor on the symbol to rename: `:Rename newname` | |
command! -nargs=1 Rename :call OmniSharp#RenameTo("<args>") | |
nnoremap <Leader>cf :OmniSharpCodeFormat<CR> | |
" Start the omnisharp server for the current solution | |
nnoremap <Leader>ss :OmniSharpStartServer<CR> | |
nnoremap <Leader>sp :OmniSharpStopServer<CR> | |
" Enable snippet completion | |
let g:OmniSharp_want_snippet=1 | |
" vimspector | |
let g:vimspector_enable_mappings = 'HUMAN' | |
" see https://robots.thoughtbot.com/faster-grepping-in-vim | |
if executable('ag') | |
" Use ag over grep | |
set grepprg=ag\ --nogroup\ --nocolor | |
" Use ag in CtrlP for listing files. Lightning fast and respects .gitignore | |
"let g:ctrlp_user_command = 'ag %s -l --nocolor -g ""' | |
" https://github.com/kien/ctrlp.vim/issues/58#issuecomment-247017402 | |
let g:ctrlp_user_command = 'ag %s -l --nocolor --hidden -g ""' | |
" ag is fast enough that CtrlP doesn't need to cache | |
let g:ctrlp_use_caching = 0 | |
" bind K to grep word under cursor | |
nnoremap K :grep! "\b<C-R><C-W>\b"<CR>:cw<CR> | |
endif | |
" allow backspacing over everything in insert mode. only needed for mac vim | |
" (homebrew version). see https://stackoverflow.com/a/3534090/34315 | |
set backspace=indent,eol,start | |
" Color name (:help cterm-colors) or ANSI code | |
let g:limelight_conceal_ctermfg = 'gray' | |
let g:limelight_conceal_ctermfg = 240 | |
" Color name (:help gui-colors) or RGB color | |
let g:limelight_conceal_guifg = 'DarkGray' | |
let g:limelight_conceal_guifg = '#777777' | |
" Default: 0.5 | |
let g:limelight_default_coefficient = 0.7 | |
" Number of preceding/following paragraphs to include (default: 0) | |
let g:limelight_paragraph_span = 2 | |
" Beginning/end of paragraph | |
" When there's no empty line between the paragraphs | |
" and each paragraph starts with indentation | |
"let g:limelight_bop = '^\s' | |
"let g:limelight_eop = '\ze\n^\s' | |
" Highlighting priority (default: 10) | |
" Set it to -1 not to overrule hlsearch | |
let g:limelight_priority = -1 | |
" https://github.com/junegunn/goyo.vim/blob/master/README.md#callbacks | |
function! s:goyo_enter() | |
silent !tmux set status off | |
silent !tmux list-panes -F '\#F' | grep -q Z || tmux resize-pane -Z | |
set noshowmode | |
set noshowcmd | |
set scrolloff=999 | |
Limelight | |
" ... | |
endfunction | |
function! s:goyo_leave() | |
silent !tmux set status on | |
silent !tmux list-panes -F '\#F' | grep -q Z && tmux resize-pane -Z | |
set showmode | |
set showcmd | |
set scrolloff=5 | |
Limelight! | |
" ... | |
endfunction | |
autocmd! User GoyoEnter nested call <SID>goyo_enter() | |
autocmd! User GoyoLeave nested call <SID>goyo_leave() | |
cnoreabbrev <expr> ut ((getcmdtype() is# ':' && getcmdline() is# 'ut')?('OmniSharpRunTest'):('ut')) | |
" gist-vim config | |
let g:gist_get_multiplefile = 1 | |
let g:gist_clip_command = 'pbcopy' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment