Add condition function to module config

The function is called with the language and bufnr, if it returns false,
the module is disabled for that buffer.

This gives the user more fine-grained control over whether a module is
started.
This commit is contained in:
patrick96 2021-11-09 18:24:35 +01:00 committed by Stephan Seitz
parent 6888242b98
commit e3dabec462
2 changed files with 12 additions and 6 deletions

View file

@ -58,7 +58,7 @@ local function longest_string_length(list)
return length
end
local function append_module_table(curbuf, parserlist, namespace, modulelist)
local function append_module_table(curbuf, origbuf, parserlist, namespace, modulelist)
local maxlen_parser = longest_string_length(parserlist)
table.sort(modulelist)
@ -77,7 +77,7 @@ local function append_module_table(curbuf, parserlist, namespace, modulelist)
for _, module in pairs(modulelist) do
local modlen = #module
module = namespace_prefix .. module
if configs.is_enabled(module, parser) then
if configs.is_enabled(module, parser, origbuf) then
line = line .. ""
else
line = line .. ""
@ -91,6 +91,7 @@ local function append_module_table(curbuf, parserlist, namespace, modulelist)
end
local function print_info_modules(parserlist, module)
local origbuf = api.nvim_get_current_buf()
api.nvim_command "enew"
local curbuf = api.nvim_get_current_buf()
@ -109,7 +110,7 @@ local function print_info_modules(parserlist, module)
table.sort(parserlist)
for _, namespace in ipairs(namespaces) do
append_module_table(curbuf, parserlist, namespace, modules[namespace])
append_module_table(curbuf, origbuf, parserlist, namespace, modules[namespace])
end
api.nvim_buf_set_option(curbuf, "modified", false)