Skip to content

Commit

Permalink
fix(ex.lsp.null_ls): Fix mock for absent none-ls plugin
Browse files Browse the repository at this point in the history
.
  • Loading branch information
vladimir-popov committed Jun 8, 2024
1 parent 0840c9b commit eaa09f0
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions lua/lualine/components/ex/lsp/null_ls.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ local log = require('plenary.log').new({ plugin = 'ex.lsp.null-ls' })
-- we should be ready to three possible cases:
-- * when null-ls is not loaded we should load it only on demand;
-- * when null-ls is not installed we should mock it to avoid errors;
-- * when it is installed and loaded we should it use it.
-- * when it is installed and loaded we should use it.
local null_ls = setmetatable({}, {
__index = function(self, key)
-- attempt to lazy load null-ls plugin
Expand All @@ -12,9 +12,9 @@ local null_ls = setmetatable({}, {
rawset(self, 'is_installed', is_installed)
rawset(self, 'null_ls', null_ls)
if is_installed then
log.debug('null-ls is installed')
log.debug('none-ls is installed')
else
log.warn('null-ls is not installed.')
log.warn('none-ls is not installed.')
end
end
-- return original plugin if it's installed
Expand All @@ -23,9 +23,13 @@ local null_ls = setmetatable({}, {
end
-- return mock:
if key == 'get_source' then
return {}
return function()
return {}
end
elseif key == 'is_registered' then
return false
return function()
return false
end
else
return nil
end
Expand Down

0 comments on commit eaa09f0

Please sign in to comment.