diff --git a/vim/.vim/prefs/airline.vim b/vim/.vim/prefs/airline.vim new file mode 100644 index 0000000..b387c41 --- /dev/null +++ b/vim/.vim/prefs/airline.vim @@ -0,0 +1,76 @@ +" AirLine visual settings +if !exists('g:airline_symbols') + let g:airline_symbols = {} +endif + +let g:airline_theme='onedark' +" let g:airline_stl_path_style = 'short' + +let g:airline#extensions#coc#enabled = 1 + +let g:airline_left_sep='' +let g:airline_left_alt_sep = '' +let g:airline_right_sep='' +let g:airline_right_alt_sep = '' +let g:airline_symbols.branch = '' +let g:airline_symbols.readonly = '' +let g:airline_symbols.dirty = '' +let g:airline_symbols.linenr = '␤' +"let g:airline_symbols.whitespace = 'Ξ' +let g:airline_powerline_fonts = 1 +let g:airline#extensions#tabline#enabled = 1 +let g:airline#extensions#tabline#formatter = 'unique_tail_improved' +let g:airline#extensions#tabline#show_buffers = 0 +let g:airline#extensions#tabline#show_splits = 1 +let g:airline#extensions#tabline#show_tabs = 1 +let g:airline#extensions#tabline#show_tab_nr = 0 +let g:airline#extensions#tabline#show_tab_type = 0 +let g:airline#extensions#tabline#exclude_preview = 1 +let g:airline#extensions#tabline#show_close_button = 0 +let g:airline#extensions#tabline#fnamemod = ':t' + +lua << EOF +function getCitc() + local fname = vim.api.nvim_buf_get_name(0) + if string.find(fname, '/google/src/cloud/', 1, true) then + local parts = split(fname, '/') + return parts[5] + end +end +EOF + +" let g:airline_section_c = execute("lua getCitc()") +let g:airline_mode_map = { + \ '__' : '------', + \ 'n' : 'NORMAL', + \ 'c' : 'COMMAND', + \ 'i' : 'INSERT', + \ 'R' : 'REPLACE', + \ 's' : 'SELECT', + \ 'S' : 'S-LINE', + \ '' : 'S-BLOCK', + \ 'v' : 'VISUAL', + \ 'V' : 'V-LINE', + \ '' : 'V-BLOCK', + \ } + +let g:PaperColor_Theme_Options = { + \ 'language': { + \ 'python': { + \ 'highlight_builtins' : 1 + \ }, + \ 'cpp': { + \ 'highlight_standard_library': 1 + \ }, + \ 'c': { + \ 'highlight_builtins' : 1 + \ } + \ }, + \ 'theme': { + \ 'default.dark': { + \ 'transparent_background': 1 + \ } + \ } + \ } + + diff --git a/vim/.vim/prefs/ctrlp.vim b/vim/.vim/prefs/ctrlp.vim new file mode 100644 index 0000000..14b5ce5 --- /dev/null +++ b/vim/.vim/prefs/ctrlp.vim @@ -0,0 +1,42 @@ +" -------- CTRL-P -------- +let g:ctrlp_map = '' +let g:ctrlp_show_hidden = 1 +let g:ctrlp_working_path_mode = 'ra' +set wildignore+=*/tmp/*,*.so,*.swo,*.swp,*.zip,*.o,*.d " MacOSX/Linux +"let g:ctrlp_custom_ignore = '\v[\/](vendor|node_modules|target|dist|build)|(\.(swp|ico|git|svn))$' +let g:ctrlp_custom_ignore = { + \ 'dir': 'vendor\|node_modules\|target\|dist\|build\|mntdeps', + \'file': '\v\.(swp|ico|git|svn|exe)' +\ } +"let g:ctrlp_user_command = ['.git/', 'git --git-dir=%s/.git ls-files -oc --exclude-standard'] +let g:ctrlp_extensions = ['smarttabs'] +let g:ctrlp_switch_buffer = 'ETVH' +let g:ctrlp_open_new_file = 't' + +" Let CtrlP not go all the way up to the root of the client. Instead, consider a +" METADATA file to delimit a project. +let g:ctrlp_root_markers = ['METADATA'] + +" CtrlP auto cache clearing. +function! SetupCtrlP() + if exists("g:loaded_ctrlp") && g:loaded_ctrlp + augroup CtrlPExtension + autocmd! + autocmd FocusGained * CtrlPClearCache + autocmd BufWritePost * CtrlPClearCache + augroup END + endif +endfunction +if has("autocmd") + autocmd VimEnter * :call SetupCtrlP() +endif + +" Ripgrep (rg) is a super fast search utility +" Use rg for ctrl-p plugin +if executable('rg') + set grepprg=rg\ --hidden\ --color=never + let g:ctrlp_use_caching = 0 + let g:ctrlp_user_command = 'rg --files --hidden --color=never * %s' +endif + + diff --git a/vim/.vim/prefs/devicons.vim b/vim/.vim/prefs/devicons.vim new file mode 100644 index 0000000..e8e2920 --- /dev/null +++ b/vim/.vim/prefs/devicons.vim @@ -0,0 +1,22 @@ +let s:brown = "964B00" +let s:aqua = "3AFFDB" +let s:blue = "689FB6" +let s:darkBlue = "44788E" +let s:purple = "834F79" +let s:lightPurple = "834F79" +let s:red = "AE403F" +let s:beige = "F5C06F" +let s:yellow = "F09F17" +let s:orange = "D4843E" +let s:darkOrange = "F16529" +let s:pink = "CB6F6F" +let s:salmon = "EE6E73" +let s:green = "8FAA54" +let s:lightGreen = "31B53E" +let s:white = "FFFFFF" +let s:rspec_red = 'FE405F' +let s:git_orange = 'F54D27' + +" If you have vim-devicons you can customize your icons for each file type. +let g:NERDTreeExtensionHighlightColor = {} "this line is needed to avoid error +let g:NERDTreeExtensionHighlightColor['java'] = s:lightGreen "assigning it to an empty string will skip highlight diff --git a/vim/.vim/prefs/fzf.vim b/vim/.vim/prefs/fzf.vim new file mode 100644 index 0000000..2519c57 --- /dev/null +++ b/vim/.vim/prefs/fzf.vim @@ -0,0 +1,30 @@ +"nnoremap :FZF -m +"let $FZF_DEFAULT_COMMAND = 'ag -g ""' + +" nmap :FZF + +nmap (fzf-maps-n) +xmap (fzf-maps-x) +omap (fzf-maps-o) +let g:fzf_preview_window = ['right:50%', 'ctrl-/'] +let g:fzf_history_dir = '~/.local/share/fzf-history' +let g:fzf_command_prefix = 'Fzf' +" use the same keybindings for fzf as in shell +" nnoremap :FzfHgFiles +" nnoremap :FzfHgRg +let s:hg_command = 'hg files 2>/dev/null' + +command! -bang FzfHgFiles +\ call fzf#run(fzf#wrap({ +\ 'source': s:hg_command, +\ 'options': $FZF_DEFAULT_OPTS . " " . $FZF_CTRL_T_OPTS, +\ }), +\ 0 +\ ) +command! -bang -nargs=* FzfHgRg +\ call fzf#vim#grep( +\ s:rg_command . " " . . " " . "$(" . s:hg_command . ")", 1, +\ 0 ? fzf#vim#with_preview('up:60%') +\ : fzf#vim#with_preview('right:50%'), +\ 0) + diff --git a/vim/.vim/prefs/imp.vim b/vim/.vim/prefs/imp.vim index c240a72..cb6422b 100644 --- a/vim/.vim/prefs/imp.vim +++ b/vim/.vim/prefs/imp.vim @@ -4,9 +4,13 @@ set runtimepath+=/google/src/files/head/depot/google3/experimental/users/tstone/ set runtimepath+=/google/src/files/head/depot/google3/experimental/users/tstone/vim/imp-csearch Glug! glaive -Glaive imp plugin[mappings] Suggest[default]=buffer,csearch,prompt,primp Report[default]=popupnotify +" Glaive imp Suggest[default]=buffer,primp,csearch,prompt Report[default]=popupnotify +" Glaive imp Suggest[default]=buffer,csearch,prompt,primp Report[default]=popupnotify +" Glaive imp Pick[default]=inputlist Suggest[default]=buffer,primp,csearch,prompt Report[default]=echo +Glaive imp Pick[default]=fzf Suggest[default]=buffer,primp,csearch,prompt Report[default]=echo " " nnoremap csi :CsImporter -nnoremap csi :ImpSuggest -" nnoremap ii :ImpSuggest -" nnoremap if :ImpFirst +nnoremap csi :ImpSuggest +nnoremap ii :ImpSuggest +nnoremap if :ImpFirst + diff --git a/vim/.vim/prefs/leader.vim b/vim/.vim/prefs/leader.vim index f96a386..eda7ba5 100644 --- a/vim/.vim/prefs/leader.vim +++ b/vim/.vim/prefs/leader.vim @@ -1,18 +1,6 @@ -" mnemonic: (i)nsert (l)ambda -imap il l* - -" HEX<->ASCII -" mnemonic: (h)ex (t)o (a)scii -vnoremap hta :s/\%V\x\x/\=nr2char(printf("%d", "0x".submatch(0)))/g`< -" mnemonic: (a)scii (t)o (h)ex -vnoremap ath :s/\%V./\=printf("%x",char2nr(submatch(0)))/g`< - - - let g:windowswap_map_keys = 0 "prevent default bindings nnoremap yw :call WindowSwap#MarkWindowSwap() - " --------- SURROUND MAPPINGS --------- " " Surround a word with "quotes" map " ysiw" @@ -86,20 +74,6 @@ endfunction nmap toi :CocCommand tsserver.organizeImports - -" --------- FUGITIVE MAPPINGS --------- -nmap dg :diffget -nmap dp :diffput -nmap du :diffupdate -vmap dg :diffget -vmap dp :diffput -vmap du :diffupdate - -nmap giw :Gwrite -nmap gic :Gcommit -v -nmap gid :Gdiff -nmap gis :Gstatus - "" --------- NERD Commenter " Create default mappings let g:NERDCreateDefaultMappings = 0 diff --git a/vim/.vim/prefs/mappings.vim b/vim/.vim/prefs/mappings.vim index d8cdbb9..cfe1d35 100644 --- a/vim/.vim/prefs/mappings.vim +++ b/vim/.vim/prefs/mappings.vim @@ -12,7 +12,6 @@ map [D " remove mapping to be used in nerdtree inoremap -" Fox for Ack cnoremap %% =fnameescape(expand("%:p:h")."/") " move vertically by visual line @@ -40,7 +39,7 @@ nnoremap nnoremap [e :execute 'move -1-'. v:count1 nnoremap ]e :execute 'move +'. v:count1 -" Create window splits easier. The default +" Create window splits easier nnoremap vv v nnoremap ss s @@ -49,7 +48,4 @@ nnoremap CocCommand explorer " always use very magic mode when searching "nnoremap / /\v "vnoremap / /\v -" -vnoremap // y/\V=escape(@",'/\') - -nmap :CocCommand java.debug.vimspector.start +nnoremap ww :call WindowSwap#EasyWindowSwap() diff --git a/vim/.vim/prefs/plug_prefs.vim b/vim/.vim/prefs/plug_prefs.vim index 4f96adf..680e3cc 100644 --- a/vim/.vim/prefs/plug_prefs.vim +++ b/vim/.vim/prefs/plug_prefs.vim @@ -1,186 +1,7 @@ -let pyxversion = 3 - - -" -------- FZF -------- -" nmap :FZF - -nmap (fzf-maps-n) -xmap (fzf-maps-x) -omap (fzf-maps-o) -let g:fzf_preview_window = ['right:50%', 'ctrl-/'] - -let g:fzf_command_prefix = 'Fzf' -let s:hg_command = 'hg whatsout --template= -- ' - -" command! -bang -nargs=* HgFiles -" \ call fzf#vim#grep( -" \ 'git grep --line-number -- '.shellescape(), 0, -" \ fzf#vim#with_preview({'dir': systemlist('git rev-parse --show-toplevel')[0]}), 0) - -command! -bang FzfHgFiles -\ call fzf#run(fzf#wrap({ -\ 'source': s:hg_command, -\ }), -\ 0 -\ ) -command! -bang -nargs=* FzfHgRg -\ call fzf#vim#grep( -\ s:rg_command . " " . . " " . "$(" . s:hg_command . ")", 1, -\ 0 ? fzf#vim#with_preview('up:60%') -\ : fzf#vim#with_preview('right:50%'), -\ 0) - -" -" -" -------- CTRL-P -------- -" let g:ctrlp_map = '' -" let g:ctrlp_show_hidden = 1 -" let g:ctrlp_working_path_mode = 'ra' -" set wildignore+=*/tmp/*,*.so,*.swo,*.swp,*.zip,*.o,*.d " MacOSX/Linux -" "let g:ctrlp_custom_ignore = '\v[\/](vendor|node_modules|target|dist|build)|(\.(swp|ico|git|svn))$' -" let g:ctrlp_custom_ignore = { -" \ 'dir': 'vendor\|node_modules\|target\|dist\|build\|mntdeps', -" \'file': '\v\.(swp|ico|git|svn|exe)' -" \ } -" "let g:ctrlp_user_command = ['.git/', 'git --git-dir=%s/.git ls-files -oc --exclude-standard'] -" let g:ctrlp_extensions = ['smarttabs'] -" let g:ctrlp_switch_buffer = 'ETVH' -" let g:ctrlp_open_new_file = 't' -" -" " Let CtrlP not go all the way up to the root of the client. Instead, consider a -" " METADATA file to delimit a project. -" let g:ctrlp_root_markers = ['METADATA'] -" -" " CtrlP auto cache clearing. -" function! SetupCtrlP() -" if exists("g:loaded_ctrlp") && g:loaded_ctrlp -" augroup CtrlPExtension -" autocmd! -" autocmd FocusGained * CtrlPClearCache -" autocmd BufWritePost * CtrlPClearCache -" augroup END -" endif -" endfunction -" if has("autocmd") -" autocmd VimEnter * :call SetupCtrlP() -" endif -" -" " Ripgrep (rg) is a super fast search utility -" " Use rg for ctrl-p plugin -" if executable('rg') -" set grepprg=rg\ --hidden\ --color=never -" let g:ctrlp_use_caching = 0 -" let g:ctrlp_user_command = 'rg --files --hidden --color=never * %s' -" endif - - -" -------- VIM-MARKDOWN -------- -let g:vim_markdown_folding_disabled = 1 - - -" -------- LATEX -------- -let g:windowswap_map_keys = 0 "prevent default bindings -nnoremap ww :call WindowSwap#EasyWindowSwap() - -"Don't ask to save when changing buffers (i.e. when jumping to a type definition) -set hidden - -let g:UltiSnipsExpandTrigger = "" -inoremap pumvisible() ? "=UltiSnips#ExpandSnippetOrJump()" : "\" -let g:vim_php_refactoring_use_default_mapping = 0 -nnoremap da :call PhpDocAll() - -" If you want :UltiSnipsEdit to split your window. -let g:UltiSnipsEditSplit="vertical" - -let g:php_html_in_heredoc = 0 -let g:php_html_in_nowdoc = 0 -let g:php_sql_query = 0 -let g:php_sql_heredoc = 0 -let g:php_sql_nowdoc = 0 - -let jshint2_read = 1 +" ONE LINERS ONLY " set statusline+=%#warningmsg# " set statusline+=%{SyntasticStatuslineFlag()} " set statusline+=%* set statusline=%{pathshorten(expand('%:f'))} let g:rainbow_active = 1 "set to 0 if you want to enable it later via :RainbowToggle - -" FZF -"nnoremap :FZF -m -"let $FZF_DEFAULT_COMMAND = 'ag -g ""' -let g:fzf_history_dir = '~/.local/share/fzf-history' - -" vim-easy-align - -" Start interactive EasyAlign in visual mode (e.g. vipga) -xmap ga (EasyAlign) -" Start interactive EasyAlign for a motion/text object (e.g. gaip) -nmap ga (EasyAlign) -let g:scratchpad_ftype = 'md' - -" NERDTree -" Help w/ lag -let g:NERDTreeLimitedSyntax = 1 - -let s:brown = "964B00" -let s:aqua = "3AFFDB" -let s:blue = "689FB6" -let s:darkBlue = "44788E" -let s:purple = "834F79" -let s:lightPurple = "834F79" -let s:red = "AE403F" -let s:beige = "F5C06F" -let s:yellow = "F09F17" -let s:orange = "D4843E" -let s:darkOrange = "F16529" -let s:pink = "CB6F6F" -let s:salmon = "EE6E73" -let s:green = "8FAA54" -let s:lightGreen = "31B53E" -let s:white = "FFFFFF" -let s:rspec_red = 'FE405F' -let s:git_orange = 'F54D27' - -" If you have vim-devicons you can customize your icons for each file type. -let g:NERDTreeExtensionHighlightColor = {} "this line is needed to avoid error -let g:NERDTreeExtensionHighlightColor['java'] = s:lightGreen "assigning it to an empty string will skip highlight - -let g:jdbPort="5005" - -" Set a nicer foldtext function -set foldtext=MyFoldText() -function! MyFoldText() - let line = getline(v:foldstart) - if match( line, '^[ \t]*\(\/\*\|\/\/\)[*/\\]*[ \t]*$' ) == 0 - let initial = substitute( line, '^\([ \t]\)*\(\/\*\|\/\/\)\(.*\)', '\1\2', '' ) - let linenum = v:foldstart + 1 - while linenum < v:foldend - let line = getline( linenum ) - let comment_content = substitute( line, '^\([ \t\/\*]*\)\(.*\)$', '\2', 'g' ) - if comment_content != '' - break - endif - let linenum = linenum + 1 - endwhile - let sub = initial . ' ' . comment_content - else - let sub = line - let startbrace = substitute( line, '^.*{[ \t]*$', '{', 'g') - if startbrace == '{' - let line = getline(v:foldend) - let endbrace = substitute( line, '^[ \t]*}\(.*\)$', '}', 'g') - if endbrace == '}' - let sub = sub.substitute( line, '^[ \t]*}\(.*\)$', '...}\1', 'g') - endif - endif - endif - let n = v:foldend - v:foldstart + 1 - let info = " " . n . " lines" - let sub = sub . " " - let num_w = getwinvar( 0, '&number' ) * getwinvar( 0, '&numberwidth' ) - let fold_w = getwinvar( 0, '&foldcolumn' ) - let sub = strpart( sub, 0, winwidth(0) - strlen( info ) - num_w - fold_w - 1 ) - return sub . info -endfunction diff --git a/vim/.vim/prefs/ui.vim b/vim/.vim/prefs/ui.vim index 08606b6..74342e5 100644 --- a/vim/.vim/prefs/ui.vim +++ b/vim/.vim/prefs/ui.vim @@ -8,100 +8,9 @@ highlight ExtraWhitespace ctermbg=red let g:cpp_class_scope_highlight = 1 let g:cpp_experimental_template_highlight = 1 -" AirLine visual settings -if !exists('g:airline_symbols') - let g:airline_symbols = {} -endif - -let g:airline_theme='onedark' -" let g:airline_stl_path_style = 'short' - -let g:airline#extensions#coc#enabled = 1 - -let g:airline_left_sep='' -let g:airline_left_alt_sep = '' -let g:airline_right_sep='' -let g:airline_right_alt_sep = '' -let g:airline_symbols.branch = '' -let g:airline_symbols.readonly = '' -let g:airline_symbols.dirty = '' -let g:airline_symbols.linenr = '␤' -"let g:airline_symbols.whitespace = 'Ξ' -let g:airline_powerline_fonts = 1 -let g:airline#extensions#tabline#enabled = 1 -let g:airline#extensions#tabline#formatter = 'unique_tail_improved' -let g:airline#extensions#tabline#show_buffers = 0 -let g:airline#extensions#tabline#show_splits = 1 -let g:airline#extensions#tabline#show_tabs = 1 -let g:airline#extensions#tabline#show_tab_nr = 0 -let g:airline#extensions#tabline#show_tab_type = 0 -let g:airline#extensions#tabline#exclude_preview = 1 -let g:airline#extensions#tabline#show_close_button = 0 -let g:airline#extensions#tabline#fnamemod = ':t' - -lua << EOF -function getCitc() - local fname = vim.api.nvim_buf_get_name(0) - if string.find(fname, '/google/src/cloud/', 1, true) then - local parts = split(fname, '/') - return parts[5] - end -end -EOF - -" let g:airline_section_c = execute("lua getCitc()") - -let g:airline_mode_map = { - \ '__' : '------', - \ 'n' : 'NORMAL', - \ 'c' : 'COMMAND', - \ 'i' : 'INSERT', - \ 'R' : 'REPLACE', - \ 's' : 'SELECT', - \ 'S' : 'S-LINE', - \ '' : 'S-BLOCK', - \ 'v' : 'VISUAL', - \ 'V' : 'V-LINE', - \ '' : 'V-BLOCK', - \ } - -let g:PaperColor_Theme_Options = { - \ 'language': { - \ 'python': { - \ 'highlight_builtins' : 1 - \ }, - \ 'cpp': { - \ 'highlight_standard_library': 1 - \ }, - \ 'c': { - \ 'highlight_builtins' : 1 - \ } - \ }, - \ 'theme': { - \ 'default.dark': { - \ 'transparent_background': 1 - \ } - \ } - \ } - - " Function to let me know what syntax hilighting group is under the cursor. " Not used often function! SynGroup() let l:s = synID(line('.'), col('.'), 1) echo synIDattr(l:s, 'name') . ' -> ' . synIDattr(synIDtrans(l:s), 'name') endfun - -function! PhpSyntaxOverride() - " Put snippet overrides in this function. - hi! link phpDocTags phpDefine - hi! link phpDocParam phpType -endfunction - -augroup phpSyntaxOverride - autocmd! -autocmd FileType php call PhpSyntaxOverride() -augroup END - - -" Highlight the symbol and its references when holding the cursor. diff --git a/vim/.vimrc b/vim/.vimrc index 34b86e7..044349f 100644 --- a/vim/.vimrc +++ b/vim/.vimrc @@ -82,6 +82,7 @@ call plug#begin('~/.vim/plugged') if filereadable(expand("~/.vimrc.local")) source ~/.vimrc.local endif + if filereadable(expand("~/use_google")) source ~/.vim/prefs/google.vim endif @@ -93,6 +94,9 @@ call plug#begin('~/.vim/plugged') source ~/.vim/prefs/golang.vim source ~/.vim/prefs/ultisnips.vim source ~/.vim/prefs/ripgrep.vim + source ~/.vim/prefs/fzf.vim + source ~/.vim/prefs/devicons.vim + source ~/.vim/prefs/airline.vim call plug#end() " required " Require CiderLSP and Diagnostics modules @@ -155,3 +159,6 @@ set omnifunc= completeopt=menuone,noinsert,noselect let g:lsp_log_verbose = 1 let g:lsp_log_file = expand('~/vim-lsp.log') + +"Don't ask to save when changing buffers (i.e. when jumping to a type definition) +set hidden