mirror of
https://github.com/neovim/neovim.git
synced 2024-12-24 13:15:09 -07:00
fix(editorconfig): only warn once on errors
This commit is contained in:
parent
32e69bd397
commit
dc45fb4655
@ -1,5 +1,6 @@
|
|||||||
local M = {}
|
local M = {}
|
||||||
|
|
||||||
|
--- @type table<string,fun(bufnr: integer, val: string, opts?: table)>
|
||||||
M.properties = {}
|
M.properties = {}
|
||||||
|
|
||||||
--- Modified version of the builtin assert that does not include error position information
|
--- Modified version of the builtin assert that does not include error position information
|
||||||
@ -19,7 +20,7 @@ end
|
|||||||
---
|
---
|
||||||
---@private
|
---@private
|
||||||
local function warn(msg, ...)
|
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',
|
title = 'editorconfig',
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
@ -168,12 +169,12 @@ end
|
|||||||
---
|
---
|
||||||
---@param filepath string File path of the file to apply EditorConfig settings to
|
---@param filepath string File path of the file to apply EditorConfig settings to
|
||||||
---@param dir string Current directory
|
---@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
|
---@private
|
||||||
local function parse(filepath, dir)
|
local function parse(filepath, dir)
|
||||||
local pat = nil
|
local pat --- @type vim.regex?
|
||||||
local opts = {}
|
local opts = {} --- @type table<string,string|boolean>
|
||||||
local f = io.open(dir .. '/.editorconfig')
|
local f = io.open(dir .. '/.editorconfig')
|
||||||
if f then
|
if f then
|
||||||
for line in f:lines() do
|
for line in f:lines() do
|
||||||
@ -217,7 +218,7 @@ function M.config(bufnr)
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local opts = {}
|
local opts = {} --- @type table<string,string|boolean>
|
||||||
for parent in vim.fs.parents(path) do
|
for parent in vim.fs.parents(path) do
|
||||||
for k, v in pairs(parse(path, parent)) do
|
for k, v in pairs(parse(path, parent)) do
|
||||||
if opts[k] == nil then
|
if opts[k] == nil then
|
||||||
@ -230,7 +231,7 @@ function M.config(bufnr)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local applied = {}
|
local applied = {} --- @type table<string,string|boolean>
|
||||||
for opt, val in pairs(opts) do
|
for opt, val in pairs(opts) do
|
||||||
if val ~= 'unset' then
|
if val ~= 'unset' then
|
||||||
local func = M.properties[opt]
|
local func = M.properties[opt]
|
||||||
|
Loading…
Reference in New Issue
Block a user