vimrc: optimise plugin loading + linter setting

* theme change to space_vim_theme
* airline theme change to violet
* compensate for themes not setting italic by setting it ourselves
* airline mode set to the short versions of normal, insert, visual,
  etc...

* enable vim popups (ballooneval)

* add ALE linter

* syntastic conditional loading
* Plug plugins conditional loading
* plugins slowing down vim startup are only loaded based on
  event hooks that's active once vim loaded the file {CursorHold,CursorHoldI}
* {plugin,theme,general} clean-up
This commit is contained in:
surtur 2021-05-03 02:05:15 +02:00
parent b8a4e7ecf0
commit de591a7f7a
Signed by: wanderer
GPG Key ID: 19CE1EC1D9E0486D

@ -3,8 +3,6 @@ set nocompatible
filetype off "required
filetype plugin on " required
" Enable heavy omni completion.
if !exists('g:neocomplete#sources#omni#input_patterns')
let g:neocomplete#sources#omni#input_patterns = {}
@ -17,58 +15,123 @@ if empty(glob('~/.vim/autoload/plug.vim'))
autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
endif
" Run PlugInstall if there are missing plugins
autocmd VimEnter * if len(filter(values(g:plugs), '!isdirectory(v:val.dir)'))
\| PlugInstall --sync | source $MYVIMRC
\| endif
" both "filetype indent on" and "syntax on" are called by Plug, keeping DRY
call plug#begin()
Plug 'drewtempelmeyer/palenight.vim', { 'as': 'palenight' }
Plug 'jacoborus/tender.vim'
Plug 'dracula/vim', { 'as': 'dracula' }
Plug 'lervag/vimtex', { 'for': 'tex' }
Plug 'xuhdev/vim-latex-live-preview', { 'for': 'tex' }
Plug 'chikamichi/mediawiki.vim', { 'for': 'wiki' }
Plug 'liuchengxu/space-vim-theme'
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
Plug 'ctrlpvim/ctrlp.vim'
Plug 'justmao945/vim-clang'
Plug 'ctrlpvim/ctrlp.vim', { 'on': [] }
" 🌷 Distraction-free writing in Vim
Plug 'junegunn/goyo.vim', { 'for': 'markdown' }
Plug 'preservim/nerdcommenter', { 'on': [] }
Plug 'tpope/vim-surround'
" fugitive.vim: A Git wrapper so awesome, it should be illegal
Plug 'tpope/vim-fugitive'
Plug 'tpope/vim-repeat'
Plug 'tpope/vim-speeddating'
Plug 'tpope/vim-afterimage'
Plug 'tpope/vim-jdaddy'
Plug 'tpope/vim-unimpaired'
Plug 'tpope/vim-ragtag'
Plug 'gorodinskiy/vim-coloresque'
Plug 'lpinilla/vim-codepainter'
Plug 'tpope/vim-speeddating', { 'on': [] }| " quick date incrementing
" plugin fails to work if it's only loaded on a predefined list of
" formats, commented for now
" Plug 'tpope/vim-afterimage', { 'for': ['xpm', 'png', 'ico', 'gif'] }
Plug 'tpope/vim-jdaddy', { 'for': 'json' }
Plug 'tpope/vim-ragtag', { 'for': ['html', 'xhtml', 'wml', 'xml', 'xslt', 'xsd', 'jsp', 'php', 'aspperl', 'aspvbs', 'cf', 'mason', 'htmldjango', 'eruby'] }
Plug 'gorodinskiy/vim-coloresque'| " coloured background for colour names/codes
Plug 'lpinilla/vim-codepainter'| " text highlighting
Plug 'rhysd/git-messenger.vim'
Plug 'Yggdroot/indentLine'
Plug 'cespare/vim-toml', { 'for': 'toml' }
Plug 'Glench/Vim-Jinja2-Syntax'
Plug 'preservim/nerdcommenter'
Plug 'preservim/nerdtree'
Plug 'Xuyuanp/nerdtree-git-plugin'
Plug 'mfukar/robotframework-vim', { 'for': 'robotframework' }
Plug 'preservim/nerdtree', { 'on': 'NERDTreeToggle' }
Plug 'Xuyuanp/nerdtree-git-plugin', { 'on': 'NERDTreeToggle' }
Plug 'tiagofumo/vim-nerdtree-syntax-highlight', { 'on': 'NERDTreeToggle' }
Plug 'roxma/nvim-yarp'
Plug 'roxma/vim-hug-neovim-rpc'
Plug 'Shougo/deoplete.nvim'
Plug 'vim-syntastic/syntastic'
Plug 'vim-syntastic/syntastic', { 'on': [] }
Plug 'dense-analysis/ale'
Plug 'OmniSharp/omnisharp-vim', { 'for': ['cs', 'csh'] }
Plug 'justmao945/vim-clang', { 'on': [] }
Plug 'cdelledonne/vim-cmake'
Plug 'majutsushi/tagbar'
Plug 'lvht/tagbar-markdown', { 'for': 'markdown' }
Plug 'lervag/vimtex', { 'for': 'tex' }
Plug 'xuhdev/vim-latex-live-preview', { 'for': 'tex' }
Plug 'cespare/vim-toml', { 'for': 'toml' }
Plug 'Glench/Vim-Jinja2-Syntax'
Plug 'pearofducks/ansible-vim'
Plug 'aouelete/sway-vim-syntax'
Plug 'hashivim/vim-terraform'
Plug 'aouelete/sway-vim-syntax', { 'for': 'sway' }
Plug 'rust-lang/rust.vim', { 'for': 'rust' }
Plug 'fatih/vim-go', { 'for': 'go', 'do': ':GoInstallBinaries' }
Plug 'chikamichi/mediawiki.vim', { 'for': 'wiki' }
Plug 'mfukar/robotframework-vim', { 'for': 'robotframework' }
call plug#end()
let g:palenight_terminal_italics=1
let g:crystalline_theme = 'default'
let g:airline_powerline_fonts = 1
let g:Powerline_symbols = "fancy" " sth like this probably set as a default but won't hurt here
let g:airline_highlighting_cache = 1
" let g:airline_theme = 'dracula'
" violet, wombat, deus
let g:airline_theme = 'violet'
let g:airline#extensions#tabline#enabled = 1
let g:airline#extensions#tabline#formatter = 'unique_tail'
let g:airline_mode_map = {
\ '__' : '-',
\ 'c' : 'C',
\ 'i' : 'I',
\ 'ic' : 'I-C',
\ 'ix' : 'I-X',
\ 'n' : 'N',
\ 'multi' : 'M',
\ 'ni' : 'N',
\ 'no' : 'N',
\ 'R' : 'R',
\ 'Rv' : 'R',
\ 's' : 'S',
\ 'S' : 'S',
\ '' : 'S',
\ 't' : 'T',
\ 'v' : 'V',
\ 'V' : 'V-L',
\ '' : 'V-B',
\ }
" skip displaying fileformat output if the output matches a configured string.
let g:airline#parts#ffenc#skip_expected_string='utf-8[unix]'
let g:airline#extensions#ale#enabled = 1
let g:ale_lint_on_text_changed = 'normal'
let g:ale_lint_on_insert_leave = 1
let g:ale_lint_delay = 1000| " the default being 200
let g:ale_completion_autoimport = 1
let g:ale_linters = { 'go': ['gopls', 'govet', 'golint'],
\ 'dockerfile': ['hadolint'],
\ 'cs': ['OmniSharp'] }
let g:ale_fixers = { 'c': ['clang-format', 'clangtidy'],
\ 'cpp': ['clang-format', 'clangtidy'],
\ 'go': ['gopls'] }
if has('patch-8.1.1880')
set completeopt=longest,menuone,popuphidden
" Highlight the completion documentation popup background/foreground the same as
" the completion menu itself, for better readability with highlighted
" documentation.
set completepopup=highlight:Pmenu,border:off
else
set completeopt=longest,menuone,preview
" Set desired preview window height for viewing documentation.
set previewheight=5
endif
let g:gitgutter_terminal_reports_focus=0
let g:gitgutter_async = 1
let g:gitgutter_sign_allow_clobber=0
set foldtext=gitgutter#fold#foldtext()
let g:deoplete#enable_at_startup = 1
let g:deoplete#enable_ignore_case = 1
@ -100,6 +163,15 @@ let g:git_messenger_close_on_cursor_moved = v:false
let g:git_messenger_always_into_popup = v:true
hi gitmessengerHash term=None guifg=#f0eaaa ctermfg=111
" OmniSharp
" IDE0010: Populate switch - display in ALE as `Info`
" IDE0055: Fix formatting - display in ALE as `Warning` style error
" CS8019: Duplicate of IDE0005
let g:OmniSharp_diagnostic_overrides = {
\ 'IDE0010': {'type': 'I'},
\ 'IDE0055': {'type': 'W', 'subtype': 'Style'},
\ 'CS8019': {'type': 'None'},
\}
let g:syntastic_always_populate_loc_list = 1
let g:syntastic_auto_loc_list = 2
@ -112,17 +184,22 @@ let g:syntastic_error_symbol = "✗"
let g:syntastic_warning_symbol = "⚠"
set statusline+=%#warningmsg#
set statusline+=%{SyntasticStatuslineFlag()}
set statusline+=%{exists('g:loaded_syntastic_plugin')?SyntasticStatuslineFlag():''}
set statusline+=%*
let g:syntastic_javascript_checkers = ['jsl']
let g:syntastic_python_checkers = ['flake8,pylint-3']
let g:syntastic_python_checkers = ['flake8', 'pylint-3']
let g:syntastic_c_compiler = 'clang'
let g:syntastic_c_check_header = 1
let g:syntastic_c_auto_refresh_includes = 1
let g:syntastic_cpp_check_header = 1
let g:syntastic_cpp_auto_refresh_includes = 1
let g:syntastic_c_cpplint_exec = 'cppcheck'
let g:syntastic_c_cpplint_exec = ['cppcheck', 'clang-check', 'clang-tidy']
let g:syntastic_go_checkers = ['go', 'gopls', 'golint', 'govet']
let g:terraform_align=1
let g:terraform_fold_sections=1
let g:terraform_fmt_on_save=1
" change cursor shape for different editing modes, neovim does this by default
if !has('nvim')
@ -157,6 +234,13 @@ nnoremap gb :!git blame %<CR>
nnoremap <silent> <Leader>ll :w! !pdflatex -shell-escape -interaction=nonstopmode $PWD/*.tex<CR><CR>
nnoremap <Leader>l :exec &conceallevel ? "set conceallevel=0" : "set conceallevel=1"<CR><CR>
" toggle GitGutterLineHighlights
nnoremap <Leader>d :GitGutterLineHighlightsToggle<cr>
" ALE bindings
nmap <silent> <C-k> <Plug>(ale_previous_wrap)
nmap <silent> <C-j> <Plug>(ale_next_wrap)
nnoremap <Leader>a :ALEDetail<cr>
" ------ wayland copy
xnoremap <silent>"+y y:call system("wl-copy", @")<cr>
@ -223,6 +307,7 @@ augroup END
" define indent-based folding, after loading a file switch to manual folding
augroup vimrc
autocmd!
au BufReadPre * setlocal foldmethod=indent
au BufWinEnter * if &fdm == 'indent' | setlocal foldmethod=manual | endif
augroup END
@ -242,14 +327,75 @@ au BufNewFile,BufRead *.py,*.pyw,*.pyx,?akefil*
\ setlocal tabstop=4 shiftwidth=4 noexpandtab autoindent
\ fileformat=unix
" Linux kernel style tabs
au BufNewFile,BufRead *.c,*.h,*.cpp
au BufNewFile,BufRead,BufEnter *.c,*.h,*.cpp
\ setlocal tabstop=8 shiftwidth=8 softtabstop=8 noexpandtab autoindent
\ textwidth=79 fileformat=unix
au BufNewFile,BufRead *.tex
au BufNewFile,BufRead,BufEnter *.tex
\ setlocal tabstop=2 shiftwidth=2 softtabstop=2 expandtab autoindent
\ textwidth=79 fileformat=unix conceallevel=0
au BufNewFile,BufRead,BufEnter *.cs
\ setlocal ft=cs tabstop=4 shiftwidth=4 softtabstop=4 noexpandtab autoindent
\ textwidth=80 fileformat=unix conceallevel=0
au BufNewFile,BufRead *.cshtml
\ setlocal ft=csh tabstop=4 shiftwidth=4 softtabstop=4 noexpandtab autoindent
\ textwidth=80 fileformat=unix conceallevel=0
augroup async_plug_load
autocmd!
" these two take the longest to load, let's do it in a semi-non-blocking
" fashion
autocmd CursorHold,CursorHoldI * call plug#load('syntastic', 'nerdcommenter', 'vim-clang', 'vim-speeddating', 'ctrlp.vim')
\| autocmd! async_plug_load
augroup END
augroup omnisharp_commands
autocmd!
" Show type information automatically when the cursor stops moving.
" Note that the type is echoed to the Vim command line, and will overwrite
" any other messages in this space including e.g. ALE linting messages.
autocmd CursorHold *.cs OmniSharpTypeLookup
" The following commands are contextual, based on the cursor position.
autocmd FileType cs nmap <silent> <buffer> gd <Plug>(omnisharp_go_to_definition)
autocmd FileType cs nmap <silent> <buffer> <Leader>osfu <Plug>(omnisharp_find_usages)
autocmd FileType cs nmap <silent> <buffer> <Leader>osfi <Plug>(omnisharp_find_implementations)
autocmd FileType cs nmap <silent> <buffer> <Leader>ospd <Plug>(omnisharp_preview_definition)
autocmd FileType cs nmap <silent> <buffer> <Leader>ospi <Plug>(omnisharp_preview_implementations)
autocmd FileType cs nmap <silent> <buffer> <Leader>ost <Plug>(omnisharp_type_lookup)
autocmd FileType cs nmap <silent> <buffer> <Leader>osd <Plug>(omnisharp_documentation)
autocmd FileType cs nmap <silent> <buffer> <Leader>osfs <Plug>(omnisharp_find_symbol)
autocmd FileType cs nmap <silent> <buffer> <Leader>osfx <Plug>(omnisharp_fix_usings)
autocmd FileType cs nmap <silent> <buffer> <C-\> <Plug>(omnisharp_signature_help)
autocmd FileType cs imap <silent> <buffer> <C-\> <Plug>(omnisharp_signature_help)
" Navigate up and down by method/property/field
autocmd FileType cs nmap <silent> <buffer> [[ <Plug>(omnisharp_navigate_up)
autocmd FileType cs nmap <silent> <buffer> ]] <Plug>(omnisharp_navigate_down)
" Find all code errors/warnings for the current solution and populate the quickfix window
autocmd FileType cs nmap <silent> <buffer> <Leader>osgcc <Plug>(omnisharp_global_code_check)
" Contextual code actions (uses fzf, vim-clap, CtrlP or unite.vim selector when available)
autocmd FileType cs nmap <silent> <buffer> <Leader>osca <Plug>(omnisharp_code_actions)
autocmd FileType cs xmap <silent> <buffer> <Leader>osca <Plug>(omnisharp_code_actions)
" Repeat the last code action performed (does not use a selector)
autocmd FileType cs nmap <silent> <buffer> <Leader>os. <Plug>(omnisharp_code_action_repeat)
autocmd FileType cs xmap <silent> <buffer> <Leader>os. <Plug>(omnisharp_code_action_repeat)
autocmd FileType cs nmap <silent> <buffer> <Leader>os= <Plug>(omnisharp_code_format)
autocmd FileType cs nmap <silent> <buffer> <Leader>osnm <Plug>(omnisharp_rename)
autocmd FileType cs nmap <silent> <buffer> <Leader>osre <Plug>(omnisharp_restart_server)
autocmd FileType cs nmap <silent> <buffer> <Leader>osst <Plug>(omnisharp_start_server)
autocmd FileType cs nmap <silent> <buffer> <Leader>ossp <Plug>(omnisharp_stop_server)
augroup END
" ------ adv maps ------
" strip trailing whitespace, ss (strip space)
@ -281,7 +427,6 @@ set tags=.tags;
set incsearch " incrimental search
set hlsearch " highlighting when searching
filetype indent plugin on
set autoindent
set backspace=2
@ -314,13 +459,19 @@ set smartcase " ... unless they contain at least one capital let
set noscrollbind
set updatetime=1000
syntax enable
colo palenight " new fav highlighting
colo space_vim_theme " new fav highlighting
" compensate for lack of theme italics
for s in ["Comment", "Constant", "Include", "Define", "Macro", "Delimiter", "Debug", "Identifier", "Boolean", "markdownItalic"]
execute "hi " s " cterm=italic"
endfor
set conceallevel=0 " for jsons
set ttymouse=sgr " tmux mouse behaviour
set mouse=a " enable mouse in n,v,i,c,h modes
set laststatus=2 " show powerline status bar
set laststatus=2 " show powerline status bar
set t_Co=256
set notermguicolors
set gfn=Fira\ Code\ weight=450\ 12
set ballooneval " vim8+ popups
let g:netrw_beval = 1