set nocompatible call plug#begin('~/.config/nvim/plugged') "General plugins Plug 'editorconfig/editorconfig-vim' Plug 'scrooloose/nerdtree' Plug 'scrooloose/nerdcommenter' Plug 'airblade/vim-gitgutter' " coc and ale Plug 'neoclide/coc.nvim', {'branch': 'release'} Plug 'w0rp/ale' Plug 'cjrh/vim-conda' Plug 'roxma/nvim-yarp' Plug 'roxma/vim-hug-neovim-rpc' Plug 'benekastah/neomake' Plug 'FooSoft/vim-argwrap' Plug 'tpope/vim-fugitive' Plug 'chrisbra/Colorizer' Plug 'ctrlpvim/ctrlp.vim' Plug 'fergdev/vim-cursor-hist' Plug 'lifepillar/vim-outlaw' Plug 'sickill/vim-pasta' Plug 'twinside/vim-hoogle' Plug 'mptre/vim-printf' Plug 'zef/vim-cycle' Plug 'tpope/vim-repeat' Plug 'majutsushi/tagbar' Plug 'vim-airline/vim-airline' Plug 'vim-airline/vim-airline-themes' Plug 'edkolev/tmuxline.vim' Plug 'sheerun/vim-polyglot' "Themes Plug 'nanotech/jellybeans.vim' " HTML support Plug 'mattn/emmet-vim' Plug 'lepture/vim-jinja' " Javascript support Plug 'pangloss/vim-javascript', { 'for': 'javascript' } " Python support Plug 'SirVer/ultisnips' Plug 'honza/vim-snippets' "Haskell Plug 'neovimhaskell/haskell-vim' Plug 'eagletmt/neco-ghc' "markdown Plug 'godlygeek/tabular' Plug 'plasticboy/vim-markdown' Plug 'iamcco/markdown-preview.nvim', { 'do': 'cd app && yarn install' } "go Plug 'fatih/vim-go', {'do': ':GoUpdateBinaries'} "Java Plug 'artur-shaik/vim-javacomplete2' "utils Plug 'junegunn/vim-easy-align' Plug 'triglav/vim-visual-increment' "toml Plug 'cespare/vim-toml' "fbs Plug 'zchee/vim-flatbuffers' call plug#end() :set dictionary="/usr/dict/words" xmap ga (EasyAlign) nmap ga (EasyAlign) let g:colorizer_auto_color = 1 let g:airline_powerline_fonts = 1 let g:airline#extensions#tabline#enabled = 1 let g:tmuxline_preset = "minimal" let g:powerline_pycmd = "py3" "coc config let g:coc_global_extensions = ['coc-json', 'coc-git', 'coc-css', 'coc-go', 'coc-tsserver', 'coc-html', 'coc-snippets', 'coc-yank', 'coc-toml', 'coc-eslint', 'coc-prettier', 'coc-highlight', 'coc-import-cost'] nmap [g (coc-diagnostic-prev) nmap ]g (coc-diagnostic-next) nmap gd (coc-definition) nmap gy (coc-type-definition) nmap gi (coc-implementation) nmap gr (coc-references) nnoremap K :call show_documentation() nnoremap :CocDiagnostics nnoremap :CocFix nnoremap :CocRestart :ALEReset function! s:show_documentation() if (index(['vim','help'], &filetype) >= 0) execute 'h '.expand('') else call CocAction('doHover') endif endfunction "ale let g:ale_linters_explicit = 1 let g:ale_fixers = { \ '*': ['remove_trailing_lines', 'trim_whitespace'], \ 'python': ['autopep8','yapf'], \ 'javascript': ['prettier','eslint'], \ 'typescript': ['prettier','tslint'], \ 'solidity': ['prettier'], \ 'go': ['goimports','gofmt'], \} let g:ale_linters = { \ '*': ['remove_trailing_lines', 'trim_whitespace'], \ 'python': [], \ 'javascript': [], \ 'typescript': [], \ 'go': [], \} let g:ale_fix_on_save = 1 " airline let g:airline#extensions#ale#enabled = 1 set hidden set nobackup set nowritebackup " Better display for messages set cmdheight=1 " You will have bad experience for diagnostic messages when it's default 4000. set updatetime=300 set mmp=5000 " don't give |ins-completion-menu| messages. set shortmess+=c " always show signcolumns set signcolumn=yes " Use tab for trigger completion with characters ahead and navigate. " Use command ':verbose imap ' to make sure tab is not mapped by other plugin. inoremap \ pumvisible() ? "\" : \ check_back_space() ? "\" : \ coc#refresh() inoremap pumvisible() ? "\" : "\" function! s:check_back_space() abort let col = col('.') - 1 return !col || getline('.')[col - 1] =~# '\s' endfunction " Use to trigger completion. inoremap coc#refresh() " Use to confirm completion, `u` means break undo chain at current position. " Coc only does snippet and additional edit on confirm. inoremap pumvisible() ? "\" : "\u\" " Or use `complete_info` if your vim support it, like: " inoremap complete_info()["selected"] != "-1" ? "\" : "\u\" " Use `[g` and `]g` to navigate diagnostics nmap [g (coc-diagnostic-prev) nmap ]g (coc-diagnostic-next) " Remap keys for gotos nmap gd (coc-definition) nmap gy (coc-type-definition) nmap gi (coc-implementation) nmap gr (coc-references) " Use K to show documentation in preview window nnoremap K :call show_documentation() function! s:show_documentation() if (index(['vim','help'], &filetype) >= 0) execute 'h '.expand('') else call CocAction('doHover') endif endfunction " Highlight symbol under cursor on CursorHold autocmd CursorHold * silent call CocActionAsync('highlight') autocmd FileType scss setl iskeyword+=@-@ " Remap for rename current word nmap rn (coc-rename) " Remap for format selected region xmap f (coc-format-selected) nmap f (coc-format-selected) augroup mygroup autocmd! " Setup formatexpr specified filetype(s). autocmd FileType typescript,json setl formatexpr=CocAction('formatSelected') " Update signature help on jump placeholder autocmd User CocJumpPlaceholder call CocActionAsync('showSignatureHelp') augroup end " Remap for do codeAction of selected region, ex: `aap` for current paragraph xmap a (coc-codeaction-selected) nmap a (coc-codeaction-selected) " Remap for do codeAction of current line nmap ac (coc-codeaction) " Fix autofix problem of current line nmap qf (coc-fix-current) " Create mappings for function text object, requires document symbols feature of languageserver. xmap if (coc-funcobj-i) xmap af (coc-funcobj-a) omap if (coc-funcobj-i) omap af (coc-funcobj-a) " Use for select selections ranges, needs server support, like: coc-tsserver, coc-python nmap (coc-range-select) xmap (coc-range-select) " Use `:Format` to format current buffer command! -nargs=0 Format :call CocAction('format') " Use `:Fold` to fold current buffer command! -nargs=? Fold :call CocAction('fold', ) " use `:OR` for organize import of current buffer command! -nargs=0 OR :call CocAction('runCommand', 'editor.action.organizeImport') " Add status line support, for integration with other plugin, checkout `:h coc-status` set statusline^=%{coc#status()}%{get(b:,'coc_current_function','')} " Using CocList " Show all diagnostics nnoremap a :CocList diagnostics " Manage extensions nnoremap e :CocList extensions " Show commands nnoremap c :CocList commands " Find symbol of current document nnoremap o :CocList outline " Search workspace symbols nnoremap s :CocList -I symbols " Do default action for next item. nnoremap j :CocNext " Do default action for previous item. nnoremap k :CocPrev " Resume latest coc list nnoremap p :CocListResume autocmd User CocJumpPlaceholder call CocActionAsync('showSignatureHelp') " " Cursor hist nnoremap j :call g:CursorHistForward() nnoremap k :call g:CursorHistBack() " NERDTree configuration let NERDTreeDirArrows=1 let g:NERDTreeDirArrowExpandable = '▸' let g:NERDTreeDirArrowCollapsible = '▾' let g:NERDTreeWinSize = 50 let NERDTreeShowHidden=1 let NERDTreeIgnore = ['\.pyc$', '__pycache__'] " Nerd tree nnoremap :NERDTreeToggle nnoremap f :NERDTreeFind vnoremap " Python syntax let python_highlight_all=1 " Javscript syntax let g:javascript_plugin_jsdoc = 1 let g:javascript_plugin_flow = 1 " JSX let g:jsx_ext_required = 0 " ArgWrap let g:argwrap_tail_comma_braces = '[' nnoremap w :ArgWrap " " Env variables " " " Python host config " let g:conda_startup_msg_suppress = 1 let g:conda_startup_wrn_suppress = 1 if !empty($CONDA_PREFIX) let g:python3_host_prog = $CONDA_PREFIX . '/bin/python' endif let s:current_python_path=$CONDA_PREFIX.'/bin/python' call coc#config('python', {'pythonPath': s:current_python_path}) " " Common settings " set encoding=utf-8 set autoread set backspace=indent,eol,start set ruler set showmode set history=1000 set hidden set ignorecase set smartcase set hlsearch set incsearch set showmatch set noerrorbells set novisualbell set laststatus=2 set autoindent set cindent set shiftwidth=2 set softtabstop=2 set tabstop=2 set expandtab set scrolloff=5 set foldmethod=indent set foldlevel=99 set showcmd set number set relativenumber set mouse=a set redrawtime=10000 set inccommand=split set nowrap " show completion options on set wildmenu " complete only up to the point of ambiguity set wildmode=list:longest " turn backup off, since most stuff is in git set nowb set noswapfile " ignore theme color for background let g:jellybeans_overrides = { \ 'background': { 'ctermbg': 'NONE', '256ctermbg': 'NONE' }, \} colorscheme jellybeans " Sync " and + registers set clipboard=unnamedplus " " Key mappings " let g:tex_flavor = "latex" " Toggle between line numbers and relative line numbers nnoremap u :exe "set " . (&relativenumber == 1 ? "norelativenumber" : "relativenumber") " Toggle between line numbers and relative line numbers au InsertEnter * :set norelativenumber au InsertLeave * :set relativenumber " Map leader let mapleader="\" "ctrlP let g:ctrlp_map = '' let g:ctrlp_cmd = 'CtrlP' let g:ctrlp_working_path_mode = 'ra' let g:ctrlp_user_command = ['.git/', 'git --git-dir=%s/.git ls-files -oc --exclude-standard'] set wildignore+=*/tmp/*,*.so,*.swp,*.zip " MacOSX/Linux let g:ctrlp_custom_ignore = 'dist' let g:ctrlp_custom_ignore = { \ 'dir': 'node_modules\|v[\/]\.(git|hg|svn)\|dist$', \ 'file': '\v\.(exe|so|dll)$', \ 'link': 'some_bad_symbolic_links', \ } " move between splits with hjkl map h map j map k map l " Remove search highlight on Enter nnoremap :nohlsearch " Don't loose selection on < or > xnoremap < >gv " Grepper nnoremap p :Grepper " ArgWrap nnoremap w :ArgWrap " trim whitespace on save au BufWritePre * :%s/\s\+$//e syntax sync fromstart autocmd FileType python setlocal completeopt-=preview autocmd BufReadPost,FileReadPost,BufNewFile,BufEnter * call system("tmux rename-window '" . expand("%:t") . "'") function! s:check_back_space() abort "{{{ let col = col('.') - 1 return !col || getline('.')[col - 1] =~ '\s' endfunction"}}}