diff options
author | CppCXY <812125110@qq.com> | 2022-02-21 11:56:42 +0800 |
---|---|---|
committer | CppCXY <812125110@qq.com> | 2022-02-21 11:56:42 +0800 |
commit | bfcbdd35745ff1fc821781ec2153edfe87c63767 (patch) | |
tree | a4176bac90828ef5fe99cc6ee43021d4b70dc2d4 /script | |
parent | 1d3698919f08ebd53ccdc76ba3eb301886eaddf4 (diff) | |
download | lua-language-server-bfcbdd35745ff1fc821781ec2153edfe87c63767.zip |
提供默认配置
Diffstat (limited to 'script')
-rw-r--r-- | script/config/config.lua | 2 | ||||
-rw-r--r-- | script/provider/formatting.lua | 14 |
2 files changed, 16 insertions, 0 deletions
diff --git a/script/config/config.lua b/script/config/config.lua index e44b9372..a430d623 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 >> false, + ['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('^(.+)/[^/]*$') |