diff options
m--------- | 3rd/EmmyLuaCodeStyle | 0 | ||||
-rw-r--r-- | script/provider/formatting.lua | 34 | ||||
-rw-r--r-- | script/provider/spell.lua | 2 |
3 files changed, 30 insertions, 6 deletions
diff --git a/3rd/EmmyLuaCodeStyle b/3rd/EmmyLuaCodeStyle -Subproject e3f93a9032a80ac77533ffc5f94c45eaf0b21d7 +Subproject 8f513f2cf3f007ea5f1240176761a408f3d343d diff --git a/script/provider/formatting.lua b/script/provider/formatting.lua index 78f962ea..4c153330 100644 --- a/script/provider/formatting.lua +++ b/script/provider/formatting.lua @@ -19,7 +19,7 @@ local updateType = { Deleted = 3, } -fw.event(function (ev, path) +fw.event(function(ev, path) if util.stringEndWith(path, '.editorconfig') then for uri, fsPath in pairs(loadedUris) do loadedUris[uri] = nil @@ -33,11 +33,6 @@ fw.event(function (ev, path) end end) -config.watch(function (uri, key, value) - if key == "Lua.format.defaultConfig" then - codeFormat.set_default_config(value) - end -end) local m = {} @@ -48,6 +43,7 @@ function m.updateConfig(uri) if not m.loadedDefaultConfig then m.loadedDefaultConfig = true codeFormat.set_default_config(config.get(uri, 'Lua.format.defaultConfig')) + m.updateNonStandardSymbols(config.get(nil, 'Lua.runtime.nonstandardSymbol')) end local currentUri = uri @@ -80,4 +76,30 @@ function m.updateConfig(uri) end end +---@param symbols? string[] +function m.updateNonStandardSymbols(symbols) + if symbols == nil then + return + end + + local eqTokens = {} + for token in pairs(symbols) do + if token:find("=") and token ~= "!=" then + table.insert(eqTokens, token) + end + end + + if #eqTokens ~= 0 then + codeFormat.set_nonstandard_symbol('=', eqTokens) + end +end + +config.watch(function(uri, key, value) + if key == "Lua.format.defaultConfig" then + codeFormat.set_default_config(value) + elseif key == "Lua.runtime.nonstandardSymbol" then + m.updateNonStandardSymbols(value) + end +end) + return m diff --git a/script/provider/spell.lua b/script/provider/spell.lua index b315b3aa..60efc223 100644 --- a/script/provider/spell.lua +++ b/script/provider/spell.lua @@ -6,6 +6,7 @@ end local fs = require 'bee.filesystem' local config = require 'config' local diagnostics = require 'provider.diagnostic' +local pformatting = require 'provider.formatting' local m = {} @@ -45,6 +46,7 @@ function m.initDictionary() m.loadDictionaryFromFile(basicDictionary:string()) m.loadDictionaryFromFile(luaDictionary:string()) + pformatting.updateNonStandardSymbols(config.get(nil, "Lua.runtime.nonstandardSymbol")) end config.watch(function (uri, key, value, oldValue) |