diff --git a/.gitignore b/.gitignore index bc16b27..93b0170 100644 --- a/.gitignore +++ b/.gitignore @@ -3,5 +3,10 @@ !/.gitignore !/programs + /programs/nvim/* !/programs/nvim/init.vim +!/programs/nvim/plugins + +/programs/tmux/* +!/programs/tmux/.tmux.conf diff --git a/programs/nvim/plugins/grep-operator.vim b/programs/nvim/plugins/grep-operator.vim new file mode 100644 index 0000000..6ac7a98 --- /dev/null +++ b/programs/nvim/plugins/grep-operator.vim @@ -0,0 +1,23 @@ +nnoremap g :set operatorfunc=GrepOperatorg@ +vnoremap g :call GrepOperator(visualmode()) + +nnoremap cj :cnext +nnoremap ck :cprev + +function! s:GrepOperator(type) + let saved_unnamed_register = @@ + + if a:type ==# 'v' + exe "normal! `y" + elseif a:type ==# 'char' + exe "normal! `[v`]y" + else + return + endif + + silent exe ":grep! -R " . shellescape(@@) . " ." + copen + + let @@ = saved_unnamed_register +endfunction +