Migrate init.vim to Vim9 script as well

This commit is contained in:
Danielle McLean 2022-07-02 16:38:38 +10:00
parent fc59f3cf4c
commit a17be94d77
Signed by: 00dani
GPG Key ID: 52C059C3B22A753E
1 changed files with 34 additions and 37 deletions

View File

@ -1,43 +1,39 @@
vim9script
set encoding=utf-8
scriptencoding utf-8
function! s:ensure_dir(dir)
if filewritable(a:dir) != 2
call mkdir(a:dir, "p", 0700)
def EnsureDir(dir: string): void
if filewritable(dir) != 2
mkdir(dir, "p", 0700)
endif
endfunction
enddef
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()
# 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 | minpac#update()
command! PackClean source $XDG_CONFIG_HOME/vim/plugins.vim | minpac#clean()
command! PackStatus source $XDG_CONFIG_HOME/vim/plugins.vim | 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
# 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
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
g:gruvbox_italic = 1
g:gruvbox_improved_strings = 1
g:gruvbox_improved_warnings = 1
if has('gui_running') || has('termguicolors')
set termguicolors
silent! packadd gruvbox
let g:airline_theme = 'gruvbox'
g:airline_theme = 'gruvbox'
colorscheme gruvbox
else
colorscheme inkpot
@ -57,6 +53,7 @@ set linebreak showbreak=↩
set modelines=5
set showcmd
set wildmode=longest,full
silent! set wildoptions+=pum
set tabstop=2 shiftwidth=2
@ -70,8 +67,8 @@ else
set number
endif
for s:dir in ['backup', 'swap', 'undo']
call s:ensure_dir($XDG_STATE_HOME . '/vim/' . s:dir)
for dir in ['backup', 'swap', 'undo']
EnsureDir($XDG_STATE_HOME .. '/vim/' .. dir)
endfor
set backupdir=.,$XDG_STATE_HOME/vim/backup
@ -81,22 +78,22 @@ if exists('+undofile')
set undodir=$XDG_STATE_HOME/vim/undo
endif
let g:airline_powerline_fonts = 1
let g:airline#extensions#battery#enabled = 1
g:airline_powerline_fonts = 1
g:airline#extensions#battery#enabled = 1
let g:csv_no_conceal = 1
g:csv_no_conceal = 1
let vim_svelte_plugin_use_typescript = 1
g:vim_svelte_plugin_use_typescript = 1
let g:LatexBox_Folding = 1
let g:NERDTreeHijackNetrw = 1
g:LatexBox_Folding = 1
g:NERDTreeHijackNetrw = 1
let g:ale_set_balloons = 1
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\|\.\)$'}
\}
\}
g:mucomplete#can_complete = {
default: {
omni: (t) => strlen(&l:omnifunc) > 0 && t =~# '\m\k\%(\k\|\.\)$'
}
}