fix(dials): dials.nvim stopped working after making changes to plugin files

This commit is contained in:
Folke Lemaitre 2024-07-03 19:06:43 +02:00
parent b9a8a4ad7f
commit 455557c1f6
No known key found for this signature in database
GPG key ID: 41F8B1FBACAE2040

View file

@ -1,6 +1,4 @@
local M = {} local M = {}
---@type table<string, table<string, string[]>>
M.dials_by_ft = {}
---@param increment boolean ---@param increment boolean
---@param g? boolean ---@param g? boolean
@ -9,7 +7,7 @@ function M.dial(increment, g)
-- Use visual commands for VISUAL 'v', VISUAL LINE 'V' and VISUAL BLOCK '\22' -- Use visual commands for VISUAL 'v', VISUAL LINE 'V' and VISUAL BLOCK '\22'
local is_visual = mode == "v" or mode == "V" or mode == "\22" local is_visual = mode == "v" or mode == "V" or mode == "\22"
local func = (increment and "inc" or "dec") .. (g and "_g" or "_") .. (is_visual and "visual" or "normal") local func = (increment and "inc" or "dec") .. (g and "_g" or "_") .. (is_visual and "visual" or "normal")
local group = M.dials_by_ft[vim.bo.filetype] or "default" local group = vim.g.dials_by_ft[vim.bo.filetype] or "default"
return require("dial.map")[func](group) return require("dial.map")[func](group)
end end
@ -170,6 +168,6 @@ return {
end, end,
config = function(_, opts) config = function(_, opts)
require("dial.config").augends:register_group(opts.groups) require("dial.config").augends:register_group(opts.groups)
M.dials_by_ft = opts.dials_by_ft vim.g.dials_by_ft = opts.dials_by_ft
end, end,
} }