-
-
Save Daivasmara/c3e5bbad57c218900ce62c92de8b410f to your computer and use it in GitHub Desktop.
NVIM v0.9.0
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
call plug#begin('~/.vim/plugged') | |
Plug 'challenger-deep-theme/vim', { 'as': 'challenger-deep' } | |
Plug 'morhetz/gruvbox' | |
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' } | |
Plug 'junegunn/fzf.vim' | |
Plug 'stsewd/fzf-checkout.vim' | |
Plug 'sheerun/vim-polyglot' | |
Plug 'vim-airline/vim-airline' | |
Plug 'vim-airline/vim-airline-themes' | |
Plug 'neoclide/coc.nvim', {'branch': 'release'} | |
Plug 'vimwiki/vimwiki' | |
Plug 'iamcco/markdown-preview.nvim', { 'do': { -> mkdp#util#install() }, 'for': ['markdown', 'vim-plug']} | |
Plug 'voldikss/vim-floaterm' | |
Plug 'preservim/nerdtree' | |
Plug 'ryanoasis/vim-devicons' | |
Plug 'airblade/vim-gitgutter' | |
Plug 'alvan/vim-closetag' | |
Plug 'tpope/vim-fugitive' | |
Plug 'tpope/vim-surround' | |
Plug 'tpope/vim-rails' | |
Plug 'tpope/vim-commentary' | |
Plug 'jiangmiao/auto-pairs' | |
Plug 'szw/vim-maximizer' | |
Plug 'dense-analysis/ale' | |
Plug 'github/copilot.vim' | |
Plug 'christoomey/vim-tmux-navigator' | |
call plug#end() | |
let mapleader = "," | |
syntax on | |
set clipboard+=unnamedplus | |
set nowrap | |
set encoding=UTF-8 | |
set tabstop=8 softtabstop=0 expandtab shiftwidth=2 smarttab | |
set number relativenumber | |
set laststatus=2 | |
set noshowmode | |
set updatetime=250 | |
set nocompatible | |
filetype plugin on | |
nnoremap gb <C-O><C-S> | |
nnoremap <C-J> <C-W><C-J> | |
nnoremap <C-K> <C-W><C-K> | |
nnoremap <C-L> <C-W><C-L> | |
nnoremap <C-H> <C-W><C-H> | |
noremap <leader>1 1gt | |
noremap <leader>2 2gt | |
noremap <leader>3 3gt | |
noremap <leader>4 4gt | |
noremap <leader>5 5gt | |
noremap <leader>6 6gt | |
noremap <leader>7 7gt | |
noremap <leader>8 8gt | |
noremap <leader>9 9gt | |
nnoremap cp :let @+=expand("%")<CR> | |
autocmd FileType json syntax match Comment +\/\/.\+$+ | |
autocmd BufRead,BufNewFile tsconfig.json set filetype=jsonc | |
let g:floaterm_keymap_toggle = '<Leader>`' | |
let g:closetag_filenames = '*.html,*.xhtml,*.phtml,*js,*jsx' | |
let g:gitgutter_realtime = 1 | |
let g:vim_markdown_folding_disabled = 1 | |
let g:typescript_indent_disable = 1 | |
let g:typescript_compiler_binary = 'npx tsc' | |
let g:loaded_perl_provider = 0 | |
let g:python3_host_prog = '~/.pyenv/shims/python3' | |
let g:go_def_mode='gopls' | |
let g:go_info_mode='gopls' | |
let g:svelte_preprocessor_tags = [ | |
\ { 'name': 'ts', 'tag': 'script', 'as': 'typescript' } | |
\ ] | |
let g:svelte_preprocessors = ['ts', 'scss'] | |
autocmd BufWritePre *.go :call CocAction('runCommand', 'editor.action.organizeImport') | |
au BufNewFile,BufRead *.go setlocal noet ts=4 sw=4 sts=4 | |
" FUNCTIONS | |
" J -> join lines without spaces | |
fun! s:join_spaceless() | |
execute 'normal! gJ' | |
" Remove character under the cursor if it's whitespace. | |
if matchstr(getline('.'), '\%' . col('.') . 'c.') =~ '\s' | |
execute 'normal! dw' | |
endif | |
endfun | |
nnoremap J :call <SID>join_spaceless()<CR> | |
" Tab Number | |
fu! MyTabLabel(n) | |
let buflist = tabpagebuflist(a:n) | |
let winnr = tabpagewinnr(a:n) | |
let string = fnamemodify(bufname(buflist[winnr - 1]), ':t') | |
return empty(string) ? '[unnamed]' : string | |
endfu | |
fu! MyTabLine() | |
let s = '' | |
for i in range(tabpagenr('$')) | |
if i + 1 == tabpagenr() | |
let s .= '%#TabLineSel#' | |
else | |
let s .= '%#TabLine#' | |
endif | |
let s .= ' '. (i+1) . ' ' | |
let s .= ' %{MyTabLabel(' . (i + 1) . ')} ' | |
endfor | |
return s | |
endfu | |
set tabline=%!MyTabLine() | |
" FZF RG | |
nnoremap <silent> <C-t> :Windows<CR> | |
nnoremap <silent> <C-o> :Buffers<CR> | |
nnoremap <silent> <C-p> :Files<CR> | |
nnoremap <silent> <C-]> :Rg<CR> | |
function! RipgrepFzf(query, fullscreen) | |
let command_fmt = 'rg --column --line-number --no-heading --color=always --smart-case %s || true' | |
let initial_command = printf(command_fmt, shellescape(a:query)) | |
let reload_command = printf(command_fmt, '{q}') | |
let spec = {'options': ['--phony', '--query', a:query, '--bind', 'change:reload:'.reload_command]} | |
call fzf#vim#grep(initial_command, 1, fzf#vim#with_preview(spec), a:fullscreen) | |
endfunction | |
command! -nargs=* -bang Rg call RipgrepFzf(<q-args>, <bang>0) | |
" FZF Checkout | |
nmap <leader>gc :GBranches<CR> | |
" Challenger Deep | |
let g:challenger_deep_termcolors = 16 | |
if has('nvim') || has('termguicolors') | |
set termguicolors | |
endif | |
colorscheme challenger_deep | |
" CoC | |
set nobackup | |
set nowritebackup | |
set updatetime=300 | |
set signcolumn=yes | |
inoremap <silent><expr> <TAB> | |
\ coc#pum#visible() ? coc#pum#next(1) : | |
\ CheckBackspace() ? "\<Tab>" : | |
\ coc#refresh() | |
inoremap <expr><S-TAB> coc#pum#visible() ? coc#pum#prev(1) : "\<C-h>" | |
inoremap <silent><expr> <CR> coc#pum#visible() ? coc#pum#confirm() | |
\: "\<C-g>u\<CR>\<c-r>=coc#on_enter()\<CR>" | |
function! CheckBackspace() abort | |
let col = col('.') - 1 | |
return !col || getline('.')[col - 1] =~# '\s' | |
endfunction | |
if has('nvim') | |
inoremap <silent><expr> <c-space> coc#refresh() | |
else | |
inoremap <silent><expr> <c-@> coc#refresh() | |
endif | |
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 ShowDocumentation()<CR> | |
function! ShowDocumentation() | |
if CocAction('hasProvider', 'hover') | |
call CocActionAsync('doHover') | |
else | |
call feedkeys('K', 'in') | |
endif | |
endfunction | |
autocmd CursorHold * silent call CocActionAsync('highlight') | |
autocmd FileType scss setl iskeyword+=@-@ | |
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) | |
nmap <leader>cl <Plug>(coc-codelens-action) | |
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) | |
if has('nvim-0.4.0') || has('patch-8.2.0750') | |
nnoremap <silent><nowait><expr> <C-f> coc#float#has_scroll() ? coc#float#scroll(1) : "\<C-f>" | |
nnoremap <silent><nowait><expr> <C-b> coc#float#has_scroll() ? coc#float#scroll(0) : "\<C-b>" | |
inoremap <silent><nowait><expr> <C-f> coc#float#has_scroll() ? "\<c-r>=coc#float#scroll(1)\<cr>" : "\<Right>" | |
inoremap <silent><nowait><expr> <C-b> coc#float#has_scroll() ? "\<c-r>=coc#float#scroll(0)\<cr>" : "\<Left>" | |
vnoremap <silent><nowait><expr> <C-f> coc#float#has_scroll() ? coc#float#scroll(1) : "\<C-f>" | |
vnoremap <silent><nowait><expr> <C-b> coc#float#has_scroll() ? coc#float#scroll(0) : "\<C-b>" | |
endif | |
nmap <silent> <C-s> <Plug>(coc-range-select) | |
xmap <silent> <C-s> <Plug>(coc-range-select) | |
command! -nargs=0 Format :call CocActionAsync('format') | |
command! -nargs=? Fold :call CocAction('fold', <f-args>) | |
command! -nargs=0 OR :call CocActionAsync('runCommand', 'editor.action.organizeImport') | |
command! -nargs=0 Prettier :CocCommand prettier.forceFormatDocument | |
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> | |
nnoremap <silent><nowait> <space>y :<C-u>CocList -A --normal yank<cr> | |
" Vim Rails | |
nnoremap gt :A<CR> | |
nnoremap gm :R<CR> | |
" NERDTree | |
nnoremap <silent> <C-n> :NERDTreeToggle<CR> | |
nnoremap <silent> gn :NERDTreeFind<CR> | |
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif | |
let g:NERDTreeDirArrowExpandable = '' | |
let g:NERDTreeDirArrowCollapsible = '' | |
" Jedi | |
let g:jedi#goto_definitions_command = "gd" | |
let g:jedi#rename_command = "<leader>rn" | |
" Vim Fugitive | |
nmap <leader>gs :G<CR> | |
nmap <leader>gl :G log<CR> | |
nmap <leader>gb :G blame<CR> | |
nmap <leader>gd :G diff<CR> | |
nmap <leader>g2 :diffget //2<CR> | |
nmap <leader>g3 :diffget //3<CR> | |
" Vimwiki | |
let g:vimwiki_key_mappings = { 'table_mappings': 0 } | |
let wiki = {} | |
let wiki.path = '~/vimwiki/' | |
let wiki.nested_syntaxes = {'sh': 'sh', 'js': 'javascript', 'python': 'python', 'ruby': 'ruby'} | |
let g:vimwiki_list = [wiki] | |
nmap <leader>wa :VimwikiAll2HTML<CR> | |
nmap <leader>wo :Vimwiki2HTMLBrowse<CR> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
~/.config/nvim/init.vim