mirror of
https://github.com/neovim/neovim.git
synced 2026-01-05 02:47:28 +10:00
feat(editorconfig): allow editorconfig to be toggled dynamically
Rather than only check `editorconfig_enable` when the plugin is loaded, check it each time the autocommand fires, so that users may enable or disable it dynamically. Also check for a buffer local version of the variable, so that editorconfig can be enabled or disabled per-buffer.
This commit is contained in:
@@ -1,11 +1,14 @@
|
||||
if vim.g.editorconfig_enable == false or vim.g.editorconfig_enable == 0 then
|
||||
return
|
||||
end
|
||||
|
||||
local group = vim.api.nvim_create_augroup('editorconfig', {})
|
||||
vim.api.nvim_create_autocmd({ 'BufNewFile', 'BufRead', 'BufFilePost' }, {
|
||||
group = group,
|
||||
callback = function(args)
|
||||
-- Buffer-local enable has higher priority
|
||||
local enable =
|
||||
vim.F.if_nil(vim.b.editorconfig_enable, vim.F.if_nil(vim.g.editorconfig_enable, true))
|
||||
if not enable then
|
||||
return
|
||||
end
|
||||
|
||||
require('editorconfig').config(args.buf)
|
||||
end,
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user