mirror of
https://git.decapod.one/brethil/dotfiles
synced 2024-12-22 23:31:32 +01:00
145 lines
4.0 KiB
VimL
145 lines
4.0 KiB
VimL
let g:uname = system('uname | tr -d "\n"') " Get platform name (stripping the trailing newline)
|
||
|
||
" Install all plugins
|
||
source $DOTFILES/vim/plugs.vim
|
||
|
||
" Sanity
|
||
set encoding=utf-8
|
||
scriptencoding utf-8
|
||
|
||
"" Style
|
||
" enable truecolor mode
|
||
if has('termguicolors')
|
||
set termguicolors
|
||
else
|
||
let &t_8f = "\<Esc>[38:2:%lu:%lu:%lum"
|
||
let &t_8b = "\<Esc>[48:2:%lu:%lu:%lum"
|
||
endif
|
||
if !empty($THEME_PREFER_LIGHT)
|
||
set background=light
|
||
else
|
||
set background=dark
|
||
endif
|
||
let g:gruvbox_contrast_dark='hard'
|
||
let g:gruvbox_sign_column='bg0'
|
||
|
||
" Show some gui colors in term
|
||
let g:gruvbox_guisp_fallback='bg'
|
||
colorscheme gruvbox
|
||
|
||
" General stuff
|
||
set nowrap
|
||
set mouse=a
|
||
set mousemodel=popup_setpos " allow for ALE code actions
|
||
if has('mouse_sgr') " fixes unclickable panes after a specific column (~220?)
|
||
set ttymouse=sgr
|
||
else
|
||
set ttymouse=xterm2
|
||
end
|
||
|
||
set relativenumber number
|
||
set foldlevelstart=3 foldmethod=indent nofoldenable "without foldenable all folds are open at startup"
|
||
|
||
set nobackup nowb noswapfile " no need for backups of every file
|
||
set history=10000
|
||
|
||
set list listchars=tab:›\ ,trail:•,extends:#,nbsp:.
|
||
|
||
set splitbelow splitright
|
||
set autoread
|
||
" Don't redraw while executing macros (good performance config)
|
||
set lazyredraw
|
||
|
||
set ignorecase smartcase " ignore case on search but be smart about it
|
||
set hlsearch "highlight search results (using *)
|
||
|
||
set expandtab shiftwidth=4 tabstop=4 "always use spaces
|
||
|
||
" Completion menu config (see :h completopt)
|
||
set completeopt=menu,menuone,noselect,noinsert
|
||
" Show completion suggestions in popups instead of preview window
|
||
set completeopt+=popup
|
||
|
||
" Highlight the line the cursor is on
|
||
set cursorline
|
||
|
||
" Minimum fold size
|
||
set foldminlines=3
|
||
|
||
" Timeout for combined keymaps (half a sec)
|
||
set timeoutlen=500
|
||
|
||
autocmd FileType qf,ll setlocal wrap "quickfix,loclist
|
||
autocmd FileType markdown setlocal wrap spell spelllang=it,en
|
||
autocmd FileType yaml,yml setlocal shiftwidth=2 softtabstop=2 expandtab
|
||
autocmd FileType vue setlocal shiftwidth=2 softtabstop=2 expandtab
|
||
|
||
autocmd FileType go setlocal noexpandtab makeprg=go\ build
|
||
autocmd FileType rust set makeprg=cargo\ build
|
||
autocmd FileType python set keywordprg="pydoc"
|
||
|
||
syntax match jsonComment "//.*"
|
||
syntax match jsonComment "\(/\*\)\|\(\*/\)"
|
||
hi def link jsonComment Comment
|
||
|
||
|
||
augroup dvc
|
||
au BufRead dvc.yaml let b:ale_fix_on_save=0
|
||
au BufRead *.dvc let b:ale_fix_on_save=0
|
||
au BufRead *.dvc set filetype=yaml
|
||
augroup END
|
||
|
||
augroup ansible
|
||
au BufRead,BufNewFile */playbooks/*.yml set filetype=yaml.ansible
|
||
augroup END
|
||
|
||
augroup githubactions
|
||
au BufRead,BufNewFile */.github/*/*.y{,a}ml
|
||
\ let b:ale_linters = {'yaml': ['actionlint'] }
|
||
augroup END
|
||
|
||
augroup iptables
|
||
au BufRead,BufNewFile rules.v[46],*.rules setlocal filetype=iptables
|
||
augroup END
|
||
|
||
augroup vimconfig
|
||
autocmd! bufwritepost ~/.vimrc source ~/.vimrc
|
||
autocmd! bufwritepost $DOTFILES/vim/vimrc source ~/.vimrc
|
||
autocmd! bufwritepost $DOTFILES/vim/shortcuts.vim source ~/.vimrc
|
||
autocmd! bufwritepost $DOTFILES/vim/plugs.vim PlugInstall
|
||
autocmd! bufwritepost $DOTFILES/vim/plugs.vim PlugUpdate
|
||
augroup END
|
||
|
||
if has('persistent_undo')
|
||
let undo_dir=$HOME . '/.vim/undo'
|
||
if !isdirectory(undo_dir)
|
||
call mkdir(undo_dir , 'p', 0700)
|
||
endif
|
||
let &undodir=undo_dir
|
||
set undofile
|
||
endif
|
||
|
||
augroup dotgit
|
||
" Return to last edit position when opening files (from amix's vimrc)
|
||
au BufReadPost * if ! exists('b:dotgitFolder') | if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif
|
||
" set a marker to avoid returning to the previous position in .git folders
|
||
" (avoids returning to previous position for COMMIT_EDITMSG etc )
|
||
au BufReadPost */.git/* let b:dotgitFolder = 1
|
||
augroup END
|
||
|
||
" Bash like keys for the command line
|
||
cnoremap <C-A> <Home>
|
||
cnoremap <C-E> <End>
|
||
cnoremap <C-K> <C-U>
|
||
|
||
cnoremap <C-P> <Up>
|
||
cnoremap <C-N> <Down>
|
||
|
||
source $DOTFILES/vim/plugins_config.vim
|
||
source $DOTFILES/vim/shortcuts.vim
|
||
source $DOTFILES/vim/functions.vim
|
||
|
||
if filereadable('.vimrc.local')
|
||
source .vimrc.local
|
||
endif
|