diff --git a/dot-config/vim/init.vim b/dot-config/vim/init.vim index a8e0cc6..e625c12 100644 --- a/dot-config/vim/init.vim +++ b/dot-config/vim/init.vim @@ -18,14 +18,16 @@ if !isdirectory($XDG_CACHE_HOME .. '/vim/pack') PackUpdate endif -if has('gui_running') || has('termguicolors') - if $COLORTERM == 'truecolor' - &t_8f = "\[38:2:%lu:%lu:%lum" - &t_8b = "\[48:2:%lu:%lu:%lum" - endif +# If both Vim and the terminal it's running in support true colour, use it. +# Otherwise we just fall back to 256-colour mode, or even the old 16-colour +# mode if necessary! +if has('termguicolors') && $COLORTERM == 'truecolor' set termguicolors endif +# Colour scheme and corresponding settings. gruvbox8 happens to work on pretty +# much any setup (GUI vim, true-colour terminal, 256 colours, even a 2-colour +# term if necessary!) so we don't need to mess around too much here. set background=dark g:gruvbox_transp_bg = 1 g:gruvbox_italicize_strings = 0 @@ -33,60 +35,72 @@ g:gruvbox_filetype_hi_groups = 1 g:gruvbox_plugin_hi_groups = 1 colorscheme gruvbox8 +# I like being able to drop out of Insert mode without reaching for the Escape +# key in the corner. Some folks use jk instead but I find jj nice and quick. inoremap jj + +# lotabout/skim.vim's fuzzy file finder! It's basically a copy of fzf.vim, but +# it uses skim as the backend instead of fzf. Rust versions of command-line +# tools my beloved nnoremap :Files -silent! packadd! editorconfig +# We will always have Editorconfig available as an optional package, either +# because it was bundled with Vim or because Minpac installed it that way. +packadd! editorconfig -if exists('+belloff') - set belloff+=ctrlg +set belloff+=ctrlg + +# I like to explicitly set 'modelines' to the default 5 because some +# distributions change it to zero in the global config, and I want modelines +# to work. +set modelines=5 + +if has('linebreak') + set breakindent breakindentopt=sbr + set linebreak showbreak=↩ endif +set relativenumber +set showcmd + set completeopt+=menuone - -set linebreak showbreak=↩ -set modelines=5 -set showcmd set wildmode=longest,full -if has('patch-8.2.4325') - set wildoptions+=pum -endif +set wildoptions+=pum # This is a window-local setting but I like 2 by default. :) set conceallevel=2 +# I like small indents. This setup supports both vim-sleuth and editorconfig, +# so files with different indent schemes will automatically be handled +# correctly, but this default is what I like personally. Also, I *vastly* +# prefer tabs over spaces for indentation, for the simple reason that if +# someone else needs a bigger indent size than I do, they can just change +# their editor's tabstop setting rather than having to reindent the whole +# file. set tabstop=2 shiftwidth=2 -if exists('+breakindent') - set breakindent breakindentopt=sbr -endif - -if exists('+relativenumber') - set relativenumber -else - set number -endif - for dir_name in ['backup', 'swap', 'undo'] EnsureDir($XDG_STATE_HOME .. '/vim/' .. dir_name) endfor +# Try to save backup and swap files alongside the original file, but if that's +# not possible (directory not writable, for example), then fall back to the +# appropriate XDG directory instead. set backupdir=.,$XDG_STATE_HOME/vim/backup set directory=.,$XDG_STATE_HOME/vim/swap + +# I like persistent undo! If Vim was built with it, then persist undo files +# for eveything in the XDG state home. :) if exists('+undofile') set undofile set undodir=$XDG_STATE_HOME/vim/undo endif -# This setup installs both tpope/vim-sensible and tpope/vim-sleuth, so we -# don't also need vim-polyglot to provide that same functionality. -g:polyglot_disabled = ['sensible', 'autoindent'] - g:csv_no_conceal = 1 -g:vim_svelte_plugin_use_typescript = 1 - -g:LatexBox_Folding = 1 +g:GPGDefaultRecipients = [ + 'Danielle McLean ', +] g:markdown_folding = 1 @@ -94,21 +108,27 @@ g:ale_set_balloons = 1 nmap (ale_previous_wrap) nmap (ale_next_wrap) +# Get the correct filetype icons and matching colours when viewing a directory +# in Fern. As the name implies, this requires Nerd Fonts support, either by +# using a patched font or by having your setup substitute an icon font when +# necessary. g:fern#renderer = 'nerdfont' augroup glyphPalette autocmd! autocmd FileType fern g:glyph_palette#apply() augroup END -g:mucomplete#can_complete = { - default: { - omni: (t) => strlen(&l:omnifunc) > 0 && t =~# '\m\k\%(\k\|\.\)$' - } -} - +# Configure a statusline and tabline using vim-crystalline. I tried a bunch of +# different statusline plugins and this one, which is basically just a utility +# library for writing your *own* statusline functions, worked the best for my +# purposes. Very quick, naturally very configurable, I could tell the modified +# buffer + to appear in red, all that good stuff. Yay! import "./statusline.vim" statusline.Init() +# Set up LSP client support. My lsp.vim module both tells yegappan/lsp which +# LSP servers it can connect to and provides a way to install those servers if +# necessary. import "./lsp.vim" lsp.Configure() diff --git a/dot-config/vim/plugins.vim b/dot-config/vim/plugins.vim index 25e8f2d..e217e04 100644 --- a/dot-config/vim/plugins.vim +++ b/dot-config/vim/plugins.vim @@ -1,5 +1,9 @@ vim9script silent! packadd minpac + +# Automatically bootstrap Minpac if necessary. Once it's installed it knows +# how to manage and update itself, but Vim doesn't know how to install it +# without our help. ;) if !exists('g:loaded_minpac') silent !git clone https://github.com/k-takata/minpac.git $XDG_CACHE_HOME/vim/pack/minpac/opt/minpac augroup minpac @@ -9,34 +13,58 @@ if !exists('g:loaded_minpac') endif packadd minpac +# Minpac is told to install into the XDG cache home because if we do blow away +# that directory, it can and will simply reinstall everything I've configured +# it to install the next time Vim is launched. minpac#init({dir: $XDG_CACHE_HOME .. '/vim'}) minpac#add('k-takata/minpac', {type: 'opt'}) -minpac#add('tpope/vim-sensible') -minpac#add('prabirshrestha/async.vim') + +# tpope/vim-sensible is a collection of default Vim settings that "everyone +# can agree on", and is an excellent starting point for anyone's Vim config. +# We'd like it to load first, before any other plugins. However somewhat +# confusingly, Vim's native 'packages' feature adds plugins from pack/*/start +# to 'runtimepath' in REVERSE alphabetical order, so we have to put +# vim-sensible at the end of the alphabet like so to get it loaded first. +minpac#add('tpope/vim-sensible', {name: 'zz-vim-sensible'}) + +# Git support. Fugitive is a pretty famous wrapper that adds :Git commands +# when you're in a repo, and Rhubarb is a GitHub-specific support addon for +# it. (I don't personally use GitHub much, but work does, so whatever.) +# Signify marks changed lines in the current buffer with symbols in the left +# margin, which I finde very helpful. +minpac#add('tpope/vim-fugitive') +minpac#add('tpope/vim-rhubarb') +minpac#add('mhinz/vim-signify') minpac#add('lifepillar/vim-gruvbox8') +# Project handling. Direnv is a tool for setting project-local environment +# variables as you cd around, and Editorconfig is a generic format telling +# text editors what your preferred indent size and stuff are for the given +# project. Both are very helpful to have integrated with Vim. +minpac#add('direnv/direnv.vim') if !isdirectory($VIMRUNTIME .. '/pack/dist/opt/editorconfig') - minpac#add('editorconfig/editorconfig-vim') + # If this Vim doesn't already provide Editorconfig as part of its runtime, + # install it ourselves, using exactly the same package name and type (opt, so + # that it can be loaded with :packadd). + minpac#add('editorconfig/editorconfig-vim', {name: 'editorconfig', type: 'opt'}) endif -minpac#add('direnv/direnv.vim') -minpac#add('godlygeek/tabular') -minpac#add('jamessan/vim-gnupg') -minpac#add('junegunn/vim-easy-align') -minpac#add('lifepillar/vim-mucomplete') +# skim is a standalone fuzzy finder, kinda like fzf or fzy or selecta, but +# written in Rust. These two plugins teach Vim to integrate with it, so you +# can use skim's high performance fuzzy finding to locate stuff (files, +# buffers, colorschemes) inside Vim. Nice! minpac#add('lotabout/skim') minpac#add('lotabout/skim.vim') -minpac#add('mhinz/vim-signify') -minpac#add('sjl/vitality.vim') + +minpac#add('godlygeek/tabular') +minpac#add('jamessan/vim-gnupg') +minpac#add('lifepillar/vim-mucomplete') minpac#add('tpope/vim-apathy') minpac#add('tpope/vim-commentary') -minpac#add('tpope/vim-dadbod') minpac#add('tpope/vim-endwise') minpac#add('tpope/vim-eunuch') -minpac#add('tpope/vim-fugitive') minpac#add('tpope/vim-repeat') -minpac#add('tpope/vim-rhubarb') minpac#add('tpope/vim-sleuth') minpac#add('tpope/vim-surround') minpac#add('tpope/vim-unimpaired') @@ -60,15 +88,6 @@ minpac#add('lambdalisue/fern-git-status.vim') minpac#add('lambdalisue/fern-ssh') minpac#add('alvan/vim-closetag') -minpac#add('LaTeX-Box-Team/LaTeX-Box') -minpac#add('vhda/verilog_systemverilog.vim') -minpac#add('sheerun/vim-polyglot') - -minpac#add('eipipuz/factor.vim') - -minpac#add('ehamberg/vim-cute-python') -minpac#add('Glench/Vim-Jinja2-Syntax') -minpac#add('tweekmonster/braceless.vim') minpac#add('vito-c/jq.vim') minpac#add('NoahTheDuke/vim-just') @@ -77,20 +96,13 @@ minpac#add('fladson/vim-kitty') minpac#add('fpob/nette.vim') -minpac#add('leafOfTree/vim-svelte-plugin') - if executable('task') - minpac#add('farseer90718/vim-taskwarrior') + minpac#add('blindFS/vim-taskwarrior') endif minpac#add('pedrohdz/vim-yaml-folds') -minpac#add('alx741/yesod.vim') -minpac#add('pbrisbin/vim-syntax-shakespeare') - if has('macunix') minpac#add('rizzatti/dash.vim') - # We rename this plugin to make sure it loads AFTER vim-polyglot, - # since it won't work properly if it's loaded first. - minpac#add('itspriddle/vim-marked', {name: 'zzvim-marked'}) + minpac#add('itspriddle/vim-marked') endif