From ae70101eba1829f2da54545026810dba12734f86 Mon Sep 17 00:00:00 2001 From: Autumn Naber Date: Fri, 25 Aug 2023 14:17:40 -0700 Subject: [PATCH] Added optional YCM integration --- .gitmodules | 3 ++ gitconfig | 16 +++--- setup.sh | 18 ++++--- tmux.conf | 4 +- vim/bundle/YouCompleteMe | 1 + vimrc | 103 +++++++++++++++++++++++++++++---------- 6 files changed, 104 insertions(+), 41 deletions(-) create mode 160000 vim/bundle/YouCompleteMe diff --git a/.gitmodules b/.gitmodules index 50c72f5..d4bced5 100644 --- a/.gitmodules +++ b/.gitmodules @@ -37,3 +37,6 @@ [submodule "vim/bundle/vim-bufferline"] path = vim/bundle/vim-bufferline url = https://github.com/bling/vim-bufferline +[submodule "vim/bundle/YouCompleteMe"] + path = vim/bundle/YouCompleteMe + url = https://github.com/ycm-core/YouCompleteMe.git diff --git a/gitconfig b/gitconfig index bc52fdc..6fc42c0 100644 --- a/gitconfig +++ b/gitconfig @@ -1,17 +1,19 @@ [user] - email = anaber@pm.me + email = anaber@pm.me name = Autumn Naber [diff] - tool = vimdiff + tool = vimdiff [difftool] - prompt = false + prompt = false [alias] df = difftool [merge] - tool = fugitive + tool = fugitive [mergetool] - prompt = false + prompt = false [mergetool "fugitive"] - cmd = vim -f -c \"Gvdiff\" \"$MERGED\" + cmd = vim -f -c \"Gvdiff\" \"$MERGED\" [push] - default = simple + default = simple +[core] + editor = vim diff --git a/setup.sh b/setup.sh index 156dfbc..2dc0a89 100755 --- a/setup.sh +++ b/setup.sh @@ -1,5 +1,6 @@ #!/bin/bash +echo "Updating bash_profile" if [ -n "$(grep AZSQFRB8 $HOME/.bash_profile)" ]; then read -p "These configurations have already been applied. Continue? [y/N] " if [ "$REPLY" == "y" ] || [ "$REPLY" == "Y" ]; then @@ -10,15 +11,13 @@ if [ -n "$(grep AZSQFRB8 $HOME/.bash_profile)" ]; then exit 0 fi fi - cat bash_profile_ext >> $HOME/.bash_profile -if [ ! "$(ls -A ./vim/bundle/taglist)" ]; then - echo "Pulling tags, since you're lazy..." - git submodule init - git submodule update -fi +echo "Pulling and updating tags" +git submodule init +git submodule update --recursive +echo "Copying configs" copy_list=(ctags dircolors gitconfig inputrc tmux.conf vim vimrc Xdefaults) for config in ${copy_list[@]}; do cp -fr "$config" $HOME/."$config" @@ -29,3 +28,10 @@ echo "= Be sure to adjust the Git user/email as necessary!!!!! =" echo "==========================================================" echo "" echo "Please log out and log back in for changes to take effect." +echo "" +echo "" +echo "NOTE: If you wand to use YCM, you need to do the following:" +echo " - Install python3-dev" +echo " - Install either vim-nox or build vim from source with python3 enabled" +echo " - cd ~/.vim/bundle/YouCompleteMe && python3 install.py --clangd-completer" +echo " - Remove comment markers under OPTION B in your .vimrc" diff --git a/tmux.conf b/tmux.conf index fd86887..eb46ab6 100644 --- a/tmux.conf +++ b/tmux.conf @@ -47,9 +47,9 @@ set -g pane-active-border-style 'bg=colour0 fg=colour7' # statusbar set -g status-position bottom set -g status-justify left -set -g status-style 'bg=colour18 fg=colour7' +set -g status-style 'bg=colour8 fg=colour7' set -g status-left '' -set -g status-right '#[fg=colour7,bg=colour237] %H:%M:%S ' +set -g status-right '#[fg=colour7,bg=colour237] LOCAL %H:%M:%S ' set -g status-right-length 50 set -g status-left-length 20 diff --git a/vim/bundle/YouCompleteMe b/vim/bundle/YouCompleteMe new file mode 160000 index 0000000..4f1dcf4 --- /dev/null +++ b/vim/bundle/YouCompleteMe @@ -0,0 +1 @@ +Subproject commit 4f1dcf4f971517b5a41d420b3671259f917e3827 diff --git a/vimrc b/vimrc index 86c2202..361afe1 100644 --- a/vimrc +++ b/vimrc @@ -1,20 +1,29 @@ execute pathogen#infect() +" Tab length-related settings set expandtab set tabstop=4 set shiftwidth=4 + +" Mouse mode set mouse=nicr set ttymouse=sgr "Support wide screens + +" Search Settings set incsearch set hlsearch set ignorecase set smartcase set smartindent -set tags=./tags; :nnoremap :nohlsearch:echo + syntax on filetype plugin indent on colorscheme apprentice +set switchbuf+=uselast " Use last window when making selection from quickfix window +set redrawtime=5000 " Increase maximum redraw time to use syntax highlighting for large files + +set backspace=indent,eol,start " Make backspace key work in insert mode nnoremap tn :tabnew @@ -27,7 +36,12 @@ map :vsp :exec("tag ".expand("")) " Load all of the helptags now, after plugins have been loaded. " All messages and errors will be ignored. silent! helptags ALL -" + +" Return to last edit position whan opening a file +autocmd BufReadPost * + \ if line("'\"") > 0 && line("'\"") <= line("$") | + \ exe "normal! g`\"" | + \ endif if &term =~ '^screen' " tmux will send xterm-style keys when its xterm-keys option is on @@ -42,22 +56,56 @@ nnoremap n :NERDTreeFocus nnoremap :NERDTreeToggle nnoremap :NERDTreeFind -" Taglist +"""" Taglist +set tags=./tags; " Recursively search backwards for ctags file +" CTRL-l to open taglist nnoremap :TlistToggle +" CTRL-p to show function name in status bar nnoremap :TlistShowPrototype -let Tlist_Use_Right_Window = 1 " Move window to right side -let Tlist_Exit_OnlyWindow = 1 " Close if only window left -let Tlist_Hightlight_Tag_On_BufEnter = 1 " Hightlight current tag -let Tlist_Display_Prototypte = 1 " Show full prototype at bottom +let Tlist_Use_Right_Window = 1 " Move window to right side +let Tlist_Exit_OnlyWindow = 1 " Close if only window left +let Tlist_Hightlight_Tag_On_BufEnter = 1 " Hightlight current tag +let Tlist_Display_Prototypte = 1 " Show full prototype at bottom let Tlist_Ctags_Cmd = 'ctags --extra=-q --c++-kinds=-p' -" vim-rainbow +"""" vim-rainbow let g:rainbow_active = 1 let g:rainbow_guifgs = ['RoyalBlue3', 'DarkOrange3', 'DarkOrchid3', 'FireBrick'] let g:rainbow_ctermfgs = ['lightblue', 'lightgreen', 'yellow', 'red', 'magenta'] +"""" Gitgutter +" CTRL-g to toggle GitGutter display nnoremap :GitGutterToggle +" Fugitive conflict resolution +nnoremap gd :Gvdiff +nnoremap gdh :diffget //2 +nnoremap gdl :diffget //3 + +"""" YAML editor settings +autocmd FileType yaml setlocal ts=2 sts=2 sw=2 expandtab +autocmd FileType yml setlocal ts=2 sts=2 sw=2 expandtab +autocmd FileType puml setlocal ts=4 sts=4 sw=4 expandtab +let g:indentLine_char = '┆' +let g:indentLine_color_term = 237 + +" vim-airline +let g:airline#extensions#whitespace#enabled = 0 +" Hide branch information in status line +if !exists('g:airline_symbols') + let g:airline_symbols = {} +endif +let g:airline_symbols.colnr = '' +let g:airline#extensions#taglist#enabled = 1 +let g:airline#extensions#tabline#enabled = 0 +let g:airline#extensions#bufferline#enabled = 0 +function! InitAirline() + let g:airline_section_b = airline#section#create([]) +endfunction +autocmd VimEnter * call InitAirline() + +""" Use one of these options depending on software +"" OPTION A: Vim 8.x without YCM (easy setup) " OmniCpp let OmniCpp_MayCompleteDot = 0 let OmniCpp_MayCompleteArrow = 0 @@ -66,17 +114,6 @@ let OmniCpp_MayCompleteArrow = 0 " Supertab let g:SuperTabDefaultCompletionType = "" -" Fugitive conflict resolution -nnoremap gd :Gvdiff -nnoremap gdh :diffget //2 -nnoremap gdl :diffget //3 - -" YAML editor settings -autocmd FileType yaml setlocal ts=2 sts=2 sw=2 expandtab -autocmd FileType yml setlocal ts=2 sts=2 sw=2 expandtab -let g:indentLine_char = '┆' -let g:indentLine_color_term = 237 - " Syntastic set statusline+=%#warningmsg# set statusline+=%{SyntasticStatuslineFlag()} @@ -95,10 +132,24 @@ nnoremap :SyntasticToggleMode " autocmd FileType cpp if stridx(expand("%:p"), "/home/anaber/work/trenton/") == 0 | " \ let g:syntastic_cpp_clang_tidy_args = "-p /home/anaber/work/trenton" | endif -" vim-airline -let g:airline#extensions#whitespace#enabled = 0 -if !exists('g:airline_symbols') - let g:airline_symbols = {} -endif -let g:airline_symbols.colnr = '' -let g:airline#extensions#taglist#enabled = 1 +"" OPTION B: Vim 9.x + Python3 support + YCM (really nice) +" YouCompleteMe settings +"let g:ycm_autoclose_preview_window_after_insertion = 1 +"let g:ycm_autoclose_preview_window_after_completion = 1 +"let g:ycm_open_loclist_on_ycm_diags = 1 " Open location list to view diagnostics +"let g:ycm_max_num_candidates = 20 " Max number of completion suggestions +"let g:ycm_max_num_candidates = 20 " Max number of completion suggestions +"let g:ycm_max_num_identifier_candidates = 10 " Max number of identifier-based suggestions +"let g:ycm_auto_trigger = 0 " Disable completion menu. Use for completion +"let g:ycm_show_diagnostic_ui = 1 " Show diagnostic display features +"let g:ycm_error_symbol = '>>' " The error symbol in Vim gutter +"let g:ycm_enable_diagnostic_signs = 1 " Display icons in Vim's gutter, error, warnings +"let g:ycm_enable_diagnostic_highlighting = 1 " Highlight regions of diagnostic text +"let g:ycm_echo_current_diagnostic = 1 " Echo line's diagnostic that cursor is on +"let g:ycm_min_num_of_chars_for_completion = 4 " Wait for 4 characters before completion +" +"" Show compilation errors +"nnoremap :YcmDiags +"" Toggle documentation popup (\D) +"nmap D (YCMHover) +""" END OPTIONS