diff --git a/my_configs.vim b/my_configs.vim deleted file mode 100644 index 115009ca..00000000 --- a/my_configs.vim +++ /dev/null @@ -1,377 +0,0 @@ -set nu -set nocompatible -let mapleader = "\" -set cmdheight=1 -set foldmethod=indent "set default foldmethod -set cursorline -highlight Cursorline cterm=bold ctermbg=16 -set scrolloff=1 -set swapfile -set shortmess=a -" set tabstop=2 -" set shiftwidth=2 -" set expandtab - -" copy and paste -vmapy mby:silent exec "!rm ~/.vbuf":tabnew ~/.vbufp:w:bdelete!:silent exec "!{ sed -z '$ s@\\n$@@' ~/.vbuf \| xsel; }" :redraw!`b -nmapy mbyiw:silent exec "!rm ~/.vbuf":tabnew ~/.vbufp:w:bdelete!:silent exec "!{ sed -z '$ s@\\n$@@' ~/.vbuf \| xsel; }":redraw!`b -nmapyy yy:silent exec "!rm ~/.vbuf":tabnew ~/.vbufpggdd:w:bdelete!:silent exec "!{ sed -z '$ s@\\n$@@' ~/.vbuf \| xsel; }":redraw! -nmapyya mbvG$y:silent exec "!rm ~/.vbuf":redraw!:tabnew ~/.vbufpgg:w:bdelete!:silent exec "!{ sed -z '$ s@\\n$@@' ~/.vbuf \| xsel; }":redraw!`b -nmapyyaa mbggvG$y:silent exec "!rm -f ~/.vbuf":redraw!:tabnew ~/.vbufpgg:w:bdelete!:silent exec "!{ sed -z '$ s@\\n$@@' ~/.vbuf \| xsel; }":redraw!`b -nmapp :r! sed -z '$ s@\\n$@@' ~/.vbuf - -" auxiliary -nmapu :diffupdate -nmapo :only -nmap/ :noh -nmapw -nmapq :q -nmapw :w -nmapwq :wq -nmapd diw -nmapd diwdiwdiwdiw -nmap 0 -nmap $ -vmap 0 -vmap $ -imap -imap 0ai -noremap k zz:call HighLightCursor(2) -noremap j zz:call HighLightCursor(2) - -" if in diff mode, set as diff shortcut, else set as other -if &diff - map 1 :diffget 1:diffupdate - map 2 :diffget 2:diffupdate - map 3 :diffget 3:diffupdate -else - map 1 1gt - map 2 2gt - map 3 3gt - map 4 4gt - map 5 5gt - map 6 6gt - map 7 7gt - map 8 8gt - map 9 9gt -endif - -set autochdir -set tags=./tags;,tags; - -function! GoToTagWithNewTab() - :set noignorecase - let tagWord = expand("") - :tabe - execute "tj ".expand(tagWord) - - let tagFilename = expand('%:t') - if tagFilename == '' - :tabclose - :tabprevious - else - :silent! normal jzok - :call HighLightCursor(2) - endif - :set ignorecase -endfunction - -function! GoToTagWithNewSplit() - :set noignorecase - let tagWord = expand("") - :vnew - execute "tj ".expand(tagWord) - - let tagFilename = expand('%:t') - if tagFilename == '' - :q - else - :silent! normal jzok - :call HighLightCursor(2) - endif - :set ignorecase -endfunction - -function! HighLightCursor(time) - let s:time_local = a:time - while 1 - :highlight Cursorline cterm=bold ctermbg=13 - redraw - sleep 100m - :highlight Cursorline cterm=bold ctermbg=16 - redraw - let s:time_local -= 1 - if s:time_local == 0 - break - endif - sleep 100m - endwhile -endfunction - -map ] :call GoToTagWithNewTab() -map \ :call GoToTagWithNewSplit() -map [ } -map t T -map n :NERDTree - -map f mtgd -map f mt -map g :noh`t :call HighLightCursor(2) -map h :call HighLightCursor(2) - -" bookmark -map a ma -map a `azz :call HighLightCursor(2) - -" run when start -autocmd VimEnter * call HighLightCursor(2) - -" set spell check -map c :set spell spelllang=en_us -autocmd BufRead,BufNewFile *.txt,*.md set spell spelllang=en_us - -" set ycm -" let g:ycm_global_ycm_extra_conf = "/Users/Hans/.vim_runtime/sources_forked/YouCompleteMe/.ycm_extra_conf.py" -" let g:ycm_add_preview_to_completeopt = 0 -" let g:ycm_show_diagnostics_ui = 0 -" let g:ycm_server_log_level = 'info' -" let g:ycm_min_num_identifier_candidate_chars = 2 -" let g:ycm_collect_identifiers_from_comments_and_strings = 1 -" let g:ycm_complete_in_strings=1 -" let g:ycm_key_invoke_completion = '' -" let g:ycm_autoclose_preview_window_after_completion = 0 -" let g:ycm_autoclose_preview_window_after_insertion = 1 -" set completeopt=menu,menuone,preview -" -" noremap -" -" let g:ycm_semantic_triggers = { -" \ 'c,cpp,cu,python,java,go,erlang,perl,py': ['re!\w{2}'], -" \ 'cs,lua,javascript': ['re!\w{2}'], -" \ } -" let g:ycm_filetype_blacklist = { -" \ 'tagbar' : 1, -" \ 'qf' : 1, -" \ 'notes' : 1, -" \ 'unite' : 1, -" \ 'vimwiki' : 1, -" \ 'pandoc' : 1, -" \ 'infolog' : 1, -" \ 'mail' : 1 -" \} - -" automatically paste without format -let &t_SI .= "\[?2004h" -let &t_EI .= "\[?2004l" - -inoremap [200~ XTermPasteBegin() - -function! XTermPasteBegin() - set pastetoggle=[201~ - set paste - return "" -endfunction - -" Commenting blocks of code. -autocmd FileType c,cpp,cu,java,scala let b:comment_leader = '// ' -autocmd FileType sh,ruby,python let b:comment_leader = '# ' -autocmd FileType conf,fstab let b:comment_leader = '# ' -autocmd FileType tex let b:comment_leader = '% ' -autocmd FileType mail let b:comment_leader = '> ' -autocmd FileType vim let b:comment_leader = '" ' -noremap . mb:silent s/^/=escape(b:comment_leader,'\/')/:nohlsearch`blll -noremap , mb:silent s/^\V=escape(b:comment_leader,'\/')//e:nohlsearch`b - -" For smooth motion -if v:version < 705 " Version less than 7.04.15 does not support - let g:comfortable_motion_no_default_key_mappings = 1 -else - let g:comfortable_motion_scroll_down_key = "j" - let g:comfortable_motion_scroll_up_key = "k" - let g:comfortable_motion_no_default_key_mappings = 1 - let g:comfortable_motion_impulse_multiplier = 1 " Feel free to increase/decrease this value. - nnoremap :call comfortable_motion#flick(g:comfortable_motion_impulse_multiplier * winheight(0) * 2) - nnoremap :call comfortable_motion#flick(g:comfortable_motion_impulse_multiplier * winheight(0) * -2) -endif - -" For move between split window -nnoremap fh h -nnoremap fj j -nnoremap fk k -nnoremap fl l - - - -" Relative line number -" set number relativenumber -" augroup numbertoggle -" autocmd! -" autocmd BufEnter,FocusGained,InsertLeave * set relativenumber -" autocmd BufLeave,FocusLost,InsertEnter * set norelativenumber -" augroup END - -" Handle url and file -function! HandleURL() - " substitute \", \', // - let s:line = substitute(getline("."), "\\\"", " ", "g") - let s:line = substitute(s:line, "\\\'", " ", "g") - let s:line = substitute(s:line, "`", " ", "g") - let s:line = substitute(s:line, "${HOME}", "~", "g") - - let s:uri_http = matchstr(s:line, '[a-z]*:\/\/[^ >,;)]*') - let s:uri_www = matchstr(s:line, 'www[^ >,;)]*') - let s:line = substitute(s:line, "//", " ", "") - let s:uri_path = matchstr(s:line, '\(\./\|\~\|\.\./\|/\)[^ >,;)]*') - - let s:open_list = ["pdf", "jpg", "jpeg", "png", "doc", "docx"] - - if s:uri_http != "" - silent exec "!open '".s:uri_http."'" - redraw! - echo "'".s:uri_http."' opened" - elseif s:uri_www != "" - silent exec "!open https://'".s:uri_www."'" - redraw! - echo "'https://".s:uri_www."' opened" - elseif s:uri_path != "" - let s:uri_path = substitute(s:uri_path, "^\\\~", $HOME, "") - if isdirectory(s:uri_path) - silent exec "!open '".s:uri_path."'" - redraw! - echo "'".s:uri_path."' opened" - elseif filereadable(s:uri_path) - let s:suffix = fnamemodify(s:uri_path, ':e') - - if index(s:open_list, s:suffix) == -1 - :IHT - else - silent exec "!open '".s:uri_path."'" - endif - redraw! - echo "'".s:uri_path."' opened" - else - echo "'".s:uri_path."' does not exists" - endif - else - :IHT - redraw! - echo ":IHT" - endif -endfunction -map o :call HandleURL() - -function! ToggleErrors() - if empty(filter(tabpagebuflist(), 'getbufvar(v:val, "&buftype") is# "quickfix"')) - " No location/quickfix list shown, open syntastic error location panel - SyntasticCheck - Errors - echo "Syntax Check Finished" - else - lclose - SyntasticReset - echo "Syntax Check Closed" - endif -endfunction -nnoremap :call ToggleErrors() -nnoremap :lnext:call HighLightCursor(1) -nnoremap :lprevious:call HighLightCursor(1) - -" vim header -let g:header_field_author = 'Xinyue Ou' -let g:header_field_author_email = 'xinyue3ou@gmail.com' -let g:header_field_modified_by = 0 -let g:header_field_modified_timestamp = 0 -let g:header_field_license_id = 'MIT' -" No auto header -let g:header_auto_add_header = 0 -map :AddHeader - -" Nerd Tree -autocmd StdinReadPre * let s:std_in=1 -" Automatically toggle when no file specified -autocmd VimEnter * if argc() == 0 && !exists("s:std_in") | NERDTree | endif -" Automatically toggle when opening up a directory -autocmd VimEnter * if argc() == 1 && isdirectory(argv()[0]) && !exists("s:std_in") | exe 'NERDTree' argv()[0] | wincmd p | ene | endif -map :NERDTreeToggle -" Close vim if the only window left open is a NerdTree -autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif - -" Color Scheme -set background=dark -colorscheme gruvbox - -" NerdCommenter -" Add spaces after comment delimiters by default -let g:NERDSpaceDelims = 1 - -" Use compact syntax for prettified multi-line comments -let g:NERDCompactSexyComs = 1 - -" Align line-wise comment delimiters flush left instead of following code indentation -let g:NERDDefaultAlign = 'left' - -" Set a language to use its alternate delimiters by default -let g:NERDAltDelims_java = 1 - -" Add your own custom formats or override the defaults -let g:NERDCustomDelimiters = { 'c': { 'left': '/**','right': '*/' } } - -" Allow commenting and inverting empty lines (useful when commenting a region) -let g:NERDCommentEmptyLines = 1 - -" Enable trimming of trailing whitespace when uncommenting -let g:NERDTrimTrailingWhitespace = 1 - -" Enable NERDCommenterToggle to check all selected lines is commented or not -let g:NERDToggleCheckAllLines = 1 - -" Tab Navigation -nnoremap th :tabfirst -nnoremap tk :tabnext -nnoremap tj :tabprev -nnoremap tl :tablast -nnoremap tt :tabedit -nnoremap tn :tabnew -nnoremap tm :tabm -nnoremap td :tabclose - -" Clear highlighting when press esc -nnoremap :noh -set timeout ttimeout -set timeoutlen=200 ttimeoutlen=50 - - -" Enable gentle auto pair -let g:AutoPairsUseInsertedCount = 1 - -" YCM disable preview -set completeopt-=preview - -let g:gruvbox_contrast_dark = 'hard' -set background=dark " Setting light mode - -" Terminal mapping -tnoremap h -tnoremap j -tnoremap k -tnoremap l - -nnoremap ts :terminal -nnoremap tv :vert terminal - - -" Get rid of the annoying arrow key problems -nnoremap OA -nnoremap OB -nnoremap OC -nnoremap OD -inoremap OA -inoremap OB -inoremap OC -inoremap OD - -" Change the pane size up and down -nnoremap :resize +1 -nnoremap :resize -1 -nnoremap :vertical resize +1 -nnoremap :vertical resize -1 diff --git a/vimrcs/basic.vim b/vimrcs/basic.vim index b4cf349b..c168aa43 100644 --- a/vimrcs/basic.vim +++ b/vimrcs/basic.vim @@ -267,7 +267,7 @@ au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g set laststatus=2 " Format the status line -set statusline=\ %{HasPaste()}%F%m%r%h\ %w\ \ CWD:\ %r%{getcwd()}%h\ \ \ Line:\ %l\ \ Column:\ %c +set statusline=\ %{HasPaste()}%F%m%r%h\ %w\ %p\ \ CWD:\ %r%{getcwd()}%h\ \ \ Line:\ %l\ Total:\ %L\ \ Column:\ %c """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" diff --git a/vimrcs/google.vim b/vimrcs/google.vim new file mode 100644 index 00000000..f2eeeccd --- /dev/null +++ b/vimrcs/google.vim @@ -0,0 +1,49 @@ +source /usr/share/vim/google/google.vim + + +" Piper plugin mappings +Glug piper plugin[mappings] + +" g4 plugin +Glug g4 + +Glug youcompleteme-google +let g:ycm_always_populate_location_list = 1 + +" BlazeDeps +" Use :BlazeDepsUpdate to update the BUILD file dependency +Glug blazedeps + +au User lsp_setup call lsp#register_server({ + \ 'name': 'CiderLSP', + \ 'cmd': {server_info->[ + \ '/google/bin/releases/editor-devtools/ciderlsp', + \ '--tooltag=vim-lsp', + \ '--noforward_sync_responses', + \ ]}, + \ 'whitelist': ['c', 'cpp', 'proto', 'textproto', 'go'], + \}) +let g:asyncomplete_auto_popup = 0 + + +" Clang include fixer +" Normal mode. +function HeaderFix() + let g:clang_include_fixer_query_mode=0 + pyf /usr/lib/clang-include-fixer/clang-include-fixer.py +endfunction +function HeaderQuery() + let g:clang_include_fixer_query_mode=1 + pyf /usr/lib/clang-include-fixer/clang-include-fixer.py +endfunction +command Headerfix call HeaderFix() +command Headerquery call HeaderQuery() + + +let localleader=, +nnoremap hf :Headerfix +nnoremap hq :Headerquery + +" Show diff of the current file in a new pane. +nnoremap d :SignifyDiff! + diff --git a/vimrcs/plugins_config.vim b/vimrcs/plugins_config.vim index 6842b632..9ad74d4a 100644 --- a/vimrcs/plugins_config.vim +++ b/vimrcs/plugins_config.vim @@ -121,7 +121,7 @@ let g:lightline = { \ 'colorscheme': 'wombat', \ 'active': { \ 'left': [ ['mode', 'paste'], - \ ['fugitive', 'readonly', 'filename', 'modified'] ], + \ ['fugitive', 'readonly', 'absolutepath', 'filename', 'modified'] ], \ 'right': [ [ 'lineinfo' ], ['percent'] ] \ }, \ 'component': { @@ -177,3 +177,34 @@ let g:ale_lint_on_enter = 0 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" let g:gitgutter_enabled=0 nnoremap d :GitGutterToggle + +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" => Template +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +let g:tmpl_author_email = 'xyharry@google.com' +let g:tmpl_author_name = 'Xinyue Ou' +let g:templates_use_licensee = 0 + +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" => Vim-lsp + Async +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" vim-lsp +nnoremap gd :LspDefinition " gd in Normal mode triggers gotodefinition +nnoremap gr :LspReferences " gr in Normal mode shows all references + +" Send async completion requests. +" WARNING: Might interfere with other completion plugins. +let g:lsp_async_completion = 1 + +" Enable UI for diagnostics +let g:lsp_signs_enabled = 1 " enable diagnostics signs in the gutter +let g:lsp_diagnostics_echo_cursor = 1 " enable echo under cursor when in normal mode + +" Enabling fuzzy completion +let g:asyncomplete_smart_completion = 1 +let g:asyncomplete_auto_popup = 1 +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" => SuperTab +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" Start selection from the beginning of the list. +let g:SuperTabDefaultCompletionType = ""