Last active
July 29, 2020 17:36
-
-
Save CHINOBv/9189605bfe8e715665b22aa49d85f4f6 to your computer and use it in GitHub Desktop.
My configuration for NeoVim
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
set number | |
set title | |
set mouse=a | |
set numberwidth=1 | |
set clipboard=unnamed | |
syntax enable | |
set showcmd | |
set ruler | |
set encoding=utf8 | |
set showmatch | |
set sw=2 | |
set relativenumber | |
set laststatus=2 | |
set noshowmode | |
set cursorline | |
set colorcolumn=120 | |
set nowrap | |
set tabstop=2 | |
set softtabstop=2 | |
set shiftround | |
set expandtab | |
set hidden | |
set ignorecase | |
set smartcase | |
set spelllang=en,es | |
set termguicolors | |
"set background=dark | |
" Specify a directory for plugins | |
call plug#begin('~/.vim/plugged') | |
Plug 'neoclide/coc.nvim', {'branch': 'release'} | |
Plug 'scrooloose/nerdtree' | |
"Plug 'tsony-tsonev/nerdtree-git-plugin' | |
Plug 'Xuyuanp/nerdtree-git-plugin' | |
Plug 'tiagofumo/vim-nerdtree-syntax-highlight' | |
Plug 'ryanoasis/vim-devicons' | |
Plug 'airblade/vim-gitgutter' | |
Plug 'ctrlpvim/ctrlp.vim' " fuzzy find files | |
Plug 'scrooloose/nerdcommenter' | |
Plug 'prettier/vim-prettier', { 'do': 'yarn install' } | |
Plug 'christoomey/vim-tmux-navigator' | |
Plug 'morhetz/gruvbox' | |
Plug 'HerringtonDarkholme/yats.vim' " TS Syntax | |
"""""""""""""""""" | |
"" Status | |
"""""""""""""""""" | |
Plug 'airblade/vim-gitgutter' | |
Plug 'vim-airline/vim-airline' | |
""""""""""""""""""""" | |
" Syntax Support | |
" Individual syntax plugins not needed, because provided by polyglot | |
Plug 'sheerun/vim-polyglot' | |
" handled below | |
let g:polyglot_disabled = ['css', 'ts', 'typescript', 'js', 'javascript', 'hbs', 'json'] | |
" CSS | |
Plug 'alexlafroscia/postcss-syntax.vim' | |
" Typescript syntax | |
Plug 'leafgarland/typescript-vim' | |
" JavaScript Syntax | |
Plug 'pangloss/vim-javascript' | |
let g:javascript_plugin_jsdoc = 1 | |
" Ember template highlighting | |
Plug 'joukevandermaas/vim-ember-hbs' | |
" Nested syntax highlighting | |
" needed for js/ts named template literals | |
" and markdown. | |
Plug 'Quramy/vim-js-pretty-template' | |
"Syntax | |
Plug 'sheerun/vim-polyglot' | |
Plug 'pangloss/vim-javascript', { 'for': 'javascript' } | |
Plug 'othree/html5.vim', { 'for': 'html' } | |
Plug 'plasticboy/vim-markdown', { 'for': 'markdown' } | |
Plug 'hail2u/vim-css3-syntax', { 'for': 'css' } | |
Plug 'pangloss/vim-javascript' " JavaScript support | |
Plug 'leafgarland/typescript-vim' " TypeScript syntax | |
Plug 'maxmellon/vim-jsx-pretty' " JS and JSX syntax | |
Plug 'jparise/vim-graphql' " GraphQL syntax | |
"FZF | |
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' } | |
Plug 'junegunn/fzf.vim' | |
"Search Files | |
Plug 'ctrlpvim/ctrlp.vim' | |
Plug 'haya14busa/incsearch.vim' | |
"Utils | |
Plug 'tpope/vim-surround' | |
Plug 'tpope/vim-repeat' | |
Plug 'tpope/vim-eunuch' | |
Plug 'jiangmiao/auto-pairs' | |
Plug 'tpope/vim-fugitive' | |
Plug 'airblade/vim-gitgutter' | |
Plug 'xuyuanp/nerdtree-git-plugin' | |
"Auto Complete | |
Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' } | |
Plug 'Shougo/neco-syntax' " Fuente general de auto completado | |
" Funcs | |
Plug 'Shougo/echodoc.vim' | |
"Snippets | |
Plug 'sirver/ultisnips' | |
Plug 'honza/vim-snippets' | |
" Initialize plugin system | |
call plug#end() | |
command! -nargs=0 Prettier :CocCommand prettier.formatFile | |
let mapleader=" " | |
nmap <C-s><Plug>(easymotion-s2) | |
nmap <Leader>nt :NERDTreeFind<CR> | |
nmap <Leader>w :w<CR> | |
nmap <Leader>0 :q<CR> | |
nnoremap <Leader>j :bprevious<CR> | |
nmap <Leader>l :bnext<CR> | |
nmap <Leader>q :bdelete<CR> | |
inoremap jk <ESC> | |
"nmap <C-n> :NERDTreeToggle<CR> | |
"vmap ++ <plug>NERDCommenterToggle | |
"nmap ++ <plug>NERDCommenterToggle | |
" open NERDTree automatically | |
"autocmd StdinReadPre * let s:std_in=1 | |
"autocmd VimEnter * NERDTree | |
let g:NERDTreeGitStatusWithFlags = 1 | |
"let g:WebDevIconsUnicodeDecorateFolderNodes = 1 | |
"let g:NERDTreeGitStatusNodeColorization = 1 | |
"let g:NERDTreeColorMapCustom = { | |
"\ "Staged" : "#0ee375", | |
"\ "Modified" : "#d9bf91", | |
"\ "Renamed" : "#51C9FC", | |
"\ "Untracked" : "#FCE77C", | |
"\ "Unmerged" : "#FC51E6", | |
"\ "Dirty" : "#FFBD61", | |
"\ "Clean" : "#87939A", | |
"\ "Ignored" : "#808080" | |
"\ } | |
let g:NERDTreeIgnore = ['^node_modules$'] | |
" vim-prettier | |
"let g:prettier#quickfix_enabled = 0 | |
"let g:prettier#quickfix_auto_focus = 0 | |
" prettier command for coc | |
command! -nargs=0 Prettier :CocCommand prettier.formatFile | |
" run prettier on save | |
"let g:prettier#autoformat = 0 | |
"autocmd BufWritePre *.js,*.jsx,*.mjs,*.ts,*.tsx,*.css,*.less,*.scss,*.json,*.graphql,*.md,*.vue,*.yaml,*.html PrettierAsync | |
" ctrlp | |
let g:ctrlp_user_command = ['.git/', 'git --git-dir=%s/.git ls-files -oc --exclude-standard'] | |
" j/k will move virtual lines (lines that wrap) | |
noremap <silent> <expr> j (v:count == 0 ? 'gj' : 'j') | |
noremap <silent> <expr> k (v:count == 0 ? 'gk' : 'k') | |
set relativenumber | |
set smarttab | |
set cindent | |
set tabstop=2 | |
set shiftwidth=2 | |
" always uses spaces instead of tab characters | |
set expandtab | |
colorscheme gruvbox | |
" sync open file with NERDTree | |
" " 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 BufEnter * call SyncTree() | |
" coc config | |
let g:coc_global_extensions = [ | |
\ 'coc-snippets', | |
\ 'coc-pairs', | |
\ 'coc-tsserver', | |
\ 'coc-eslint', | |
\ 'coc-prettier', | |
\ 'coc-json', | |
\ ] | |
" from readme | |
" if hidden is not set, TextEdit might fail. | |
set hidden " Some servers have issues with backup files, see #649 set nobackup set nowritebackup " Better display for messages set cmdheight=2 " You will have bad experience for diagnostic messages when it's default 4000. | |
set updatetime=300 | |
" 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 <tab>' to make sure tab is not mapped by other plugin. | |
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 | |
" Use <c-space> to trigger completion. | |
inoremap <silent><expr> <c-space> coc#refresh() | |
" Use <cr> to confirm completion, `<C-g>u` means break undo chain at current position. | |
" Coc only does snippet and additional edit on confirm. | |
inoremap <expr> <cr> pumvisible() ? "\<C-y>" : "\<C-g>u\<CR>" | |
" Or use `complete_info` if your vim support it, like: | |
" inoremap <expr> <cr> complete_info()"selected"] != "-1" ? "\<C-y>" : "\<C-g>u\<CR>" | |
" Use `[g` and `]g` to navigate diagnostics | |
nmap <silent> [g <Plug>(coc-diagnostic-prev) | |
nmap <silent> ]g <Plug>(coc-diagnostic-next) | |
" Remap keys for gotos | |
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) | |
" Use K to show documentation in preview window | |
nnoremap <silent> K :call <SID>show_documentation()<CR> | |
function! s:show_documentation() | |
if (index(['vim','help'], &filetype) >= 0) | |
execute 'h '.expand('<cword>') | |
else | |
call CocAction('doHover') | |
endif | |
endfunction | |
" Highlight symbol under cursor on CursorHold | |
autocmd CursorHold * silent call CocActionAsync('highlight') | |
" Remap for rename current word | |
nmap <F2> <Plug>(coc-rename) | |
" Remap for format selected region | |
xmap <leader>f <Plug>(coc-format-selected) | |
nmap <leader>f <Plug>(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: `<leader>aap` for current paragraph | |
xmap <leader>a <Plug>(coc-codeaction-selected) | |
nmap <leader>a <Plug>(coc-codeaction-selected) | |
" Remap for do codeAction of current line | |
nmap <leader>ac <Plug>(coc-codeaction) | |
" Fix autofix problem of current line | |
nmap <leader>qf <Plug>(coc-fix-current) | |
" Create mappings for function text object, requires document symbols feature of languageserver. | |
xmap if <Plug>(coc-funcobj-i) | |
xmap af <Plug>(coc-funcobj-a) | |
omap if <Plug>(coc-funcobj-i) | |
omap af <Plug>(coc-funcobj-a) | |
" Use <C-d> for select selections ranges, needs server support, like: coc-tsserver, coc-python | |
nmap <silent> <C-d> <Plug>(coc-range-select) | |
xmap <silent> <C-d> <Plug>(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', <f-args>) | |
" 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 <silent> <space>a :<C-u>CocList diagnostics<cr> | |
" Manage extensions | |
nnoremap <silent> <space>e :<C-u>CocList extensions<cr> | |
" Show commands | |
nnoremap <silent> <space>c :<C-u>CocList commands<cr> | |
" Find symbol of current document | |
nnoremap <silent> <space>o :<C-u>CocList outline<cr> | |
" Search workspace symbols | |
nnoremap <silent> <space>s :<C-u>CocList -I symbols<cr> | |
" Do default action for next item. | |
nnoremap <silent> <space>j :<C-u>CocNext<CR> | |
" Do default action for previous item. | |
nnoremap <silent> <space>k :<C-u>CocPrev<CR> | |
" Resume latest coc list | |
nnoremap <silent> <space>p :<C-u>CocListResume<CR>[ | |
"StatusS | |
"""""""""""""""""" | |
"" Status | |
"""""""""""""""""" | |
let g:airline_powerline_fonts = 1 | |
if !exists('g:airline_symbols') | |
let g:airline_symbols = {} | |
endif | |
let g:airline_symbols.space = "\ua0" | |
let g:airline#extensions#tabline#enabled = 0 | |
let g:airline#extensions#tabline#formatter = 'unique_tail_improved' | |
""""""""""""""""""""" | |
let NERDTreeQuitOnOpen=1 | |
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
set number | |
set title | |
set mouse=a | |
set numberwidth=1 | |
set clipboard=unnamed | |
syntax enable | |
set showcmd | |
set ruler | |
set encoding=utf8 | |
set showmatch | |
set sw=2 | |
set relativenumber | |
set laststatus=2 | |
set noshowmode | |
set cursorline | |
set colorcolumn=120 | |
set nowrap | |
set tabstop=2 | |
set softtabstop=2 | |
set shiftround | |
set expandtab | |
set hidden | |
set ignorecase | |
set smartcase | |
set spelllang=en,es | |
"set termguicolors | |
"set background=dark | |
set clipboard+=unnamedplus | |
set clipboard=unnamedplus | |
" Specify a directory for plugins | |
call plug#begin('~/.vim/plugged') | |
Plug 'rafi/awesome-vim-colorschemes' | |
let $NVIM_TUI_ENABLE_TRUE_COLOR=1 | |
Plug 'stsewd/sphinx.nvim', { 'do': ':UpdateRemotePlugins' } | |
Plug 'pangloss/vim-javascript' | |
Plug 'neoclide/coc.nvim', {'branch': 'release'} | |
" coc extensions | |
let g:coc_global_extensions = ['coc-tslint-plugin', 'coc-tsserver', 'coc-emmet', 'coc-css', 'coc-html', 'coc-json', 'coc-yank', 'coc-prettier'] | |
"------------------------ VIM TSX ------------------------ | |
" by default, if you open tsx file, neovim does not show syntax colors | |
" vim-tsx will do all the coloring for jsx in the .tsx file | |
Plug 'ianks/vim-tsx' | |
"------------------------ VIM TSX ------------------------ | |
" by default, if you open tsx file, neovim does not show syntax colors | |
" typescript-vim will do all the coloring for typescript keywords | |
Plug 'leafgarland/typescript-vim' | |
"------------------------ THEME ------------------------ | |
" most importantly you need a good color scheme to write good code :D | |
Plug 'dikiaap/minimalist' | |
Plug 'scrooloose/nerdtree' | |
"Plug 'tsony-tsonev/nerdtree-git-plugin' | |
Plug 'Xuyuanp/nerdtree-git-plugin' | |
Plug 'tiagofumo/vim-nerdtree-syntax-highlight' | |
Plug 'ryanoasis/vim-devicons' | |
Plug 'airblade/vim-gitgutter' | |
Plug 'ctrlpvim/ctrlp.vim' " fuzzy find files | |
Plug 'scrooloose/nerdcommenter' | |
Plug 'prettier/vim-prettier', { 'do': 'yarn install' } | |
Plug 'christoomey/vim-tmux-navigator' | |
Plug 'morhetz/gruvbox' | |
Plug 'HerringtonDarkholme/yats.vim' " TS Syntax | |
"""""""""""""""""" | |
"" Status | |
"""""""""""""""""" | |
Plug 'airblade/vim-gitgutter' | |
Plug 'vim-airline/vim-airline' | |
""""""""""""""""""""" | |
" Syntax Support | |
" Individual syntax plugins not needed, because provided by polyglot | |
Plug 'sheerun/vim-polyglot' | |
" handled below | |
let g:polyglot_disabled = ['css', 'ts', 'typescript', 'js', 'javascript', 'hbs', 'json'] | |
" CSS | |
Plug 'alexlafroscia/postcss-syntax.vim' | |
" Typescript syntax | |
Plug 'leafgarland/typescript-vim' | |
" JavaScript Syntax | |
Plug 'pangloss/vim-javascript' | |
let g:javascript_plugin_jsdoc = 1 | |
" Ember template highlighting | |
Plug 'joukevandermaas/vim-ember-hbs' | |
" Nested syntax highlighting | |
" needed for js/ts named template literals | |
" and markdown. | |
Plug 'Quramy/vim-js-pretty-template' | |
" === Javascript Plugins === " | |
" Typescript syntax highlighting | |
Plug 'HerringtonDarkholme/yats.vim' | |
" ReactJS JSX syntax highlighting | |
Plug 'mxw/vim-jsx' | |
" === vim-javascript === " | |
" Enable syntax highlighting for JSDoc | |
let g:javascript_plugin_jsdoc = 1 | |
" === vim-jsx === " | |
" Highlight jsx syntax even in non .jsx files | |
let g:jsx_ext_required = 0 | |
" === javascript-libraries-syntax === " | |
let g:used_javascript_libs = 'underscore,requirejs,chai,jquery' | |
"Syntax | |
Plug 'sheerun/vim-polyglot' | |
Plug 'pangloss/vim-javascript', { 'for': 'javascript' } | |
Plug 'othree/html5.vim', { 'for': 'html' } | |
Plug 'plasticboy/vim-markdown', { 'for': 'markdown' } | |
Plug 'hail2u/vim-css3-syntax', { 'for': 'css' } | |
Plug 'pangloss/vim-javascript' " JavaScript support | |
Plug 'leafgarland/typescript-vim' " TypeScript syntax | |
"Plug 'maxmellon/vim-jsx-pretty' " JS and JSX syntax | |
Plug 'jparise/vim-graphql' " GraphQL syntax | |
"FZF | |
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' } | |
Plug 'junegunn/fzf.vim' | |
"Search Files | |
Plug 'ctrlpvim/ctrlp.vim' | |
Plug 'haya14busa/incsearch.vim' | |
"Utils | |
Plug 'tpope/vim-surround' | |
Plug 'tpope/vim-repeat' | |
Plug 'tpope/vim-eunuch' | |
Plug 'jiangmiao/auto-pairs' | |
Plug 'tpope/vim-fugitive' | |
Plug 'airblade/vim-gitgutter' | |
Plug 'xuyuanp/nerdtree-git-plugin' | |
"Auto Complete | |
Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' } | |
Plug 'Shougo/neco-syntax' " Fuente general de auto completado | |
Plug 'Shougo/neco-vim' | |
Plug 'neoclide/coc-neco' | |
Plug 'nvim-lua/completion-nvim' | |
"lua require'nvim_lsp'.pyls.setup{on_attach=require'completion'.on_attach} | |
" Use completion-nvim in every buffer | |
"autocmd BufEnter * lua require'completion'.on_attach() | |
" Set completeopt to have a better completion experience | |
set completeopt=menuone,noinsert,noselect | |
" Funcs | |
Plug 'Shougo/echodoc.vim' | |
"Snippets | |
Plug 'sirver/ultisnips' | |
Plug 'honza/vim-snippets' | |
function! PackagerInit() abort | |
packadd vim-packager | |
call packager#init() | |
call packager#add('kristijanhusak/vim-packager', { 'type': 'opt' }) | |
call packager#add('tpope/vim-dadbod') | |
call packager#add('kristijanhusak/vim-dadbod-completion') | |
call packager#add('Shougo/deoplete.nvim') | |
"or | |
call packager#add('haorenW1025/completion-nvim') | |
endfunction | |
" For built in omnifunc | |
autocmd FileType sql setlocal omnifunc=vim_dadbod_completion#omni | |
" For completion-nvim | |
augroup completion | |
autocmd! | |
" autocmd BufEnter * lua require'completion'.on_attach() | |
autocmd FileType sql let g:completion_trigger_character = ['.', '"'] | |
augroup END | |
" Source is automatically added, you just need to include it in the chain complete list | |
"let g:completion_chain_complete_list = {[ | |
" \ 'sql': [ | |
" \ {'complete_items': ['vim-dadbod-completion']}, | |
" \ ], | |
" ]} | |
let g:vim_dadbod_completion_mark = 'MYMARK' | |
Plug 'drewtempelmeyer/palenight.vim' | |
let g:lightline = { 'colorscheme': 'palenight' } | |
let g:airline_theme = "palenight" | |
if (has("nvim")) | |
"For Neovim 0.1.3 and 0.1.4 < https://github.com/neovim/neovim/pull/2198 > | |
let $NVIM_TUI_ENABLE_TRUE_COLOR=1 | |
endif | |
"For Neovim > 0.1.5 and Vim > patch 7.4.1799 < https://github.com/vim/vim/commit/61be73bb0f965a895bfb064ea3e55476ac175162 > | |
"Based on Vim patch 7.4.1770 (`guicolors` option) < https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd > | |
" < https://github.com/neovim/neovim/wiki/Following-HEAD#20160511 > | |
if (has("termguicolors")) | |
set termguicolors | |
endif | |
" Italics for my favorite color scheme | |
let g:palenight_terminal_italics=1 | |
" Initialize plugin system | |
call plug#end() | |
command! -nargs=0 Prettier :CocCommand prettier.formatFile | |
let mapleader=" " | |
nmap <C-s><Plug>(easymotion-s2) | |
nmap <Leader>nt :NERDTreeFind<CR> | |
nmap <Leader>w :w<CR> | |
nmap <Leader>0 :q<CR> | |
nnoremap <Leader>j :bprevious<CR> | |
nmap <Leader>l :bnext<CR> | |
nmap <Leader>q :bdelete<CR> | |
inoremap jk <ESC> | |
"nmap <C-n> :NERDTreeToggle<CR> | |
"vmap ++ <plug>NERDCommenterToggle | |
"nmap ++ <plug>NERDCommenterToggle | |
" open NERDTree automatically | |
"autocmd StdinReadPre * let s:std_in=1 | |
"autocmd VimEnter * NERDTree | |
let g:NERDTreeGitStatusWithFlags = 1 | |
"let g:WebDevIconsUnicodeDecorateFolderNodes = 1 | |
"let g:NERDTreeGitStatusNodeColorization = 1 | |
"let g:NERDTreeColorMapCustom = { | |
"\ "Staged" : "#0ee375", | |
"\ "Modified" : "#d9bf91", | |
"\ "Renamed" : "#51C9FC", | |
"\ "Untracked" : "#FCE77C", | |
"\ "Unmerged" : "#FC51E6", | |
"\ "Dirty" : "#FFBD61", | |
"\ "Clean" : "#87939A", | |
"\ "Ignored" : "#808080" | |
"\ } | |
let g:NERDTreeIgnore = ['^node_modules$'] | |
" vim-prettier | |
"let g:prettier#quickfix_enabled = 0 | |
"let g:prettier#quickfix_auto_focus = 0 | |
" prettier command for coc | |
command! -nargs=0 Prettier :CocCommand prettier.formatFile | |
" run prettier onsave | |
"let g:prettier#autoformat = 0 | |
"autocmd BufWritePre *.js,*.jsx,*.mjs,*.ts,*.tsx,*.css,*.less,*.scss,*.json,*.graphql,*.md,*.vue,*.yaml,*.html PrettierAsync | |
" ctrlp | |
let g:ctrlp_user_command = ['.git/', 'git --git-dir=%s/.git ls-files -oc --exclude-standard'] | |
" j/k will move virtual lines (lines that wrap) | |
noremap <silent> <expr> j (v:count == 0 ? 'gj' : 'j') | |
noremap <silent> <expr> k (v:count == 0 ? 'gk' : 'k') | |
set relativenumber | |
set smarttab | |
set cindent | |
set tabstop=2 | |
set shiftwidth=2 | |
" always uses spaces instead of tab characters | |
set expandtab | |
colorscheme gruvbox | |
" sync open file with NERDTree | |
" " 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 BufEnter * call SyncTree() | |
" coc config | |
let g:coc_global_extensions = [ | |
\ 'coc-snippets', | |
\ 'coc-pairs', | |
\ 'coc-tsserver', | |
\ 'coc-eslint', | |
\ 'coc-prettier', | |
\ 'coc-json', | |
\ 'coc-dictionary', | |
\ 'coc-tag', | |
\ 'coc-word', | |
\ 'coc-emoji', | |
\ 'coc-omni', | |
\ 'coc-syntax', | |
\ 'coc-gocode', | |
\ 'coc-ultisnips', | |
\ 'coc-neosnippet', | |
\ ] | |
" from readme | |
" if hidden is not set, TextEdit might fail. | |
set hidden " Some servers have issues with backup files, see #649 set nobackup set nowritebackup " Better display for messages set cmdheight=2 " You will have bad experience for diagnostic messages when it's default 4000. | |
set updatetime=250 | |
" 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 <tab>' to make sure tab is not mapped by other plugin. | |
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 | |
" Use <c-space> to trigger completion. | |
inoremap <silent><expr> <c-space> coc#refresh() | |
" Use <cr> to confirm completion, `<C-g>u` means break undo chain at current position. | |
" Coc only does snippet and additional edit on confirm. | |
inoremap <expr> <cr> pumvisible() ? "\<C-y>" : "\<C-g>u\<CR>" | |
" Or use `complete_info` if your vim support it, like: | |
" inoremap <expr> <cr> complete_info()"selected"] != "-1" ? "\<C-y>" : "\<C-g>u\<CR>" | |
" Use `[g` and `]g` to navigate diagnostics | |
nmap <silent> [g <Plug>(coc-diagnostic-prev) | |
nmap <silent> ]g <Plug>(coc-diagnostic-next) | |
" Remap keys for gotos | |
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) | |
" Use K to show documentation in preview window | |
nnoremap <silent> K :call <SID>show_documentation()<CR> | |
function! s:show_documentation() | |
if (index(['vim','help'], &filetype) >= 0) | |
execute 'h '.expand('<cword>') | |
else | |
call CocAction('doHover') | |
endif | |
endfunction | |
" Highlight symbol under cursor on CursorHold | |
autocmd CursorHold * silent call CocActionAsync('highlight') | |
" Remap for rename current word | |
nmap <F2> <Plug>(coc-rename) | |
" Remap for format selected region | |
xmap <leader>f <Plug>(coc-format-selected) | |
nmap <leader>f <Plug>(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: `<leader>aap` for current paragraph | |
xmap <leader>a <Plug>(coc-codeaction-selected) | |
nmap <leader>a <Plug>(coc-codeaction-selected) | |
" Remap for do codeAction of current line | |
nmap <leader>ac <Plug>(coc-codeaction) | |
" Fix autofix problem of current line | |
nmap <leader>qf <Plug>(coc-fix-current) | |
" Create mappings for function text object, requires document symbols feature of languageserver. | |
xmap if <Plug>(coc-funcobj-i) | |
xmap af <Plug>(coc-funcobj-a) | |
omap if <Plug>(coc-funcobj-i) | |
omap af <Plug>(coc-funcobj-a) | |
" Use <C-d> for select selections ranges, needs server support, like: coc-tsserver, coc-python | |
nmap <silent> <C-d> <Plug>(coc-range-select) | |
xmap <silent> <C-d> <Plug>(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', <f-args>) | |
" 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 <silent> <space>a :<C-u>CocList diagnostics<cr> | |
" Manage extensions | |
nnoremap <silent> <space>e :<C-u>CocList extensions<cr> | |
" Show commands | |
nnoremap <silent> <space>c :<C-u>CocList commands<cr> | |
" Find symbol of current document | |
nnoremap <silent> <space>o :<C-u>CocList outline<cr> | |
" Search workspace symbols | |
nnoremap <silent> <space>s :<C-u>CocList -I symbols<cr> | |
" Do default action for next item. | |
nnoremap <silent> <space>j :<C-u>CocNext<CR> | |
" Do default action for previous item. | |
nnoremap <silent> <space>k :<C-u>CocPrev<CR> | |
" Resume latest coc list | |
nnoremap <silent> <space>p :<C-u>CocListResume<CR>[ | |
"StatusS | |
"""""""""""""""""" | |
"" Status | |
"""""""""""""""""" | |
let g:airline_powerline_fonts = 1 | |
if !exists('g:airline_symbols') | |
let g:airline_symbols = {} | |
endif | |
let g:airline_symbols.space = "\ua0" | |
let g:airline#extensions#tabline#enabled = 0 | |
let g:airline#extensions#tabline#formatter = 'unique_tail_improved' | |
""""""""""""""""""""" | |
let NERDTreeQuitOnOpen=1 | |
" == AUTOCMD ================================ | |
" by default .ts file are not identified as typescript and .tsx files are not | |
" identified as typescript react file, so add following | |
au BufNewFile,BufRead *.ts setlocal filetype=typescript | |
au BufNewFile,BufRead *.tsx setlocal filetype=typescript.tsx | |
" == AUTOCMD END ================================ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment