Files
dot_files/vimrc
2024-03-12 09:05:54 -07:00

153 lines
5.2 KiB
VimL

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
: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>
map <C-\> :tab split<CR>:exec("tag ".expand("<cword>"))<CR>
map <A-]> :vsp <CR>:exec("tag ".expand("<cword>"))<CR>
" Load all plugins now.
" Plugins need to be added to runtimepath before helptags can be generated.
" packloadall
" 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
execute "set <xUp>=\e[1;*A"
execute "set <xDown>=\e[1;*B"
execute "set <xRight>=\e[1;*C"
execute "set <xLeft>=\e[1;*D"
endif
" Nerdtree
nnoremap <leader>n :NERDTreeFocus<CR>
nnoremap <C-n> :NERDTreeToggle<CR>
nnoremap <C-f> :NERDTreeFind<CR>
"""" Tagbar
set tags=./tags; " Recursively search backwards for ctags file
set tagbsearch " Use binary search in tags file (assumes sorted)
set tagcase=match " Match case when searching tags (much faster)
nnoremap <C-l> :TagbarToggle<CR>
"""" 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
" set omnifunc=syntaxcomplete#Complete
" Supertab
let g:SuperTabDefaultCompletionType = "<c-x><c-]>"
" Syntastic
set statusline+=%#warningmsg#
set statusline+=%{SyntasticStatuslineFlag()}
set statusline+=%*
let g:syntastic_always_populate_loc_list = 1
let g:syntastic_auto_loc_list = 1
let g:syntastic_check_on_open = 0
let g:syntastic_check_on_wq = 0
nnoremap <C-y> :SyntasticToggleMode<CR>
"" Optional. Configure before enabling
" let g:syntastic_cpp_checkers = ['clang_tidy']
" let g:syntastic_c_checkers = ['clang_tidy']
" let g:syntastic_cpp_clang_tidy_post_args = ""
" 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
"" 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
"
"let g:ycm_confirm_extra_conf = 0
"" \y to apply FixIt command
"nnoremap <leader>y :YcmCompleter FixIt<CR>
"" Show compilation errors
"nnoremap <silent> <C-y> :YcmDiags<CR>
"" Toggle documentation popup (\D)
"nmap <leader>D <plug>(YCMHover)
""" END OPTIONS