diff options
author | Lewis Russell <lewis6991@gmail.com> | 2023-08-23 11:22:10 +0100 |
---|---|---|
committer | Lewis Russell <me@lewisr.dev> | 2023-08-23 14:45:02 +0100 |
commit | dc45fb4655f5ce56c0bbcb179ef1c38149491d9f (patch) | |
tree | afec32e51f2b23664399144f7ea0d2718b8af388 | |
parent | 32e69bd3971ce864b22d73f3a57cee03727f0b86 (diff) | |
download | rneovim-dc45fb4655f5ce56c0bbcb179ef1c38149491d9f.tar.gz rneovim-dc45fb4655f5ce56c0bbcb179ef1c38149491d9f.tar.bz2 rneovim-dc45fb4655f5ce56c0bbcb179ef1c38149491d9f.zip |
fix(editorconfig): only warn once on errors
-rw-r--r-- | runtime/lua/editorconfig.lua | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/runtime/lua/editorconfig.lua b/runtime/lua/editorconfig.lua index 7311cccbe7..48faa54d97 100644 --- a/runtime/lua/editorconfig.lua +++ b/runtime/lua/editorconfig.lua @@ -1,5 +1,6 @@ local M = {} +--- @type table<string,fun(bufnr: integer, val: string, opts?: table)> M.properties = {} --- Modified version of the builtin assert that does not include error position information @@ -19,7 +20,7 @@ end --- ---@private local function warn(msg, ...) - vim.notify(string.format(msg, ...), vim.log.levels.WARN, { + vim.notify_once(string.format(msg, ...), vim.log.levels.WARN, { title = 'editorconfig', }) end @@ -168,12 +169,12 @@ end --- ---@param filepath string File path of the file to apply EditorConfig settings to ---@param dir string Current directory ----@return table Table of options to apply to the given file +---@return table<string,string|boolean> Table of options to apply to the given file --- ---@private local function parse(filepath, dir) - local pat = nil - local opts = {} + local pat --- @type vim.regex? + local opts = {} --- @type table<string,string|boolean> local f = io.open(dir .. '/.editorconfig') if f then for line in f:lines() do @@ -217,7 +218,7 @@ function M.config(bufnr) return end - local opts = {} + local opts = {} --- @type table<string,string|boolean> for parent in vim.fs.parents(path) do for k, v in pairs(parse(path, parent)) do if opts[k] == nil then @@ -230,7 +231,7 @@ function M.config(bufnr) end end - local applied = {} + local applied = {} --- @type table<string,string|boolean> for opt, val in pairs(opts) do if val ~= 'unset' then local func = M.properties[opt] |