This is becoming quite the list! Thanks for your recommendations, everybody. I’ll have enough for a couple more bike rides (but feel free to keep them coming).
Another great thing about coc.nvim is its ability to automatically format files on save through its plugins.
I've turned on automatic formatting for Elixir and Rust files by adding both to `coc.preferences.formatOnSaveFiletypes` in `coc-settings.json`.
I released Grim (https://github.com/jeffkreeftmeijer/vim-dim/blob/49c5833997461afbd5c9b06582d23382e40a245f/colors/grim.vim), and vim-nightfall (https://github.com/jeffkreeftmeijer/vim-nightfall) this week, so I’ve officially added both to my Vim configuration for monochrome syntax highlighting in both light and dark mode.
Minimal effort .mov-to-.gif with ffmpeg. Improvements welcome.
That’s it for now! Please take it for a spin and let me know if you find something I can improve on.
Have a smart configuration in your ~/.vimrc yourself? Turn it into a plugin! A good place to start (and the source of most of my VimL-fu) is https://learnvimscriptthehardway.stevelosh.com.
That’s it! Sourcing our plugin once more, we can switch macOS’s appearance to dark mode and have Vim automatically follow when it gains focus.
To add our autocommand to our plugin, we’ll wrap it in an `augroup` to make sure it’s reloaded properly when we load the plugin multiple times, for whatever reason:
autocmd FocusGained,BufEnter * call UpdateBackground()
We’ll use autocommands, which fire automatically when a certain trigger happens. In our case, we’ll call our function when Vim gains focus (`FocusGained`) or when entering a buffer (`BufEnter`):
:autocmd FocusGained,BufEnter * call UpdateBackground()
Let’s try our function. To load our file, call `:source %` (`%` is a shortcut for the current file).
Then, we can switch the background by running `:call UpdateBackground()`. It should switch to match macOS’s background mode. 🎉
In nightfall.vim, we'll define a function:
if system("defaults read -g AppleInterfaceStyle") == "Dark\n"
if &bg == "light" | set bg=dark | endif
if &bg == "dark" | set bg=light | endif
With our prototype done, let’s build that plugin. After settling on a name, we’ll create a directory and a file to store our plugin in.
$ mkdir -p ~/.vim/pack/plugins/start/vim-nightfall/plugin
$ nvim ~/.vim/pack/plugins/start/vim-nightfall/plugin/nightfall.vim
Combining these, we can set our background color based on the `AppleInterfaceStyle`:
:if system("defaults read -g AppleInterfaceStyle") == "Dark\n"
: if &bg == "light" | set bg=dark | endif
: if &bg == "dark" | set bg=light | endif
We can use an if-statement to set `bg=dark` if it’s currently “light”, and vice versa:
:if &bg == "light" | set bg=dark | endif
:if &bg == "dark" | set bg=light | endif
First things first. We need to know when to switch the background color. We’ll check `defaults read -g AppleInterfaceStyle`, which produces `Dark\n` when macOS’s dark mode is turned on.
In Vim, as a boolean:
:echom system("defaults read -g AppleInterfaceStyle") == "Dark\n"
Server run by the main developers of the project It is not focused on any particular niche interest - everyone is welcome as long as you follow our code of conduct!