Last active
July 27, 2021 10:38
-
-
Save Aragami1408/c075f608761d14ea1a9884a9b1c1a559 to your computer and use it in GitHub Desktop.
nvim config file with vimplug plugins
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('~/.config/nvim/plugged') | |
Plug 'junegunn/vim-easy-align' | |
Plug 'scrooloose/nerdtree' | |
Plug 'morhetz/gruvbox' | |
Plug 'neoclide/coc.nvim', {'branch': 'release'} | |
Plug 'vim-airline/vim-airline' | |
Plug 'vim-airline/vim-airline-themes' | |
Plug 'terryma/vim-multiple-cursors' | |
Plug 'junegunn/fzf.vim' | |
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } } | |
Plug 'preservim/nerdcommenter' | |
Plug 'easymotion/vim-easymotion' | |
Plug 'elixir-editors/vim-elixir' | |
Plug 'Xuyuanp/nerdtree-git-plugin' | |
Plug 'junegunn/vim-github-dashboard' | |
Plug 'tpope/vim-fugitive' | |
Plug 'junegunn/gv.vim' | |
Plug 'jackguo380/vim-lsp-cxx-highlight' | |
Plug 'liuchengxu/vista.vim' | |
if has('nvim') || has('patch-8.0.902') | |
Plug 'mhinz/vim-signify' | |
else | |
Plug 'mhinz/vim-signify', { 'branch': 'legacy' } | |
endif | |
Plug 'mhinz/vim-startify' | |
call plug#end() | |
" Basic config section | |
colorscheme gruvbox | |
set background=dark | |
set clipboard=unnamedplus | |
set nu rnu | |
augroup numbertoggle | |
autocmd! | |
autocmd BufEnter,FocusGained,InsertLeave * set norelativenumber | |
autocmd BufLeave,FocusLost,InsertEnter * set relativenumber | |
augroup end | |
set autoread | |
set autowrite | |
set autoindent | |
set si | |
syntax on | |
set nobackup | |
set nowb | |
set noswapfile | |
set backupdir=~/tmp,/tmp | |
set backupcopy=yes | |
set backupskip=/tmp/*,$TMPDIR/*,$TMP/*,$TEMP/* | |
set directory=/tmp | |
set encoding=utf-8 | |
set hidden | |
set foldenable | |
set foldmethod=marker | |
set cmdheight=2 | |
set updatetime=100 | |
set shortmess+=c | |
set tabstop=8 softtabstop=0 expandtab shiftwidth=4 smarttab | |
set list | |
set listchars=tab:>·,trail:~,extends:>,precedes:< | |
set backspace=eol,start,indent | |
set whichwrap+=<,>,h,l | |
set undofile | |
set undodir=$HOME/.config/nvim/undo | |
set undolevels=1000 | |
set undoreload=10000 | |
set updatetime=300 | |
let g:clipboard = { | |
\ 'name': 'xclip-xfce4-clipman', | |
\ 'copy': { | |
\ '+': 'xclip -selection clipboard', | |
\ '*': 'xclip -selection clipboard', | |
\ }, | |
\ 'paste': { | |
\ '+': 'xclip -selection clipboard -o', | |
\ '*': 'xclip -selection clipboard -o', | |
\ }, | |
\ 'cache_enabled': 1, | |
\ } | |
" insert init.vim path after :e | |
command! -nargs=0 VimConfig :e ~/.config/nvim/init.vim | |
set splitbelow | |
set splitright | |
" Floating Term | |
let s:float_term_border_win = 0 | |
let s:float_term_win = 0 | |
function! FloatTerm(...) | |
" Configuration | |
let height = float2nr((&lines - 2) * 0.6) | |
let row = float2nr((&lines - height) / 2) | |
let width = float2nr(&columns * 0.6) | |
let col = float2nr((&columns - width) / 2) | |
" Border Window | |
let border_opts = { | |
\ 'relative': 'editor', | |
\ 'row': row - 1, | |
\ 'col': col - 2, | |
\ 'width': width + 4, | |
\ 'height': height + 2, | |
\ 'style': 'minimal' | |
\ } | |
" Terminal Window | |
let opts = { | |
\ 'relative': 'editor', | |
\ 'row': row, | |
\ 'col': col, | |
\ 'width': width, | |
\ 'height': height, | |
\ 'style': 'minimal' | |
\ } | |
let top = "╭" . repeat("─", width + 2) . "╮" | |
let mid = "│" . repeat(" ", width + 2) . "│" | |
let bot = "╰" . repeat("─", width + 2) . "╯" | |
let lines = [top] + repeat([mid], height) + [bot] | |
let bbuf = nvim_create_buf(v:false, v:true) | |
call nvim_buf_set_lines(bbuf, 0, -1, v:true, lines) | |
let s:float_term_border_win = nvim_open_win(bbuf, v:true, border_opts) | |
let buf = nvim_create_buf(v:false, v:true) | |
let s:float_term_win = nvim_open_win(buf, v:true, opts) | |
" Styling | |
hi FloatWinBorder guifg=#87bb7c | |
call setwinvar(s:float_term_border_win, '&winhl', 'Normal:FloatWinBorder') | |
call setwinvar(s:float_term_win, '&winhl', 'Normal:Normal') | |
if a:0 == 0 | |
terminal | |
else | |
call termopen(a:1) | |
endif | |
startinsert | |
" Close border window when terminal window close | |
autocmd TermClose * ++once :bd! | call nvim_win_close(s:float_term_border_win, v:true) | |
endfunction | |
" Basic key mapping section | |
let g:mapleader = " " | |
nmap <leader>w :w!<cr> | |
map <silent> <leader><cr> :noh<cr> | |
nnoremap L l | |
nnoremap H h | |
nnoremap l w | |
nnoremap h b | |
nnoremap <C-k> <C-u> | |
nnoremap <C-j> <C-d> | |
inoremap <C-f> <Right> | |
inoremap <C-b> <Left> | |
inoremap <C-e> <C-o>$ | |
inoremap <C-a> <C-o>^ | |
nnoremap <leader><tab> za | |
nnoremap <leader>wv :vsplit<CR> | |
nnoremap <leader>ws :split<CR> | |
nnoremap <leader>wh :wincmd h<CR> | |
nnoremap <leader>wl :wincmd l<CR> | |
nnoremap <leader>wk :wincmd k<CR> | |
nnoremap <leader>wj :wincmd j<CR> | |
nnoremap <leader>w= :wincmd =<CR> | |
nnoremap <leader>tt :call FloatTerm()<CR> | |
nnoremap <leader>tg :call FloatTerm('"lazygit"')<CR> | |
nnoremap <leader>tn :call FloatTerm('"node"')<CR> | |
nnoremap <leader>tp :call FloatTerm('"python"')<CR> | |
nnoremap <leader>th :call FloatTerm('"ghci"')<CR> | |
" NERDTree config section | |
let NERDTreeMinimalUI=1 | |
nnoremap <leader>op :NERDTreeToggle<cr> | |
autocmd StdinReadPre * let s:std_in=1 | |
autocmd VimEnter * if argc() == 0 && !exists('s:std_in') | NERDTree | endif | |
autocmd StdinReadPre * let s:std_in=1 | |
autocmd VimEnter * if argc() == 1 && isdirectory(argv()[0]) && !exists('s:std_in') | execute 'NERDTree' argv()[0] | wincmd p | enew | execute 'cd '.argv()[0] | endif | |
autocmd BufEnter * if bufname('#') =~ 'NERD_tree_\d\+' && bufname('%') !~ 'NERD_tree_\d\+' && winnr('$') > 1 | let buf=bufnr() | buffer# | execute "normal! \<C-W>w" | execute 'buffer'.buf | endif | |
let g:NERDTreeDirArrowExpandable = '▸' | |
let g:NERDTreeDirArrowCollapsible = '▾' | |
let g:NERDTreeShowHidden=1 | |
" coc.nvim config section | |
if has("patch-8.1.1564") | |
set signcolumn=number | |
else | |
set signcolumn=yes | |
endif | |
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 | |
if has('nvim') | |
inoremap <silent><expr> <c-space> coc#refresh() | |
else | |
inoremap <silent><expr> <c-@> coc#refresh() | |
endif | |
inoremap <silent><expr> <cr> pumvisible() ? coc#_select_confirm() | |
\: "\<C-g>u\<CR>\<c-r>=coc#on_enter()\<CR>" | |
nmap <silent> <leader> [g <Plug>(coc-diagnostic-prev) | |
nmap <silent> <leader> ]g <Plug>(coc-diagnostic-next) | |
nmap <silent> <leader>gd <Plug>(coc-definition) | |
nmap <silent> <leader>gy <Plug>(coc-type-definition) | |
nmap <silent> <leader>gi <Plug>(coc-implementation) | |
nmap <silent> <leader>gr <Plug>(coc-references) | |
nnoremap <silent> <leader>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>gf <Plug>(coc-format-selected) | |
nmap <leader>gf <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>as <Plug>(coc-codeaction-selection) | |
nmap <leader>as <Plug>(coc-codeaction-selection) | |
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) | |
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 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> | |
"airline config | |
nnoremap <leader>bn :bnext<CR> | |
nnoremap <leader>bp :bprevious<CR> | |
nmap <leader>b1 :bfirst<CR> | |
nmap <leader>b2 :bfirst<CR>:bn<CR> | |
nmap <leader>b3 :bfirst<CR>:2bn<CR> | |
nmap <leader>b4 :bfirst<CR>:3bn<CR> | |
nmap <leader>b5 :bfirst<CR>:4bn<CR> | |
nmap <leader>b6 :bfirst<CR>:5bn<CR> | |
nmap <leader>b7 :bfirst<CR>:6bn<CR> | |
nmap <leader>b8 :bfirst<CR>:7bn<CR> | |
nmap <leader>b9 :bfirst<CR>:8bn<CR> | |
nmap <leader>b0 :bfirst<CR>:9bn<CR> | |
nmap <leader>bw :bwipe<CR> | |
let g:airline#extensions#tabline#enabled = 1 | |
let g:airline#extensions#tabline#left_sep = ' ' | |
let g:airline#extensions#tabline#left_alt_sep = '|' | |
let g:airline#extensions#tabline#formatter = 'unique_tail_improved' | |
"vista.vim config | |
function! NearestMethodOrFunction() abort | |
return get(b:, 'vista_nearest_method_or_function', '') | |
endfunction | |
set statusline+=%{NearestMethodOrFunction()} | |
autocmd VimEnter * call vista#RunForNearestMethodOrFunction() | |
let g:vista_icon_indent = ["╰─▸ ", "├─▸ "] | |
let g:vista_default_executive = 'ctags' | |
let g:vista_executive_for = { | |
\ 'cpp': 'vim_lsp', | |
\ } | |
let g:vista_ctags_cmd = { | |
\ 'haskell': 'hasktags -x -o - -c', | |
\ } | |
let g:vista_fzf_preview = ['right:50%'] | |
let g:vista#renderer#enable_icon = 1 | |
let g:vista#renderer#icons = { | |
\ "function": "\uf794", | |
\ "variable": "\uf71b", | |
\ } | |
"fzf config section | |
let g:fzf_layout = { 'window': { | |
\ 'width': 0.9, | |
\ 'height': 0.7, | |
\ 'highlight': 'Comment', | |
\ 'rounded': v:false } } | |
let $FZF_DEFAULT_COMMAND = 'rg --files --hidden' | |
" fzf quick hotkeys | |
nnoremap <silent> <leader>gf :Files <CR> | |
nnoremap <silent> <leader>gg? :GFiles? <CR> | |
nnoremap <silent> <leader>gb :Buffers <CR> | |
nnoremap <silent> <leader>gh :History <CR> | |
nnoremap <silent> <leader>gc :Color <CR> | |
nnoremap <silent> <leader>gs :Snippets <CR> | |
let g:choosewin_overlay_enable = 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment