Skip to content

Commit

Permalink
Merge pull request #1477 from CppCXY/master
Browse files Browse the repository at this point in the history
限制typeformat
  • Loading branch information
sumneko authored Aug 23, 2022
2 parents 4405d92 + 1515018 commit 58d02c9
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion 3rd/EmmyLuaCodeStyle
Submodule EmmyLuaCodeStyle updated 32 files
+46 −0 CHANGELOG.md
+19 −2 CodeFormatLib/src/CodeFormatLib.cpp
+3 −2 CodeFormatLib/src/LuaCodeFormat.cpp
+3 −2 CodeFormatLib/src/LuaCodeFormat.h
+3 −2 CodeFormatServer/src/LanguageService.cpp
+4 −2 CodeService/CMakeLists.txt
+58 −0 CodeService/src/FormatElement/SepElement.cpp
+39 −0 CodeService/src/LuaEditorConfig.cpp
+100 −3 CodeService/src/LuaFormatter.cpp
+16 −3 CodeService/src/TypeFormat/LuaTypeFormat.cpp
+18 −0 CodeService/src/TypeFormat/LuaTypeFormatOptions.cpp
+10 −0 Test/test_script/format_text/wait_format_by_option/.editorconfig
+15 −0 Test/test_script/format_text/wait_format_by_option/table_separator_style-eq-comma.lua
+15 −0 Test/test_script/format_text/wait_format_by_option/table_separator_style-eq-semicolon.lua
+8 −0 Test/test_script/format_text/wait_format_by_option/trailing_table_separator-eq-always.lua
+8 −0 Test/test_script/format_text/wait_format_by_option/trailing_table_separator-eq-never.lua
+8 −0 Test/test_script/format_text/wait_format_by_option/trailing_table_separator-eq-smart.lua
+10 −0 Test/test_script/format_text/wait_format_by_option_should_be/.editorconfig
+15 −0 Test/test_script/format_text/wait_format_by_option_should_be/table_separator_style-eq-comma.lua
+15 −0 Test/test_script/format_text/wait_format_by_option_should_be/table_separator_style-eq-semicolon.lua
+8 −0 Test/test_script/format_text/wait_format_by_option_should_be/trailing_table_separator-eq-always.lua
+8 −0 Test/test_script/format_text/wait_format_by_option_should_be/trailing_table_separator-eq-never.lua
+8 −0 Test/test_script/format_text/wait_format_by_option_should_be/trailing_table_separator-eq-smart.lua
+1 −0 include/CodeService/FormatElement/FormatElementType.h
+18 −0 include/CodeService/FormatElement/SepElement.h
+1 −2 include/CodeService/FormatElement/TextElement.h
+15 −0 include/CodeService/LuaCodeStyleEnum.h
+4 −2 include/CodeService/LuaCodeStyleOptions.h
+2 −0 include/CodeService/LuaFormatter.h
+5 −3 include/CodeService/TypeFormat/LuaTypeFormat.h
+13 −0 include/CodeService/TypeFormat/LuaTypeFormatOptions.h
+7 −1 lua.template.editorconfig
1 change: 1 addition & 0 deletions make/code_format.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
6 changes: 6 additions & 0 deletions script/config/template.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -371,6 +372,11 @@ 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)
>> {
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),
Expand Down
4 changes: 3 additions & 1 deletion script/core/type-formatting.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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] = {
Expand Down

0 comments on commit 58d02c9

Please sign in to comment.