" ================================== GENERAL ================================= set wildmenu " Better command-line completion set lazyredraw " Redraw only when we need to set relativenumber " Enable relative line numbers set number " Display current line number set tabstop=2 " Number of visual spaces per TAB set softtabstop=2 " Number of spaces in tab when editing set shiftwidth=2 " Number of spaces inserted on TAB press set expandtab " Insert spaces instead of tabs set incsearch " Show search matches as you type set hlsearch " Highlight all search matches set ignorecase " Use case insensitive search set smartcase " Except when using capital letters set encoding=utf-8 " Default encoding is UTF-8 scriptencoding utf-8 autocmd bufenter set colorcolumn=0 " Don't show colorcolumn by default autocmd FileType python set colorcolumn=89 " Highlight 89th column for python files set cursorline " Highlight current line set fillchars=vert:🭰,fold:-,eob:\ , set splitbelow " Vertical split splits below the current buffer set splitright " Horizontalsplit splits at the right of the current buffer set nowrap " Disable line wrap set noswapfile " Disavle swap file set confirm " Always ask for saving changes set background=dark " Use dark UI set diffopt+=vertical " Use vertical split for diffs set list " Show unprintable chars set listchars=tab:>-,trail:•,extends:#,nbsp:• " List of chars to show set history=100 " Remember 100 last commands set undolevels=100 " Use more levels of undo set nofoldenable " Don't fold by default set foldmethod=indent " Fold based on indentation set foldnestmax=5 " Maximum fold level set scrolloff=4 " Keep 4 lines above and below while scrolling highlight NonText ctermfg=0 " ============================== ABBREVIATIONS =============================== cnoreabbrev Qa qa cnoreabbrev QA qa cnoreabbrev Wq wq cnoreabbrev WQ wq cnoreabbrev Wqa wqa cnoreabbrev WQa wqa cnoreabbrev WQA wqa " =================================== KEYS =================================== " Split navigations nnoremap nnoremap nnoremap nnoremap " Change buffer width nnoremap > :vertical res +1 nnoremap < :vertical res -1 " Change buffer height nnoremap + :res +1 nnoremap - :res -1 " Use H and L to move at the beggining and at the end of the line nnoremap L $ nnoremap H ^ " Set Space as leader key let mapleader = ' ' " Open this file on F12 nnoremap :vsplit ~/.vimrc " Search mappings: These will make it so that going to the next one in a " search will center on the line it's found in. nnoremap n nzzzv nnoremap N Nzzzv " Insert python breakpoint map obreakpoint() " Copy to clipboard vnoremap y "+y nnoremap Y "+yg_ nnoremap y "+y nnoremap yy "+yy " Paste from clipboard nnoremap p "+p nnoremap P "+P vnoremap p "+p vnoremap P "+P " Use kj or jk for exit Insert mode, also move cursor rigth inoremap jk inoremap kj " Use double space for save nnoremap :w " This is important for COC and ALE work together let g:ale_disable_lsp = 1 " Toggle folding by TAB map za " ================================== PLUGINS ================================= call plug#begin('~/.vim/plugged') " Commnet/uncomment the code Plug 'tpope/vim-commentary' " Quoting/parenthesizing made simple Plug'tpope/vim-surround' " Enable repeating supported plugin maps with '.' Plug 'tpope/vim-repeat' " Camelcase, undersore, acronym words motions Plug 'chaoren/vim-wordmotion' " Fuzzy funder Plug 'junegunn/fzf.vim' " Asynchronous linting/fixing Plug 'dense-analysis/ale' " Working with CSV files Plug 'chrisbra/csv.vim' " Copy link to line in repo Plug 'biggerfisch/vim-gurl' " A tree file system explorer Plug 'scrooloose/nerdtree' " Displays tags in a window, ordered by scope Plug 'majutsushi/tagbar' " === Git === " A Git wrapper Plug 'tpope/vim-fugitive' " Shows a git diff in the gutter (sign column) and stages/undoes hunks Plug 'airblade/vim-gitgutter' " A plugin of NERDTree showing git status Plug 'Xuyuanp/nerdtree-git-plugin' " Autocompletion Plug 'neoclide/coc.nvim', {'branch': 'release'} " GitHub Copilot Plug 'github/copilot.vim' " === Python === " Python docstring generator Plug 'heavenshell/vim-pydocstring', { 'do': 'make install', 'for': 'python' } " Enhanced syntax highlightitng Plug 'sheerun/vim-polyglot' " No-BS Python code folding Plug 'tmhedberg/SimpylFold' " Syntax highlight for requerements.txt Plug 'raimon49/requirements.txt.vim', {'for': 'requirements'} " === UI === " Retro groove color scheme Plug 'morhetz/gruvbox' " Rainbow delimiters Plug 'luochen1990/rainbow' " Lean & mean status/tabline Plug 'bling/vim-airline' " Visually displaying indent levels Plug 'Yggdroot/indentLine' call plug#end() " =============================== PLUGINS SETUP ============================== " === Rainbow === let g:rainbow_active = 1 " === Tagbar === map :TagbarToggle let g:tagbar_autofocus = 0 " === Indent lines === let g:indentLine_char = '🭰' " === Theme === colorscheme gruvbox let g:gruvbox_italic = 1 set background=dark " === Airline === let g:airline_powerline_fonts = 1 let g:airline#extensions#tagbar#enabled = 1 let g:airline#extensions#ale#enabled = 1 let g:airline_skip_empty_sections = 1 let g:airline#parts#ffenc#skip_expected_string='utf-8[unix]' let g:airline#extensions#virtualenv#enabled = 1 function! AirlineInit() let g:airline_section_a = airline#section#create_left(['branch']) let g:airline_section_b = airline#section#create_left(['file']) let g:airline_section_c = airline#section#create_left(['tagbar']) let g:airline_section_x = airline#section#create_left(['readonly']) let g:airline_section_z = airline#section#create_right(['%l:%c/%L']) endfunction autocmd VimEnter * call AirlineInit() " === Colorizer === let g:colorizer_auto_color = 1 " === Ale === map :ALEFix let g:ale_list_window_size = 5 let g:ale_sign_error = '•' let g:ale_sign_warning = '•' let g:ale_echo_msg_error_str = 'E' let g:ale_echo_msg_warning_str = 'W' let g:ale_echo_msg_format = '[%linter%] %s [%severity%]' let g:ale_lint_on_text_changed = 'never' let g:ale_linters = { \ 'python': ['ruff', 'black', 'mypy'], \ 'md': ['mdl'], \ 'yaml': ['yamllint'], \ 'yml': ['yamllint'], \} let g:ale_fixers = { \ '*': ['remove_trailing_lines', 'trim_whitespace'], \ 'python': ['black', 'isort'], \ 'yaml': ['yamlfix'], \ 'yml': ['yamlfix'], \ 'json': ['jq'] \} nnoremap :ALENext nnoremap :ALEPrevious " === GitGutter === nnoremap :GitGutterPrevHunk nnoremap :GitGutterNextHunk nnoremap U :GitGutterUndoHunk highlight SignColumn ctermbg=bg highlight GitGutterAdd ctermfg=2 ctermbg=bg highlight GitGutterChange ctermfg=3 ctermbg=bg highlight GitGutterDelete ctermfg=1 ctermbg=bg highlight GitGutterChangeDelete ctermfg=166 ctermbg=bg let g:gitgutter_highlight_linenrs = 0 let g:gitgutter_sign_modified_removed = '~͟' let g:gitgutter_sign_removed_above_and_below = '_͞' " === FZF === map :Ag map :GFiles nnoremap :Ag " Save search results to quickfix list function! s:build_quickfix_list(lines) call setqflist(map(copy(a:lines), '{ "filename": v:val }')) copen cc endfunction let g:fzf_action = { \ 'ctrl-q': function('s:build_quickfix_list'), \ 'ctrl-t': 'tab split', \ 'ctrl-x': 'split', \ 'ctrl-v': 'vsplit', \ 'ctrl-a': 'select-all' \} command! -bang -nargs=? -complete=dir GFiles \ call fzf#vim#gitfiles(, fzf#vim#with_preview(), 0) command! -bang -nargs=* Ag call fzf#vim#ag(, ' --ignore-dir={node_modules,fme,venv,jest_cache,logs} --ignore=package-lock.json', fzf#vim#with_preview({'options': '--delimiter : --nth 4..'}), 0) autocmd! FileType fzf set laststatus=0 noshowmode noruler \| autocmd BufLeave set laststatus=2 showmode ruler " === NERDTree === map :NERDTreeToggle nmap F :NERDTreeFind let NERDTreeMapJumpParent='h' let NERDTreeMapOpenSplit='' let NERDTreeMapOpenVSplit='' let NERDTreeShowHidden=1 augroup vimrc " Close vim when only NERDTree is open autocmd bufenter * if ( \winnr("$") == 1 && \exists("b:NERDTree") && \b:NERDTree.isTabTree() \) | q | endif augroup END " Files to hide in NERDTree let NERDTreeIgnore = ['\~$', '\.pyc$', '\.pyo$', '\.class$', 'pip-log\.txt$', \'\.o$', '__pycache__', '.git', 'venv', '.cache'] let NERDTreeHighlightCursorline = 0 let g:NERDTreeFileExtensionHighlightFullName = 1 let g:NERDTreeExactMatchHighlightFullName = 1 let g:NERDTreePatternMatchHighlightFullName = 1 " Higlight NERDTree's filetypes with given color function! NERDTreeHighlightFile(ext, color) exec 'autocmd filetype nerdtree highlight ' . a:ext.' ctermfg='. a:color exec 'autocmd filetype nerdtree syn match ' . a:ext.' #^\s\+.*'. a:ext.'$#' endfunction " Apply above function to all file types call NERDTreeHighlightFile('css', 5) call NERDTreeHighlightFile('csv', 8) call NERDTreeHighlightFile('geojson', 10) call NERDTreeHighlightFile('html', 166) call NERDTreeHighlightFile('ipynb', 12) call NERDTreeHighlightFile('js', 3) call NERDTreeHighlightFile('json', 2) call NERDTreeHighlightFile('less', 13) call NERDTreeHighlightFile('log', 7) call NERDTreeHighlightFile('md', 6) call NERDTreeHighlightFile('MD', 6) call NERDTreeHighlightFile('rst', 14) call NERDTreeHighlightFile('mjml', 208) call NERDTreeHighlightFile('mjs', 11) call NERDTreeHighlightFile('py', 4) call NERDTreeHighlightFile('scss', 13) call NERDTreeHighlightFile('sh', 1) call NERDTreeHighlightFile('sql', 9) call NERDTreeHighlightFile('ts', 11) call NERDTreeHighlightFile('spec.ts', 8) call NERDTreeHighlightFile('xml', 15) call NERDTreeHighlightFile('yaml', 'magenta') call NERDTreeHighlightFile('yml', 'magenta') let g:NERDTreeMinimalMenu=1 " === NERDTree Git Plugin === " Prefixes for files with different git status let g:NERDTreeGitStatusIndicatorMapCustom = { \ 'Modified' : '*', \ 'Staged' : '+', \ 'Untracked' : '_', \ 'Renamed' : '%', \ 'Unmerged' : '═', \ 'Deleted' : 'x', \ 'Dirty' : '@', \ 'Clean' : 'C', \ 'Ignored' : '•', \ 'Unknown' : '?'} " === CSV.vim === augroup filetypedetect au! BufRead,BufNewFile *.csv,*.dat,*.CSV setfiletype csv augroup END let g:vim_json_syntax_conceal = 0 " === PyDocstring === nmap (pydocstring) " === COC === let g:coc_global_extensions = ['coc-tsserver', 'coc-jedi'] " Remap keys for applying codeAction to the current line. nmap a (coc-codeaction) " Apply AutoFix to problem on the current line. nmap f (coc-fix-current) " Completion nmap gd (coc-definition) nmap gt (coc-type-definition) nmap gi (coc-implementation) nmap gr (coc-references) " Prettify selected code. xmap p (coc-format-selected) nmap p (coc-format-selected) let g:python_highlight_all = 1 " Use (Shift-)TAB to iterate through autocomplete list inoremap coc#pum#visible() ? coc#pum#next(1) : "\" inoremap coc#pum#visible() ? coc#pum#prev(1) : "\" " ======== Vim Gurl ====================== let g:vimgurl_yank_register = '+' " copy to system buffer " ======== GitHub Copilot ====================== " nmap gc :Copilot panel