diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2022-06-01 07:15:57 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-06-01 07:15:57 +0800 |
commit | bc61df2e50fa78e616eaa2c6039be8808806b894 (patch) | |
tree | ec7ad269baac14a2afa806e44454896cfb98398d /script | |
parent | 496b61d601003619aeb6243300b9b3b0f5be944a (diff) | |
parent | bcbf06f7c4908811bcf490aa43d143c049ce0640 (diff) | |
download | lua-language-server-bc61df2e50fa78e616eaa2c6039be8808806b894.zip |
Merge pull request #1187 from CppCXY/master
FIX #1175
Diffstat (limited to 'script')
-rw-r--r-- | script/provider/formatting.lua | 34 | ||||
-rw-r--r-- | script/provider/spell.lua | 2 |
2 files changed, 30 insertions, 6 deletions
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) |