Skip to content

Instantly share code, notes, and snippets.

@AD0791
Last active February 25, 2020 18:29
Show Gist options
  • Save AD0791/e64085cfda4f938bf3b2446892900dcb to your computer and use it in GitHub Desktop.
Save AD0791/e64085cfda4f938bf3b2446892900dcb to your computer and use it in GitHub Desktop.
vplug
0 " Specify a directory for plugins
1 call plug#begin('~/.vim/plugged')
2 Plug 'sheerun/vim-polyglot'
3 Plug 'neoclide/coc.nvim', {'branch': 'release'}
4 Plug 'scrooloose/nerdtree'
5 "Plug 'tsony-tsonev/nerdtree-git-plugin'
6 Plug 'Xuyuanp/nerdtree-git-plugin'
7 Plug 'tiagofumo/vim-nerdtree-syntax-highlight'
8 Plug 'ryanoasis/vim-devicons'
9 Plug 'airblade/vim-gitgutter'
10 Plug 'ctrlpvim/ctrlp.vim' " fuzzy find files
11 Plug 'scrooloose/nerdcommenter'
12 "Plug 'prettier/vim-prettier', { 'do': 'yarn install' }
13
14 Plug 'christoomey/vim-tmux-navigator'
15
16 "Plug 'drewtempelmeyer/palenight.vim'
17 "Plug 'morhetz/gruvbox'
18 Plug 'icymind/neosolarized'
19
20 Plug 'HerringtonDarkholme/yats.vim' " TS Syntax
21
22 Plug 'tpope/vim-markdown'
23
24 " tabnine : no config needed
25 Plug 'zxqfl/tabnine-vim'
26
27 " wakatime
28 Plug 'wakatime/vim-wakatime'
29 Plug 'wakatime/wakatime'
30
31 " Initialize plugin system
32 call plug#end()
33
34
" wakatime setup
22
23 let g:wakatime_PythonBinary = '/Library/Frameworks/Python.framework/Versions/3.8/bin/python3' " (Default: 'python3')
24
25 " :WakaTimeApiKey - change the api key saved in your ~/.wakatime.cfg
26 ":WakaTimeDebugEnable - enable debug mode (may slow down Vim so disable when finished debugging)
27 ":WakaTimeDebugDisable - disable debug mode
28 ":WakaTimeScreenRedrawEnable - enable screen redraw to prevent artifacts (only for Vim < 8.0)
29 ":WakaTimeScreenRedrawEnableAuto - redraw screen when plugin takes too long (only for Vim < 8.0)
30 ":WakaTimeScreenRedrawDisable - disable screen redraw
31 ":WakaTimeToday - echo your total coding activity for Today
32
33
34
35
36
37 set background=dark
38 colorscheme NeoSolarized
39
40
41 "let g:lightline.colorscheme = 'palenight'
42 "let g:airline_theme = "solarized"
43
1 if (has("nvim"))
2 "For Neovim 0.1.3 and 0.1.4 < https://github.com/neovim/neovim/pull/2198 >
3 let $NVIM_TUI_ENABLE_TRUE_COLOR=1
4 endif
5
6 "For Neovim > 0.1.5 and Vim > patch 7.4.1799 < https://github.com/vim/vim/commit/61be73bb0f965a895bfb064ea3e55476ac175162 >
7 "Based on Vim patch 7.4.1770 (`guicolors` option) < https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd >
8 " < https://github.com/neovim/neovim/wiki/Following-HEAD#20160511 >
9 if (has("termguicolors"))
10 set termguicolors
11 endif
12
13
14 " Italics for my favorite color scheme
15 "let g:palenight_terminal_italics=1
16
17
18 inoremap jk <ESC>
19 nmap <C-n> :NERDTreeToggle<CR>
20 vmap ++ <plug>NERDCommenterToggle
21 nmap ++ <plug>NERDCommenterToggle
22
23 " open NERDTree automaticaly
24 "autocmd StdinReadPre * let s:std_in=1
25 "autocmd VimEnter * NERDTree
26
27 let g:NERDTreeGitStatusWithFlags = 1
28 "let g:WebDevIconsUnicodeDecorateFolderNodes = 1
29 "let g:NERDTreeGitStatusNodeColorization = 1
30 "let g:NERDTreeColorMapCustom = {
31 "\ "Staged" : "#0ee375",
32 "\ "Modified" : "#d9bf91",
33 "\ "Renamed" : "#51C9FC",
34 "\ "Untracked" : "#FCE77C",
35 "\ "Unmerged" : "#FC51E6",
36 "\ "Dirty" : "#FFBD61",
37 "\ "Clean" : "#87939A",
38 "\ "Ignored" : "#808080"
39 "\ }
40
41
42 let g:NERDTreeIgnore = ['^node_modules$']
" vim-prettier
0 "let g:prettier#quickfix_enabled = 0
1 "let g:prettier#quickfix_auto_focus = 0
2 " prettier command for coc
3 command! -nargs=0 Prettier :CocCommand prettier.formatFile
4 " run prettier on save
5 "let g:prettier#autoformat = 0
6 "autocmd BufWritePre *.js,*.jsx,*.mjs,*.ts,*.tsx,*.css,*.less,*.scss,*.json,*.graphql,*.md,*.vue,*.yaml,*.html PrettierAsync
7
8
9 " ctrlp
10 let g:ctrlp_user_command = ['.git/', 'git --git-dir=%s/.git ls-files -oc --exclude-standard']
11
12 " j/k will move virtual lines (lines that wrap)
13 noremap <silent> <expr> j (v:count == 0 ? 'gj' : 'j')
14 noremap <silent> <expr> k (v:count == 0 ? 'gk' : 'k')
15
16 set relativenumber
17
18 set smarttab
19 set cindent
20 set tabstop=2
21 set shiftwidth=2
22 " always uses spaces instead of tab characters
23 set expandtab
24
25 "colorscheme gruvbox
26
27 " sync open file with NERDTree
28 " " Check if NERDTree is open or active
29 function! IsNERDTreeOpen()
30 return exists("t:NERDTreeBufName") && (bufwinnr(t:NERDTreeBufName) != -1)
31 endfunction
32
33 " Call NERDTreeFind iff NERDTree is active, current window contains a modifiable
34 " file, and we're not in vimdiff
35 function! SyncTree()
36 if &modifiable && IsNERDTreeOpen() && strlen(expand('%')) > 0 && !&diff
37 NERDTreeFind
38 wincmd p
39 endif
40 endfunction
41
42 " Highlight currently open buffer in NERDTree
43 autocmd BufEnter * call SyncTree()
" coc config
0 let g:coc_global_extensions = [
1 \ 'coc-snippets',
0 \ 'coc-pairs',
1 \ 'coc-tsserver',
2 \ 'coc-eslint',
3 \ 'coc-prettier',
4 \ 'coc-json',
5 \ ]
6 " from readme
7 " if hidden is not set, TextEdit might fail.
8 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 f or diagnostic messages when it's default 4000.
9 set updatetime=300
10
11 " don't give |ins-completion-menu| messages.
12 set shortmess+=c
13
14 " always show signcolumns
15 set signcolumn=yes
16
17 " Use tab for trigger completion with characters ahead and navigate.
18 " Use command ':verbose imap <tab>' to make sure tab is not mapped by other plugin.
19 inoremap <silent><expr> <TAB>
20 \ pumvisible() ? "\<C-n>" :
21 \ <SID>check_back_space() ? "\<TAB>" :
22 \ coc#refresh()
23 inoremap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<C-h>"
24
25 function! s:check_back_space() abort
26 let col = col('.') - 1
27 return !col || getline('.')[col - 1] =~# '\s'
28 endfunction
29
30 " Use <c-space> to trigger completion.
31 inoremap <silent><expr> <c-space> coc#refresh()
32
33 " Use <cr> to confirm completion, `<C-g>u` means break undo chain at current position.
34 " Coc only does snippet and additional edit on confirm.
35 inoremap <expr> <cr> pumvisible() ? "\<C-y>" : "\<C-g>u\<CR>"
36 " Or use `complete_info` if your vim support it, like:
37 " inoremap <expr> <cr> complete_info()["selected"] != "-1" ? "\<C-y>" : "\<C-g>u\<CR>"
38
39 " Use `[g` and `]g` to navigate diagnostics
40 nmap <silent> [g <Plug>(coc-diagnostic-prev)
41 nmap <silent> ]g <Plug>(coc-diagnostic-next)
" Remap keys for gotos
1 nmap <silent> gd <Plug>(coc-definition)
2 nmap <silent> gy <Plug>(coc-type-definition)
3 nmap <silent> gi <Plug>(coc-implementation)
4 nmap <silent> gr <Plug>(coc-references)
5
6 " Use K to show documentation in preview window
7 nnoremap <silent> K :call <SID>show_documentation()<CR>
8
9 function! s:show_documentation()
10 if (index(['vim','help'], &filetype) >= 0)
11 execute 'h '.expand('<cword>')
12 else
13 call CocAction('doHover')
14 endif
15 endfunction
16
17 " Highlight symbol under cursor on CursorHold
18 autocmd CursorHold * silent call CocActionAsync('highlight')
19
20 " Remap for rename current word
21 nmap <F2> <Plug>(coc-rename)
22
23 " Remap for format selected region
24 xmap <leader>f <Plug>(coc-format-selected)
25 nmap <leader>f <Plug>(coc-format-selected)
26
27 augroup mygroup
28 autocmd!
29 " Setup formatexpr specified filetype(s).
30 autocmd FileType typescript,json setl formatexpr=CocAction('formatSelected')
31 " Update signature help on jump placeholder
32 autocmd User CocJumpPlaceholder call CocActionAsync('showSignatureHelp')
33 augroup end
34
35 " Remap for do codeAction of selected region, ex: `<leader>aap` for current paragraph
36 xmap <leader>a <Plug>(coc-codeaction-selected)
37 nmap <leader>a <Plug>(coc-codeaction-selected)
38
39 " Remap for do codeAction of current line
40 nmap <leader>ac <Plug>(coc-codeaction)
41 " Fix autofix problem of current line
42 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)
39 " Use <C-d> for select selections ranges, needs server support, like: coc-tsserver, coc-python
38 nmap <silent> <C-d> <Plug>(coc-range-select)
37 xmap <silent> <C-d> <Plug>(coc-range-select)
36
35 " Use `:Format` to format current buffer
34 command! -nargs=0 Format :call CocAction('format')
33
32 " Use `:Fold` to fold current buffer
31 command! -nargs=? Fold :call CocAction('fold', <f-args>)
30
29 " use `:OR` for organize import of current buffer
28 command! -nargs=0 OR :call CocAction('runCommand', 'editor.action.organizeImport')
27
26 " Add status line support, for integration with other plugin, checkout `:h coc-status`
25 set statusline^=%{coc#status()}%{get(b:,'coc_current_function','')}
24
23 " Using CocList
22 " Show all diagnostics
21 nnoremap <silent> <space>a :<C-u>CocList diagnostics<cr>
20 " Manage extensions
19 nnoremap <silent> <space>e :<C-u>CocList extensions<cr>
18 " Show commands
17 nnoremap <silent> <space>c :<C-u>CocList commands<cr>
16 " Find symbol of current document
15 nnoremap <silent> <space>o :<C-u>CocList outline<cr>
14 " Search workspace symbols
13 nnoremap <silent> <space>s :<C-u>CocList -I symbols<cr>
12 " Do default action for next item.
11 nnoremap <silent> <space>j :<C-u>CocNext<CR>
10 " Do default action for previous item.
9 nnoremap <silent> <space>k :<C-u>CocPrev<CR>
8 " Resume latest coc list
7 nnoremap <silent> <space>p :<C-u>CocListResume<CR>l
6
5
4
3 " markdown
2 let g:markdown_fenced_languages = ['html', 'python', 'bash=sh', 'R']
1 let g:markdown_syntax_conceal = 0
0 let g:markdown_minlines = 100
Nvim:
.config/nvim/init.vim
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment