From 51c3aabbfc8a6adb2473c0371f231026571f18b7 Mon Sep 17 00:00:00 2001 From: Michael Campagnaro Date: Mon, 9 Sep 2019 15:31:47 -0400 Subject: [PATCH] Rearrange some vimrc functions --- vimrc | 81 +++++++++++++++++++++++++++++++---------------------------- 1 file changed, 42 insertions(+), 39 deletions(-) diff --git a/vimrc b/vimrc index 63daffe..65373c7 100644 --- a/vimrc +++ b/vimrc @@ -98,11 +98,11 @@ if IsWindows() else " Fuzzy search " @incomplete Test out ctrlp for non-Windows setup. - Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' } - Plug 'junegunn/fzf.vim' + " Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' } + " Plug 'junegunn/fzf.vim' " @fixme Doesn't do anything under Windows... - Plug 'ervandew/supertab' " Improved autocompletion. + " Plug 'ervandew/supertab' " Improved autocompletion. endif "/////////////////// @@ -895,19 +895,52 @@ nnoremap :cp """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -" SEARCHING +" SEARCH """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -" Search using ripgrep (first install with Rust: cargo install ripgrep) -" Ignores vendor folder. if !IsWindows() command! -bang -nargs=* Find call fzf#vim#grep('rg --column --line-number --no-heading --fixed-strings --ignore-case --no-ignore --hidden --follow --glob "!vendor/*" --pretty "always" '.shellescape(), 1, 0) endif -" TODO: Not sure if I still need this -map gs :let @/ = "" +" Search using ripgrep (first install with Rust: cargo install ripgrep) +" Ignores vendor folder. +function! Search(case_sensitive) + let helper = "[" . (a:case_sensitive ? "case-sensitive" : "case-insensitive") . "] search: " + let term = input(helper) + if empty(term) + return + endif -" Replace the selected text in all files within the repo + "@note --pretty (i.e. colors) is not enabled in vim-ripgrep because the + "quickfix window doesn't seem to parse the ansi color codes. + let rg_args = "--trim -g \"!vendor/*\"" + + if !a:case_sensitive + let rg_args .= " --ignore-case" + endif + + if IsWindows() + exec 'Rg ' . rg_args . ' "' . term . '"' + else + " @incomplete Test out ripgrep on non-Windows OS + echo "Not implemented" + endif +endfunction +map s :call Search(0) +map ss :call Search(1) + +" Navigation for the vim-ripgrep search results. +" Hit o on a result line to open the file at that line. +" Hit p on a result line to open the file at that line and return to the results pane. +nnoremap o (&buftype is# "quickfix" ? "\|:lopen" : "o") +nnoremap p (&buftype is# "quickfix" ? "\|:copen" : "p") + + +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" SEARCH & REPLACE +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" + +" Replace the selected text in all files within the repo. function! GlobalReplaceIt(confirm_replacement) if exists(':Ggrep') call inputsave() @@ -939,36 +972,6 @@ endfunction map gg :call GlobalReplaceIt(0) map gr :call GlobalReplaceIt(1) -function! Search(case_sensitive) - let helper = "[" . (a:case_sensitive ? "case-sensitive" : "case-insensitive") . "] search: " - let term = input(helper) - if empty(term) - return - endif - - "@note --pretty (i.e. colors) is not enabled in vim-ripgrep because the - "quickfix window doesn't seem to parse the ansi color codes. - let rg_args = "--trim -g \"!vendor/*\"" - - if !a:case_sensitive - let rg_args .= " --ignore-case" - endif - - if IsWindows() - exec 'Rg ' . rg_args . ' "' . term . '"' - else - " @incomplete Test out ripgrep on non-Windows OS - echo "Not implemented" - endif -endfunction -map s :call Search(0) -map ss :call Search(1) - -" Navigation for the vim-ripgrep search results. -" Hit o on a result line to open the file at that line. -" Hit p on a result line to open the file at that line and return to the results pane. -nnoremap o (&buftype is# "quickfix" ? "\|:lopen" : "o") -nnoremap p (&buftype is# "quickfix" ? "\|:copen" : "p") """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " RENAME CURRENT FILE