Skip to content

Commit 604d7ff

Browse files
authored
Merge pull request #959 from CppCXY/master
format support default config by setting
2 parents 7baf51c + e518eed commit 604d7ff

File tree

5 files changed

+19
-3
lines changed

5 files changed

+19
-3
lines changed

3rd/bee.lua

3rd/luamake

Submodule luamake updated 1 file

script/config/config.lua

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,8 @@ local Template = {
209209
['Lua.window.statusBar'] = Type.Boolean >> true,
210210
['Lua.window.progressBar'] = Type.Boolean >> true,
211211
['Lua.format.enable'] = Type.Boolean >> true,
212+
['Lua.format.defaultConfig'] = Type.Hash(Type.String, Type.String)
213+
>> {},
212214
['Lua.IntelliSense.traceLocalSet'] = Type.Boolean >> false,
213215
['Lua.IntelliSense.traceReturn'] = Type.Boolean >> false,
214216
['Lua.IntelliSense.traceBeSetted'] = Type.Boolean >> false,

script/provider/formatting.lua

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ local fs = require 'bee.filesystem'
55
local fw = require 'filewatch'
66
local util = require 'utility'
77
local diagnostics = require 'provider.diagnostic'
8+
local config = require 'config'
89

910
local loadedUris = {}
1011

@@ -31,10 +32,23 @@ fw.event(function (ev, path)
3132
end
3233
end)
3334

35+
config.watch(function (uri, key, value)
36+
if key == "Lua.format.defaultConfig" then
37+
codeFormat.set_default_config(value)
38+
end
39+
end)
40+
3441
local m = {}
3542

43+
m.loadedDefaultConfig = false
44+
3645
---@param uri uri
3746
function m.updateConfig(uri)
47+
if not m.loadedDefaultConfig then
48+
m.loadedDefaultConfig = true
49+
codeFormat.set_default_config(config.get(uri, 'Lua.format.defaultConfig'))
50+
end
51+
3852
local currentUri = uri
3953
while true do
4054
currentUri = currentUri:match('^(.+)/[^/]*$')

0 commit comments

Comments
 (0)