2020-02-13 11:14:03 -06:00
|
|
|
set fileencoding=utf8
|
|
|
|
|
2020-11-07 00:23:20 -06:00
|
|
|
let $vimdir = $XDG_CONFIG_HOME.'/nvim'
|
2017-02-28 10:56:23 -06:00
|
|
|
|
2020-11-07 00:23:20 -06:00
|
|
|
if empty(glob($vimdir.'/autoload/plug.vim'))
|
2020-11-21 16:40:42 -06:00
|
|
|
silent !curl -fLo $vimdir/autoload/plug.vim --create-dirs
|
|
|
|
\ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
|
|
|
|
autocmd VimEnter * PlugInstall --sync | source $vimdir.'init.vim'
|
2018-11-01 22:44:07 -05:00
|
|
|
endif
|
|
|
|
|
2020-11-20 15:27:02 -06:00
|
|
|
let g:completion_enable_auto_popup = 0
|
2020-11-07 00:23:20 -06:00
|
|
|
let g:indent_guide_auto_colors = 1
|
|
|
|
let g:indent_guides_enable_on_vim_startup = 1
|
|
|
|
let g:jsonnet_fmt_on_save = 0
|
2021-03-06 22:09:03 -06:00
|
|
|
let g:skipview_files = ['COMMIT_EDITMSG']
|
2021-03-06 22:07:30 -06:00
|
|
|
" let g:fzf_preview_window = ['down:40%:hidden', 'ctrl-/']
|
2020-11-07 00:23:20 -06:00
|
|
|
|
|
|
|
call plug#begin($vimdir.'/plugged')
|
2020-11-09 22:57:12 -06:00
|
|
|
Plug 'junegunn/vim-plug' " plugin manager should manage itself
|
|
|
|
Plug 'sheerun/vim-polyglot' " handles language-specific configuration
|
2020-11-13 14:38:05 -06:00
|
|
|
Plug 'neovim/nvim-lspconfig' " deeper language integration via language servers
|
2020-11-20 15:27:02 -06:00
|
|
|
Plug 'nvim-lua/completion-nvim' " language server completion
|
2021-03-06 22:07:30 -06:00
|
|
|
Plug 'junegunn/fzf' " fzf
|
2020-11-09 22:57:12 -06:00
|
|
|
Plug 'junegunn/fzf.vim' " helpers for using fzf in vim
|
|
|
|
Plug 'editorconfig/editorconfig-vim' " loads project-specific editor settings
|
|
|
|
Plug 'tpope/vim-sleuth' " try and detect indent method
|
|
|
|
Plug 'vim-scripts/LargeFile' " gracefully handle very large files
|
2020-11-17 17:17:03 -06:00
|
|
|
Plug 'vim-scripts/restore_view.vim' " persistent buffer views
|
2020-11-09 22:57:12 -06:00
|
|
|
Plug 'nathanaelkane/vim-indent-guides' " indentation guides
|
|
|
|
Plug 'christoomey/vim-tmux-navigator' " allow window navigation to play nicely with tmux
|
|
|
|
Plug 'tpope/vim-commentary' " toggle comments in code easily
|
|
|
|
Plug 'tpope/vim-repeat' " better vim repeating for plugin-provided actions
|
|
|
|
Plug 'machakann/vim-sandwich' " quickly modify text surrounding objects
|
|
|
|
Plug 'michaeljsmith/vim-indent-object' " adds an indentation level text object
|
|
|
|
Plug 'bkad/CamelCaseMotion' " camel case and underscore word movements
|
|
|
|
Plug 'wellle/targets.vim' " adds some more handy text objects
|
|
|
|
Plug 'tpope/vim-obsession' " even better session handling
|
|
|
|
Plug 'dhruvasagar/vim-prosession' " even better session handling
|
2020-11-20 15:27:02 -06:00
|
|
|
Plug 'dhruvasagar/vim-prosession' " even better session handling
|
|
|
|
Plug 'neoclide/coc.nvim', {'branch': 'release'}
|
2018-11-01 22:44:07 -05:00
|
|
|
call plug#end()
|
|
|
|
|
2020-11-20 15:27:02 -06:00
|
|
|
" luafile $vimdir/lsp.lua
|
|
|
|
" autocmd BufEnter * lua require('completion').on_attach()
|
|
|
|
|
2017-02-08 11:54:30 -06:00
|
|
|
filetype on
|
|
|
|
filetype indent on
|
|
|
|
filetype plugin on
|
|
|
|
|
2020-11-07 00:23:20 -06:00
|
|
|
" use :h option-list if you need to know what these do
|
|
|
|
set encoding=utf8
|
|
|
|
set tabstop=2 shiftwidth=2 softtabstop=2 noexpandtab
|
|
|
|
set autoindent smartindent
|
2020-11-09 23:19:36 -06:00
|
|
|
set list nostartofline listchars=trail:·,tab:\ \ ,trail:~
|
2020-11-08 08:27:48 -06:00
|
|
|
set linebreak formatoptions=crql1jn " TODO: see if there is more in `:h fo-table`
|
2020-11-07 00:23:20 -06:00
|
|
|
set synmaxcol=200
|
|
|
|
set lazyredraw
|
|
|
|
set scrolloff=8 sidescrolloff=15
|
|
|
|
set mouse=a
|
|
|
|
set splitright splitbelow
|
|
|
|
set noerrorbells visualbell t_vb=
|
|
|
|
set nobackup nowritebackup noswapfile
|
|
|
|
set timeout ttimeoutlen=100 timeoutlen=150
|
2020-11-20 15:27:02 -06:00
|
|
|
set hidden shortmess+=Iac
|
2020-11-07 00:23:20 -06:00
|
|
|
set history=1000
|
|
|
|
set undofile undodir=$vimdir/undo undolevels=1000 undoreload=10000
|
|
|
|
set spellfile=$vimdir/spell/en.utf-8.add
|
|
|
|
set ignorecase smartcase incsearch wrapscan hlsearch
|
|
|
|
set foldmethod=syntax foldlevel=99 foldnestmax=10 foldlevelstart=99 " TODO: get good at folding
|
|
|
|
set noautowrite autochdir autoread
|
2020-11-17 17:17:03 -06:00
|
|
|
set nomodeline noshowmode noshowcmd laststatus=2 noruler
|
2020-11-07 00:23:20 -06:00
|
|
|
set clipboard+=unnamedplus
|
|
|
|
set t_Co=256
|
2020-11-09 23:19:36 -06:00
|
|
|
let &fcs = 'eob: '
|
2017-02-08 11:54:30 -06:00
|
|
|
|
2020-11-07 00:23:20 -06:00
|
|
|
syntax enable
|
|
|
|
colorscheme base16-donokai
|
|
|
|
|
|
|
|
hi Search cterm=NONE ctermbg=blue ctermfg=black
|
|
|
|
hi LineNr ctermbg=none ctermfg=8
|
|
|
|
hi CursorLineNr ctermbg=18 ctermfg=gray
|
|
|
|
hi IndentGuidesEven ctermbg=18
|
|
|
|
hi Normal ctermbg=NONE
|
2020-11-20 15:27:02 -06:00
|
|
|
hi ColorColumn ctermbg=18
|
|
|
|
hi TooLongColorColumn ctermbg=18 ctermfg=1
|
2020-11-17 17:17:03 -06:00
|
|
|
hi ActiveBuffer ctermbg=4 ctermfg=0
|
2021-01-06 10:52:45 -06:00
|
|
|
hi DirtyBuffer ctermbg=3 ctermfg=0
|
2020-11-17 17:17:03 -06:00
|
|
|
hi StatusLine ctermbg=18 ctermfg=7
|
|
|
|
hi StatusLineNC ctermbg=18 ctermfg=7
|
2020-11-07 00:23:20 -06:00
|
|
|
|
2020-11-09 22:57:12 -06:00
|
|
|
call matchadd('ColorColumn', '\%81v', 100)
|
|
|
|
call matchadd('TooLongColorColumn', '\%121v', 200)
|
2020-11-07 00:23:20 -06:00
|
|
|
|
2020-11-08 08:27:48 -06:00
|
|
|
command! W write
|
|
|
|
|
2020-11-07 00:23:20 -06:00
|
|
|
inoremap jj <Esc>
|
2021-04-14 14:53:02 -05:00
|
|
|
inoremap jJ <Esc>
|
|
|
|
inoremap Jj <Esc>
|
|
|
|
inoremap JJ <Esc>
|
2020-11-07 00:23:20 -06:00
|
|
|
inoremap jk <Esc>
|
2021-04-14 14:53:02 -05:00
|
|
|
inoremap jK <Esc>
|
|
|
|
inoremap Jk <Esc>
|
|
|
|
inoremap JK <Esc>
|
2020-11-07 00:23:20 -06:00
|
|
|
|
2020-11-22 00:21:37 -06:00
|
|
|
nnoremap <C-q> :qa<CR>
|
|
|
|
inoremap <C-q> <Esc><C-q>
|
|
|
|
|
2020-11-07 00:23:20 -06:00
|
|
|
nnoremap <C-p> :GitFiles<CR>
|
|
|
|
nnoremap <C-o> :Files<CR>
|
|
|
|
nnoremap <C-u> :GFiles?<CR>
|
|
|
|
nnoremap <C-b> :Buffers<CR>
|
|
|
|
|
|
|
|
nnoremap <C-h> :TmuxNavigateLeft<CR>
|
|
|
|
nnoremap <C-j> :TmuxNavigateDown<CR>
|
|
|
|
nnoremap <C-k> :TmuxNavigateUp<CR>
|
|
|
|
nnoremap <C-l> :TmuxNavigateRight<CR>
|
|
|
|
tnoremap <C-h> <C-\><C-n>:TmuxNavigateLeft<CR>
|
|
|
|
tnoremap <C-j> <C-\><C-n>:TmuxNavigateDown<CR>
|
|
|
|
tnoremap <C-k> <C-\><C-n>:TmuxNavigateUp<CR>
|
|
|
|
tnoremap <C-l> <C-\><C-n>:TmuxNavigateRight<CR>
|
|
|
|
|
|
|
|
map <silent> ,w <Plug>CamelCaseMotion_w
|
|
|
|
map <silent> ,b <Plug>CamelCaseMotion_b
|
|
|
|
map <silent> ,e <Plug>CamelCaseMotion_e
|
|
|
|
map <silent> ,ge <Plug>CamelCaseMotion_ge
|
|
|
|
omap <silent> ib <Plug>CamelCaseMotion_ib
|
|
|
|
xmap <silent> ib <Plug>CamelCaseMotion_ib
|
|
|
|
omap <silent> ie <Plug>CamelCaseMotion_ie
|
|
|
|
xmap <silent> ie <Plug>CamelCaseMotion_ie
|
|
|
|
|
|
|
|
map <F3> mw:%s/\s\+$//<CR>:let @/ = ""<CR>'w
|
|
|
|
map <F4> :setlocal spell!<CR>
|
|
|
|
|
|
|
|
nnoremap <expr> n 'Nn'[v:searchforward]
|
|
|
|
nnoremap <expr> N 'nN'[v:searchforward]
|
|
|
|
|
|
|
|
cnoremap <c-n> <down>
|
|
|
|
cnoremap <c-p> <up>
|
|
|
|
|
|
|
|
xnoremap < <gv
|
|
|
|
xnoremap > >gv
|
|
|
|
|
2021-03-22 10:47:23 -05:00
|
|
|
nnoremap gd :call CocAction('jumpDefinition')<CR>
|
|
|
|
|
2020-11-20 15:27:02 -06:00
|
|
|
" TODO: learn about the wildmenu `q:`
|
|
|
|
|
2020-11-07 00:23:20 -06:00
|
|
|
let mapleader = "\<Space>"
|
2020-11-09 22:57:12 -06:00
|
|
|
nnoremap <silent> <leader>r :source $vimdir/init.vim<CR>:echo 'Reloaded init.vim'<CR>
|
2021-03-22 10:47:23 -05:00
|
|
|
nnoremap <silent> <leader>gv :e $vimdir/init.vim<CR>
|
2020-11-07 00:23:20 -06:00
|
|
|
nnoremap <silent> <leader>w :bd<CR>
|
2020-11-17 17:17:03 -06:00
|
|
|
nnoremap <silent> <leader>h :b#<CR>
|
|
|
|
nnoremap <silent> <leader>k :bnext<CR>
|
|
|
|
nnoremap <silent> <leader>j :bprevious<CR>
|
2020-11-09 22:57:12 -06:00
|
|
|
nnoremap <leader>/ :let @/ = ""<CR>:<BACKSPACE>
|
2020-11-07 00:23:20 -06:00
|
|
|
|
|
|
|
nnoremap <leader>t :split<CR>:term<CR>:resize 24<CR>:startinsert<CR>
|
|
|
|
tnoremap <C-w> <C-\><C-n>:q!<CR>
|
|
|
|
|
2020-11-17 17:17:03 -06:00
|
|
|
function! NeatFoldText()
|
2020-11-21 13:59:19 -06:00
|
|
|
" TODO: finish this!
|
2020-11-17 17:17:03 -06:00
|
|
|
let lines_count = v:foldend - v:foldstart + 1
|
|
|
|
let foldchar = matchstr(&fillchars, 'fold:\zs.')
|
|
|
|
let foldtextstart = strpart('^' . repeat(foldchar, v:foldlevel*2) . line, 0, (winwidth(0)*2)/3)
|
|
|
|
let foldtextend = printf("%s %".(winwidth(0)-20)."dL", foldtextstart, getline(v:foldstart), lines_count)
|
|
|
|
let foldtextlength = strlen(substitute(foldtextstart . foldtextend, '.', 'x', 'g')) + &foldcolumn
|
|
|
|
return printf("%s%d", substitute(getline(v:foldstart), "^.", ">"), lines_count)
|
|
|
|
endfunction
|
|
|
|
set foldtext=NeatFoldText()
|
|
|
|
|
2020-11-21 13:59:19 -06:00
|
|
|
" TODO: only update this portion when needed instead of every render?
|
|
|
|
function! StatusLineBufferByNum(bufnum)
|
2021-01-06 10:52:45 -06:00
|
|
|
let l:bufinfo = getbufinfo(a:bufnum)[0]
|
2020-11-21 16:40:42 -06:00
|
|
|
let l:prefix = ' %#InactiveBuffer#'
|
2020-11-17 17:17:03 -06:00
|
|
|
let l:suffix = '%* '
|
2021-01-06 10:52:45 -06:00
|
|
|
|
|
|
|
if l:bufinfo.changed
|
|
|
|
let l:prefix = '%#DirtyBuffer# '
|
|
|
|
let l:suffix = ' %*'
|
|
|
|
end
|
|
|
|
|
2020-11-17 17:17:03 -06:00
|
|
|
if l:bufinfo['hidden'] == 0 && index(l:bufinfo['windows'], g:statusline_winid) >= 0
|
|
|
|
let l:prefix = '%#ActiveBuffer# '
|
2020-11-21 16:40:42 -06:00
|
|
|
let l:suffix = ' %*'
|
2021-01-15 10:18:48 -06:00
|
|
|
if l:bufinfo.changed
|
|
|
|
let l:prefix = '%#ActiveBuffer# *'
|
|
|
|
let l:suffix = ' %*'
|
|
|
|
end
|
2020-11-17 17:17:03 -06:00
|
|
|
endif
|
2021-01-06 10:52:45 -06:00
|
|
|
|
2020-11-17 17:17:03 -06:00
|
|
|
return l:prefix . fnamemodify(bufname(a:bufnum), ':t') . l:suffix
|
|
|
|
endfunction
|
|
|
|
|
2020-11-20 15:27:02 -06:00
|
|
|
au BufReadPost * | if stridx(&ft, 'commit') >= 0 | exe "startinsert!" | endif
|
|
|
|
|
2020-11-21 16:40:42 -06:00
|
|
|
let g:status_line_max_length = 5
|
2020-11-17 17:17:03 -06:00
|
|
|
function! StatusLineBuffers()
|
2020-12-07 20:50:13 -06:00
|
|
|
" TODO: mark buffers with unsaved changes
|
2020-11-21 16:40:42 -06:00
|
|
|
let l:active_index = -1
|
2020-11-21 13:59:19 -06:00
|
|
|
let l:acc = []
|
2020-11-21 16:40:42 -06:00
|
|
|
for l:bufnum in nvim_list_bufs()
|
|
|
|
let l:bufinfo = getbufinfo(l:bufnum)[0]
|
|
|
|
if l:bufinfo.listed == 0
|
|
|
|
continue
|
|
|
|
end
|
2020-11-21 13:59:19 -06:00
|
|
|
let l:entry = StatusLineBufferByNum(bufnum)
|
|
|
|
let l:acc = add(l:acc, l:entry)
|
2020-11-21 16:40:42 -06:00
|
|
|
if l:entry =~ "^%#ActiveBuffer#"
|
|
|
|
let l:active_index = index(l:acc, l:entry)
|
2020-11-21 13:59:19 -06:00
|
|
|
endif
|
|
|
|
endfor
|
2020-11-21 16:40:42 -06:00
|
|
|
if l:active_index >= 0
|
|
|
|
" TODO: instead implement this as a wraparound carousel?
|
|
|
|
let l:offset = g:status_line_max_length / 2
|
|
|
|
let l:min_buf_num = max([0, (l:active_index - offset)])
|
|
|
|
let l:max_buf_num = min([(len(l:acc) - 1), (l:min_buf_num + g:status_line_max_length - 1)])
|
|
|
|
let l:min_buf_num = max([0, (l:max_buf_num - g:status_line_max_length + 1)])
|
|
|
|
let l:buflist = join(l:acc[(l:min_buf_num):(l:max_buf_num)], '')
|
|
|
|
let l:prefix = ""
|
|
|
|
let l:suffix = ""
|
|
|
|
if l:min_buf_num > 0
|
|
|
|
let l:prefix = "< "
|
|
|
|
endif
|
|
|
|
if l:max_buf_num < len(l:acc) - 1
|
|
|
|
let l:suffix = " >"
|
|
|
|
endif
|
|
|
|
return l:prefix . l:buflist . l:suffix
|
|
|
|
else
|
|
|
|
return join(l:acc, '')
|
|
|
|
endif
|
2020-11-17 17:17:03 -06:00
|
|
|
endfunction
|
|
|
|
|
|
|
|
function! StatusLine()
|
2020-11-21 16:40:42 -06:00
|
|
|
" try
|
2020-11-21 13:59:19 -06:00
|
|
|
return StatusLineBuffers().'%*%=%c,%l/%L (%p%%)'
|
2020-11-21 16:40:42 -06:00
|
|
|
" catch
|
|
|
|
" return 'buflisterr%*%=%c,%l/%L (%p%%)'
|
|
|
|
" endtry
|
2020-11-17 17:17:03 -06:00
|
|
|
endfunction
|
|
|
|
|
2021-02-05 14:00:28 -06:00
|
|
|
augroup slime
|
|
|
|
au!
|
|
|
|
autocmd BufNewFile,BufRead *.slimleex set syntax=slim
|
|
|
|
augroup END
|
|
|
|
|
2020-11-20 15:27:02 -06:00
|
|
|
" set laststatus=0 showtabline tabline=%!StatusLine()
|
2020-11-17 17:17:03 -06:00
|
|
|
set statusline=%!StatusLine()
|
2020-11-09 22:57:12 -06:00
|
|
|
|
2020-11-20 15:27:02 -06:00
|
|
|
imap <silent> <c-n> <Plug>(completion_trigger)
|