Skip to content

Commit bc61df2

Browse files
authored
Merge pull request #1187 from CppCXY/master
FIX #1175
2 parents 496b61d + bcbf06f commit bc61df2

File tree

3 files changed

+31
-7
lines changed

3 files changed

+31
-7
lines changed

script/provider/formatting.lua

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ local updateType = {
1919
Deleted = 3,
2020
}
2121

22-
fw.event(function (ev, path)
22+
fw.event(function(ev, path)
2323
if util.stringEndWith(path, '.editorconfig') then
2424
for uri, fsPath in pairs(loadedUris) do
2525
loadedUris[uri] = nil
@@ -33,11 +33,6 @@ fw.event(function (ev, path)
3333
end
3434
end)
3535

36-
config.watch(function (uri, key, value)
37-
if key == "Lua.format.defaultConfig" then
38-
codeFormat.set_default_config(value)
39-
end
40-
end)
4136

4237
local m = {}
4338

@@ -48,6 +43,7 @@ function m.updateConfig(uri)
4843
if not m.loadedDefaultConfig then
4944
m.loadedDefaultConfig = true
5045
codeFormat.set_default_config(config.get(uri, 'Lua.format.defaultConfig'))
46+
m.updateNonStandardSymbols(config.get(nil, 'Lua.runtime.nonstandardSymbol'))
5147
end
5248

5349
local currentUri = uri
@@ -80,4 +76,30 @@ function m.updateConfig(uri)
8076
end
8177
end
8278

79+
---@param symbols? string[]
80+
function m.updateNonStandardSymbols(symbols)
81+
if symbols == nil then
82+
return
83+
end
84+
85+
local eqTokens = {}
86+
for token in pairs(symbols) do
87+
if token:find("=") and token ~= "!=" then
88+
table.insert(eqTokens, token)
89+
end
90+
end
91+
92+
if #eqTokens ~= 0 then
93+
codeFormat.set_nonstandard_symbol('=', eqTokens)
94+
end
95+
end
96+
97+
config.watch(function(uri, key, value)
98+
if key == "Lua.format.defaultConfig" then
99+
codeFormat.set_default_config(value)
100+
elseif key == "Lua.runtime.nonstandardSymbol" then
101+
m.updateNonStandardSymbols(value)
102+
end
103+
end)
104+
83105
return m

script/provider/spell.lua

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ end
66
local fs = require 'bee.filesystem'
77
local config = require 'config'
88
local diagnostics = require 'provider.diagnostic'
9+
local pformatting = require 'provider.formatting'
910

1011
local m = {}
1112

@@ -45,6 +46,7 @@ function m.initDictionary()
4546

4647
m.loadDictionaryFromFile(basicDictionary:string())
4748
m.loadDictionaryFromFile(luaDictionary:string())
49+
pformatting.updateNonStandardSymbols(config.get(nil, "Lua.runtime.nonstandardSymbol"))
4850
end
4951

5052
config.watch(function (uri, key, value, oldValue)

0 commit comments

Comments
 (0)