From 70acf70f0bdfb0da95905ea974ab29f45c1eec97 Mon Sep 17 00:00:00 2001 From: Dmytro Meleshko Date: Sun, 25 Apr 2021 20:48:46 +0300 Subject: [PATCH] [nvim] entirely get rid of the CtrlSF plugin --- nvim/dotfiles/plugins-list.vim | 3 --- nvim/plugin/files.vim | 29 +++++++++++++++++++++-------- 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/nvim/dotfiles/plugins-list.vim b/nvim/dotfiles/plugins-list.vim index c08d2bf..ff2ce70 100644 --- a/nvim/dotfiles/plugins-list.vim +++ b/nvim/dotfiles/plugins-list.vim @@ -43,9 +43,6 @@ Plug 'vim-airline/vim-airline' Plug 'tpope/vim-obsession' Plug 'romainl/vim-qf' - if g:vim_ide - Plug 'dyng/ctrlsf.vim' - endif " }}} " Git {{{ diff --git a/nvim/plugin/files.vim b/nvim/plugin/files.vim index 14fa58f..da700db 100644 --- a/nvim/plugin/files.vim +++ b/nvim/plugin/files.vim @@ -20,6 +20,23 @@ nnoremap empty(&buftype) ? ":writewall\" : "\" command! -bang -nargs=* Rg call fzf#vim#grep(s:rg_cmd . ' --column --line-number --no-heading --fixed-strings --smart-case --color always ' . shellescape(), 1, 0) command! -bang -nargs=* Find Rg endif + + nnoremap / :grep + + function! s:grep_mapping_star_normal() + let word = expand("") + if !empty(word) + call feedkeys(":\grep " . shellescape('\b' . word . '\b'), 'n') + endif + endfunction + function! s:grep_mapping_star_visual() + let tmp = @" + normal! y + call feedkeys(":\grep " . shellescape(@"), 'n') + let @" = tmp + endfunction + nnoremap * call grep_mapping_star_normal() + xnoremap * call grep_mapping_star_visual() " }}} @@ -29,7 +46,10 @@ nnoremap empty(&buftype) ? ":writewall\" : "\" let g:loaded_netrwPlugin = 1 " re-add Netrw's gx mappings since we've disabled them nnoremap gx call netrw#BrowseX(expand(''),netrw#CheckIfRemote()) - xnoremap gx call netrw#BrowseXVis() + " This one can be rewritten in a way to not clobber the yank register... + " Most notably, the built-in mapping, which uses netrw#BrowseXVis(), doesn't + " work and breaks the editor, at least for me. + xnoremap gx y:call netrw#BrowseX(@",netrw#CheckIfRemote()) " }}} @@ -176,10 +196,3 @@ nnoremap empty(&buftype) ? ":writewall\" : "\" augroup END " }}} - - -" CtrlSF {{{ - nmap / CtrlSFPrompt - nmap * CtrlSFCwordPath - xmap * CtrlSFVwordPath -" }}}