Last active
September 6, 2021 14:48
-
-
Save Igortorrente/81aac8b5388429442c47c563296b99e5 to your computer and use it in GitHub Desktop.
Vimrc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" Vim configuration " | |
" folder : ~/ or $HOME/ " | |
" Last edit: 15/12/2020 " | |
" ========== Editor Setings ========== | |
" Highlight search | |
set hlsearch | |
" Incremental search | |
set incsearch | |
" No compatibility with vi | |
set nocp | |
" Enable plugin | |
filetype off | |
" Fold code type | |
setlocal foldmethod=syntax | |
"setlocal foldmethod=indent | |
" This (should) improve the syntax Highlight perfomance drastically | |
syntax sync minlines=255 | |
" Highlight Current line | |
set cursorline | |
" Set terminal title to current file name and path | |
" set title | |
" set UTF-8 encoding | |
set enc=utf-8 | |
set fenc=utf-8 | |
set termencoding=utf-8 | |
" Use indentation of previous line | |
set autoindent | |
" Use intelligent indentation for C | |
set smartindent | |
" configure tabwidth and insert spaces instead of tabs | |
set tabstop=4 " tab width is 4 spaces | |
set shiftwidth=4 " indent also with 4 spaces | |
set noexpandtab " don't expand tabs to spaces | |
" Show tabs and trail spaces | |
set list | |
set listchars=tab:>-,trail:¶ | |
"set listchars+=space: | |
" Wrap lines at 119 chars. | |
set textwidth=120 | |
" Turn syntax highlighting on | |
"set t_Co=256 | |
syntax on | |
" Turn line numbers on | |
set number | |
" Highlight matching braces | |
set showmatch | |
" Intelligent comments | |
set comments=sl:/*,mb:\ *,elx:\ */ | |
" Open multiple files in tabs | |
tab all | |
" ========== Vim Setings ========== | |
" Search down into subfolders (like fuzzy finder) | |
" Hit tab to :find by partial match | |
" Use * to make it fuzzy | |
" Provides tab-completion for all file-related tasks | |
set path+=** | |
" Display all matching files when we tab complete | |
set wildmenu | |
" enable mouse handling on vim | |
" set mouse=n | |
if (has("termguicolors")) | |
set termguicolors | |
endif | |
" ========== Explorer Setings ========== | |
" File browsing configuration | |
" Use 't' to open a file in a new tab | |
" open in prior configuration | |
let g:netrw_browser_split = 4 | |
" open splits to the right | |
let g:netrw_altv = 1 | |
" Tree view | |
let g:netrw_liststyle = 3 | |
" ========== Remaping ========== | |
" Switch between header/source with F4 | |
map <F4> :e %:p:s,.h$,.X123X,:s,.cp*$,.h,:s,.X123X$,.cp*,<CR> | |
" Recreate tags file with F5 | |
map <F5> :!ctags -R --c++-kinds=+p --extra=+q --fields=+iaS .<CR> | |
" New tab with crtl-T | |
map <C-T> :tab split<CR> | |
" Close tab with crtl-W | |
map <C-e> :tabclose<CR> | |
" Swith to next(right) tab using crtl+shift-right | |
map <C-right> gt | |
" Swith to previous(left) tab using crtl+shift-right | |
map <C-left> gT | |
" Add a newtab to definition | |
map g[ :tab split<CR>:exec("tag ".expand("<cword>"))<CR> | |
if &diff | |
” diff settings | |
map <M-Down> ]c | |
map <M-Up> [c | |
map <M-Left> do | |
map <M-Right> dp | |
map <F9> :new<CR>:read !svn diff<CR>:set syntax=diff buftype=nofile<CR>gg | |
endif | |
" ========== Ctags ========== | |
" This offers intelligent C++ completion when typing ‘.’ ‘->’ or <C-o> | |
" Load standard tag files | |
" set tags=~/.vim/tags/usr_include | |
" ========== New Feature functions ========== | |
" Try load cscope recursively | |
function! LoadCscope() | |
let db = findfile("cscope.out", ".;") | |
if (!empty(db)) | |
let path = strpart(db, 0, match(db, "/cscope.out$")) | |
set nocscopeverbose " suppress 'duplicate connection' error | |
exe "cs add " . db . " " . path | |
set cscopeverbose | |
" else add the database pointed to by environment variable | |
elseif $CSCOPE_DB != "" | |
cs add $CSCOPE_DB | |
endif | |
endfunction | |
au BufEnter /* call LoadCscope() | |
" Let's save undo info! | |
if !isdirectory($HOME."/.var/vim-undo-dir") | |
call mkdir($HOME."/.var/vim-undo-dir", "", 0770) | |
endif | |
if !isdirectory($HOME."/.var/vim-undo-dir") | |
call mkdir($HOME."/.var/vim-undo-dir", "", 0700) | |
endif | |
set undodir=~/.var/vim-undo-dir | |
set undofile | |
" ========== Vundle ========== | |
" Vundle configuration https://linuxhint.com/vim-vundle-tutorial/ | |
set rtp+=~/.vim/bundle/Vundle.vim | |
call vundle#begin() | |
Plugin 'VundleVim/Vundle.vim' | |
" Add plugins here: | |
" https://vimawesome.com/plugin/syntastic | |
" Plugin 'scrooloose/syntastic' | |
" https://vimawesome.com/plugin/vim-gitgutter | |
Plugin 'airblade/vim-gitgutter' | |
" https://vimawesome.com/plugin/palenight-vim | |
Plugin 'drewtempelmeyer/palenight.vim' | |
" https://vimawesome.com/plugin/vim-airline | |
Plugin 'bling/vim-airline' | |
" https://vimawesome.com/plugin/localvimrc | |
Plugin 'embear/vim-localvimrc' | |
" https://vimawesome.com/plugin/fugitive-vim | |
Plugin 'tpope/vim-fugitive' | |
" https://vimawesome.com/plugin/omnicppcomplete | |
Plugin 'OmniCppComplete' | |
" https://vimawesome.com/plugin/vim-glsl | |
Plugin 'tikhomirov/vim-glsl' | |
" https://vimawesome.com/plugin/quickhl-vim | |
Plugin 't9md/vim-quickhl' | |
" https://vimawesome.com/plugin/gsession-vim | |
Plugin 'c9s/gsession.vim' | |
" https://vimawesome.com/plugin/vim-syntax-extra | |
Plugin 'justinmk/vim-syntax-extra' | |
call vundle#end() | |
filetype plugin indent on | |
" ========== Plugin configurations ========== | |
"Palenight configuration | |
set background=dark | |
colorscheme palenight | |
"let g:lightline.colorscheme = 'palenight' | |
let g:airline_theme = "palenight" | |
let g:palenight_terminal_italics=1 | |
" Fugitive vim configutation | |
" Alias to open the Gstatus in another tab | |
command Gstat tab G | |
" Mutiple highligh config | |
" Add highlight to the word | |
nmap <Space>m <Plug>(quickhl-manual-this) | |
xmap <Space>m <Plug>(quickhl-manual-this) | |
" Highlight the exact word(Preferable) | |
nmap <Space>w <Plug>(quickhl-manual-this-whole-word) | |
xmap <Space>w <Plug>(quickhl-manual-this-whole-word) | |
" Remove all highlights | |
nmap <Space>M <Plug>(quickhl-manual-reset) | |
xmap <Space>M <Plug>(quickhl-manual-reset) | |
" Remove the word highlight | |
nmap <Space>c <Plug>(quickhl-manual-clear) | |
vmap <Space>c <Plug>(quickhl-manual-clear) | |
" Gsession.vim | |
" To save session: GSessionMake | |
let g:local_session_filename = '.session.vim' | |
" ========== Workarounds ========== | |
" vim hardcodes background color erase even if the terminfo file does | |
" not contain bce (not to mention that libvte based terminals | |
" incorrectly contain bce in their terminfo files). This causes | |
" incorrect background rendering when using a color theme with a | |
" background color. | |
let &t_ut='' | |
" Vim glsl workaround, | |
" For some reason this isn't been called | |
autocmd BufNewFile,BufRead *.vert,*.tesc,*.tese,*.glsl,*.geom,*.frag,*.comp set filetype=glsl |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment