Improve vimrc to include more information and settings

+ Add more binds, even if left default, for reference or quick adjusting
+ Adjust sourcerer.vim for ultra-black background
+ Set clang_complete to use snippets for code completion in C / C++
+ Set clang_complete binds jump-to declaration and jump-out to + and _ respectively
+ Add information to vimrc to allow adjusting clang options
+ Highlight column 80 on cpp and c files
+ Revert to unicode symbols by default, left powerline symbols commented out for now
This commit is contained in:
Shaun Reed 2021-03-03 16:11:33 +00:00
parent b73166a724
commit e11d0b1e20
4 changed files with 83 additions and 25 deletions

View File

@ -22,5 +22,5 @@ export PATH=$PATH:/opt/
# Example path for autocompletion using libclang-9-dev package, obtained by the following command # Example path for autocompletion using libclang-9-dev package, obtained by the following command
# find /usr/ -name libclang.so.1 2>/dev/null # find /usr/ -name libclang.so.1 2>/dev/null
#export LIBCLANG="/usr/lib/llvm-9/lib/libclang.so.1" export LIBCLANG="/usr/lib/llvm-10/lib/libclang.so.1"

View File

@ -21,7 +21,7 @@ let colors_name = "sourcerer"
" █▓▒░ GUI colors " █▓▒░ GUI colors
hi Normal guifg=#c2c2b0 guibg=#222222 gui=NONE hi Normal guifg=#c2c2b0 guibg=#000000 gui=NONE
hi ColorColumn guifg=NONE guibg=#1c1c1c hi ColorColumn guifg=NONE guibg=#1c1c1c
hi Cursor guifg=NONE guibg=#626262 gui=NONE hi Cursor guifg=NONE guibg=#626262 gui=NONE
hi CursorColumn guibg=#2d2d2d hi CursorColumn guibg=#2d2d2d

98
.vimrc
View File

@ -3,7 +3,33 @@
" General Vim Settings " General Vim Settings
" Highlight the column cursor is on
" May slow screen redraw time, so off by default
""set cursorcolumn
" Keep the bottom / top of the page n lines from the cursor
set scrolloff=5
" Persistant undo
" :help undo-persistence
set undodir=~/.vim/undodir
set undofile
" Combine vim clipboard with global clipboard buffer
" Allows using y and p to copy into CTRL-C buffer, vice versa
" :help 'clipboard'
set clipboard+=unnamed
" Allows true colors in vim (> 8 bit colors)
" :help termguicolors
set termguicolors
" Custom formatting based on filetype
" :help autocmd
"" autocmd FileType yaml set tabstop=2 shiftwidth=2
" Highlight column 80 in c and cpp files
autocmd FileType cpp,c set colorcolumn=80
" Define function in vim to remove whitespace " Define function in vim to remove whitespace
fun! TrimWhitespace() fun! TrimWhitespace()
@ -33,7 +59,7 @@ set mouse=a
set number set number
" Use Powerline symbols " Use Powerline symbols
"let g:airline_powerline_fonts = 1 ""let g:airline_powerline_fonts = 1
" Enable Syntax Highlighting in Vim " Enable Syntax Highlighting in Vim
syntax on syntax on
@ -46,18 +72,22 @@ set nocp
set backspace=indent,eol,start set backspace=indent,eol,start
" Set terminal title when opening file " Set terminal title when opening file
" autocmd BufEnter * let &titlestring = ' ' . expand("%:t") "" autocmd BufEnter * let &titlestring = ' ' . expand("%:t")
" set title "" set title
" Custom Vim Keybindings " Custom Vim Keybindings
" nnoremap <C-e> <C-w> " Modify and remove leading quotation " nnoremap <C-e> <C-w> " Modify and remove leading quotation
" :help mappings
" Set window jump to custom binding " Set window jump to custom binding
" default Ctrl-W conflict - closes browser tabs " default Ctrl-W conflict - closes browser tabs
nnoremap <C-e> <C-w> nnoremap <C-e> <C-w>
nnoremap <C-b> :!make -C build/ " Build and run keybinds
"" nnoremap <C-b> :!make -C build/
nnoremap <C-b> :!cmake -S . -B ./build/ && cmake --build ./build
nnoremap <C-d> :!./build/scrap
" Vim Plugin Settings " Vim Plugin Settings
@ -77,8 +107,10 @@ let g:airline_theme='kalisi'
let g:ale_hover_to_preview = 1 let g:ale_hover_to_preview = 1
" Hover detail info in balloons " Hover detail info in balloons
""let g:ale_set_balloons = 1 ""let g:ale_set_balloons = 1
let g:ale_sign_error = '🗙' let g:ale_sign_error = 'X'
let g:ale_sign_warning = '⚠' let g:ale_sign_warning = '?'
""let g:ale_sign_error = '🗙'
""let g:ale_sign_warning = '⚠'
highlight ALEWarningSign ctermbg=Yellow highlight ALEWarningSign ctermbg=Yellow
highlight ALEWarningSign ctermfg=Black highlight ALEWarningSign ctermfg=Black
highlight ALEWarning ctermbg=DarkYellow highlight ALEWarning ctermbg=DarkYellow
@ -93,9 +125,9 @@ nmap <silent> <C-j> <Plug>(ale_next_wrap)
" Colorizer plugin settings " Colorizer plugin settings
" See :h colorizer in Vim for more info " See :h colorizer in Vim for more info
"let g:colorizer_colornames = 0 " Don't color literal names, like red, green, etc "let g:colorizer_colornames = 0 " Don't color literal names, like red, green, etc
let g:colorizer_auto_color = 1 let g:colorizer_auto_color = 0
"let g:colorizer_skip_comments = 1 ""let g:colorizer_skip_comments = 1
"let g:colorizer_auto_filetype ='css,html,vim' ""let g:colorizer_auto_filetype ='css,html,vim'
nnoremap <C-c> :ColorToggle<CR> nnoremap <C-c> :ColorToggle<CR>
" Symbols important to vim / terminal layouts " Symbols important to vim / terminal layouts
@ -124,20 +156,46 @@ let g:airline_symbols.paste = 'Þ'
let g:airline_symbols.paste = '∥' let g:airline_symbols.paste = '∥'
let g:airline_symbols.whitespace = 'Ξ' let g:airline_symbols.whitespace = 'Ξ'
" TODO: Add condition to toggle unicode / airline symbols
" By default use unicode for compatability on all systems
" airline symbols " airline symbols
let g:airline_left_sep = '' ""let g:airline_left_sep = ''
let g:airline_left_alt_sep = '' ""let g:airline_left_alt_sep = ''
let g:airline_right_sep = '' ""let g:airline_right_sep = ''
let g:airline_right_alt_sep = '' ""let g:airline_right_alt_sep = ''
let g:airline_symbols.branch = '' ""let g:airline_symbols.branch = ''
let g:airline_symbols.readonly = '' ""let g:airline_symbols.readonly = ''
let g:airline_symbols.linenr = '' ""let g:airline_symbols.linenr = ''
" Clang completeion settings
" If this is set, clang_complete will not be loaded at all
""let g:clang_complete_loaded=1
" Required clang library path
let g:clang_library_path=$LIBCLANG let g:clang_library_path=$LIBCLANG
" Clang user option settings examples
""let g:clang_user_options='-std=c++11 stdlib=libc++'
""let g:clang_user_options='-include malloc.h'
" The algo used to sort results (priority, alpha, none)
let g:clang_sort_algo="priority"
let g:clang_close_preview=1 let g:clang_close_preview=1
let g:clang_jumpto_declaration_key="<C-]>" let g:clang_jumpto_declaration_in_preview_key="\\"
let g:clang_jumpto_back_key="<C-O>" let g:clang_jumpto_declaration_key="+"
let g:clang_jumpto_back_key="_"
" Whether or not clang should complete preprocessor patterns
let g:clang_complete_macros=1
" Whether or not clang should complete programming paterns (for, while, etc)
let g:clang_complete_patterns=1 let g:clang_complete_patterns=1
" Following two lines allow clang to complete patterns using snippets
let g:clang_snippets=1
" Which completion engine to use (clang_complete, ultisnips, snipmate)
let g:clang_snippets_engine='clang_complete'
" Should clang use placeholders for insertion within snippets
" This allows parameters, typenames, etc to be inserted
" Use <TAB> in normal mode to move to next param
let g:clang_trailing_placeholder=1

