Skip to content

Commit

Permalink
target neovim 0.4.4
Browse files Browse the repository at this point in the history
  • Loading branch information
cormacrelf committed Sep 17, 2020
1 parent 447e51d commit 5087492
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ brew install cormacrelf/tap/dark-notify

## Neovim usage

Then add a plugin with your favourite plugin manager:
Requires neovim 0.4.4 or later.

Add a plugin with your favourite plugin manager:

```vim
Plug 'cormacrelf/dark-notify'
Expand Down
20 changes: 15 additions & 5 deletions lua/dark_notify.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,25 @@ function trim6(s)
return s:match'^()%s*$' and '' or s:match'^%s*(.*%S)'
end

-- See https://github.com/neovim/neovim/issues/12544
-- neovim 0.5.0 will have vim.g.variable_name, but let's target 0.4.4 as it's already released
function mk_config()
local exists = vim.api.nvim_call_function("exists", {"dark_notify_config"})
if exists ~= 1 then
vim.api.nvim_set_var("dark_notify_config", {})
end
end

function get_config()
return vim.g.dark_switcher_config or {}
mk_config()
return vim.api.nvim_get_var("dark_notify_config")
end

-- See https://github.com/neovim/neovim/issues/12544
function edit_config(fn)
local edit = vim.g.dark_switcher_config or {}
mk_config()
local edit = vim.api.nvim_get_var("dark_notify_config")
fn(edit)
vim.g.dark_switcher_config = edit
vim.api.nvim_set_var("dark_notify_config", edit)
end

function apply_mode(mode)
Expand All @@ -28,7 +38,7 @@ function apply_mode(mode)

-- now try to reload lightline
local reloader = config.lightline_loaders[lltheme]
local lightline = vim.call("exists", "g:loaded_lightline")
local lightline = vim.api.nvim_call_function("exists", {"g:loaded_lightline"})

if lightline == 1 then
local update = false
Expand Down

0 comments on commit 5087492

Please sign in to comment.