-
Notifications
You must be signed in to change notification settings - Fork 1
NeoVim
Alexander Ross edited this page Apr 18, 2021
·
1 revision
Use Appearance for NeoVim.
First of all you will of course need to have NeoVim installed. But you also need to install NeoVim Remote for this script to work.
Copy and paste the following content to a file at ~/.config/appearance/hooks/neovim
.
#!/usr/bin/env bash
set -exuo pipefail
NEOVIM_REMOTE="/usr/local/bin/nvr"
if ! command -v $NEOVIM_REMOTE &> /dev/null
then
echo "Command \"nvr\" could not be found"
echo "Install using: \"pip3 install neovim-remote\" or read more at https://github.com/mhinz/neovim-remote"
exit 1
fi
for server in $($NEOVIM_REMOTE --serverlist)
do
if [ "$1" == "Dark" ]; then
$NEOVIM_REMOTE --servername $server -cc ":call DarkMode()"
else
$NEOVIM_REMOTE --servername $server -cc ":call LightMode()"
fi
done
Make it executable by running chmod u+x ~/.config/appearance/hooks/neovim
.
The hook will call on the function DarkMode
when macOS enters dark mode and LightMode
when macOS enters light mode. So we need to implement those methods as well for NeoVim. So edit your .vimrc
or init.vim
file and add those methods by copy and paste the content below. This will also make sure that NeoVim always starts with the correct colorscheme.
function! DarkMode()
set background=dark " Replace this with whatever is needed to setup the correct dark mode for you
endfunction
function! LightMode()
set background=light " Replace this with whatever is needed to setup the correct light mode for you
endfunction
if (filereadable(expand("~/.config/appearance/current")) && readfile(expand("~/.config/appearance/current"))[0] == "Light")
call LightMode()
else
call DarkMode()
endif
Copyright © 2021 Alexander Ross