View File

@ -6,6 +6,7 @@ Once installed, editing source code in vim supports features displayed in the sc
![Vim screenshot](VimScreenshot.png) ![Vim screenshot](VimScreenshot.png)
### Install Dotfiles ### Install Dotfiles
Easiest installation is to clone repository into home directory - Easiest installation is to clone repository into home directory -
@ -51,17 +52,16 @@ Submodule path '.vim/bundle/vim-signify': checked out '16eee41d2b267523b84bd4ac1
### Install Clang Completion ### Install Clang Completion
**These configurations require the installation and setup of libclang for clang completion** **These configurations require the installation of clang for clang completion**
If you don't want clang completion, just remove the plugin directory from `~/.vim/bundle/`. If you don't want clang completion, just remove the plugin directory from `~/.vim/bundle/`.
If you don't remove clang completion and skip the following steps, vim will show errors when opening source code files. This is because these configurations use clang completion for source code auto completion and drop-down menus within vim. If you don't remove clang completion and skip the following steps, vim will show errors when opening source code files. This is because these configurations use clang completion for source code auto completion and drop-down menus within vim.
I use the `libclang-10-dev` package for this. You can use whichever version you want, but to use the same version as I do, you could run the following commands.
Note that the `printf` command may take some time to finish, since it is searching your system for a needed file. Note that the `printf` command may take some time to finish, since it is searching your system for a needed file.
```bash ```bash
sudo apt install libclang-10-dev sudo apt install clang
printf "export LIBCLANG=\""$(find /usr/ -name libclang.so.1 2>/dev/null)"\"\n\n" >> .bash_aliases printf "export LIBCLANG=\""$(find /usr/ -name libclang.so.1 2>/dev/null)"\"\n\n" >> .bash_aliases
echo "let g:clang_library_path=\$LIBCLANG" >> ~/.vimrc echo "let g:clang_library_path=\$LIBCLANG" >> ~/.vimrc
source ~/.bashrc source ~/.bashrc