summaryrefslogtreecommitdiff
path: root/script
diff options
context:
space:
mode:
authorCppCXY <812125110@qq.com>2022-08-17 20:04:37 +0800
committerCppCXY <812125110@qq.com>2022-08-17 20:04:37 +0800
commitc3d602a11de758f14e46a2b49539e5fe9c76dd8c (patch)
tree0660df12b41dafd8bd28d2de949caeb46483e771 /script
parente5ebce3d90da8cb59eee373fa119ad6eb8472546 (diff)
downloadlua-language-server-c3d602a11de758f14e46a2b49539e5fe9c76dd8c.zip
提交typeformat选项相关
Diffstat (limited to 'script')
-rw-r--r--script/config/template.lua3
-rw-r--r--script/core/type-formatting.lua4
2 files changed, 6 insertions, 1 deletions
diff --git a/script/config/template.lua b/script/config/template.lua
index 60f3dbca..a08b9e53 100644
--- a/script/config/template.lua
+++ b/script/config/template.lua
@@ -181,6 +181,7 @@ end, function (self, ...)
self.subs = { ... }
end)
+---@format disable-next
local template = {
['Lua.runtime.version'] = Type.String >> 'Lua 5.4' << {
'Lua 5.1',
@@ -371,6 +372,8 @@ local template = {
['Lua.format.enable'] = Type.Boolean >> true,
['Lua.format.defaultConfig'] = Type.Hash(Type.String, Type.String)
>> {},
+ ['Lua.typeFormat.config'] = Type.Hash(Type.String, Type.String)
+ >> {},
['Lua.spell.dict'] = Type.Array(Type.String),
['Lua.telemetry.enable'] = Type.Or(Type.Boolean >> false, Type.Nil) >> nil,
['Lua.misc.parameters'] = Type.Array(Type.String),
diff --git a/script/core/type-formatting.lua b/script/core/type-formatting.lua
index c6316d80..90892604 100644
--- a/script/core/type-formatting.lua
+++ b/script/core/type-formatting.lua
@@ -2,6 +2,7 @@ local files = require 'files'
local lookBackward = require 'core.look-backward'
local guide = require "parser.guide"
local codeFormat = require "code_format"
+local config = require "config"
local function insertIndentation(uri, position, edits)
local text = files.getText(uri)
@@ -98,7 +99,8 @@ local function typeFormat(results, uri, position, ch, options)
end
local converter = require("proto.converter")
local pos = converter.packPosition(uri, position)
- local success, result = codeFormat.type_format(uri, text, pos.line, pos.character, options)
+ local typeFormatOptions = config.get(uri, 'Lua.typeFormat.config')
+ local success, result = codeFormat.type_format(uri, text, pos.line, pos.character, options, typeFormatOptions)
if success then
local range = result.range
results[#results+1] = {