diff --git a/vimrc b/vimrc index 7bb6565..4d05c38 100644 --- a/vimrc +++ b/vimrc @@ -45,7 +45,6 @@ let s:rainbow_theme = s:default_bg "################################################################ "################################################################ - call plug#begin('~/.vim/plugged') "//////////////////////////////////////////////////////////////// @@ -54,29 +53,27 @@ call plug#begin('~/.vim/plugged') Plug 'bling/vim-airline' Plug 'vim-scripts/AnsiEsc.vim' -Plug 'embear/vim-localvimrc' -Plug 'tpope/vim-obsession' " Continuously updated session files -Plug 'tpope/vim-fugitive' " Git wrapper -Plug 'junegunn/goyo.vim' " Distraction-free mode with centered buffer +Plug 'embear/vim-localvimrc' " Add a .lvimrc to a folder to override .vimrc config. +Plug 'tpope/vim-obsession' " Continuously updated session files +Plug 'tpope/vim-fugitive' " Git wrapper +Plug 'junegunn/goyo.vim' " Distraction-free mode with centered buffer +Plug 'jremmen/vim-ripgrep' " Wrapper around ripgrep (must intall ripgrep first; use Rust: cargo install ripgrep) +Plug 'itchyny/vim-cursorword' " Underlines the word under the cursor +Plug 'airblade/vim-gitgutter' " See git diff in the gutter and stage/unstage hunks. + if IsWindows() Plug 'suxpert/vimcaps' " Disable capslock (useful if the OS isn't configured to do so) -endif - -Plug 'itchyny/vim-cursorword' " Underlines the word under the cursor -" (MAYBE) Plug 'itchyny/vim-winfix' - -Plug 'airblade/vim-gitgutter' - -if !IsWindows() +else Plug 'Shougo/vimproc.vim', {'do' : 'make'} Plug 'itchyny/dictionary.vim' " A way to query dictionary.com with :Dictionary + + " Fuzzy search + Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' } + Plug 'junegunn/fzf.vim' endif -" Automatically discover and 'properly' update ctags files on save -"Plug 'craigemery/vim-autotag' Plug 'majutsushi/tagbar' - Plug 'jeetsukumaran/vim-filesearch' Plug 'rking/ag.vim' Plug 'nelstrom/vim-qargs' " For search and replace @@ -92,10 +89,20 @@ Plug 'tommcdo/vim-kangaroo' Plug 'skywind3000/asyncrun.vim' Plug 'mh21/errormarker.vim' -" Plug 'shougo/unite.vim' # Create user interfaces. Not currently needed. -" DISABLED since it requires vim 7.3.598+ and I don't have that on my macbook -" Plug 'Valloric/YouCompleteMe' +"/////////////////// +" MAYBE SOME DAY +"/////////////////// +"Plug 'shougo/unite.vim' " Create user interfaces. Not currently needed. +"Plug 'itchyny/vim-winfix' " Fix the focus and the size of windows in Vim +"/////////////////// +" DISABLED +"/////////////////// +" I don't think I need this anymore... +"Plug 'craigemery/vim-autotag' " Automatically discover and 'properly' update ctags files on save + +" Doesn't do anything on my Windows desktop... +"Plug 'ervandew/supertab' " For autocompletion "//////////////////////////////////////////////////////////////// " COLORS @@ -235,8 +242,10 @@ set writebackup " allow backspacing over everything in insert mode set backspace=indent,eol,start -" Spell checking autocomplete -set complete+=kspell + +set complete+=kspell " Spell checking autocomplete. +set complete-=i " Don't scan all included files since it's really slow. + " Enable highlighting for syntax syntax on " Enable file type detection. @@ -246,11 +255,16 @@ syntax on " use emacs-style tab completion when selecting files, etc set wildmenu set wildmode=longest,list,full -set wildignore+=*/tmp/*,*/log/*,*.so,*.swp,*.zip,*/rdoc/* +set wildignore+=*/log/*,*.so,*.swp,*.zip,*/rdoc/* let &colorcolumn=s:max_row_length -" Show trailing whitespace + +" Requires ripgrep to be installed. +set grepprg=rg\ --vimgrep + +" Show trailing whitespace. set list listchars=tab:»·,trail:· -" Adding this since the esc remap on the 'i' key had a long delay when pressed + +" Adding this since the esc remap on the 'i' key had a long delay when pressed. set timeoutlen=300 ttimeoutlen=0 " Allow undo when doing back into a closed file @@ -379,15 +393,15 @@ nmap rv :so $MYVIMRC :cmap %/ %:p:h/ " remap saving and quiting -nmap w :w +nmap w :w! nmap q :q nmap qq :q! nmap x :x -:ca Wa wa -:ca WA wa +:ca Wa wa! +:ca WA wa! :ca WQ wq :ca Wq wq -:ca W w +:ca W w! :ca Q q " lowercase the e (have a habit of making it uppercase) @@ -476,9 +490,9 @@ command! -nargs=+ -complete=custom,s:CompleteFilenameWithoutExtension OpenCppSou :ca c OpenCppSource :ca C OpenCppSource -command! -nargs=+ -complete=custom,s:CompleteFilenameWithoutExtension OpenCppHeader execute ':e .h' -:ca h OpenCppHeader -:ca H OpenCppHeader +"command! -nargs=+ -complete=custom,s:CompleteFilenameWithoutExtension OpenCppHeader execute ':e .h' +":ca h OpenCppHeader +":ca H OpenCppHeader command! -nargs=+ -complete=custom,s:CompleteFilenameWithoutExtension OpenCppSourceAndHeader execute ':vsp | :e .h | :sp .cpp' :ca b OpenCppSourceAndHeader @@ -517,17 +531,14 @@ inoremap let g:localvimrc_sandbox = 0 let g:localvimrc_ask = 0 - """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " TAGBAR """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" noremap :TagbarToggle - """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " GITGUTTER """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" - let g:gitgutter_enabled = 0 let g:gitgutter_highlight_lines = 1 nmap ha GitGutterStageHunk @@ -553,6 +564,10 @@ let g:syntastic_check_on_wq = 0 "let g:syntastic_rust_rustc_fname = '' "let g:syntastic_rust_checkers = ['rustc'] +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" RIPGREP +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +let g:rg_highlight = 1 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " GIT @@ -629,7 +644,6 @@ endfunction """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" set tags+=tags;$HOME - "----------------------------------------------------------------------------------------- @@ -845,9 +859,11 @@ noremap :call HideBuildResultsAndClearErrors() " Execute build script " Optimizations off +nnoremap ba :AsyncRun! -save=2 ./build_all* nnoremap b :AsyncRun! -save=2 ./build* " Optimizations on nnoremap bb :AsyncRun! -save=2 ./build -o 1 +nnoremap baa :AsyncRun! -save=2 ./build_all* -o 1 nnoremap :call SilentBuild() " Execute run script @@ -868,6 +884,13 @@ nnoremap :cp """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " SEARCHING """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" + +" 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 @/ = "" @@ -903,19 +926,26 @@ function! Search() let l:term = input('Grep search term: ') if l:term != '' if IsWindows() - " TODO: add --exclude= support to filesearch plugin - exec 'Fsgrep "' . l:term . '"' + "Fsgrep is slow...." + "exec 'Fsgrep "' . l:term . '"' + + "@note --pretty (i.e. colors) is not enabled in vim-ripgrep because the + "quickfix window doesn't seem to parse the ansi color codes. + exec 'Rg --trim --ignore-case -g "!vendor/*" "' . l:term . '"' else - " is pt faster than ag? I forget now and didn't document it - "exec 'pt "' . l:term . '"' - exec 'Ag "' . l:term . '"' + "exec 'Ag "' . l:term . '"' + " ripgrep is faster than Ag. + execute 'Find '.l:term endif endif endfunction map s :call Search() -command! -nargs=+ MyGrep execute 'silent grep! ' | copen 33 - +" 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") "//////////////////////////////////////////////////////////////// " FILESEARCH PLUGIN @@ -928,7 +958,7 @@ command! -nargs=+ MyGrep execute 'silent grep! ' | copen 33 "//////////////////////////////////////////////////////////////// " SELECTA -- find files with fuzzy-search "//////////////////////////////////////////////////////////////// -" + " Run a given vim command on the results of fuzzy selecting from a given shell " command. See usage below. function! SelectaCommand(choice_command, selecta_args, vim_command) diff --git a/windows/bashrc b/windows/bashrc index d493dd6..85f73cb 100644 --- a/windows/bashrc +++ b/windows/bashrc @@ -49,3 +49,7 @@ if [ -f ~/.git-completion.bash ]; then fi cd ~ + +export NVM_DIR="$HOME/.nvm" +[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm +[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion