diff options
m--------- | 3rd/EmmyLuaCodeStyle | 0 | ||||
-rw-r--r-- | script/provider/formatting.lua | 35 | ||||
-rw-r--r-- | script/provider/spell.lua | 2 |
3 files changed, 31 insertions, 6 deletions
diff --git a/3rd/EmmyLuaCodeStyle b/3rd/EmmyLuaCodeStyle -Subproject 1bdfe5a82bc1bac0251d463bcec1af5768e5f65 +Subproject 8f513f2cf3f007ea5f1240176761a408f3d343d diff --git a/script/provider/formatting.lua b/script/provider/formatting.lua index 73b6608d..2c8a222e 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 @@ -36,11 +36,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 = {} @@ -51,6 +46,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 @@ -83,4 +79,31 @@ 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 + local result = codeFormat.set_nonstandard_symbol('=', eqTokens) + log.info(result) + 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) |