Added optional YCM integration

This commit is contained in:
Autumn Naber
2023-08-25 14:17:40 -07:00
parent 0e39019e63
commit ae70101eba
6 changed files with 104 additions and 41 deletions

3
.gitmodules vendored
View File

@@ -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

View File

@@ -15,3 +15,5 @@
cmd = vim -f -c \"Gvdiff\" \"$MERGED\"
[push]
default = simple
[core]
editor = vim

View File

@@ -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"

View File

@@ -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

95
vimrc
View File

@@ -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 <silent> <Space> :nohlsearch<Bar>:echo<CR>
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<CR>
@@ -27,7 +36,12 @@ map <A-]> :vsp <CR>:exec("tag ".expand("<cword>"))<CR>
" 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,8 +56,11 @@ nnoremap <leader>n :NERDTreeFocus<CR>
nnoremap <C-n> :NERDTreeToggle<CR>
nnoremap <C-f> :NERDTreeFind<CR>
" Taglist
"""" Taglist
set tags=./tags; " Recursively search backwards for ctags file
" CTRL-l to open taglist
nnoremap <C-l> :TlistToggle<CR>
" CTRL-p to show function name in status bar
nnoremap <C-p> :TlistShowPrototype<CR>
let Tlist_Use_Right_Window = 1 " Move window to right side
let Tlist_Exit_OnlyWindow = 1 " Close if only window left
@@ -51,13 +68,44 @@ 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 <C-g> :GitGutterToggle<CR>
" Fugitive conflict resolution
nnoremap <leader>gd :Gvdiff<CR>
nnoremap gdh :diffget //2<CR>
nnoremap gdl :diffget //3<CR>
"""" 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 = "<c-x><c-]>"
" Fugitive conflict resolution
nnoremap <leader>gd :Gvdiff<CR>
nnoremap gdh :diffget //2<CR>
nnoremap gdl :diffget //3<CR>
" 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 <C-y> :SyntasticToggleMode<CR>
" 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 <C-space> 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 <silent> <C-y> :YcmDiags<CR>
"" Toggle documentation popup (\D)
"nmap <leader>D <plug>(YCMHover)
""" END OPTIONS