From 0c5cadaea6812dcecf234af82653ae90411eee2d Mon Sep 17 00:00:00 2001 From: Jonathan Hodgson Date: Fri, 30 Jul 2021 10:50:27 +0100 Subject: [PATCH] VIM: Setup ripgrep and inccommand RIPGREP ripgrep is now my grep command and I can use [c and ]c for moving between quickfix entries INCCOMMAND Setting this makes vim show the results of substitute commands as they are types --- nvim/.config/nvim/plugin/mappings.vim | 3 ++ nvim/.config/nvim/plugin/omnisharp.vim | 41 ++++++++++++++++++++++++++ nvim/.config/nvim/plugin/settings.vim | 8 +++++ 3 files changed, 52 insertions(+) create mode 100644 nvim/.config/nvim/plugin/omnisharp.vim diff --git a/nvim/.config/nvim/plugin/mappings.vim b/nvim/.config/nvim/plugin/mappings.vim index aafac9ab..aa86e1e6 100644 --- a/nvim/.config/nvim/plugin/mappings.vim +++ b/nvim/.config/nvim/plugin/mappings.vim @@ -75,3 +75,6 @@ vnoremap / /\v " Makes vim re-select visual selection when using < or > vnoremap < >gv + +nnoremap [c :cprevious +nnoremap ]c :cnext diff --git a/nvim/.config/nvim/plugin/omnisharp.vim b/nvim/.config/nvim/plugin/omnisharp.vim new file mode 100644 index 00000000..79399f0e --- /dev/null +++ b/nvim/.config/nvim/plugin/omnisharp.vim @@ -0,0 +1,41 @@ +"let g:OmniSharp_highlighting = 0 +let g:OmniSharp_selector_ui = 'fzf' + +augroup omnisharp_commands + autocmd! + + " Show type information automatically when the cursor stops moving. + " Note that the type is echoed to the Vim command line, and will overwrite + " any other messages in this space including e.g. ALE linting messages. + "autocmd CursorHold *.cs OmniSharpTypeLookup + + " The following commands are contextual, based on the cursor position. + autocmd FileType cs nmap (omnisharp_go_to_definition) + autocmd FileType cs nmap osfi (omnisharp_find_implementations) + autocmd FileType cs nmap ospd (omnisharp_preview_definition) + autocmd FileType cs nmap ospi (omnisharp_preview_implementations) + autocmd FileType cs nmap K (omnisharp_type_lookup) + autocmd FileType cs nmap osd (omnisharp_documentation) + autocmd FileType cs nmap osfs (omnisharp_find_symbol) + autocmd FileType cs nmap osfx (omnisharp_fix_usings) + + " Navigate up and down by method/property/field + autocmd FileType cs nmap [[ (omnisharp_navigate_up) + autocmd FileType cs nmap ]] (omnisharp_navigate_down) + " Find all code errors/warnings for the current solution and populate the quickfix window + autocmd FileType cs nmap osgcc (omnisharp_global_code_check) + " Contextual code actions (uses fzf, vim-clap, CtrlP or unite.vim selector when available) + autocmd FileType cs nmap osca (omnisharp_code_actions) + autocmd FileType cs xmap osca (omnisharp_code_actions) + " Repeat the last code action performed (does not use a selector) + autocmd FileType cs nmap os. (omnisharp_code_action_repeat) + autocmd FileType cs xmap os. (omnisharp_code_action_repeat) + + autocmd FileType cs nmap os= (omnisharp_code_format) + + autocmd FileType cs nmap osnm (omnisharp_rename) + + autocmd FileType cs nmap osre (omnisharp_restart_server) + autocmd FileType cs nmap osst (omnisharp_start_server) + autocmd FileType cs nmap ossp (omnisharp_stop_server) +augroup END diff --git a/nvim/.config/nvim/plugin/settings.vim b/nvim/.config/nvim/plugin/settings.vim index 27dd5649..59ec690b 100644 --- a/nvim/.config/nvim/plugin/settings.vim +++ b/nvim/.config/nvim/plugin/settings.vim @@ -49,6 +49,14 @@ set formatoptions+=r " Automatically insert comment leader after hitting o or O set formatoptions+=o +" Show the results of the substitute command as you type +set inccommand=nosplit + +if executable('rg') + set grepprg=rg\ --vimgrep\ --no-heading\ --color=never\ --glob=\"!shell-logs/*\" + set grepformat=%f:%l:%c:%m,%f:%l:%m +endif + augroup colorcols autocmd! autocmd FileType,VimEnter,BufEnter * call mine#functions#colorcols()