Created
November 4, 2019 04:05
-
-
Save zzandland/bccb1fab61afa2d1ed4303ce5d7d9309 to your computer and use it in GitHub Desktop.
init.vim
This file contains hidden or 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
| " ============================================================================ | |
| " Active plugins | |
| " You can disable or add new ones here: | |
| " this needs to be here, so vim-plug knows we are declaring the plugins we | |
| " want to use | |
| call plug#begin('~/.config/nvim/plugged') | |
| " Now the actual plugins: | |
| " Override configs by directory | |
| Plug 'arielrossanigo/dir-configs-override.vim' | |
| " Code commenter | |
| Plug 'scrooloose/nerdcommenter' | |
| " Better fileviewer | |
| Plug 'scrooloose/nerdtree' | |
| " Git plugin | |
| Plug 'Xuyuanp/nerdtree-git-plugin' | |
| " Class/module browser | |
| Plug 'majutsushi/tagbar' | |
| " Search results counter | |
| Plug 'vim-scripts/IndexedSearch' | |
| " Gruvbox theme for airline | |
| Plug 'morhetz/gruvbox' | |
| " Gruvbox 8 theme | |
| Plug 'lifepillar/vim-gruvbox8' | |
| " Airline | |
| Plug 'vim-airline/vim-airline' | |
| Plug 'vim-airline/vim-airline-themes' | |
| " Code and files fuzzy finder | |
| " Plug 'ctrlpvim/ctrlp.vim' | |
| " Extension to ctrlp, for fuzzy command finder | |
| " Plug 'fisadev/vim-ctrlp-cmdpalette' | |
| Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' } | |
| Plug 'junegunn/fzf.vim' | |
| " Pending tasks list | |
| Plug 'fisadev/FixedTaskList.vim' | |
| " Intellisense engine with full language server protocol support as VSCode | |
| Plug 'neoclide/coc.nvim', {'branch': 'release'} | |
| " Automatically close parenthesis, etc | |
| Plug 'Townk/vim-autoclose' | |
| " Surround | |
| Plug 'tpope/vim-surround' | |
| " Indent text object | |
| Plug 'michaeljsmith/vim-indent-object' | |
| " Indentation based movements | |
| Plug 'jeetsukumaran/vim-indentwise' | |
| " Better language packs | |
| Plug 'sheerun/vim-polyglot' | |
| " Paint css colors with the real color | |
| Plug 'lilydjwg/colorizer' | |
| " TODO is there a better option for neovim? | |
| " Window chooser | |
| Plug 't9md/vim-choosewin' | |
| " Automatically sort python imports | |
| Plug 'fisadev/vim-isort' | |
| " Highlight matching html tags | |
| Plug 'valloric/MatchTagAlways' | |
| " Code snippets for productivity | |
| Plug 'SirVer/ultisnips' | |
| Plug 'honza/vim-snippets' | |
| " Git integration | |
| Plug 'tpope/vim-fugitive' | |
| " Git/mercurial/others diff icons on the side of the file lines | |
| Plug 'mhinz/vim-signify' | |
| " Yank history navigation | |
| Plug 'vim-scripts/YankRing.vim' | |
| " Window swapper | |
| Plug 'wesQ3/vim-windowswap' | |
| " Syntax highlighting for neomutt | |
| Plug 'neomutt/neomutt.vim' | |
| " Tell vim-plug we finished declaring plugins, so it can load them | |
| call plug#end() | |
| " ============================================================================ | |
| " Vim settings and mappings | |
| " You can edit them as you wish | |
| " change leader key to comma | |
| let mapleader="," | |
| " tabs and spaces handling | |
| set expandtab | |
| set tabstop=2 | |
| set softtabstop=2 | |
| set shiftwidth=2 | |
| " show line numbers | |
| set nu | |
| " omni completion | |
| filetype plugin indent on | |
| set omnifunc=syntaxcomplete#Complete | |
| " spellcheck on | |
| set spelllang=en_us | |
| set spellfile=~/.config/nvim/spell/en.utf-8.add | |
| autocmd BufNewFile,BufRead *.md,*.txt,*.tex setlocal spell | |
| " needed so deoplete can auto select the first suggestion | |
| set completeopt+=noinsert | |
| " comment this line to enable autocompletion preview window | |
| " (displays documentation related to the selected completion option) | |
| set completeopt-=preview | |
| " autocompletion of files and commands behaves like shell | |
| " (complete only the common part, list the options that match) | |
| set wildmode=list:longest | |
| " automatically use the system clipboard for copy and paste | |
| set clipboard=unnamedplus | |
| " tab navigation mappings | |
| map tt :tabnew | |
| map <M-Right> :tabn<CR> | |
| imap <M-Right> <ESC>:tabn<CR> | |
| map <M-Left> :tabp<CR> | |
| imap <M-Left> <ESC>:tabp<CR> | |
| " when scrolling, keep cursor 3 lines away from screen border | |
| set scrolloff=3 | |
| " clear search results | |
| nnoremap <silent> // :noh<CR> | |
| " clear empty spaces at the end of lines on save of python files | |
| autocmd BufWritePre *.py :%s/\s\+$//e | |
| " automate g++ Makefile compilation and execution | |
| command Make !make; ./test; make clean | |
| " automate g++ compilation and execution | |
| command C !g++ %:t; ./a.out; rm a.out | |
| " automate JVM bytecode compilation then execution | |
| command Jav !jav %:t:r | |
| " automate python execution | |
| command Py !python %:t | |
| " Terminal Function | |
| let g:term_buf = 0 | |
| let g:term_win = 0 | |
| function! TermToggle(height) | |
| if win_gotoid(g:term_win) | |
| hide | |
| else | |
| botright new | |
| exec "resize " . a:height | |
| try | |
| exec "buffer " . g:term_buf | |
| catch | |
| call termopen($SHELL, {"detach": 0}) | |
| let g:term_buf = bufnr("") | |
| set nonumber | |
| set norelativenumber | |
| set signcolumn=no | |
| endtry | |
| startinsert! | |
| let g:term_win = win_getid() | |
| endif | |
| endfunction | |
| " Toggle terminal on/off (neovim) | |
| nnoremap <F1> :call TermToggle(12)<CR> | |
| tnoremap <F1> <C-\><C-n>:call TermToggle(12)<CR> | |
| " ============================================================================ | |
| " Plugins settings and mappings | |
| " Edit them as you wish. | |
| " Gruvbox ----------------------------- | |
| set background=dark | |
| colorscheme gruvbox8 | |
| " Tagbar ----------------------------- | |
| " toggle tagbar display | |
| map <F4> :TagbarToggle<CR> | |
| " autofocus on tagbar open | |
| let g:tagbar_autofocus = 1 | |
| " NERDTree ----------------------------- | |
| " open nerdtree with the current file selected | |
| nmap <F3> :NERDTreeFind<CR> | |
| " don't show these file types | |
| let NERDTreeIgnore = ['\.pyc$', '\.pyo$', '\.class$', '\.o$'] | |
| " no more ? for help | |
| let NERDTreeMinimalUI=1 | |
| " nerdtree starts when file opens | |
| autocmd StdinReadPre * let s:std_in=1 | |
| autocmd VimEnter * if argc() == 1 && isdirectory(argv()[0]) && !exists("s:std_in") | exe 'NERDTree' argv()[0] | wincmd p | ene | exe 'cd '.argv()[0] | endif | |
| " close nerdtree if only it remains | |
| autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif | |
| " NERDCommenter --------------------------- | |
| let g:NERDSpaceDelims = 1 | |
| " Tasklist ------------------------------ | |
| " show pending tasks list | |
| map <F2> :TaskList<CR> | |
| " Coc ----------------------------------------- | |
| " eslint correction | |
| nmap <F5> :CocCommand eslint.executeAutofix<CR> | |
| " Fzf ------------------------------ | |
| " | |
| " Reverse the layout to make the FZF list top-down | |
| let $FZF_DEFAULT_OPTS='--layout=reverse' | |
| " Using the custom window creation function | |
| let g:fzf_layout = { 'window': 'call FloatingFZF()' } | |
| " Customize fzf colors to match your color scheme | |
| let g:fzf_colors = | |
| \ { 'fg': ['fg', 'Normal'], | |
| \ 'bg': ['bg', 'Normal'], | |
| \ 'hl': ['fg', 'Comment'], | |
| \ 'fg+': ['fg', 'CursorLine', 'CursorColumn', 'Normal'], | |
| \ 'bg+': ['bg', 'CursorLine', 'CursorColumn'], | |
| \ 'hl+': ['fg', 'Statement'], | |
| \ 'info': ['fg', 'PreProc'], | |
| \ 'border': ['fg', 'Ignore'], | |
| \ 'prompt': ['fg', 'Conditional'], | |
| \ 'pointer': ['fg', 'Exception'], | |
| \ 'marker': ['fg', 'Keyword'], | |
| \ 'spinner': ['fg', 'Label'], | |
| \ 'header': ['fg', 'Comment'] } | |
| " Function to create the custom floating window | |
| function! FloatingFZF() | |
| " creates a scratch, unlisted, new, empty, unnamed buffer | |
| " to be used in the floating window | |
| let buf = nvim_create_buf(v:false, v:true) | |
| " 90% of the height | |
| let height = float2nr(&lines * 0.9) | |
| " 60% of the height | |
| let width = float2nr(&columns * 0.6) | |
| " horizontal position (centralized) | |
| let horizontal = float2nr((&columns - width) / 2) | |
| " vertical position (one line down of the top) | |
| let vertical = 1 | |
| let opts = { | |
| \ 'relative': 'editor', | |
| \ 'row': vertical, | |
| \ 'col': horizontal, | |
| \ 'width': width, | |
| \ 'height': height | |
| \ } | |
| " open the new window, floating, and enter to it | |
| call nvim_open_win(buf, v:true, opts) | |
| endfunction | |
| func! Test(a) | |
| echom "cword: "."\"".a:a."\"" | |
| endfunction | |
| " Reverse the layout to make the FZF list top-down | |
| let $FZF_DEFAULT_OPTS='--layout=reverse' | |
| " Using the custom window creation function | |
| let g:fzf_layout = { 'window': 'call FloatingFZF()' } | |
| " Customize fzf colors to match your color scheme | |
| let g:fzf_colors = | |
| \ { 'fg': ['fg', 'Normal'], | |
| \ 'bg': ['bg', 'Normal'], | |
| \ 'hl': ['fg', 'Comment'], | |
| \ 'fg+': ['fg', 'CursorLine', 'CursorColumn', 'Normal'], | |
| \ 'bg+': ['bg', 'CursorLine', 'CursorColumn'], | |
| \ 'hl+': ['fg', 'Statement'], | |
| \ 'info': ['fg', 'PreProc'], | |
| \ 'border': ['fg', 'Ignore'], | |
| \ 'prompt': ['fg', 'Conditional'], | |
| \ 'pointer': ['fg', 'Exception'], | |
| \ 'marker': ['fg', 'Keyword'], | |
| \ 'spinner': ['fg', 'Label'], | |
| \ 'header': ['fg', 'Comment'] } | |
| " Function to create the custom floating window | |
| function! FloatingFZF() | |
| " creates a scratch, unlisted, new, empty, unnamed buffer | |
| " to be used in the floating window | |
| let buf = nvim_create_buf(v:false, v:true) | |
| " 90% of the height | |
| let height = float2nr(&lines * 0.9) | |
| " 60% of the height | |
| let width = float2nr(&columns * 0.6) | |
| " horizontal position (centralized) | |
| let horizontal = float2nr((&columns - width) / 2) | |
| " vertical position (one line down of the top) | |
| let vertical = 1 | |
| let opts = { | |
| \ 'relative': 'editor', | |
| \ 'row': vertical, | |
| \ 'col': horizontal, | |
| \ 'width': width, | |
| \ 'height': height | |
| \ } | |
| " open the new window, floating, and enter to it | |
| call nvim_open_win(buf, v:true, opts) | |
| endfunction | |
| func! Test(a) | |
| echom "cword: "."\"".a:a."\"" | |
| endfunction | |
| " file finder mapping | |
| nmap ,f :Files<CR> | |
| " general code finder in all files mapping | |
| nmap ,r :Rg<CR> | |
| " search under the cursor | |
| nmap ,R :exec 'Rg' expand('<cword>')<CR> | |
| " commands finder mapping | |
| nmap ,c :Commands<CR> | |
| " Files command with preview window | |
| command! -bang -nargs=? -complete=dir Files | |
| \ call fzf#vim#files(<q-args>, fzf#vim#with_preview('right:60%'), <bang>0) | |
| " Ripgrep setting with preview window | |
| command! -bang -nargs=* Rg | |
| \ call fzf#vim#grep( | |
| \ 'rg --column --no-heading --fixed-strings --line-number --color=always --smart-case '.shellescape(<q-args>), 1, | |
| \ fzf#vim#with_preview({'options': '--delimiter : --nth 4.. -e'}, 'right:60%'), | |
| \ <bang>0) | |
| " Window Chooser ------------------------------ | |
| " mapping | |
| nmap - <Plug>(choosewin) | |
| " show big letters | |
| let g:choosewin_overlay_enable = 1 | |
| " Signify ------------------------------ | |
| " this first setting decides in which order try to guess your current vcs | |
| " UPDATE it to reflect your preferences, it will speed up opening files | |
| let g:signify_vcs_list = [ 'git', 'hg' ] | |
| " mappings to jump to changed blocks | |
| nmap <leader>sn <plug>(signify-next-hunk) | |
| nmap <leader>sp <plug>(signify-prev-hunk) | |
| " nicer colors | |
| highlight DiffAdd cterm=bold ctermbg=none ctermfg=119 | |
| highlight DiffDelete cterm=bold ctermbg=none ctermfg=167 | |
| highlight DiffChange cterm=bold ctermbg=none ctermfg=227 | |
| highlight SignifySignAdd cterm=bold ctermbg=237 ctermfg=119 | |
| highlight SignifySignDelete cterm=bold ctermbg=237 ctermfg=167 | |
| highlight SignifySignChange cterm=bold ctermbg=237 ctermfg=227 | |
| " Autoclose ------------------------------ | |
| " Fix to let ESC work as espected with Autoclose plugin | |
| " (without this, when showing an autocompletion window, ESC won't leave insert | |
| " mode) | |
| let g:AutoClosePumvisible = {"ENTER": "\<C-Y>", "ESC": "\<ESC>"} | |
| " Yankring ------------------------------- | |
| " Fix for yankring and neovim problem when system has non-text things copied | |
| " in clipboard | |
| let g:yankring_clipboard_monitor = 0 | |
| let g:yankring_history_dir = '~/.config/nvim/' | |
| " Airline ------------------------------- | |
| let g:airline_powerline_fonts = 0 | |
| let g:airline_theme = 'gruvbox' | |
| let g:airline#extensions#whitespace#enabled = 1 | |
| " enable/disable ale integration | |
| let g:airline#extensions#ale#enabled = 1 | |
| " ale error_symbol | |
| let airline#extensions#ale#error_symbol = 'E:' | |
| " ale warning | |
| let airline#extensions#ale#warning_symbol = 'W:' | |
| " ale show_line_numbers | |
| let airline#extensions#ale#show_line_numbers = 1 | |
| " ale open_lnum_symbol | |
| let airline#extensions#ale#open_lnum_symbol = '(L' | |
| " ale close_lnum_symbol | |
| let airline#extensions#ale#close_lnum_symbol = ')' | |
| " to use fancy symbols for airline, uncomment the following lines and use a | |
| " patched font (more info on the README.rst) | |
| if !exists('g:airline_symbols') | |
| let g:airline_symbols = {} | |
| endif | |
| " " powerline symbols | |
| let g:airline_left_sep = '' | |
| let g:airline_left_alt_sep = '' | |
| let g:airline_right_sep = '' | |
| let g:airline_right_alt_sep = '' | |
| let g:airline_symbols.branch = '' | |
| let g:airline_symbols.readonly = '' | |
| let g:airline_symbols.linenr = '☰' | |
| let g:airline_symbols.maxlinenr = '' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment