dotfiles/.vim/vimrc

1794 lines
62 KiB
VimL
Raw Normal View History

" try not to put any lines in your vimrc that you don't understand :)
2022-10-06 15:58:58 +02:00
" not necessary, as vim will turn this on by default, when .vimrc is found
" set nocompatible
2023-07-10 00:38:37 +02:00
set encoding=utf-8 " important for powerline besides others
2022-10-06 15:59:22 +02:00
scriptencoding=utf8
filetype off "required
2023-07-10 00:38:37 +02:00
" hi clear
2019-04-12 19:04:50 +02:00
2022-10-06 16:00:30 +02:00
augroup install_vim_plug
autocmd!
if empty(glob('~/.vim/autoload/plug.vim'))
silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs
\ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
endif
augroup END
2022-09-11 20:09:07 +02:00
augroup plug_auto_install
autocmd!
" Run PlugInstall if there are missing plugins
autocmd VimEnter * if len(filter(values(g:plugs), '!isdirectory(v:val.dir)'))
\| PlugInstall --sync | source $MYVIMRC
\| endif
augroup END
2022-10-30 02:40:54 +01:00
let g:ale_disable_lsp = 0
" let g:ale_completion_delay = 145
" let g:ale_completion_delay = 220
let g:ale_completion_delay = 200
" needs to be set before ALE is loaded, this setting controls AUTOcomplete
let g:ale_completion_enabled = 0 " should be off when deoplete is on but appears to work just fine, too
" both "filetype indent on" and "syntax on" are called by Plug, keeping DRY
call plug#begin()
" colourschemes
Plug 'liuchengxu/space-vim-theme'
Plug 'nikolasvargas/spacemacs-theme'
2022-10-30 03:55:04 +01:00
" Plug 'romainl/Apprentice'
" Plug 'arcticicestudio/nord-vim'
Plug 'cocopon/iceberg.vim'
Plug 'sainnhe/edge'
Plug 'chriskempson/base16-vim'
Plug 'axvr/photon.vim'
Plug 'catppuccin/vim', { 'as': 'catppuccin' }
Plug 'Lokaltog/vim-monotone'
Plug 'https://git.sr.ht/~romainl/vim-bruin'
Plug 'fxn/vim-monochrome'
2023-07-10 00:38:37 +02:00
Plug 'folke/tokyonight.nvim'
2020-02-28 02:06:26 +01:00
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
Plug 'ryanoasis/vim-devicons'
Plug 'ctrlpvim/ctrlp.vim'
2022-09-12 23:14:25 +02:00
Plug 'mhinz/vim-startify'
" properly handle wayland clipboard behaviour, at least until
" https://github.com/vim/vim/issues/5157 is fixed.
Plug 'jasonccox/vim-wayland-clipboard'
" 🌷 Distraction-free writing in Vim
Plug 'junegunn/goyo.vim', { 'for': 'markdown' }
2021-05-29 21:21:59 +02:00
Plug 'preservim/nerdcommenter'
2021-05-20 20:17:10 +02:00
Plug 'airblade/vim-gitgutter'
2022-10-30 03:01:57 +01:00
Plug 'LunarWatcher/auto-pairs'
Plug 'SirVer/ultisnips', { 'on': [] }
Plug 'honza/vim-snippets', { 'on': [] }
2023-07-10 00:38:37 +02:00
" Plug 'farmergreg/vim-lastplace'
2020-02-28 02:06:26 +01:00
Plug 'tpope/vim-surround'
" fugitive.vim: A Git wrapper so awesome, it should be illegal
2020-02-28 02:06:26 +01:00
Plug 'tpope/vim-fugitive'
Plug 'tpope/vim-repeat'
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 'bazelbuild/vim-ft-bzl', { 'for': ['starlark', 'bzl'] }
Plug 'z0mbix/vim-shfmt', { 'for': ['sh', 'bash'] }
2023-07-10 00:38:37 +02:00
" post install (yarn install | npm install) then load plugin only for editing supported files
Plug 'prettier/vim-prettier', {
\ 'do': 'npm install --frozen-lockfile',
\ 'for': ['javascript', 'typescript', 'css', 'less', 'scss', 'json', 'graphql', 'vue', 'svelte', 'yaml', 'html', 'gohtmltmpl'] }
2024-03-26 21:23:33 +01:00
Plug 'gorodinskiy/vim-coloresque'| " coloured background for colour names/codes
2022-07-14 15:15:42 +02:00
" Plug 'lpinilla/vim-codepainter'| " text highlighting
Plug 'rhysd/git-messenger.vim'
2022-07-14 15:15:42 +02:00
" Plug 'Yggdroot/indentLine' " here
Plug 'adamheins/vim-highlight-match-under-cursor'
Plug 'vimwiki/vimwiki'
2024-06-26 14:37:42 +02:00
Plug 'mattn/calendar-vim'
Plug 'roxma/nvim-yarp'
Plug 'roxma/vim-hug-neovim-rpc'
Plug 'Shougo/deoplete.nvim'
2022-10-30 03:27:40 +01:00
Plug 'deoplete-plugins/deoplete-jedi', { 'for': ['python'] }
2022-10-30 04:22:15 +01:00
Plug 'Shougo/neoinclude.vim', { 'for': ['cpp'] }
Plug 'prabirshrestha/async.vim'
Plug 'prabirshrestha/vim-lsp'
Plug 'rhysd/vim-lsp-ale'
2022-10-30 03:29:12 +01:00
Plug 'rhysd/vim-clang-format', { 'for': ['cpp', 'c', 'cmake', 'java', 'proto'] }
2023-07-10 00:38:37 +02:00
Plug 'vim-test/vim-test'
Plug 'dense-analysis/ale'
" Plug 'cdelledonne/vim-cmake', { 'for': ['c', 'cpp', 'cmake'] }
" Plug 'ilyachur/cmake4vim', { 'for': ['c', 'cpp', 'cmake'] }
Plug 'OmniSharp/omnisharp-vim', { 'for': ['cs'] }
2023-07-10 00:38:37 +02:00
" Plug 'chrisbra/NrrwRgn'
2020-10-05 18:32:34 +02:00
Plug 'majutsushi/tagbar'
2022-10-30 04:21:03 +01:00
Plug 'NoahTheDuke/vim-just', { 'for': ['just'] }
2022-10-30 04:21:20 +01:00
Plug 'fladson/vim-kitty', { 'for': ['kitty'] }
2022-10-30 04:21:32 +01:00
Plug 'relastle/vim-nayvy', { 'for': ['python'] }
2023-07-10 00:38:37 +02:00
" Plug 'python-mode/python-mode', { 'for': ['python'] }
Plug 'lvht/tagbar-markdown', { 'for': 'markdown' }
2023-07-10 00:38:37 +02:00
" Plug 'preservim/vim-markdown', { 'for': 'markdown' }
2024-03-26 21:23:47 +01:00
Plug 'https://git.sr.ht/~soywod/himalaya-vim'
2023-07-10 00:38:37 +02:00
" switch to related files
" Plug 'arp242/switchy.vim', { 'for': ['go', 'c', 'cpp'] }
Plug 'lervag/vimtex', { 'for': 'tex' }
Plug 'cespare/vim-toml', { 'for': 'toml' }
Plug 'Glench/Vim-Jinja2-Syntax', { 'for': ['ansible', 'jinja2'] }
Plug 'pearofducks/ansible-vim', { 'for': ['ansible', 'jinja2'] }
2021-11-10 01:08:28 +01:00
Plug 'hashivim/vim-terraform', { 'for': 'terraform' }
Plug 'aouelete/sway-vim-syntax', { 'for': 'sway' }
2024-07-09 15:50:38 +02:00
Plug 'LnL7/vim-nix', { 'for': 'nix' }
" Plug 'MarcWeber/vim-addon-nix', { 'for': 'nix' }
2021-03-15 14:13:32 +01:00
Plug 'rust-lang/rust.vim', { 'for': 'rust' }
Plug 'fatih/vim-go', { 'for': ['go', 'gomod', 'gohtmltmpl', 'gotexttmpl'], 'do': ':GoInstallBinaries' }
2022-10-30 04:17:26 +01:00
Plug 'sebdah/vim-delve', { 'for': ['go', 'gohtmltmpl', 'gotexttmpl'] }
2022-10-30 04:17:42 +01:00
Plug 'https://git.sr.ht/~sircmpwn/hare.vim', { 'for': 'hare' }
2022-10-30 04:17:53 +01:00
Plug 'ziglang/zig.vim', { 'for': 'zig' }
2022-10-30 04:18:03 +01:00
Plug 'ollykel/v-vim', { 'for': 'v' }
2022-10-30 04:18:16 +01:00
Plug 'bfrg/vim-cpp-modern', { 'for': ['cpp', 'cmake'] }
2023-07-10 00:38:37 +02:00
Plug 'vmchale/dhall-vim', { 'for': 'dhall' }
2022-10-30 04:18:25 +01:00
Plug 'isobit/vim-caddyfile', { 'for': 'caddyfile' }
Plug 'chikamichi/mediawiki.vim', { 'for': 'wiki' }
2021-11-10 01:08:28 +01:00
Plug 's3rvac/vim-syntax-redminewiki', { 'for': 'redminewiki' }
Plug 'mfukar/robotframework-vim', { 'for': 'robotframework' }
call plug#end()
2022-07-14 15:18:41 +02:00
" turn on vimscript 9 support
let g:airline_experimental = 1
let g:airline_powerline_fonts = 1
let g:airline_highlighting_cache = 1
" violet, wombat, deus
2023-07-10 00:38:37 +02:00
" let g:airline_theme = 'violet'
" let g:airline_theme = 'base16_spacemacs'
" let g:airline_theme = 'minimalist'
let g:airline_theme = 'catppuccin_mocha'
2023-07-10 00:38:37 +02:00
" let g:airline_theme = 'iceberg'
2020-03-18 04:40:11 +01:00
let g:airline#extensions#tabline#enabled = 1
let g:airline#extensions#tabline#formatter = 'unique_tail_improved'
" show tab number instead of number of splits
let g:airline#extensions#tabline#tab_nr_type = 1
2023-07-10 00:38:37 +02:00
" Show just the filename
" let g:airline#extensions#tabline#fnamemod = ':t'
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',
\ }
2023-07-10 00:38:37 +02:00
" let g:airline_section_b = airline#section#create(['ffenc','hunks', '%f'])
" let g:airline_section_b = airline#section#create_left(['ffenc','hunks', '%f'])
" skip displaying fileformat output if the output matches a configured string.
let g:airline#parts#ffenc#skip_expected_string='utf-8[unix]'
" certain number of spaces are allowed after tabs, but not in between.
" this algorithm works well for /** */ style comments in a tab-indented file.
let g:airline#extensions#whitespace#mixed_indent_algo = 1
" turn off the warning section entirely.
let g:airline_section_warning = ''
2022-07-22 19:06:58 +02:00
let g:airline_skip_empty_sections = 1
" separator symbols
let g:airline_left_sep = ''
let g:airline_right_sep = ''
let g:airline_left_alt_sep = ''
let g:airline_right_alt_sep = ''
if !exists('g:airline_symbols')
let g:airline_symbols = {}
endif
let g:airline_symbols.branch = ''
let g:airline_symbols.colnr = '℅:'
let g:airline_symbols.readonly = ''
let g:airline_symbols.nx='∄'
" ale integration
let g:airline#extensions#ale#enabled = 1
" nrrwrgn integration
let g:airline#extensions#nrrwrgn#enabled = 1
" vcs integration
2023-07-10 00:38:37 +02:00
let g:airline#extensions#branch#enabled = 0
" show summary of changed hunks (gitgutter and/or vim-signify)
let g:airline#extensions#hunks#enabled = 1
" tabline integration
let g:airline#extensions#tabline#enabled = 1
let g:airline#extensions#ctrlp#enabled = 1
let g:airline#extensions#taboo#enabled = 0
let g:airline#extensions#battery#enabled = 0
let g:airline#extensions#bookmark#enabled = 0
let g:airline#extensions#flog#enabled = 0
let g:airline#extensions#bufferline#enabled = 0
let g:airline#extensions#capslock#enabled = 0
let g:airline#extensions#coc#enabled = 0
" syntastic integration
let g:airline#extensions#syntastic#enabled = 0
" vim-csv
let g:airline#extensions#csv#enabled = 0
let g:airline#extensions#ctrlspace#enabled = 0
" Built-in extension to displays cursor in different colors depending on the
" current mode (only works in terminals iTerm, AppleTerm and xterm)
" * this fixes the issue of airline changing terminal cursor colour in kitty+fedora35/fedora36
let g:airline#extensions#cursormode#enabled = 0
" lsp
2024-07-07 11:39:53 +02:00
let g:lsp_document_code_action_signs_enabled = 1
let g:lsp_document_code_action_signs_delay = 200
let g:lsp_document_highlight_enabled = 1
let g:lsp_document_highlight_delay = 200
let g:lsp_use_native_client = 1
let g:lsp_format_sync_timeout = 1000 " in milliseconds
let g:lsp_max_buffer_size = 10000000
" disable diagnostics support - leave that to ALE
let g:lsp_diagnostics_enabled = 0
let g:lsp_diagnostics_virtual_text_enabled = 0
" ref:
" https://github.com/rhysd/vim-lsp-ale/blob/master/doc/vim-lsp-ale.txt#L98
" let g:lsp_ale_auto_config_vim_lsp = 0
" let g:lsp_ale_auto_config_ale = 0
let g:ale_c_parse_compile_commands = 1
let g:ale_cpp_parse_compile_commands = 1
let g:ale_loclist_msg_format = '%code: %%s'
2022-10-30 04:16:28 +01:00
let g:ale_set_highlights = 0
2021-11-10 00:40:00 +01:00
let g:ale_close_preview_on_insert = 1
let g:ale_detail_to_floating_preview = 1
let g:ale_warn_about_trailing_whitespace = 1
2021-11-10 00:40:00 +01:00
let g:ale_virtualtext_cursor = 1
let g:ale_hover_to_floating_preview = 1
" let g:ale_completion_enabled = 1
" for use with <c-x><c-o>
set omnifunc=ale#completion#OmniFunc
let g:ale_completion_autoimport = 1
2021-11-10 00:40:00 +01:00
let g:ale_hover_to_preview = 1
2023-07-10 00:38:37 +02:00
" let g:ale_lsp_suggestions = 0
2021-11-10 00:40:00 +01:00
let g:ale_lsp_suggestions = 1
2022-10-30 03:30:25 +01:00
let g:ale_terraform_langserver_executable = 'terraform-ls'
let g:ale_set_balloons = 1
let g:ale_floating_window_border = ['│', '─', '╭', '╮', '╯', '╰']
" Do not keep the sign gutter open at all time.
let g:ale_sign_column_always = 0
let g:ale_sign_highlight_linenrs = 0
let g:ale_sign_offset = 1000000
let g:ale_max_signs = -1
let g:ale_change_sign_column_color = 0
let g:ale_linters_explicit = 1
let g:ale_history_enabled = 0
let g:ale_history_log_output = 0
let g:ale_warn_about_trailing_blank_lines = 1
let g:ale_warn_about_trailing_whitespace = 1
let g:ale_go_golangci_lint_package = 1
let g:ale_go_golangci_lint_options = 'run'
let g:ale_c_clang_options = '-Wall -I. -Iinclude -Iinc'
let g:ale_c_gcc_options = '-Wall -I. -Iinclude -Iinc'
let g:ale_cpp_cc_executable = 'g++'
let g:ale_cpp_cc_options = '-std=c++20 -Wall -Wextra -I. -Iinclude -Iinc'
let g:ale_cpp_clang_options = '-std=c++20 -Wall -Wextra -I. -Iinclude -Iinc'
let g:ale_cpp_gcc_options = '-std=c++20 -Wall -Wextra -I. -Iinclude -Iinc'
" let g:ale_cpp_clangtidy_checks = ['-*,clang-diagnostic-*,clang-analyzer-*,google-*,bugprone-*']
let g:ale_cpp_clangtidy_checks = ['-*,clang-diagnostic-*,clang-analyzer-*,bugprone-assert-side-effect,bugprone-inaccurate-erase,performance-move-const-arg']
let g:ale_cpp_clangtidy_extra_options = '-extra-arg=-std=c++20'
" let g:ale_cpp_clangtidy_options = ['--header-filer="" --use-color=true']
" let g:ale_cpp_cppcheck_options = '--enable=style'
let g:ale_cpp_cppcheck_options = '--language=c++ --std=c++20 --enable=all --verbose --suppress=unmatchedSuppression --suppress=missingIncludeSystem'
let g:ale_echo_cursor = 1
let g:ale_echo_msg_error_str = 'E'
let g:ale_echo_msg_warning_str = 'W'
let g:ale_echo_msg_info_str = 'I'
2023-07-10 00:38:37 +02:00
let g:ale_sign_error = '✗'
let g:ale_sign_warning = ''
2022-10-30 03:30:25 +01:00
let g:ale_sign_info = ''
" let g:ale_echo_msg_format = '%s'
let g:ale_echo_msg_format = '(%severity%): [%linter%] %s'
2021-11-10 00:40:00 +01:00
let g:ale_open_list = 0
let g:ale_list_vertical = 0
let g:ale_keep_list_window_open = 0 " no
" Show 5 lines of errors (default: 10)
let g:ale_list_window_size = 7
" Run ale upon opening a file.
let g:ale_lint_on_enter = 1
" Do not run ale upon changes to the file.
" let g:ale_lint_on_text_changed = 'never'
2023-07-10 00:38:37 +02:00
" lint in normal and insert mode.
let g:ale_lint_on_text_changed = 'always'
2023-07-10 00:38:37 +02:00
" only lint in normal mode.
" let g:ale_lint_on_text_changed = 'normal'
" Run ale after leaving insert mode.
let g:ale_lint_on_insert_leave = 1
2023-07-10 00:38:37 +02:00
let g:ale_lint_on_filetype_changed = 1
let g:ale_lint_on_save = 1
" let g:ale_lint_delay = 700
" let g:ale_lint_delay = 500
let g:ale_lint_delay = 300| " the default being 200
let g:ale_linters = {
\ 'go': ['gofumpt', 'govet', 'gofmt', 'golangci-lint', 'gopls'],
2023-07-10 00:38:37 +02:00
\ 'gohtmltmpl': ['gofumpt', 'govet', 'gofmt', 'golangci-lint', 'gopls'],
\ 'dockerfile': ['hadolint'],
\ 'c': ['clang-format', 'clangd', 'clangtidy', 'cppcheck', 'cquery', 'flawfinder'],
\ 'cpp': ['clang-format', 'g++', 'clang', 'clangd', 'clangtidy', 'cppcheck', 'flawfinder'],
\ 'cs': ['OmniSharp'],
2023-07-10 00:38:37 +02:00
\ 'css': ['vim-lsp'],
\ 'hare': ['hare', 'vim-lsp'],
\ 'lua': ['vim-lsp'],
2024-06-21 12:34:31 +02:00
\ 'nix': ['nil', 'rnix_lsp', 'alejandra', 'deadnix', 'statix', 'nixpkgs-fmt', 'vim-lsp'],
\ 'python': ['ruff', 'vim-lsp', 'pylint', 'pylsp', 'yapf', 'isort'],
2023-07-10 00:38:37 +02:00
\ 'rust': ['analyzer', 'cargo', 'rls', 'vim-lsp'],
\ 'sh': ['shellcheck', 'shfmt', 'shell', 'vim-lsp'],
\ 'bash': ['shellcheck', 'shfmt', 'shell', 'vim-lsp'],
\ 'systemd': ['systemd_analyze', 'systemdlint', 'vim-lsp'],
\ 'vim': ['vint', 'vim-lsp'],
\ 'tex': ['chktex'],
\ 'tf': ['vimls', 'vim-lsp', 'tflint', 'terraform', 'tfsec', 'checkov'],
2023-07-10 00:38:37 +02:00
\ 'terraform': ['vim-lsp', 'tflint', 'terraform', 'terraform_ls', 'terraform_lsp', 'tfsec', 'checkov'],
\ 'yaml': ['yaml-language-server', 'spectral', 'swaglint','yamllint'],
\ 'zsh': ['shellcheck', 'shell', 'vimls'],
\ }
let g:ale_fixers = { 'c': ['clang-format', 'clangd', 'clangtidy', 'cquery', 'flawfinder'],
\ 'cpp': ['clang-format', 'clangtidy'],
2024-06-26 16:40:39 +02:00
\ 'python': ['ruff_format', 'nayvy#ale_fixer', 'isort', 'yapf'],
\ 'go': ['gofumpt'],
2024-06-21 12:34:31 +02:00
\ 'nix': ['alejandra', 'nixpkgs-fmt'],
\ 'rust': ['rustfmt', 'trim_whitespace', 'remove_trailing_lines'],
\ 'vim': ['vint', 'vimls', 'generic'],
\ 'sh': ['shfmt'],
\ 'bash': ['shfmt'],
\ 'yaml': ['yamlfix'],
\ }
if has('patch-8.1.1880')
" set completeopt=longest,menuone,popuphidden
set completeopt=longest,menuone,popup
" 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
2023-07-10 00:38:37 +02:00
" Hardcore mode, disable arrow keys.
"noremap <Up> <NOP>
"noremap <Down> <NOP>
"noremap <Left> <NOP>
"noremap <Right> <NOP>
" gitgutter
let g:gitgutter_terminal_reports_focus=0
let g:gitgutter_async = 1
let g:gitgutter_sign_column_always = 1
let g:gitgutter_sign_allow_clobber=0
let g:gitgutter_set_sign_backgrounds = 0
2021-11-10 00:42:30 +01:00
let g:gitgutter_preview_win_floating = 1
set foldtext=gitgutter#fold#foldtext()
" let g:gitgutter_map_keys = 0
nmap ghs <Plug>(GitGutterStageHunk)
nmap ghu <Plug>(GitGutterUndoHunk)
nnoremap <leader>d :GitGutterLineHighlightsToggle<cr>
let g:deoplete#enable_at_startup = 0
" load deoplete config.
exec 'source ' . escape(expand('~/.vim'),' ') . '/' . 'deoplete.vimrc.vim'
2022-10-30 02:56:59 +01:00
" clang-format
let g:clang_format#auto_format=0
let g:clang_format#detect_style_file=1
augroup clang_format
autocmd!
2023-07-10 00:38:37 +02:00
autocmd FileType c,cpp,proto nnoremap <buffer><leader>cf :<C-u>ClangFormat<cr>
autocmd FileType c,cpp,proto vnoremap <buffer><leader>cf :ClangFormat<cr>
2022-10-30 02:56:59 +01:00
function! Formatonsave()
" alternative function to clang-format#auto_format param
if exists(':ClangFormat')
let l:formatdiff = 1
" pyf /usr/share/clang/clang-format.py
ClangFormat
endif
endfunction
" autocmd BufWritePre *.h,*.cc,*.cpp call Formatonsave()
augroup END
" latex
let g:tex_flavor = 'latex'
let g:tex_conceal='abdmg'
let g:Tex_MultipleCompileFormats='pdf,bib,pdf'
" let g:Tex_CompileRule_pdf = 'mkdir -p build && lualatex -output-directory=build -interaction=nonstopmode $* && cp *.bib build && cd build && bibtex %:r && cd .. && lualatex -output-directory=build -interaction=nonstopmode $* && mv build/$*.pdf .'
let g:vimtex_view_method = 'zathura'
" let g:vimtex_compiler_progname = 'pdflatex -shell-escape --interaction=nonstopmode'
" let g:vimtex_compiler_progname = 'lualatex --shell-escape --interaction=nonstopmode --synctex=1 %O %S'
" let g:vimtex_compiler_progname = 'lualatex -shell-escape --interaction=nonstopmode --synctex=1'
let g:vimtex_compiler_engine = 'lualatex'
" let g:vimtex_compiler_engine = 'pdflatex'
let g:vimtex_compiler_latexmk = {
\ 'options' : ['-pdf', '-verbose', '-bibtex', '-file-line-error','-synctex=1', '--interaction=nonstopmode'],
\}
let g:matchup_matchparen_deferred = 1
let g:vimtex_quickfix_open_on_warning = 0
let g:vimtex_quickfix_enabled = 0
2020-02-28 02:06:26 +01:00
" nerdcommenter
" _ stands for forward slash (/)
2023-07-10 00:38:37 +02:00
noremap <silent><c-_> :call nerdcommenter#Comment(0,"toggle")<cr>
2020-02-28 02:06:26 +01:00
" Add spaces after comment delimiters by default
let g:NERDSpaceDelims = 1
" Allow commenting and inverting empty lines (useful when commenting a region)
let g:NERDCommentEmptyLines = 1
" Enable trimming of trailing whitespace when uncommenting
let g:NERDTrimTrailingWhitespace = 1
"""" Enable NERDCommenterToggle to check all selected lines is commented or not
"""let g:NERDToggleCheckAllLines = 1
" Add your own custom formats or override the defaults
let g:NERDCustomDelimiters = {
\ 'vim': { 'left': '"','right': '' },
2023-07-10 00:38:37 +02:00
\ 'bib': { 'left': '\%','right': '' },
\ 'c': {'left': '/**','right': '*/' },
2023-07-10 00:38:37 +02:00
\ 'dhall': {'left': '-- | ', 'right': '' },
\ 'zsh': { 'left': '#','right': ''},
\ 'sysctl': {'left': '#', 'right': ''},
\ 'systemd': {'left': ';', 'right': ''},
\}
" let g:NERDTreeGitStatusWithFlags = 1
2020-02-28 02:06:26 +01:00
2022-07-22 18:35:29 +02:00
" netrw
let g:netrw_banner = 0
let g:netrw_keepdir = 0
" prefer tree-style listing
let g:netrw_liststyle = 3
" let g:netrw_liststyle = 1
let g:netrw_sort_options = 'i'
" open files in a new horizontal split
let g:netrw_browse_split = 1
2022-07-22 18:08:29 +02:00
" indentline
" let g:indentLine_setColors = 1
" let g:indentLine_char_list = ['|', '¦', '┆', '┊', ':']
" let g:indentLine_concealcursor = 'inc'
" let g:indentLine_conceallevel = 0
" let g:indentLine_conceallevel = 2
2020-02-28 02:06:26 +01:00
" set conceallevel for json and markdown
let g:vim_json_conceal = 0
let g:markdown_syntax_conceal = 0
" vimwiki
let g:vimwiki_list = [{'path': '~/wiki/', 'syntax': 'markdown', 'ext': 'md', 'diary_rel_path': 'Notes'}]
" let g:vimwiki_listsyms = '✗○◐●✓'
let g:vimwiki_auto_header = 1
2023-07-11 17:56:04 +02:00
""""" ultisnips
""" If you want :UltiSnipsEdit to split your window.
""" let g:UltiSnipsEditSplit="vertical"
""let g:UltiSnipsExpandTrigger='<c-t>'
""" let g:UltiSnipsJumpForwardTrigger="<c-b>"
""" let g:UltiSnipsJumpBackwardTrigger="<c-z>"
""" gitmessenger
let g:git_messenger_close_on_cursor_moved = v:false
let g:git_messenger_always_into_popup = v:true
2020-10-05 18:32:34 +02:00
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'},
\}
" --------------------------
" syntastic
"""let g:syntastic_always_populate_loc_list = 1
"""let g:syntastic_auto_loc_list = 2
"""let g:syntastic_loc_list_height = 8
"""let g:syntastic_check_on_open = 1
"""let g:syntastic_check_on_wq = 0
"""let g:syntastic_aggregate_errors = 1
"""let g:syntastic_quiet_messages = { "type": "style" }
"""let g:syntastic_enable_highlighting=1
"""let g:syntastic_echo_current_error=1
"""" let g:syntastic_auto_jump=1
"""let g:syntastic_auto_jump = 0
"""let g:syntastic_id_checkers = 1
"""let g:syntastic_error_symbol = "✗"
"""let g:syntastic_warning_symbol = "⚠"
"""function! SyntasticCheckHook(errors)
""" if !empty(a:errors)
""" let g:syntastic_loc_list_height = min([len(a:errors), 10])
""" endif
"""endfunction
"""
"""set statusline+=%#warningmsg#
"""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_c_compiler = 'clang'
"""let g:syntastic_c_check_header = 1
"""let g:syntastic_c_auto_refresh_includes = 1
"""let g:syntastic_cpp_checkers = ['cppcheck', 'g++']
"""let g:syntastic_cpp_cppcheck_args = "--language=c++ --std=c++20 --enable=all --verbose --suppress=unmatchedSuppression --suppress=missingIncludeSystem ./*.{cpp,h}"
"""let g:syntastic_cpp_compiler = 'g++'
"""let g:syntastic_cpp_compiler_options = ' -std=c++20 -Wall -Wextra'
"""let g:syntastic_cpp_check_header = 1
"""let g:syntastic_cpp_no_include_search = 0
"""let g:syntastic_cpp_remove_include_errors = 1
"""let g:syntastic_cpp_auto_refresh_includes = 1
"""let g:syntastic_c_cpplint_exec = ['cppcheck', 'clang-check', 'clang-tidy']
"""let g:syntastic_go_checkers = ['go', 'gopls', 'golint', 'govet']
"""" let g:syntastic_tex_checkers = ['lacheck', 'text/language_check']
"""let g:syntastic_tex_checkers = ['text/language_check', 'lacheck']
"""let g:syntastic_gitcommit_checkers = ['language_check']
"""let g:syntastic_yaml_checkers = ['yamllint']
"""let g:syntastic_make_checkers = ['gnumake']
"""let g:syntastic_aggregate_errors = 1
2022-07-22 18:37:25 +02:00
" ansible-vim settings
let g:ansible_unindent_after_newline=1
let g:ansible_attribute_highlight='ob'
let g:terraform_align=1
let g:terraform_fold_sections=1
let g:terraform_fmt_on_save=1
2020-02-28 02:06:26 +01:00
2022-07-14 15:37:41 +02:00
2022-10-30 03:01:57 +01:00
" autopairs
2023-07-10 00:38:37 +02:00
let g:AutoPairsMapBS = 1
let g:AutoPairsMapBSIn = 1
let g:AutoPairsMapBSAfter = 1
" ignore next char - default binding is <c-p><c-e>
2022-10-30 03:01:57 +01:00
" sometimes issues with expanding {}
let g:AutoPairsMultilineClose = 0
2023-07-10 00:38:37 +02:00
let g:AutoPairsFlyMode = 0 "jump back with <c-p><c-b>
" disable jumpy cursor - centers screen when in lower 1/3.
2022-10-30 03:01:57 +01:00
let g:AutoPairsMapCR = 0
2023-07-10 00:38:37 +02:00
" inoremap <cr> <esc>:call autopairs#AutoPairsReturn()<cr>i
2022-10-30 03:01:57 +01:00
" let g:AutoPairsFlyModeBlacklist =
" let g:AutoPairsShortcutToggle = '<c-h>'
let b:AutoPairsShortcutToggle = ''
let b:AutoPairsShortcutToggleMultilineClose = ''
let g:AutoPairsShortcutToggle = ''
let g:AutoPairsShortcutToggleMultilineClose = ''
" nmap <c-m><c-h> :call autopairs#AutoPairsToggleMultilineClose()
" Enable highlighting of C++11 attributes
let g:cpp_attributes_highlight = 1
" Highlight struct/class member variables (affects both C and C++ files)
let g:cpp_member_highlight = 1
2022-07-14 15:37:41 +02:00
" ctrlp
" Setup some default ignores
let g:ctrlp_custom_ignore = {
2023-07-10 00:38:37 +02:00
\ 'dir':'\v[\/](\.(git\/(branches|hooks|info|logs|modules|objects|rebase-merge|refs)|hg|svn)|\_site|node_modules)$',
2022-07-14 15:37:41 +02:00
\ 'file':'\v\.(exe|so|dll|class|png|jpg|jpeg)|(\.(git\/(description|index|packed-refs|COMMIT_EDITMSG|HEAD|FETCH_HEAD|ORIG_HEAD|REBASE_HEAD)))$',
\}
" Use the nearest .git directory as the cwd
" This makes a lot of sense if you are working on a project that is in version
" control. It also supports works with .svn, .hg, .bzr.
" let g:ctrlp_working_path_mode = 'r'
let g:ctrlp_working_path_mode = 'raw'
2023-07-10 00:38:37 +02:00
let g:ctrlp_cache_dir = $HOME . '/.cache/ctrlp'
" The Silver Searcher
if executable('ag')
" use ag instead of grep.
set grepprg=ag\ --nogroup\ --nocolor
" use ag in CtrlP
let g:ctrlp_user_command = 'ag %s -l --nocolor --hidden -g ""'
" ag is fast enough that CtrlP doesn't need to cache
let g:ctrlp_use_caching = 0
endif
2022-07-14 15:37:41 +02:00
2023-07-10 00:38:37 +02:00
nnoremap '<c-p>' :CtrlP<cr><cr>
nnoremap <leader>s <Plug>(ctrlp)
2022-07-14 15:37:41 +02:00
2023-07-10 00:38:37 +02:00
" let g:ctrlp_map = '<leader>s'
2022-07-14 15:37:41 +02:00
let g:ctrlp_show_hidden = 1
" Use a leader instead of the actual named binding
2023-07-10 00:38:37 +02:00
nmap <leader>p <Plug>(ctrlp)
noremap <M-p> :CtrlP :pwd<cr>
2022-07-14 15:37:41 +02:00
" ctrlp buffers
" Easy bindings for its various modes
nmap <leader>bb :CtrlPBuffer<cr>
nmap <leader>bm :CtrlPMixed<cr>
nmap <leader>bs :CtrlPMRU<cr>
" buffers
nmap <leader>T :enew<cr>
nmap <leader>bq :bp <BAR> bd #<cr>
nmap <leader>gd :bd<cr>
map gn :bn<cr>
map gp :bp<cr>
2022-07-14 15:37:41 +02:00
2022-10-30 03:11:26 +01:00
""" tmux cursor
""" change cursor shape for different editing modes, neovim does this by default
"if !has('nvim')
" if exists('$TMUX')
" let &t_SI = "\<Esc>Ptmux;\<Esc>\e[12 q\<Esc>\\"
" let &t_SR = "\<Esc>Ptmux;\<Esc>\e[4 q\<Esc>\\"
" let &t_EI = "\<Esc>Ptmux;\<Esc>\e[2 q\<Esc>\\"
" else
" let &t_SI = "\e[12 q"
" let &t_SI = "\<Esc>]12;purple\x7"
" let &t_SR = "\e[4 q"
" let &t_EI = "\e[2 q"
" endif
"endif
""" reset cursor when vim exits -> messes up cursor, don't do this
"""autocmd VimLeave * silent !echo -ne "\033]112\007"
command! W execute 'w' | edit!
command! WW execute 'silent w !sudo tee % >/dev/null' | edit!
2020-02-28 02:06:26 +01:00
command! -nargs=* Make write | make! <args> | cwindow
command Note execute 'e ~/Sync/notes/' . strftime('%y-%m-%d-%H:%M:%S') . '.md'
2022-10-30 03:15:53 +01:00
command NoteLocal execute 'e ./' . strftime('%y-%m-%d-%H:%M:%S') . '.md'
2023-07-10 00:38:37 +02:00
" easy session saving.
command! Xs :mks! | :xa "save the session, save modified files, and exit
2022-07-22 19:09:49 +02:00
" always show full path on <c-g>
nnoremap <c-g> 1<c-g>
" open a terminal in $PWD
2023-07-10 00:38:37 +02:00
nnoremap <silent> <leader>tt :terminal<cr>
" terminal normal mode
tnoremap <F1> <C-W>N
" toggle showing whitespace
2023-07-10 00:38:37 +02:00
noremap <F5> :set list!<cr>
2020-02-28 02:06:26 +01:00
" make shortcut
nnoremap <F4> :term ++hidden ++open make<cr>
nnoremap <leader><F4> :term ++open make<cr>
2023-07-10 00:38:37 +02:00
nnoremap <F8> :TagbarToggle<cr>
2023-07-10 00:38:37 +02:00
vmap gb :<C-U>!git blame % -L<C-R>=line("'<") <cr>,<C-R>=line("'>") <cr><cr>
nnoremap gb :!git blame %<cr>
" ll provided by vimtex
2023-07-10 00:38:37 +02:00
" nnoremap <silent> <leader>kk :w! !pdflatex -shell-escape -interaction=nonstopmode ./*.tex<cr><cr>
2022-10-30 03:17:47 +01:00
function! Pdfpls()
echom 'compiling ur tex goodness!'
" w!
:!pdflatex -shell-escape -interaction=nonstopmode ./*.tex
:!bibtex $PWD/*.aux
2022-10-30 03:17:47 +01:00
:!pdflatex -shell-escape -interaction=nonstopmode ./*.tex
endfunction
function! PdfLuapls()
echom 'compiling ur tex goodness!'
" w!
:!lualatex -shell-escape -interaction=nonstopmode ./*.tex
:!bibtex $PWD/*.aux
" :!lualatex -shell-escape -interaction=nonstopmode ./*.tex
endfunction
function! PdfBibLuapls()
" https://tex.stackexchange.com/a/308565
" echom "compiling ur tex goodness!"
" :!mkdir -p build
" :!lualatex -output-directory=build -shell-escape -interaction=nonstopmode ./*.tex
" :!cp *.bib build
" :!cd build
" :!bibtex %:r
" :!cd ..
" :!lualatex -output-directory=build -shell-escape -interaction=nonstopmode ./*.tex
" :!mv build/*.pdf .
:!lualatex -shell-escape -interaction=nonstopmode ./*.tex
:!bibtex ./*.aux
:!lualatex -shell-escape -interaction=nonstopmode ./*.tex
endfunction
" nnoremap <silent><leader>lb :call Pdfpls()<cr><esc>
" nnoremap <silent><leader>lb :call PdfLuapls()<cr><esc>
" nnoremap <silent><leader>lb :call PdfLuapls()<cr>
nnoremap <silent><leader>lb :call PdfBibLuapls()<cr><esc>
2023-07-10 00:38:37 +02:00
nnoremap <leader>l :exec &conceallevel ? "set conceallevel=0" : "set conceallevel=1"<cr><cr>
" ALE bindings
2023-07-10 00:38:37 +02:00
nmap <silent> <C-k> <Plug>(ale_previous_wrap)
nmap <silent> <C-j> <Plug>(ale_next_wrap)
nnoremap <leader>a :ALEDetail<cr>
2022-08-11 12:36:04 +02:00
nnoremap <c-LeftMouse> :ALEGoToDefinition<cr>
2022-08-09 17:56:10 +02:00
" [bro]wse [ol]d files
nnoremap <leader>r :bro ol<cr>
2022-08-11 12:37:19 +02:00
" easy-way ifndef tmpl
nnoremap <silent><f12> "%phr_I#ifndef __<Esc>gUwyypldwidefine <Esc>yypldwiendif //<Esc>O<Esc>
2022-08-11 12:37:41 +02:00
" tab switching
nnoremap <silent><f6> gT
nnoremap <silent><f7> gt
" resize windows
2023-07-10 00:38:37 +02:00
" imap <C-w> <C-o><C-w>
map - <C-W>-
map + <C-W>+
2022-10-30 03:18:21 +01:00
" vmap to stay in Visual Mode after shifting > and <
vmap < <gv
vmap > >gv
" moving visual blocks
2023-07-10 00:38:37 +02:00
" vnoremap J :m '>+1<cr>gv=gv
" vnoremap K :m '<-2<cr>gv=gv
2022-10-30 03:18:21 +01:00
2022-08-09 17:56:10 +02:00
2022-08-09 18:00:07 +02:00
"------------------------------------
" vim-go.vim
"------------------------------------
" use gopls
let g:go_def_mode='gopls'
let g:go_info_mode='gopls'
" Status line types/signatures.
let g:go_auto_type_info = 1
2022-10-30 03:18:57 +01:00
let g:go_highlight_types = 1
2022-08-09 18:00:07 +02:00
let g:go_highlight_functions = 1
let g:go_highlight_methods = 1
let g:go_highlight_structs = 1
let g:go_highlight_interfaces = 1
let g:go_highlight_operators = 1
let g:go_highlight_build_constraints = 1
let g:go_highlight_extra_types = 1
" if sluggish
" let g:go_highlight_structs = 0
" let g:go_highlight_interfaces = 0
" let g:go_highlight_operators = 0
let g:go_list_type = 'quickfix'
" let g:go_version_warning = 0
let g:go_fmt_fail_silently = 0
" auto formatting and importing
let g:go_fmt_command = 'gopls'
2022-08-09 18:00:07 +02:00
let g:go_fmt_autosave = 1
" go install mvdan.cc/gofumpt@latest
let g:go_gopls_gofumpt = 1
" let g:go_gopls_options = ['-remote=auto']
let g:go_gopls_options = ['-remote=unix;/tmp/.gopls-daemon.sock']
2022-08-16 14:03:51 +02:00
" let lsp handle connecting to gopls
let g:go_gopls_enabled = 1
" let g:go_doc_popup_window = 0
2023-07-10 00:38:37 +02:00
let g:go_doc_popup_window = 1
let g:go_fillstruct_mode = 'gopls'
let g:go_term_reuse = 1
let g:go_term_enabled = 1
2023-07-10 00:38:37 +02:00
let g:go_doc_balloon = 1
2022-08-09 18:00:07 +02:00
augroup vimgo
au!
au FileType go nmap <leader>gb <Plug>(go-build)
au FileType go nmap <leader>b <Plug>(go-build)
au FileType go nmap <leader>gr <Plug>(go-run)
au FileType go nmap <leader>gt <Plug>(go-test)
2023-07-10 00:38:37 +02:00
au FileType go nmap <leader>gs <Plug>(go-implements)
au FileType go nmap <leader>gi <Plug>(go-info)
au FileType go nmap <leader>ge <Plug>(go-rename)
au FileType go nmap <leader>gd <Plug>(go-doc)
" Navigation commands
2023-07-10 00:38:37 +02:00
au FileType go nmap <leader>ds <Plug>(go-def-split)
au FileType go nmap <leader>dv <Plug>(go-def-vertical)
" Alternate commands
2023-07-10 00:38:37 +02:00
au FileType go nmap <leader>hae <Plug>(go-alternate-edit)
au FileType go nmap <leader>vae <Plug>(go-alternate-vertical)
" Use new vim 8.2 popup windows for Go Doc
2022-08-09 18:00:07 +02:00
augroup END
2024-03-26 21:24:00 +01:00
" delve/dlv
let g:go_debug_windows = {
\ 'vars': 'rightbelow 60vnew',
\ 'stack': 'rightbelow 10new',
\ }
2022-04-29 00:26:07 +02:00
" go_tags
"------------------------------------
exec 'source ' . escape(expand('~/.vim'),' ') . '/' . 'gotags.vimrc.vim'
2022-04-29 00:26:07 +02:00
2023-07-10 00:38:37 +02:00
""" dhall
let g:dhall_format=1
2022-10-30 03:27:40 +01:00
2023-07-10 00:38:37 +02:00
""" python
exec 'source ' . escape(expand('~/.vim'),' ') . '/' . 'python.vimrc.vim'
2022-10-30 03:27:40 +01:00
2023-07-10 00:38:37 +02:00
""" vim-test
" see kitty -o allow_remote_control=yes --listen-on unix:/tmp/mykitty
" let test#strategy = 'kitty'
let test#strategy = 'vimterminal'
nmap <silent> <leader>t :TestNearest<CR>
nmap <silent> <leader>tf :TestFile<CR>
" nmap <silent> <leader>a :TestSuite<CR>
nmap <silent> <leader>tl :TestLast<CR>
nmap <silent> <leader>g :TestVisit<CR>
2022-10-30 03:27:40 +01:00
2023-07-10 00:38:37 +02:00
" partially superseded by jasonccox/vim-wayland-clipboard (for "+)
" still keeping the "* mappings
2023-09-28 23:45:11 +02:00
" it however breaks <c-r>
if v:vim_did_enter
nunmap <C-R>+
nunmap <C-R><c-O>+
nunmap <C-R><C-P>+
nunmap <C-R><C-R>+
"else
" augroup wlclfixes
" autocmd!
" autocmd VimEnter * nunmap <C-R>+
" autocmd VimEnter * nunmap <C-R><c-O>+
" autocmd VimEnter * nunmap <C-R><C-P>+
" autocmd VimEnter * nunmap <C-R><C-R>+
" augroup END
endif
2023-09-28 23:45:11 +02:00
2022-08-09 18:03:26 +02:00
" ------ wayland copy and pasting
let s:env = toupper(substitute(system('uname'), '\n', '', ''))
if s:env =~# 'LINUX' && executable('wl-copy')
xnoremap <silent>"+y y:call system("wl-copy", @")<cr>
xnoremap <silent>"*y y:call system("wl-copy", @")<cr>
2023-07-10 00:38:37 +02:00
" xnoremap <silent><leader>y y:call system("wl-copy --trim-newline", @*)<cr>:call system("wl-copy -p --trim-newline", @*)<cr>
2022-08-09 18:03:26 +02:00
endif
if s:env =~# 'LINUX' && executable('wl-paste')
nnoremap <silent>"+p :let @"=substitute(system("wl-paste --no-newline"), '<C-v><C-m>', '', 'g')<cr>p
nnoremap "*p :let @"=substitute(system("wl-paste --no-newline --primary"), '<C-v><C-m>', '', 'g')<cr>p
endif
2022-04-29 00:26:07 +02:00
inoremap <expr><TAB> pumvisible() ? "\<C-n>" : "\<TAB>"
2020-10-05 18:32:34 +02:00
inoremap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<left>"
2023-07-10 00:38:37 +02:00
inoremap <expr> <cr> pumvisible() ? "\<C-Y>" : "\<cr>"
" ------ autocmd ------
" Enable omni completion.
2020-10-05 18:32:34 +02:00
" autocmd FileType css setlocal omnifunc=csscomplete#CompleteCSS
" autocmd FileType html,markdown setlocal omnifunc=htmlcomplete#CompleteTags
" autocmd FileType javascript setlocal omnifunc=javascriptcomplete#CompleteJS
" autocmd FileType python setlocal omnifunc=pythoncomplete#Complete
" autocmd FileType xml setlocal omnifunc=xmlcomplete#CompleteTags
" Reload changes if file changed outside of vim requires autoread
augroup load_changed_file
autocmd!
autocmd FocusGained,BufEnter * if mode() !=? 'c' | checktime | endif
autocmd FileChangedShellPost * echo "Changes loaded from source file"
augroup END
2023-07-10 00:38:37 +02:00
" http://vim.wikia.com/wiki/Restore_cursor_to_file_position_in_previous_editing_session
" function! ResCur()
" if line("'\"") <= line("$")
" normal! g`"
" return 1
" endif
" endfunction
" when quitting a file, save the cursor position
augroup save_cursor_position
if &filetype !~# 'commit\|rebase'
autocmd!
2023-07-10 00:38:37 +02:00
" au BufReadPost * call setpos(".", getpos("'\""))|normal! zv
" autocmd BufWinEnter * call ResCur()
" autocmd BufEnter,BufWinEnter
" also automatically open any folds the cursor might land on.
autocmd BufReadPost * silent! normal! g`" zv
endif
augroup END
" when not running in a console or a terminal that doesn't support 256 colors
" enable cursorline in the currently active window and disable it in inactive ones
if $DISPLAY !=? '' && &t_Co == 256
augroup cursorline
autocmd!
2023-07-10 00:38:37 +02:00
" autocmd VimEnter,WinEnter,BufWinEnter * setlocal cursorline
autocmd WinEnter,BufWinEnter * setlocal cursorline
autocmd WinLeave * setlocal nocursorline
augroup END
endif
" when entering insert mode, relative line
" numbers are turned off, leaving absolute line numbers turned on
augroup numbertoggle
autocmd!
autocmd BufEnter,FocusGained,InsertLeave * set number relativenumber
autocmd BufLeave,FocusLost,InsertEnter * set number norelativenumber
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
"" autosave and load views
augroup save_load_views
autocmd!
" au BufWinLeave ?* mkview
" au BufWinLeave *.* silent mkview
" au BufWinLeave ?* mkview
" au VimLeavePre ?* mkview
" au BufWinEnter ?* silent loadview
" au BufReadPost ?* loadview
" au BufWinEnter,BufRead *.* loadview
" au BufWinEnter ?* loadview
au BufLeave *.* mkview
au BufWinEnter *.* loadview
augroup END
augroup filetypes
autocmd!
au FileType xml setlocal shiftwidth=4 tabstop=4
au FileType html setlocal shiftwidth=4 tabstop=4
2020-02-28 02:06:26 +01:00
2023-07-10 00:38:37 +02:00
au BufNewFile,BufRead,BufEnter *.js
\ setlocal shiftwidth=2 tabstop=2 softtabstop=2 backspace=2 expandtab autoindent
\ fileformat=unix filetype=javascript
au BufNewFile,BufRead,BufEnter *.md
\ setlocal textwidth=79 foldmethod=manual filetype=markdown
\ fileformat=unix expandtab
2022-10-06 15:37:46 +02:00
au FileType sway setl textwidth=99
2024-03-26 21:24:14 +01:00
\ tabstop=4 shiftwidth=4 softtabstop=4 noexpandtab autoindent ft=sway
au FileType rust setl
\ tabstop=8 shiftwidth=8 softtabstop=8 noexpandtab autoindent ff=unix
2024-03-26 21:24:14 +01:00
au FileType nix setl
\ fileformat=unix autoindent omnifunc=lsp#complete
au BufNewFile,BufRead *.py,*.pyw,*.pyx,?akefil*
\ setlocal tabstop=4 shiftwidth=4 noexpandtab autoindent
\ fileformat=unix
" Linux kernel style tabs - not for cpp
" au BufNewFile,BufRead,BufEnter *.c,*.h,*.cpp
au BufNewFile,BufRead,BufEnter *.c,*.h
\ set tabstop=8 shiftwidth=8 softtabstop=8 noexpandtab autoindent
\ textwidth=79 fileformat=unix omnifunc=lsp#complete
au BufNewFile,BufRead,BufEnter *.cpp,*.h,*.hpp
\ set tabstop=4 shiftwidth=4 softtabstop=4 noexpandtab autoindent
\ textwidth=79 fileformat=unix omnifunc=lsp#complete ft=cpp
" \ textwidth=79 fileformat=unix
au FileType cpp
\ set tabstop=4 shiftwidth=4 softtabstop=4 noexpandtab autoindent
\ textwidth=79 fileformat=unix omnifunc=lsp#complete
" \ textwidth=79 fileformat=unix
2023-07-10 00:38:37 +02:00
au FileType terraform
\ set fileformat=unix omnifunc=lsp#complete
au FileType css
\ set fileformat=unix omnifunc=lsp#complete
au FileType gohtmltmpl setlocal
\ fileformat=unix tabstop=2 shiftwidth=2 softtabstop=2 noexpandtab
au FileType just setlocal
\ fileformat=unix tabstop=2 shiftwidth=2 softtabstop=2 noexpandtab
au FileType caddyfile setlocal
\ fileformat=unix tabstop=8 shiftwidth=8 softtabstop=8 noexpandtab
au BufNewFile,BufRead,BufEnter Caddyfile,*.caddyfile,Caddyfile.* setlocal
\ fileformat=unix tabstop=8 shiftwidth=8 softtabstop=8 noexpandtab
au FileType tex setlocal tabstop=2
2022-08-09 17:47:09 +02:00
au BufNewFile,BufRead,BufEnter *.tex
\ setlocal tabstop=2 shiftwidth=2 softtabstop=2 expandtab autoindent
\ textwidth=79 fileformat=unix conceallevel=0
2021-02-04 22:38:07 +01:00
au BufNewFile,BufRead,BufEnter *.bib
\ setlocal ft=bib tabstop=2 shiftwidth=2 softtabstop=2 noexpandtab autoindent
\ fileformat=unix conceallevel=0
2023-07-10 00:38:37 +02:00
au FileType bib
\ setlocal tabstop=2 shiftwidth=2 softtabstop=2 noexpandtab autoindent
\ fileformat=unix conceallevel=0
autocmd FileType yaml setlocal ts=2 sts=2 sw=2 expandtab indentkeys-=0#
\ indentkeys-=<:> foldmethod=indent nofoldenable
2022-08-09 17:43:57 +02:00
au BufNewFile,BufRead,BufEnter *.cs
\ setlocal ft=cs tabstop=4 shiftwidth=4 softtabstop=4 noexpandtab autoindent
\ textwidth=79 fileformat=unix conceallevel=0
au BufNewFile,BufRead *.cshtml
\ setlocal ft=csh tabstop=4 shiftwidth=4 softtabstop=4 noexpandtab autoindent
\ textwidth=79 fileformat=unix conceallevel=0
" no autocomments, for example when entering insert mode above or below a
" commented line
autocmd FileType * setlocal formatoptions-=c formatoptions-=r formatoptions-=o
augroup END
2022-08-09 17:43:11 +02:00
augroup line_too_long
autocmd!
autocmd winEnter,BufEnter * call clearmatches() | call matchadd('ColorColumn', '\%>80v', 100)
augroup END
augroup async_plug_load
autocmd!
2021-05-29 21:21:59 +02:00
" these plugins take the longest to load, let's do it in a semi-non-blocking
" fashion
" used to use CursorHold,CursorHoldI but I'm not sure if that didn't go
" off on *every* CursorHold, so this is the solution (perhaps not as async
" anymore)...
2023-07-11 17:56:04 +02:00
" autocmd BufWinEnter * call plug#load('vim-speeddating', 'ultisnips', 'vim-snippets')
autocmd BufWinEnter * call plug#load('vim-speeddating', 'vim-snippets')
\| autocmd! async_plug_load
augroup END
if executable('clangd')
augroup lsp_clangd
autocmd!
2023-07-10 00:38:37 +02:00
" \ 'cmd': {server_info->['clangd', '-enable-snippets']},
autocmd User lsp_setup call lsp#register_server({
\ 'name': 'clangd',
\ 'cmd': {server_info->['clangd']},
\ 'allowlist': ['c', 'cpp'],
\ })
augroup END
endif
if executable('gopls')
augroup lsp_go
autocmd!
autocmd User lsp_setup call lsp#register_server({
\ 'name': 'gopls',
2022-08-16 14:03:51 +02:00
\ 'cmd': ['gopls', '-remote=unix;/tmp/.gopls-daemon.sock'],
\ 'allowlist': ['go', 'gomod', 'gosum','gotexttmpl','gohtmltmpl'],
\ 'gofumpt': 'true',
2022-10-30 04:00:59 +01:00
\ 'analyses': {'shadow': 'true'},
\ })
augroup END
endif
2024-06-21 12:34:31 +02:00
if executable('nil')
2024-07-06 11:35:38 +02:00
augroup lsp_nil
2024-06-21 12:34:31 +02:00
autocmd!
au User lsp_setup call lsp#register_server({
\ 'name': 'nil',
\ 'cmd': {server_info->[&shell, &shellcmdflag, 'nil']},
\ 'allowlist': ['nix'],
\ })
augroup END
endif
if executable('rnix-lsp')
augroup lsp_nix
autocmd!
au User lsp_setup call lsp#register_server({
\ 'name': 'rnix-lsp',
\ 'cmd': {server_info->[&shell, &shellcmdflag, 'rnix-lsp']},
\ 'allowlist': ['nix'],
\ })
augroup END
endif
" zig language server
if executable('zls')
augroup lsp_zig
autocmd!
au User lsp_setup call lsp#register_server({
\ 'name': 'zls',
\ 'cmd': {server_info->[&shell, &shellcmdflag, 'zls']},
\ 'allowlist': ['zig'],
\ })
augroup END
endif
2022-10-30 03:59:54 +01:00
" terraform language server
if executable('terraform-ls')
augroup lsp_tf
autocmd!
au User lsp_setup call lsp#register_server({
\ 'name': 'terraform-ls',
\ 'cmd': {server_info->[&shell, &shellcmdflag, 'terraform-ls']},
\ 'allowlist': ['terraform'],
\ })
2023-07-10 00:38:37 +02:00
" \ 'cmd': {server_info->[&shell, &shellcmdflag, 'terraform-ls', 'serve']},
augroup END
endif
"" tailwind ls
"if executable('tailwindcss-language-server')
" augroup lsp_twls
" autocmd!
" au User lsp_setup call lsp#register_server({
" \ 'name': 'tailwindcss-language-server',
" \ 'cmd': {server_info->[&shell, &shellcmdflag, 'tailwindcss-language-server']},
" \ 'allowlist': ['css', 'html', 'gohtmltmpl'],
" \ })
" augroup END
"endif
" this has some untold deps (on archlinux): haskell-some haskell-lsp1.4 haskell-lsp-types1.4
if executable('dhall-lsp-server')
augroup lsp_dhall
autocmd!
au User lsp_setup call lsp#register_server({
\ 'name': 'dhall-lsp-server',
\ 'cmd': {server_info->[&shell, &shellcmdflag, 'dhall-lsp-server']},
\ 'allowlist': ['dhall'],
\ })
2022-10-30 03:59:54 +01:00
augroup END
endif
if executable('pylsp')
" pip install python-language-server
2023-07-10 00:38:37 +02:00
" or python-lsp-black from the AUR
2022-10-06 15:41:40 +02:00
augroup lsp_py
autocmd!
autocmd User lsp_setup call lsp#register_server({
\ 'name': 'pyls',
2024-07-07 11:13:09 +02:00
\ 'cmd': {server_info->[&shell, &shellcmdflag, 'pylsp', '-vvv', '--log-file', '/tmp/pyls.log']},
2024-07-09 15:51:07 +02:00
\ 'settings': {'pylsp': {'plugins': {'ruff': {'enabled': 'true', 'formatEnabled': 'true',},'rope': {'enabled': 'true'}}}},
2022-10-06 15:41:40 +02:00
\ 'allowlist': ['python'],
\ })
2023-07-10 00:38:37 +02:00
" \ 'cmd': {server_info->['pyls']},
2022-10-06 15:41:40 +02:00
augroup END
endif
2024-07-06 12:16:31 +02:00
"if executable('ruff-lsp')
" augroup lsp_ruff
" autocmd!
" au User lsp_setup call lsp#register_server({
" \ 'name': 'ruff-lsp',
" \ 'cmd': {server_info->[&shell, &shellcmdflag, 'ruff-lsp']},
" \ 'allowlist': ['python'],
" \ })
" augroup END
"endif
if executable('omnisharp')
" https://www.rockyourcode.com/use-vim-for-c-sharp-development-on-linux/
augroup lsp_omnisharp
autocmd!
autocmd User lsp_setup call lsp#register_server({
\ 'name': 'omnisharp-roslyn',
\ 'cmd': {_->[&shell, &shellcmdflag, 'mono $HOME/.bin/omnisharp/omnisharp --languageserver']},
\ 'whitelist': ['cs']
\})
autocmd User lsp_server_init call <SID>setup_ls()
autocmd BufEnter * call <SID>setup_ls()
augroup END
endif
function! s:on_lsp_buffer_enabled() abort
setlocal omnifunc=lsp#complete
setlocal signcolumn=yes
if exists('+tagfunc') | setlocal tagfunc=lsp#tagfunc | endif
nmap <buffer> gd <plug>(lsp-definition)
nmap <buffer> gs <plug>(lsp-document-symbol-search)
nmap <buffer> gS <plug>(lsp-workspace-symbol-search)
nmap <buffer> gr <plug>(lsp-references)
nmap <buffer> gi <plug>(lsp-implementation)
" nmap <buffer> gt <plug>(lsp-type-definition)
nmap <buffer> <leader>rn <plug>(lsp-rename)
nmap <buffer> [g <plug>(lsp-previous-diagnostic)
nmap <buffer> ]g <plug>(lsp-next-diagnostic)
nmap <buffer> K <plug>(lsp-hover)
inoremap <buffer> <expr><c-f> lsp#scroll(+4)
inoremap <buffer> <expr><c-d> lsp#scroll(-4)
2024-07-06 11:56:04 +02:00
" simple code action for normal mode and visual mode
nmap <buffer> <Leader><Leader> <plug>(lsp-code-action)
vmap <buffer> <Leader><Leader> :LspCodeAction<CR>
" alternative that uses floating window
nmap <buffer> <Leader>f <plug>(lsp-code-action-float)
" mapping for filtered code actions
nmap <buffer> <Leader>ri :LspCodeAction refactor.inline<CR>
nmap <buffer> <Leader>ro :LspCodeAction source.organizeImports<CR>
vmap <buffer> <Leader>rm :LspCodeAction refactor.extract<CR>
nmap <buffer> <Leader>rm :LspCodeAction refactor.extract<CR>
" let g:lsp_format_sync_timeout = 1000
let g:lsp_format_sync_timeout = 700
2022-10-06 15:42:55 +02:00
augroup lsp_format_sync
autocmd!
2024-07-06 11:55:48 +02:00
autocmd! BufWritePre *.rs,*.go,*.python,*.nix call execute('LspDocumentFormatSync')
2022-10-06 15:42:55 +02:00
augroup END
" refer to doc to add more commands
endfunction
augroup lsp_install
2024-07-06 11:55:34 +02:00
autocmd!
" call s:on_lsp_buffer_enabled only for languages that have the server
" registered.
autocmd User lsp_buffer_enabled call s:on_lsp_buffer_enabled()
augroup END
if(&filetype ==# 'cs')
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)
2023-07-10 00:38:37 +02:00
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
2023-07-10 00:38:37 +02:00
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)
2023-07-10 00:38:37 +02:00
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)
2023-07-10 00:38:37 +02:00
autocmd FileType cs nmap <silent> <buffer> <leader>os= <Plug>(omnisharp_code_format)
2023-07-10 00:38:37 +02:00
autocmd FileType cs nmap <silent> <buffer> <leader>osnm <Plug>(omnisharp_rename)
2023-07-10 00:38:37 +02:00
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
endif
" ------ adv maps ------
2023-07-10 00:38:37 +02:00
" strip trailing whitespace, xs (strip space)
nnoremap <silent> <leader>xs
\ :let b:_p = getpos(".") <Bar>
\ let b:_s = (@/ != '') ? @/ : '' <Bar>
\ %s/\s\+$//e <Bar>
\ let @/ = b:_s <Bar>
\ nohlsearch <Bar>
\ unlet b:_s <Bar>
\ call setpos('.', b:_p) <Bar>
2023-07-10 00:38:37 +02:00
\ unlet b:_p <cr>
match Todo /\s\+$/
2022-10-30 03:58:49 +01:00
" repeat last edit with a number
nnoremap . :<c-u>execute "norm! " . repeat(".", v:count1)<cr>
" settings
set softtabstop=4
set tabstop=4
set shiftwidth=4
2023-07-10 00:38:37 +02:00
set shiftround " Rounds the indentation to the nearest multiple of shiftwidth.
2019-04-12 19:04:50 +02:00
set expandtab
set smarttab
2022-10-30 03:58:23 +01:00
filetype plugin indent on
2019-04-12 19:04:50 +02:00
set errorformat+=%.%#PHP:\ %m\ \(in\ %f\ on\ line\ %l\)%.%#,
\%E%[0-9]%#.%m:%f?rev=%.%##L%l\ %.%#,%C%.%#
2020-02-28 02:06:26 +01:00
set tags=.tags;
2019-04-12 19:04:50 +02:00
set incsearch " incrimental search
set hlsearch " highlighting when searching
2022-07-22 18:12:23 +02:00
set wrapscan " go back to beginning of a buffer once we reach end
2022-07-22 18:10:59 +02:00
set ignorecase " searches are case insensitive...
set smartcase " ... unless they contain at least one capital letter
2019-04-12 19:04:50 +02:00
set autoindent
set backspace=2
2023-07-10 00:38:37 +02:00
set equalalways " When on, all the windows are automatically
" made the same size after splitting or closing a window.
set splitbelow splitright " splits open at bottom and right
set lazyredraw " don't redraw while executing macros (good performance config)
set ttyfast
2022-07-21 11:49:22 +02:00
set listchars=trail:•,tab:>-,nbsp:☣,eol,extends:,precedes:
2022-07-21 12:02:47 +02:00
set nolist " show/hide tabs and EOL chars (hidden characters)
2022-07-22 18:15:47 +02:00
" don't indent wrapped lines
set nobreakindent
set confirm " ask confirmation like save before quit.
set wildmenu " Tab completion menu when using command mode
2022-07-22 18:14:33 +02:00
" https://bitbucket.org/sjl/dotfiles/src/tip/vim/vimrc#cl-153
set wildignore+=.hg,.git,.svn " Version control
set wildignore+=*.aux,*.out,*.toc " LaTeX intermediate files
set wildignore+=*.jpg,*.bmp,*.gif,*.png,*.jpeg " binary images
set wildignore+=*.o,*.obj,*.exe,*.dll,*.manifest " compiled object files
set wildignore+=*.dwo " DWARF debug object files
set wildignore+=*.spl " compiled spelling word lists
set wildignore+=*.pyc " Python byte code
set wildignore+=node_modules/**
2020-10-05 18:32:34 +02:00
set wildmode=longest:longest,full
2022-07-22 18:15:19 +02:00
" filler lines to keep text position; start diff with vertical splits; don't
" ignore case and whitespace changes
set diffopt=filler,vertical
2023-07-10 00:38:37 +02:00
" set scrolloff=3 " scroll offset, min lines above/below cursor
set scrolloff=5 " scroll offset, min lines above/below cursor
"set scrolljump=5 " jump 5 lines when running out of the screen - NO
set sidescroll=10 " minimum columns to scroll horizontally
2022-10-30 04:40:40 +01:00
set title " set titlestring based on file
2019-04-12 19:04:50 +02:00
set showcmd " show command status
set showmatch " flashes matching parenthese when cursor over the other one
2022-07-21 12:03:28 +02:00
" Make <,> match pairs, too.
" https://github.com/EHartC/dot-vimrc/blob/master/vim%20config/styling.vim
set matchpairs+=<:>
2022-08-12 21:05:58 +02:00
set matchtime=2 " how many tenths of a second to blink when matching brackets
set noshowmode " show editing mode in status (-- INSERT --)
2019-04-12 19:04:50 +02:00
set ruler " show cursor position
2021-11-10 01:21:07 +01:00
set colorcolumn=80 " Highlight column 80 to get coding horizontal bound.
set noerrorbells " bells in vim
2022-10-30 04:41:47 +01:00
" Tell vim to remember certain things when we exit
" '10 : marks will be remembered for up to 10 previously edited files
" "100 : will save up to 100 lines for each register
" :20 : up to 20 lines of command-line history will be remembered
" % : saves and restores the buffer list
set viminfo='100,"100,:20,% " '=marks for x files, "=registers for x files
2019-04-12 19:04:50 +02:00
2023-07-10 00:38:37 +02:00
" set nofoldenable
2022-07-22 18:16:44 +02:00
set foldmethod=manual " manual folding
2022-07-22 18:17:14 +02:00
set fileencoding=utf-8 " set encoding for newly saved files
set noscrollbind
2022-07-22 18:18:49 +02:00
set cmdheight=2 " lines under {status,air}line
2021-09-01 16:42:29 +02:00
set updatetime=250
2023-07-10 00:38:37 +02:00
" set updatetime=200
" set updatetime=100
2022-10-30 03:55:04 +01:00
" https://sw.kovidgoyal.net/kitty/faq/#using-a-color-theme-with-a-background-color-does-not-work-well-in-vim
" work around vim's background colour erase:
"
" vim hardcodes background color erase even if the terminfo file does
" not contain bce (not to mention that libvte based terminals
" incorrectly contain bce in their terminfo files). This causes
" incorrect background rendering when using a color theme with a
" background color.
let &t_ut=''
" Bracketed paste
let &t_BE = "\e[?2004h"
let &t_BD = "\e[?2004l"
let &t_PS = "\e[200~"
let &t_PE = "\e[201~"
" Cursor control
let &t_RC = "\e[?12$p"
let &t_SH = "\e[%d q"
let &t_RS = "\eP$q q\e\\"
let &t_SI = "\e[5 q"
let &t_SR = "\e[3 q"
let &t_EI = "\e[1 q"
let &t_VS = "\e[?12l"
" Window title
let &t_ST = "\e[22;2t"
let &t_RT = "\e[23;2t"
2022-10-30 03:55:04 +01:00
if (has('termguicolors'))
set termguicolors
2023-07-10 00:38:37 +02:00
else
set t_Co=256
2022-10-30 03:55:04 +01:00
endif
" let there be light
" set background=light
set background=dark
if &background =~# 'light'
" colo default
" colo space_vim_theme
" colo iceberg
" colo edge
" colo base16-grayscale-light
2024-03-26 21:25:17 +01:00
" colo antiphoton
colo catppuccin_latte
2022-10-30 03:55:04 +01:00
" proper light only when terminal bg is light
" colo bruin
else
" colo spacemacs-theme
" colo monotone
" colo space_vim_theme
" colo photon
colo catppuccin_mocha
2022-10-30 03:55:04 +01:00
" proper dark only when terminal bg is dark
" colo bruin
" colo monochrome
endif
" colo apprentice
" colo nord
hi CursorLineNR cterm=bold
hi ALEInfoSign guifg=#616161 ctermfg=59
hi ALEVirtualTextInfo guifg=#616161 ctermfg=59
" hi ALEVirtualTextWarning guifg=#5c6370 ctermfg=59
hi ALEVirtualTextWarning guifg=#616161 ctermfg=59
" hi ALEVirtualTextError guifg=#7f3963 ctermfg=59
hi ALEVirtualTextError guifg=#c471a3 ctermfg=59
hi GitGutterAdd guifg=#32CD32 ctermfg=59
hi GitGutterDelete guifg=#c471a3 ctermfg=59
" erase most of the background colour in this specific case.
if g:colors_name =~# 'spacemacs-theme' && &background =~# 'dark'
2023-07-10 00:38:37 +02:00
" if $TERM =~ 'xterm-256color'
" if &background =~ 'dark'
" if vim.g.colors_name == 'space_vim_theme'
" if exists('space_vim_theme' || 'spacemacs-theme')
" hi Cursor ctermfg=black cterm=reverse
" hi Cursor gui=reverse cterm=reverse ctermbg=5
" hi CursorLine gui=reverse
" hi Cursor guifg=NONE guibg=Purple ctermbg=8 cterm=reverse
" hi Cursor guifg=NONE guibg=Purple ctermbg=8
" hi Cursor guifg=NONE guibg=NONE
" hi Cursor ctermfg=15 ctermbg=11 guifg=#373040 guibg=#68727c cterm=reverse
" hi! Cursor ctermfg=4 ctermbg=2 guifg=Black guibg=Purple
" hi! iCursor ctermfg=4 ctermbg=2 guifg=Black guibg=Purple
" hi! TermCursorNC ctermfg=4 ctermbg=2 guifg=Black guibg=Purple
" hi Comment guifg=#5c6370 ctermfg=59
" hi Function cterm=bold
" hi NonText cterm=NONE ctermbg=17 gui=NONE guibg=NONE guifg=#5c6370
2022-10-30 03:55:04 +01:00
hi Normal ctermbg=NONE guibg=NONE
hi LineNr ctermbg=NONE guibg=NONE
" hi CursorLineNR cterm=bold
hi VertSplit cterm=NONE guibg=NONE
hi SignColumn ctermbg=NONE term=standout cterm=NONE guibg=NONE gui=NONE
hi GitGutterAdd ctermbg=NONE guibg=NONE cterm=bold gui=bold
hi GitGutterChange ctermbg=NONE guibg=NONE cterm=bold gui=bold
hi GitGutterDelete ctermbg=NONE guibg=NONE cterm=bold gui=bold
hi GitGutterChangeDelete ctermbg=NONE guibg=NONE cterm=bold gui=bold
" hi GitGutterAddLine ctermbg=NONE guibg=NONE
" hi GitGutterChangeLine ctermbg=NONE guibg=NONE
" hi GitGutterDeleteLine ctermbg=NONE guibg=NONE
" hi GitGutterChangeDeleteLine ctermbg=NONE guibg=NONE
" hi SignifySignAdd ctermbg=NONE guibg=NONE
" hi SignifySignChange ctermbg=NONE guibg=NONE
" hi SignifySignDelete ctermbg=NONE guibg=NONE
" hi SignifyChangeDelete ctermbg=NONE guibg=NONE
" hi SignifySignDeleteFirstSign ctermbg=NONE guibg=NONE
hi ALEErrorSign ctermbg=NONE guibg=NONE
hi ALEWarningSign ctermbg=NONE guibg=NONE
hi Terminal ctermbg=NONE guibg=NONE
endif
2022-10-30 03:56:05 +01:00
" spelling mistakes highlighting
" as per https://github.com/vim/vim/issues/6174#issuecomment-636869793
let &t_Cs = "\e[4:3m"
let &t_Ce = "\e[4:0m"
hi SpellBad guisp=red gui=undercurl guifg=NONE guibg=NONE ctermfg=NONE ctermbg=NONE term=underline cterm=undercurl ctermul=red
hi SpellCap guisp=yellow gui=undercurl guifg=NONE guibg=NONE ctermfg=NONE ctermbg=NONE term=underline cterm=undercurl ctermul=yellow
2022-10-30 03:55:04 +01:00
" compensate for lack of theme italics
2023-07-10 00:38:37 +02:00
" for s in ["Comment", "Constant", "Include", "Define", "Macro", "Delimiter", "Debug", "Identifier", "Boolean", "markdownItalic"]
" for s in ["Comment", "markdownItalic"]
for s in ['Comment', 'markdownItalic', 'Boolean']
execute 'hi ' s ' cterm=italic'
endfor
2021-05-29 21:22:54 +02:00
2023-07-10 00:38:37 +02:00
" python
hi pythonSelf ctermfg=68 guifg=#5f87d7 cterm=bold gui=bold
2021-05-29 21:22:54 +02:00
" vimtex highlight groups
hi! link texMathEnvArgName texEnvArgName
hi! link texMathZone LocalIdent
hi! link texMathZoneEnv texMathZone
hi! link texMathZoneEnvStarred texMathZone
hi! link texMathZoneX texMathZone
hi! link texMathZoneXX texMathZone
hi! link texMathZoneEnsured texMathZone
2022-10-30 03:57:48 +01:00
" keep buffer contents in memory (e.g. undo history doesn't go away if change
" buffers and not saving undo history to disk)
" enable hidden buffers
set hidden
set conceallevel=0 " for jsons
2022-10-30 03:41:51 +01:00
set ttymouse=sgr " falls back to xterm,xterm2
" temporarily set ttymouse to xterm mode, setting notballoonevalterm did not
" help
" refs:
" https://github.com/vim/vim/issues/9863
" https://github.com/kovidgoyal/kitty/issues/4992
" https://github.com/kovidgoyal/kitty/issues/5107
" https://github.com/kovidgoyal/kitty/commit/55b21b741ebc45453f089c962ec46feff394c0e4
" set ttymouse=xterm
" set noballoonevalterm
set mouse=a " enable mouse in n,v,i,c,h modes
2022-10-30 03:41:51 +01:00
set t_RV=
2022-10-30 03:42:58 +01:00
" automatically cd (autocd) to dir current file is in
set autochdir
2022-07-21 12:08:15 +02:00
2022-10-30 03:45:03 +01:00
" default; :%s/// replaces one; /g replace all; /gg replace one
" note: deprecated in Vim9 script
set nogdefault
" can select past EOL in visual block if one line is longer
set virtualedit=block
2022-10-30 03:47:41 +01:00
" set timeoutlen=1200 "more time for typing complex mappings
set timeoutlen=200
" turn off timeout; default is 1000
" fix airline mode changes without screwing up remaps of default letter keys
" (without this, using escape to exit insert mode won't change airline to
" display normal mode immediately in the terminal)
" ttimeout only applies to keycodes (so changes to default vim keys that can't
" be unmapped is not an issue, e.g. using r in multikey/prefix bindings)
2023-07-10 00:38:37 +02:00
" set notimeout ttimeout ttimeoutlen=10
set notimeout ttimeout ttimeoutlen=30
2022-10-30 03:47:41 +01:00
2022-07-21 12:08:15 +02:00
" persistent undo history (even if close buffer)
" Save undos after file closes
set undofile
" where to save undo histories
set undodir=~/.vim/undo//
" How many undos
set undolevels=2000
" save whole buffer for undo on reload if number of lines is smaller than
set undoreload=10001
" make folders automatically if they don't already exist
if !isdirectory(expand(&undodir))
2022-08-11 12:48:30 +02:00
call mkdir(expand(&undodir), 'p')
2022-07-21 12:08:15 +02:00
endif
2022-08-12 21:01:34 +02:00
set nobackup
set nowritebackup
set directory=~/.vim/swp//
if !isdirectory(expand(&directory))
call mkdir(expand(&directory), 'p')
endif
2022-07-21 12:08:15 +02:00
2022-10-30 03:40:33 +01:00
set laststatus=2 " show status bar
set report=1 " Always report number of lines changed by ex commands
2022-08-12 21:05:58 +02:00
set guifont=Fira\ Code\ weight=450\ 12
2022-10-30 03:40:33 +01:00
set ballooneval " vim8+ popups
let g:netrw_beval = 1
set t_vb=
2023-07-10 00:38:37 +02:00
" commented
" highlight ColorColumn guibg=Black ctermbg=0
" highlight ColorColumn ctermbg=0
" cursorline optimizations
set cursorlineopt=number
2022-10-30 03:39:52 +01:00
" 0 automatic selection
" 1 old engine
" 2 NFA engine
" set regexpengine=1
set regexpengine=0
" set redrawtime=500
" set synmaxcol=128
syntax sync minlines=256
2022-08-11 12:59:11 +02:00
" use +/clipboard as default register
set clipboard=unnamed,unnamedplus
2022-08-11 12:59:11 +02:00
2022-08-11 12:58:49 +02:00
" vim help had this to say about 'exrc':
"
" Enables the reading of .vimrc, .exrc and .gvimrc in the current directory.
" Setting this option is a potential security leak. E.g., consider unpacking
" a package or fetching files from github, a .vimrc in there might be a trojan
" horse. BETTER NOT SET THIS OPTION!
" Instead, define an autocommand in your .vimrc to set options for a matching
" directory.
"
" but since it's needed for direnv, we have to enable it.
set exrc
set secure
2023-07-10 00:38:37 +02:00
" nicer scrolling when long lines are wrapped.
set smoothscroll
2021-11-10 01:26:02 +01:00
2022-10-30 03:38:29 +01:00
" Append modeline before first line in buffer.
" Use substitute() instead of printf() to handle '%%s' modeline in LaTeX
" files.
function! AppendModeline()
let l:modeline = printf(' vim: set ts=%d ft=%s fenc=%s ff=%s :',
\ &tabstop, &filetype, &fileencoding, &fileformat)
let l:modeline = substitute(&commentstring, '%s', l:modeline, '')
call append (line('^'), l:modeline)
endfunction
2023-07-10 00:38:37 +02:00
nnoremap <silent> <leader>ml :call AppendModeline()<cr>
2022-10-30 03:38:29 +01:00
2022-08-11 12:33:20 +02:00
function! AskQuit (msg, proposed_action)
if confirm(a:msg, "&Quit?\n" . a:proposed_action) == 1
exit
endif
endfunction
function! EnsureDirExists ()
let required_dir = expand('%:h')
if !isdirectory(required_dir)
call AskQuit('Directory "' . required_dir . '" doesn''t exist.', '&Create it?')
try
call mkdir( required_dir, 'p' )
catch
call AskQuit('Can''t create "' . required_dir . '"', '&Continue anyway?')
endtry
endif
endfunction
augroup AutoMkdir
autocmd!
autocmd BufNewFile * :call EnsureDirExists()
augroup END
2021-11-10 01:26:02 +01:00
2022-08-11 12:41:49 +02:00
" as per https://stackoverflow.com/a/38775966
function! HeaderToggle() " bang for overwrite when saving vimrc
let file_path = expand('%')
let file_name = expand('%<')
let extension = split(file_path, '\.')[-1] " '\.' is how you really split on dot
let err_msg = 'There is no file '
if extension ==# 'cpp'
let next_file = join([file_name, '.h'], '')
if filereadable(next_file)
:e %<.h
else
echo join([err_msg, next_file], '')
endif
elseif extension ==# 'h'
let next_file = join([file_name, '.cpp'], '')
if filereadable(next_file)
:e %<.cpp
else
echo join([err_msg, next_file], '')
endif
endif
endfunction
nnoremap <leader>hh :call HeaderToggle()<cr>
if(&filetype ==# 'c') || (&filetype ==# 'cpp')
if isdirectory('include')
set path+=include
elseif isdirectory('inc')
set path+=inc
elseif isdirectory('src/include')
set path+=src/include
endif
endif
silent function! LINUX()
return has('unix') && !has('macunix') && !has('win32unix')
endfunction
2022-08-11 12:41:49 +02:00
2023-07-10 00:38:37 +02:00
" " fix meta-keys which generate <Esc>a .. <Esc>z
" let c='a'
" while c <= 'z'
" exec "set <M-".toupper(c).">=\e".c
" exec "imap \e".c." <M-".toupper(c).">"
" let c = nr2char(1+char2nr(c))
" endw
" set <M-A>=a
" imap a <M-A>
" note: this might be outdated at this point, I am not sure.
" https://github.com/bling/vim-airline/issues/539
function! RefreshUI()
if exists(':AirlineRefresh')
AirlineRefresh
else
" Clear & redraw the screen, then redraw all statuslines.
redraw!
redrawstatus!
endif
endfunction
" from vim wiki
augroup autoReloadVimRC
autocmd!
" automatically reload vimrc when it's saved
autocmd BufWritePost ~/.vimrc so ~/.vimrc | call RefreshUI()
2023-07-10 00:38:37 +02:00
autocmd BufWritePost ~/utils/dotfiles/vim/.vimrc so ~/utils/dotfiles/vim/.vimrc | call RefreshUI()
augroup END
" reload config
2023-07-10 00:38:37 +02:00
nnoremap <leader>ve :e $MYVIMRC<cr>
" reload config and call refresh fn
2023-07-10 00:38:37 +02:00
nnoremap <leader>vr :source $MYVIMRC<cr>call RefreshUI()<cr>
2022-05-06 22:52:07 +02:00
2022-10-30 03:38:06 +01:00
let base16colorspace=256
2022-05-06 22:52:07 +02:00
" as per https://github.com/direnv/direnv/wiki/Vim
2022-08-11 12:48:30 +02:00
if exists('$EXTRA_VIM')
2022-05-06 22:52:07 +02:00
for path in split($EXTRA_VIM, ':')
2022-08-11 12:48:30 +02:00
exec 'source '.path
2022-05-06 22:52:07 +02:00
endfor
endif
2022-07-21 16:30:54 +02:00
" vim: ft=vim ff=unix expandtab ts=2 sw=2