From c3d602a11de758f14e46a2b49539e5fe9c76dd8c Mon Sep 17 00:00:00 2001 From: CppCXY <812125110@qq.com> Date: Wed, 17 Aug 2022 20:04:37 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E6=8F=90=E4=BA=A4typeformat=E9=80=89?= =?UTF-8?q?=E9=A1=B9=E7=9B=B8=E5=85=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 3rd/EmmyLuaCodeStyle | 2 +- make/code_format.lua | 1 + script/config/template.lua | 3 +++ script/core/type-formatting.lua | 4 +++- 4 files changed, 8 insertions(+), 2 deletions(-) diff --git a/3rd/EmmyLuaCodeStyle b/3rd/EmmyLuaCodeStyle index 2265c0a5c..3ab6c9ff8 160000 --- a/3rd/EmmyLuaCodeStyle +++ b/3rd/EmmyLuaCodeStyle @@ -1 +1 @@ -Subproject commit 2265c0a5c472298c34e05c1f15745bf20f1cc950 +Subproject commit 3ab6c9ff8b91e07c3135afaa6620bd528aa7628a diff --git a/make/code_format.lua b/make/code_format.lua index 6cf5cfd7d..387221b37 100644 --- a/make/code_format.lua +++ b/make/code_format.lua @@ -21,6 +21,7 @@ lm:source_set 'code_format' { "Util/src/Utf8.cpp", --CodeService "CodeService/src/*.cpp", + "CodeService/src/TypeFormat/*.cpp", "CodeService/src/Spell/*.cpp", "Util/src/SymSpell/*.cpp", "CodeService/src/FormatElement/*.cpp", diff --git a/script/config/template.lua b/script/config/template.lua index 60f3dbca0..a08b9e53c 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 c6316d805..908926045 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] = { From e279acb08829e31cdaae87f93c1c187d87907e57 Mon Sep 17 00:00:00 2001 From: CppCXY <812125110@qq.com> Date: Wed, 17 Aug 2022 20:18:47 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E9=BB=98=E8=AE=A4=E4=B8=80=E4=BA=9B?= =?UTF-8?q?=E9=80=89=E9=A1=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- script/config/template.lua | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/script/config/template.lua b/script/config/template.lua index a08b9e53c..14c341e1a 100644 --- a/script/config/template.lua +++ b/script/config/template.lua @@ -373,7 +373,10 @@ local template = { ['Lua.format.defaultConfig'] = Type.Hash(Type.String, Type.String) >> {}, ['Lua.typeFormat.config'] = Type.Hash(Type.String, Type.String) - >> {}, + >> { + format_line = "true", + auto_complete_end = "true" + }, ['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), From 82ff780ca08bb6b7070746b87a52cf4ac3b5068a Mon Sep 17 00:00:00 2001 From: CppCXY <812125110@qq.com> Date: Tue, 23 Aug 2022 10:19:10 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E6=B5=8B=E8=AF=95type=20format=E5=B1=8F?= =?UTF-8?q?=E8=94=BD=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 3rd/EmmyLuaCodeStyle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/3rd/EmmyLuaCodeStyle b/3rd/EmmyLuaCodeStyle index 3ab6c9ff8..763d15e01 160000 --- a/3rd/EmmyLuaCodeStyle +++ b/3rd/EmmyLuaCodeStyle @@ -1 +1 @@ -Subproject commit 3ab6c9ff8b91e07c3135afaa6620bd528aa7628a +Subproject commit 763d15e0160aca5535f3c3b938b2230cbaea4c90