Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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