Skip to content

Commit c3d602a

Browse files
committed
提交typeformat选项相关
1 parent e5ebce3 commit c3d602a

File tree

4 files changed

+8
-2
lines changed

4 files changed

+8
-2
lines changed

make/code_format.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ lm:source_set 'code_format' {
2121
"Util/src/Utf8.cpp",
2222
--CodeService
2323
"CodeService/src/*.cpp",
24+
"CodeService/src/TypeFormat/*.cpp",
2425
"CodeService/src/Spell/*.cpp",
2526
"Util/src/SymSpell/*.cpp",
2627
"CodeService/src/FormatElement/*.cpp",

script/config/template.lua

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ end, function (self, ...)
181181
self.subs = { ... }
182182
end)
183183

184+
---@format disable-next
184185
local template = {
185186
['Lua.runtime.version'] = Type.String >> 'Lua 5.4' << {
186187
'Lua 5.1',
@@ -371,6 +372,8 @@ local template = {
371372
['Lua.format.enable'] = Type.Boolean >> true,
372373
['Lua.format.defaultConfig'] = Type.Hash(Type.String, Type.String)
373374
>> {},
375+
['Lua.typeFormat.config'] = Type.Hash(Type.String, Type.String)
376+
>> {},
374377
['Lua.spell.dict'] = Type.Array(Type.String),
375378
['Lua.telemetry.enable'] = Type.Or(Type.Boolean >> false, Type.Nil) >> nil,
376379
['Lua.misc.parameters'] = Type.Array(Type.String),

script/core/type-formatting.lua

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ local files = require 'files'
22
local lookBackward = require 'core.look-backward'
33
local guide = require "parser.guide"
44
local codeFormat = require "code_format"
5+
local config = require "config"
56

67
local function insertIndentation(uri, position, edits)
78
local text = files.getText(uri)
@@ -98,7 +99,8 @@ local function typeFormat(results, uri, position, ch, options)
9899
end
99100
local converter = require("proto.converter")
100101
local pos = converter.packPosition(uri, position)
101-
local success, result = codeFormat.type_format(uri, text, pos.line, pos.character, options)
102+
local typeFormatOptions = config.get(uri, 'Lua.typeFormat.config')
103+
local success, result = codeFormat.type_format(uri, text, pos.line, pos.character, options, typeFormatOptions)
102104
if success then
103105
local range = result.range
104106
results[#results+1] = {

0 commit comments

Comments
 (0)