Last active
November 19, 2020 15:37
-
-
Save zer0tonin/9c26bb0ddb8e581d1ce5984daeabda04 to your computer and use it in GitHub Desktop.
NeoVim config for python and JS
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
" Requirements : | |
" plug.vim | |
" pip3 install neovim | |
" npm install -g neovim | |
" Post-setup | |
" :PlugInstall | |
" :UpdateRemotePlugins | |
" :CocInstall coc-json coc-tsserver | |
" pyenv | |
let g:python_host_prog = "/home/alicegg/.pyenv/versions/neovim2/bin/python" | |
let g:python3_host_prog = "/home/alicegg/.pyenv/versions/neovim3/bin/python" | |
" plugins | |
call plug#begin('~/.vim/plugged') | |
Plug 'ctrlpvim/ctrlp.vim' | |
Plug 'vim-airline/vim-airline' | |
Plug 'tpope/vim-fugitive' | |
Plug 'zer0tonin/vim-dracula' | |
Plug 'editorconfig/editorconfig-vim' | |
Plug 'tpope/vim-sleuth' | |
Plug 'neoclide/coc.nvim', {'branch':'release'} | |
call plug#end() | |
" coc config | |
set hidden | |
set nobackup | |
set nowritebackup | |
set cmdheight=2 | |
set updatetime=300 | |
set shortmess+=c | |
set signcolumn=number | |
inoremap <silent><expr> <TAB> | |
\ pumvisible() ? "\<C-n>" : | |
\ <SID>check_back_space() ? "\<TAB>" : | |
\ coc#refresh() | |
inoremap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<C-h>" | |
function! s:check_back_space() abort | |
let col = col('.') - 1 | |
return !col || getline('.')[col - 1] =~# '\s' | |
endfunction | |
inoremap <silent><expr> <c-space> coc#refresh() | |
inoremap <silent><expr> <cr> pumvisible() ? coc#_select_confirm() | |
\: "\<C-g>u\<CR>\<c-r>=coc#on_enter()\<CR>" | |
nmap <silent> [g <Plug>(coc-diagnostic-prev) | |
nmap <silent> ]g <Plug>(coc-diagnostic-next) | |
nmap <silent> gd <Plug>(coc-definition) | |
nmap <silent> gy <Plug>(coc-type-definition) | |
nmap <silent> gi <Plug>(coc-implementation) | |
nmap <silent> gr <Plug>(coc-references) | |
nnoremap <silent> K :call <SID>show_documentation()<CR> | |
function! s:show_documentation() | |
if (index(['vim','help'], &filetype) >= 0) | |
execute 'h '.expand('<cword>') | |
elseif (coc#rpc#ready()) | |
call CocActionAsync('doHover') | |
else | |
execute '!' . &keywordprg . " " . expand('<cword>') | |
endif | |
endfunction | |
autocmd CursorHold * silent call CocActionAsync('highlight') | |
nmap <leader>rn <Plug>(coc-rename) | |
xmap <leader>f <Plug>(coc-format-selected) | |
nmap <leader>f <Plug>(coc-format-selected) | |
augroup mygroup | |
autocmd! | |
autocmd FileType typescript,json setl formatexpr=CocAction('formatSelected') | |
autocmd User CocJumpPlaceholder call CocActionAsync('showSignatureHelp') | |
augroup end | |
xmap <leader>a <Plug>(coc-codeaction-selected) | |
nmap <leader>a <Plug>(coc-codeaction-selected) | |
nmap <leader>ac <Plug>(coc-codeaction) | |
nmap <leader>qf <Plug>(coc-fix-current) | |
xmap if <Plug>(coc-funcobj-i) | |
omap if <Plug>(coc-funcobj-i) | |
xmap af <Plug>(coc-funcobj-a) | |
omap af <Plug>(coc-funcobj-a) | |
xmap ic <Plug>(coc-classobj-i) | |
omap ic <Plug>(coc-classobj-i) | |
xmap ac <Plug>(coc-classobj-a) | |
omap ac <Plug>(coc-classobj-a) | |
nnoremap <nowait><expr> <C-f> coc#float#has_scroll() ? coc#float#scroll(1) : "\<C-f>" | |
nnoremap <nowait><expr> <C-b> coc#float#has_scroll() ? coc#float#scroll(0) : "\<C-b>" | |
inoremap <nowait><expr> <C-f> coc#float#has_scroll() ? "\<c-r>=coc#float#scroll(1)\<cr>" : "\<Right>" | |
inoremap <nowait><expr> <C-b> coc#float#has_scroll() ? "\<c-r>=coc#float#scroll(0)\<cr>" : "\<Left>" | |
vnoremap <nowait><expr> <C-f> coc#float#has_scroll() ? coc#float#nvim_scroll(1, 1) : "\<C-f>" | |
vnoremap <nowait><expr> <C-b> coc#float#has_scroll() ? coc#float#nvim_scroll(0, 1) : "\<C-b>" | |
nmap <silent> <C-s> <Plug>(coc-range-select) | |
xmap <silent> <C-s> <Plug>(coc-range-select) | |
command! -nargs=0 Format :call CocAction('format') | |
command! -nargs=? Fold :call CocAction('fold', <f-args>) | |
command! -nargs=0 OR :call CocAction('runCommand', 'editor.action.organizeImport') | |
set statusline^=%{coc#status()}%{get(b:,'coc_current_function','')} | |
nnoremap <silent><nowait> <space>a :<C-u>CocList diagnostics<cr> | |
nnoremap <silent><nowait> <space>e :<C-u>CocList extensions<cr> | |
nnoremap <silent><nowait> <space>c :<C-u>CocList commands<cr> | |
nnoremap <silent><nowait> <space>o :<C-u>CocList outline<cr> | |
nnoremap <silent><nowait> <space>s :<C-u>CocList -I symbols<cr> | |
nnoremap <silent><nowait> <space>j :<C-u>CocNext<CR> | |
nnoremap <silent><nowait> <space>k :<C-u>CocPrev<CR> | |
nnoremap <silent><nowait> <space>p :<C-u>CocListResume<CR> | |
" ctrl c to exit insert | |
inoremap <c-c> <ESC> | |
" Easy window switching | |
nmap <silent> <A-Up> :wincmd k<CR> | |
nmap <silent> <A-Down> :wincmd j<CR> | |
nmap <silent> <A-Left> :wincmd h<CR> | |
nmap <silent> <A-Right> :wincmd l<CR> | |
" theme | |
colorscheme dracula | |
" disable POSIX new line | |
set nofixeol | |
" display line numbers | |
set number | |
" horizontal scrolling | |
set nowrap | |
set sidescroll=1 | |
" tabs (overriden by vim-sleuth / editorconfig) | |
set tabstop=4 | |
set softtabstop=4 | | |
set shiftwidth=4 | | |
set expandtab | | |
set autoindent | | |
set fileformat=unix | |
" escape terminal mode with ESC | |
tnoremap <Esc> <C-\><C-n> | |
" allow project specific config files | |
set exrc | |
" filetype plugin | |
:filetype plugin on | |
" ignore ctrlp | |
let g:ctrlp_custom_ignore = '\v[\/](node_modules|target|dist|venv)|(\.(swp|ico|git|svn))$' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment