diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2022-02-21 15:43:48 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-02-21 15:43:48 +0800 |
commit | 604d7ff0446d2cd5a0786cb7ace95f5dfc8f41e6 (patch) | |
tree | 781792ce96653d8813a583646ad03c0b337cb834 | |
parent | 7baf51cb7879aa39d4d9b9911300e49ee34d3ace (diff) | |
parent | e518eed9efd99c46b79c9413c5f34a0f675ab9e6 (diff) | |
download | lua-language-server-604d7ff0446d2cd5a0786cb7ace95f5dfc8f41e6.zip |
Merge pull request #959 from CppCXY/master
format support default config by setting
m--------- | 3rd/bee.lua | 0 | ||||
m--------- | 3rd/lovr-api | 0 | ||||
m--------- | 3rd/luamake | 0 | ||||
-rw-r--r-- | script/config/config.lua | 2 | ||||
-rw-r--r-- | script/provider/formatting.lua | 14 |
5 files changed, 16 insertions, 0 deletions
diff --git a/3rd/bee.lua b/3rd/bee.lua -Subproject fc279325867aecb7ed4a33acabe5fb465335146 +Subproject 226b4f55938dff7e3424437aac77e1b0932d98c diff --git a/3rd/lovr-api b/3rd/lovr-api -Subproject 6f1dab44936aeec43d5288af8fdfbd80ddcecb4 +Subproject 460b954143b298a580ef3f7bffff2fc621545f3 diff --git a/3rd/luamake b/3rd/luamake -Subproject 909a3bf9770c61efc8a3050402ecbfa4daf24dd +Subproject 843262572a2765ebe187573e32c4f8f22952c2c diff --git a/script/config/config.lua b/script/config/config.lua index ea87893d..8c06278f 100644 --- a/script/config/config.lua +++ b/script/config/config.lua @@ -209,6 +209,8 @@ local Template = { ['Lua.window.statusBar'] = Type.Boolean >> true, ['Lua.window.progressBar'] = Type.Boolean >> true, ['Lua.format.enable'] = Type.Boolean >> true, + ['Lua.format.defaultConfig'] = Type.Hash(Type.String, Type.String) + >> {}, ['Lua.IntelliSense.traceLocalSet'] = Type.Boolean >> false, ['Lua.IntelliSense.traceReturn'] = Type.Boolean >> false, ['Lua.IntelliSense.traceBeSetted'] = Type.Boolean >> false, diff --git a/script/provider/formatting.lua b/script/provider/formatting.lua index 9392259e..f73b0dc0 100644 --- a/script/provider/formatting.lua +++ b/script/provider/formatting.lua @@ -5,6 +5,7 @@ local fs = require 'bee.filesystem' local fw = require 'filewatch' local util = require 'utility' local diagnostics = require 'provider.diagnostic' +local config = require 'config' local loadedUris = {} @@ -31,10 +32,23 @@ 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 = {} +m.loadedDefaultConfig = false + ---@param uri uri function m.updateConfig(uri) + if not m.loadedDefaultConfig then + m.loadedDefaultConfig = true + codeFormat.set_default_config(config.get(uri, 'Lua.format.defaultConfig')) + end + local currentUri = uri while true do currentUri = currentUri:match('^(.+)/[^/]*$') |