vim/config/vim/init.vim
Danielle McLean ad496a7745
Support the XDG_STATE_HOME directory
It's a better place to store most of the stuff Vim wants to store lying
around on the filesystem than XDG_CACHE_HOME, it turns out? I'm still
keeping installed packages primarily in XDG_CACHE_HOME, since if that
directory is blown away then the same packages just get reinstalled
automatically and nothing particularly important is lost, but the other
stuff doesn't really belong in there.

Undo files, viminfo, and so on are definitely a good example of "state
data that should be persisted between (application) restarts, but that
is not important or portable enough to the user that it should be stored
in XDG_DATA_HOME", so XDG_STATE_HOME is a fine place for them.
2021-09-22 10:35:51 +10:00

99 lines
2.3 KiB
VimL

set encoding=utf-8
scriptencoding utf-8
function! s:ensure_dir(dir)
if filewritable(a:dir) != 2
call mkdir(a:dir, "p", 0700)
endif
endfunction
if exists('+packpath')
" These are really clever - minpac will actually be loaded on the fly only
" when you need to update or clean your packages, rather than all the time.
command! PackUpdate source $XDG_CONFIG_HOME/vim/plugins.vim | call minpac#update()
command! PackClean source $XDG_CONFIG_HOME/vim/plugins.vim | call minpac#clean()
command! PackStatus source $XDG_CONFIG_HOME/vim/plugins.vim | call minpac#status()
" If the pack directory doesn't exist, we haven't installed any packages yet,
" so let's call PackUpdate.
if !isdirectory($XDG_CACHE_HOME . '/vim/pack')
PackUpdate
endif
else
" If we're on a version of Vim that doesn't have packages, we have to load a
" plugin manager (vim-plug) on every boot.
source $XDG_CONFIG_HOME/vim/plugins.vim
endif
augroup transparent_term
autocmd!
autocmd ColorScheme * highlight Normal ctermbg=NONE guibg=NONE
augroup END
set background=dark
let g:gruvbox_italic=1
let g:gruvbox_improved_strings=1
let g:gruvbox_improved_warnings=1
if has('gui_running') || has('termguicolors')
set termguicolors
silent! packadd gruvbox
let g:airline_theme = 'gruvbox'
colorscheme gruvbox
else
colorscheme inkpot
endif
inoremap jj <Esc>
nnoremap <C-t> :Files<CR>
if exists('+belloff')
set belloff+=ctrlg
endif
set completeopt+=menuone
set linebreak showbreak=
set modelines=5
set showcmd
set wildmode=longest,full
set tabstop=2 shiftwidth=2
if exists('+breakindent')
set breakindent breakindentopt=sbr
endif
if exists('+relativenumber')
set relativenumber
else
set number
endif
for s:dir in ['backup', 'swap', 'undo']
call s:ensure_dir($XDG_STATE_HOME . '/vim/' . s:dir)
endfor
set backupdir=.,$XDG_STATE_HOME/vim/backup
set directory=.,$XDG_STATE_HOME/vim/swap
if exists('+undofile')
set undofile
set undodir=$XDG_STATE_HOME/vim/undo
endif
let g:airline_powerline_fonts = 1
let g:airline#extensions#battery#enabled = 1
let g:LatexBox_Folding = 1
let g:NERDTreeHijackNetrw = 1
let g:ale_set_balloons = 1
nmap <silent> <C-k> <Plug>(ale_previous_wrap)
nmap <silent> <C-j> <Plug>(ale_next_wrap)
let g:mucomplete#can_complete = {
\'default': {
\'omni': {t -> strlen(&l:omnifunc) > 0 && t =~# '\m\k\%(\k\|\.\)$'}
\}
\}