2021-09-26 17:32:11 +02:00
|
|
|
|
let g:uname = system('uname | tr -d "\n"') " Get platform name (stripping the trailing newline)
|
|
|
|
|
|
2021-12-08 23:58:55 +01:00
|
|
|
|
" Install all plugins
|
2020-12-06 02:29:15 +01:00
|
|
|
|
source $DOTFILES/vim/plugs.vim
|
|
|
|
|
|
|
|
|
|
" Sanity
|
|
|
|
|
set encoding=utf-8
|
|
|
|
|
scriptencoding utf-8
|
|
|
|
|
|
2021-09-26 16:07:34 +02:00
|
|
|
|
"" Style
|
|
|
|
|
" enable truecolor mode
|
2023-09-15 00:13:48 +02:00
|
|
|
|
if has('termguicolors')
|
2021-12-08 23:04:34 +01:00
|
|
|
|
set termguicolors
|
|
|
|
|
else
|
|
|
|
|
let &t_8f = "\<Esc>[38:2:%lu:%lu:%lum"
|
|
|
|
|
let &t_8b = "\<Esc>[48:2:%lu:%lu:%lum"
|
|
|
|
|
endif
|
2023-09-15 00:09:05 +02:00
|
|
|
|
if !empty($THEME_PREFER_LIGHT)
|
|
|
|
|
set background=light
|
|
|
|
|
else
|
|
|
|
|
set background=dark
|
|
|
|
|
endif
|
2021-03-08 10:06:31 +01:00
|
|
|
|
let g:gruvbox_contrast_dark='hard'
|
2021-05-19 10:38:33 +02:00
|
|
|
|
let g:gruvbox_sign_column='bg0'
|
|
|
|
|
|
2021-09-26 16:07:34 +02:00
|
|
|
|
" Show some gui colors in term
|
|
|
|
|
let g:gruvbox_guisp_fallback='bg'
|
2020-12-06 02:29:15 +01:00
|
|
|
|
colorscheme gruvbox
|
|
|
|
|
|
|
|
|
|
" General stuff
|
|
|
|
|
set nowrap
|
|
|
|
|
set mouse=a
|
2023-01-19 15:07:17 +01:00
|
|
|
|
set mousemodel=popup_setpos " allow for ALE code actions
|
2023-01-27 12:34:55 +01:00
|
|
|
|
if has('mouse_sgr') " fixes unclickable panes after a specific column (~220?)
|
|
|
|
|
set ttymouse=sgr
|
|
|
|
|
else
|
|
|
|
|
set ttymouse=xterm2
|
|
|
|
|
end
|
|
|
|
|
|
2020-12-06 02:29:15 +01:00
|
|
|
|
set relativenumber number
|
2022-11-26 00:52:01 +01:00
|
|
|
|
set foldlevelstart=3 foldmethod=indent nofoldenable "without foldenable all folds are open at startup"
|
2020-12-06 02:29:15 +01:00
|
|
|
|
|
2020-12-07 15:37:55 +01:00
|
|
|
|
set nobackup nowb noswapfile " no need for backups of every file
|
2020-12-06 02:29:15 +01:00
|
|
|
|
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 *)
|
|
|
|
|
|
2020-12-09 01:54:42 +01:00
|
|
|
|
set expandtab shiftwidth=4 tabstop=4 "always use spaces
|
|
|
|
|
|
2021-03-15 12:36:31 +01:00
|
|
|
|
" Completion menu config (see :h completopt)
|
2023-09-22 18:19:38 +02:00
|
|
|
|
set completeopt=menu,menuone,noselect,noinsert
|
2021-03-15 12:36:31 +01:00
|
|
|
|
" Show completion suggestions in popups instead of preview window
|
|
|
|
|
set completeopt+=popup
|
|
|
|
|
|
2021-09-26 16:09:15 +02:00
|
|
|
|
" Highlight the line the cursor is on
|
|
|
|
|
set cursorline
|
|
|
|
|
|
2022-03-25 08:52:57 +01:00
|
|
|
|
" Minimum fold size
|
|
|
|
|
set foldminlines=3
|
|
|
|
|
|
2023-10-25 11:44:33 +02:00
|
|
|
|
" Timeout for combined keymaps (half a sec)
|
|
|
|
|
set timeoutlen=500
|
|
|
|
|
|
2024-04-05 15:10:40 +02:00
|
|
|
|
" keep history the last 1000 opened files, 200 commands and 50 search
|
|
|
|
|
" patterns. `h` persists bookmarks across sessions
|
|
|
|
|
set viminfo='1000,<200,s50,h
|
|
|
|
|
|
2021-05-19 10:44:07 +02:00
|
|
|
|
autocmd FileType qf,ll setlocal wrap "quickfix,loclist
|
2024-06-08 17:53:35 +02:00
|
|
|
|
"autocmd FileType markdown setlocal wrap spell spelllang=it,en
|
2020-12-06 02:29:15 +01:00
|
|
|
|
autocmd FileType yaml,yml setlocal shiftwidth=2 softtabstop=2 expandtab
|
2021-01-07 11:08:00 +01:00
|
|
|
|
autocmd FileType vue setlocal shiftwidth=2 softtabstop=2 expandtab
|
2021-10-01 16:56:32 +02:00
|
|
|
|
|
|
|
|
|
autocmd FileType go setlocal noexpandtab makeprg=go\ build
|
|
|
|
|
autocmd FileType rust set makeprg=cargo\ build
|
2022-01-25 10:52:22 +01:00
|
|
|
|
autocmd FileType python set keywordprg="pydoc"
|
2021-10-01 16:56:32 +02:00
|
|
|
|
|
2021-12-08 23:57:20 +01:00
|
|
|
|
syntax match jsonComment "//.*"
|
|
|
|
|
syntax match jsonComment "\(/\*\)\|\(\*/\)"
|
|
|
|
|
hi def link jsonComment Comment
|
|
|
|
|
|
|
|
|
|
|
2023-09-15 00:13:32 +02:00
|
|
|
|
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
|
2024-08-12 18:05:51 +02:00
|
|
|
|
au BufRead,BufNewFile */tasks/*.yml set filetype=yaml.ansible
|
|
|
|
|
au BufRead,BufNewFile playbook.yml set filetype=yaml.ansible
|
2023-09-15 00:13:32 +02:00
|
|
|
|
augroup END
|
|
|
|
|
|
|
|
|
|
augroup githubactions
|
2024-08-12 18:05:51 +02:00
|
|
|
|
au BufRead,BufReadPost,BufNewFile */.github/*/*.y{,a}ml set filetype=yaml.gha
|
|
|
|
|
""|let b:ale_linters = {'yaml': ['actionlint']}
|
2023-09-15 00:13:32 +02:00
|
|
|
|
augroup END
|
2020-12-06 23:20:21 +01:00
|
|
|
|
|
2023-09-15 00:13:32 +02:00
|
|
|
|
augroup iptables
|
|
|
|
|
au BufRead,BufNewFile rules.v[46],*.rules setlocal filetype=iptables
|
|
|
|
|
augroup END
|
2022-08-12 15:52:55 +02:00
|
|
|
|
|
2023-09-15 00:13:32 +02:00
|
|
|
|
augroup vimconfig
|
2024-06-19 12:08:25 +02:00
|
|
|
|
" Reload vimrc on config change
|
2023-09-15 00:13:32 +02:00
|
|
|
|
autocmd! bufwritepost ~/.vimrc source ~/.vimrc
|
|
|
|
|
autocmd! bufwritepost $DOTFILES/vim/vimrc source ~/.vimrc
|
|
|
|
|
autocmd! bufwritepost $DOTFILES/vim/shortcuts.vim source ~/.vimrc
|
2024-06-19 12:08:25 +02:00
|
|
|
|
" Install/Update plugs on change
|
2023-09-15 00:13:32 +02:00
|
|
|
|
autocmd! bufwritepost $DOTFILES/vim/plugs.vim PlugInstall
|
|
|
|
|
autocmd! bufwritepost $DOTFILES/vim/plugs.vim PlugUpdate
|
|
|
|
|
augroup END
|
2022-08-12 15:52:55 +02:00
|
|
|
|
|
2020-12-09 01:54:42 +01:00
|
|
|
|
if has('persistent_undo')
|
2023-09-15 00:13:48 +02:00
|
|
|
|
let undo_dir=$HOME . '/.vim/undo'
|
2022-03-25 08:33:47 +01:00
|
|
|
|
if !isdirectory(undo_dir)
|
2023-09-15 00:13:48 +02:00
|
|
|
|
call mkdir(undo_dir , 'p', 0700)
|
2022-03-25 08:33:47 +01:00
|
|
|
|
endif
|
|
|
|
|
let &undodir=undo_dir
|
2020-12-09 01:54:42 +01:00
|
|
|
|
set undofile
|
|
|
|
|
endif
|
2020-12-06 02:29:15 +01:00
|
|
|
|
|
2023-09-15 00:13:32 +02:00
|
|
|
|
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
|
2024-06-29 10:53:41 +02:00
|
|
|
|
" do not apply fixers to patches
|
|
|
|
|
au BufReadPost .git/*.diff let b:ale_fix_on_save=0
|
2023-09-15 00:13:32 +02:00
|
|
|
|
augroup END
|
2020-12-06 02:29:15 +01:00
|
|
|
|
|
|
|
|
|
" 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
|
2023-09-15 00:17:56 +02:00
|
|
|
|
|
|
|
|
|
if filereadable('.vimrc.local')
|
|
|
|
|
source .vimrc.local
|
|
|
|
|
endif
|