"============================================================================== " vim-plug "============================================================================== " plugins list call plug#begin('~/.vim/plugged') Plug 'sheerun/vim-polyglot' " A ton of language syntax Plug 'morhetz/gruvbox' " Gruvbox theme Plug 'sickill/vim-monokai' " Monokai Theme Plug 'arcticicestudio/nord-vim' " Nord theme Plug 'itchyny/lightline.vim' " vim status bar Plug 'shinchu/lightline-gruvbox.vim' " Gruvbox theme for status line Plug 'airblade/vim-gitgutter' " Git gutter Plug 'lilydjwg/colorizer' " Displays the colors in file Plug 'jiangmiao/auto-pairs' " Auto create bracket/parens/quote pairs Plug 'vim-syntastic/syntastic' " coding-errors checker Plug 'neoclide/coc.nvim', {'branch': 'release'} " Lanuage server integrations Plug 'tpope/vim-fugitive' " git wrapper Plug 'fatih/vim-go', { 'do': ':GoUpdateBinaries' } " golang plugin for vim Plug 'Yggdroot/indentLine' " Indentation LInes Plug 'junegunn/fzf.vim' " Fuzzy search Plug 'francoiscabrol/ranger.vim' " Ranger f Plug 'scrooloose/nerdtree' " NerdTree - File tree (ctr-n) Plug 'Xuyuanp/nerdtree-git-plugin' " Git support in NERDTree Plug 'ryanoasis/vim-devicons' " File Icons - Always load last call plug#end() " Set encoding to utf8 set encoding=UTF-8 " install plugins automatically autocmd VimEnter * \ if len(filter(values(g:plugs), '!isdirectory(v:val.dir)')) \| PlugInstall --sync | q \| endif " remove unused plugins automatically autocmd VimEnter * \ if len(filter(split(globpath(g:plug_home, '*'), "\n"), 'isdirectory(v:val)')) \ > len(filter(values(g:plugs), 'stridx(v:val.dir, g:plug_home) == 0')) \| PlugClean | q \| endif " Toggle NerdTree with Ctrl+n map :NERDTreeToggle " Open fzf Files search map :Files " Open file search map :BLines " Indent Guides auto start let g:indent_guides_enable_on_vim_startup = 1 " Tab navigation and creation map :tabnew noremap :tabn noremap :tabp " Insert mode navigation Alt+hjkl imap imap imap imap " Set line heighlight on by default set cursorline " Set Clipboard to system set clipboard=unnamedplus " Enable mouse use in all modes set mouse=a " Auto highlight similar words when staying on a word after .5 sec set updatetime=500 augroup highlight_current_word au! au CursorHold * \ if ( expand("%") != 'NERD_tree_1' ) \ | :exec 'match Search /\V\<' . expand('') . '\>/' \ | endif augroup END "============================================================================== " Sync NERDTree with file "============================================================================== " Check if NERDTree is open or active function! IsNERDTreeOpen() return exists("t:NERDTreeBufName") && (bufwinnr(t:NERDTreeBufName) != -1) endfunction " Call NERDTreeFind iff NERDTree is active, current window contains a modifiable " file, and we're not in vimdiff function! SyncTree() if &modifiable && IsNERDTreeOpen() && strlen(expand('%')) > 0 && !&diff NERDTreeFind wincmd p endif endfunction " Highlight currently open buffer in NERDTree autocmd BufRead * call SyncTree() " Nerdtree show hidden files let NERDTreeShowHidden=1 " Dont show .git folder let NERDTreeIgnore=['\.git$'] "============================================================================== " Theme settings "============================================================================== let &t_8f = "\[38;2;%lu;%lu;%lum" let &t_8b = "\[48;2;%lu;%lu;%lum" set termguicolors " Setting dark mode set background=dark " Theme colorscheme gruvbox "============================================================================== " line number "============================================================================== " set relative number on visual mode and absolute number on insert mode set relativenumber set number autocmd InsertEnter * :set number norelativenumber autocmd InsertLeave * :set nonumber relativenumber " set backgrond and font color of line number highlight LineNr ctermfg=grey ctermbg=black " without this vim in tmux recive diffrent colors set background=dark " open files at the last remember line if has("autocmd") au BufReadPost * \ if line("'\"") > 0 && line("'\"") <= line("$") \| exe "normal! g`\"" \| endif endif "============================================================================== " TAB settings "============================================================================== "filetype plugin indent on " show existing tab with 4 spaces width set tabstop=4 " when indenting with '>', use 4 spaces width set shiftwidth=4 " On pressing tab, insert 4 spaces set expandtab "============================================================================== " set column "============================================================================== " set coding style limit at 80 chars set colorcolumn=80 "============================================================================== " mouse settings "============================================================================== " enable mouse set mouse=a "============================================================================== " file title "============================================================================== " always show current file title set title "============================================================================== " normal mode mapping "============================================================================== " mapping capsLock to ctrl map CapsLock Ctrl " this package is extending % to <> and other sifferent closures packadd! matchit :let b:match_words = '<:>,:' " enable ci( of all sorts to work from outside the parenthese nnoremap ci( %ci( nnoremap ci[ %ci[ nnoremap ci{ %ci{ " NOTE: use 'normal' for <> because % is not a regular vim command (package) nnoremap ci< :normal %ci< " enable di( of all sorts to work from outside the parenthese nnoremap di( %di( nnoremap di[ %di[ nnoremap di{ %di{ " NOTE: use 'normal' for <> because % is not a regular vim command (package) nnoremap di< :normal %di< " easy navigation on split screen nnoremap nnoremap nnoremap nnoremap " easy access to buffers " \l : list buffers " \b \f \g : go back/forward/last-used " \d : delete buffer nnoremap l :ls nnoremap b :bp nnoremap f :bn nnoremap g :e# nnoremap c :bd " make 'Y' act like 'D' and 'C' instead of working like 'yy' nnoremap Y y$ "============================================================================== " search settings "============================================================================== " ignore CASE in search set ignorecase " higlight search matches set hlsearch "============================================================================== " vim && tmux "============================================================================== " makes split-navigation act differently when in vim\tmux " in both cases navigation will be done with ctr + hjkl (without tmux prefix) if exists('$TMUX') function! TmuxOrSplitSwitch(wincmd, tmuxdir) let previous_winnr = winnr() silent! execute "wincmd " . a:wincmd if previous_winnr == winnr() call system("tmux select-pane -" . a:tmuxdir) redraw! endif endfunction let previous_title = substitute(system("tmux display-message -p '#{pane_title}'"), '\n', '', '') let &t_ti = "\]2;vim\\\" . &t_ti let &t_te = "\]2;". previous_title . "\\\" . &t_te nnoremap :call TmuxOrSplitSwitch('h', 'L') nnoremap :call TmuxOrSplitSwitch('j', 'D') nnoremap :call TmuxOrSplitSwitch('k', 'U') nnoremap :call TmuxOrSplitSwitch('l', 'R') else map h map j map k map l endif "============================================================================== " split settings "============================================================================== " " more intuitive default splits set splitbelow set splitright "============================================================================== " Lightline.vim plugin & status line "============================================================================== " make status line always visible set laststatus=2 " NOTE: 'FugitiveHead' is 'vim-fugitive' plugin's function and depend on it " configure lightline.vim status line let g:lightline = { \ 'active': { \ 'left': [ [ 'mode', 'paste' ], \ [ 'gitbranch', 'readonly', 'filename', 'modified' ] ] \ }, \ 'component_function': { \ 'gitbranch': 'FugitiveHead', \ 'filename': 'LightlineFilename', \ }, \ } " lightline colorscheme " let g:lightline.colorscheme = 'monokai' " function to get the filename from vim to lightline.vim function! LightlineFilename() return &filetype ==# 'vimfiler' ? vimfiler#get_status_string() : \ &filetype ==# 'unite' ? unite#get_status_string() : \ &filetype ==# 'vimshell' ? vimshell#get_status_string() : \ expand('%') !=# '' ? expand('%') : '[No Name]' endfunction let g:unite_force_overwrite_statusline = 0 let g:vimfiler_force_overwrite_statusline = 0 let g:vimshell_force_overwrite_statusline = 0 " actually this have no effect when lightline.vim plugin is installed set statusline+=%f "relative path (use %F for absolute path) set statusline+=%m "modified flag set statusline+=%= "left/right separator set statusline+=%l/%L "cursor line/total lines set statusline+=\ %P "percent through file "============================================================================== " Spelling settings "============================================================================== " make spell checker underline errors with vim 'set spell' command " Note: must appear after the last line that is altering colorscheme hi clear SpellBad hi SpellBad cterm=underline "============================================================================== " Delete settings "============================================================================== " make backspace always erase in insert mode and not only new inputs set backspace=indent,eol,start "============================================================================== " Fold settings "============================================================================== set foldmethod=marker "============================================================================== " vim-go settings "============================================================================== " make go-autocompletion start automatically after pressing '.' au Filetype go inoremap . . " fields and types highlight let g:go_highlight_types = 1 let g:go_highlight_extra_types = 1 " adds types like io.Reader, io.Writer etc let g:go_highlight_fields = 1 " make vim add and remove imports automatically on saving let g:go_fmt_command="goimports" " shows the under-cursor-object's signature (automatically run GoInfo) let g:go_auto_type_info = 1 " fixing `pattern uses more memory than 'maxmempattern'` error set mmp=5000 "============================================================================== " swp files "============================================================================== " Don't use swapfile set noswapfile