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 45 files
+1 −0 .clang-format
+68 −1 CHANGELOG.md
+110 −51 CodeFormatLib/src/CodeFormatLib.cpp
+12 −5 CodeFormatLib/src/LuaCodeFormat.cpp
+2 −0 CodeFormatLib/src/LuaCodeFormat.h
+3 −3 CodeFormatLib/src/Types.h
+40 −6 CodeFormatServer/src/Config/ClientConfig.cpp
+4 −5 CodeFormatServer/src/Config/ClientConfig.h
+0 −3 CodeFormatServer/src/LSP/LSPHandle.cpp
+9 −12 CodeFormatServer/src/Service/ConfigService.cpp
+119 −0 CodeService/src/Config/LuaDiagnosticStyle.cpp
+10 −0 CodeService/src/Config/LuaStyle.cpp
+21 −32 CodeService/src/Diagnostic/NameStyle/NameStyleChecker.cpp
+70 −75 CodeService/src/Diagnostic/NameStyle/NameStyleRuleMatcher.cpp
+31 −25 CodeService/src/Format/Analyzer/AlignAnalyzer.cpp
+1 −1 CodeService/src/Format/Analyzer/LineBreakAnalyzer.cpp
+1 −0 README.md
+2 −0 README_EN.md
+10 −0 Test/src/FormatResult_unitest.cpp
+43 −4 Test/src/FormatStyle_unitest.cpp
+1 −4 Test2/src/FormatTest2.cpp
+25 −23 Util/CMakeLists.txt
+166 −0 Util/src/InfoTree/InfoNode.cpp
+85 −0 Util/src/InfoTree/InfoTree.cpp
+96 −0 docs/name_style.md
+95 −0 docs/name_style_EN.md
+5 −3 include/CodeService/Config/LuaDiagnosticStyle.h
+0 −24 include/CodeService/Config/LuaDiagnosticStyleEnum.h
+1 −0 include/CodeService/Config/LuaStyle.h
+6 −0 include/CodeService/Config/LuaStyleEnum.h
+54 −0 include/CodeService/Config/NameStyleRule.h
+6 −6 include/CodeService/Diagnostic/CodeStyle/CodeStyleChecker.h
+5 −5 include/CodeService/Diagnostic/NameStyle/NameStyleChecker.h
+8 −10 include/CodeService/Diagnostic/NameStyle/NameStyleRuleMatcher.h
+3 −1 include/CodeService/Format/Analyzer/AlignAnalyzer.h
+4 −7 include/Util/CommandLine.h
+2 −2 include/Util/FileFinder.h
+10 −0 include/Util/InfoTree/InfoKind.h
+60 −0 include/Util/InfoTree/InfoNode.h
+44 −0 include/Util/InfoTree/InfoTree.h
+3 −3 include/Util/StringUtil.h
+4 −4 include/Util/Url.h
+2 −2 include/Util/Utf8.h
+144 −188 include/Util/format.h
+3 −0 lua.template.editorconfig
4 changes: 4 additions & 0 deletions locale/en-us/setting.lua
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,8 @@ Read [formatter docs](https://github.com/CppCXY/EmmyLuaCodeStyle/tree/master/doc
]]
config.spell.dict =
'Custom words for spell checking.'
config.nameStyle.config =
'Set name style config'
config.telemetry.enable =
[[
Enable telemetry to send your editor information and error logs over the network. Read our privacy policy [here](https://github.com/LuaLS/lua-language-server/wiki/Home#privacy).
Expand Down Expand Up @@ -401,6 +403,8 @@ config.diagnostics['return-type-mismatch'] =
'Enable diagnostics for return values whose type does not match the type declared in the corresponding return annotation.'
config.diagnostics['spell-check'] =
'Enable diagnostics for typos in strings.'
config.diagnostics['name-style-check'] =
'Enable diagnostics for name style.'
config.diagnostics['unbalanced-assignments']=
'Enable diagnostics on multiple assignments if not all variables obtain a value (e.g., `local x,y = 1`).'
config.diagnostics['undefined-doc-class'] =
Expand Down
4 changes: 4 additions & 0 deletions locale/pt-br/setting.lua
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,8 @@ Read [formatter docs](https://github.com/CppCXY/EmmyLuaCodeStyle/tree/master/doc
]]
config.spell.dict = -- TODO: need translate!
'Custom words for spell checking.'
config.nameStyle.config = -- TODO: need translate!
'Set name style config'
config.telemetry.enable = -- TODO: need translate!
[[
Enable telemetry to send your editor information and error logs over the network. Read our privacy policy [here](https://github.com/LuaLS/lua-language-server/wiki/Home#privacy).
Expand Down Expand Up @@ -401,6 +403,8 @@ config.diagnostics['return-type-mismatch'] = -- TODO: need translate!
'Enable diagnostics for return values whose type does not match the type declared in the corresponding return annotation.'
config.diagnostics['spell-check'] = -- TODO: need translate!
'Enable diagnostics for typos in strings.'
config.diagnostics['name-style-check'] = -- TODO: need translate!
'Enable diagnostics for name style.'
config.diagnostics['unbalanced-assignments']= -- TODO: need translate!
'Enable diagnostics on multiple assignments if not all variables obtain a value (e.g., `local x,y = 1`).'
config.diagnostics['undefined-doc-class'] = -- TODO: need translate!
Expand Down
4 changes: 4 additions & 0 deletions locale/zh-cn/setting.lua
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,8 @@ config.format.defaultConfig =
]]
config.spell.dict =
'拼写检查的自定义单词。'
config.nameStyle.config =
'设定命名风格检查的配置'
config.telemetry.enable =
[[
启用遥测,通过网络发送你的编辑器信息与错误日志。在[此处](https://github.com/LuaLS/lua-language-server/wiki/Home#privacy)阅读我们的隐私声明。
Expand Down Expand Up @@ -400,6 +402,8 @@ config.diagnostics['return-type-mismatch'] = -- TODO: need translate!
'Enable diagnostics for return values whose type does not match the type declared in the corresponding return annotation.'
config.diagnostics['spell-check'] = -- TODO: need translate!
'Enable diagnostics for typos in strings.'
config.diagnostics['name-style-check'] = -- TODO: need translate!
'Enable diagnostics for name style.'
config.diagnostics['unbalanced-assignments']= -- TODO: need translate!
'Enable diagnostics on multiple assignments if not all variables obtain a value (e.g., `local x,y = 1`).'
config.diagnostics['undefined-doc-class'] = -- TODO: need translate!
Expand Down
4 changes: 4 additions & 0 deletions locale/zh-tw/setting.lua
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,8 @@ config.format.defaultConfig =
]]
config.spell.dict =
'拼寫檢查的自訂單詞。'
config.nameStyle.config = -- TODO: need translate!
'Set name style config'
config.telemetry.enable =
[[
啟用遙測,透過網路發送你的編輯器資訊與錯誤日誌。在[此處](https://github.com/LuaLS/lua-language-server/wiki/Home#privacy)閱讀我們的隱私聲明。
Expand Down Expand Up @@ -400,6 +402,8 @@ config.diagnostics['return-type-mismatch'] = -- TODO: need translate!
'Enable diagnostics for return values whose type does not match the type declared in the corresponding return annotation.'
config.diagnostics['spell-check'] = -- TODO: need translate!
'Enable diagnostics for typos in strings.'
config.diagnostics['name-style-check'] = -- TODO: need translate!
'Enable diagnostics for name style.'
config.diagnostics['unbalanced-assignments']= -- TODO: need translate!
'Enable diagnostics on multiple assignments if not all variables obtain a value (e.g., `local x,y = 1`).'
config.diagnostics['undefined-doc-class'] = -- TODO: need translate!
Expand Down
1 change: 1 addition & 0 deletions make/code_format.lua
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ lm:source_set 'code_format' {
"Util/src/StringUtil.cpp",
"Util/src/Utf8.cpp",
"Util/src/SymSpell/*.cpp",
"Util/src/InfoTree/*.cpp",
--CodeService
"CodeService/src/**/*.cpp",
},
Expand Down
2 changes: 2 additions & 0 deletions script/config/template.lua
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,8 @@ local template = {
auto_complete_table_sep = "true"
},
['Lua.spell.dict'] = Type.Array(Type.String),
['Lua.nameStyle.config'] = Type.Hash(Type.String, Type.Or(Type.String, Type.Array(Type.Hash(Type.String, Type.String))))
>> {},
['Lua.misc.parameters'] = Type.Array(Type.String),
['Lua.misc.executablePath'] = Type.String,
['Lua.type.castNumberToInteger'] = Type.Boolean >> true,
Expand Down
35 changes: 35 additions & 0 deletions script/core/diagnostics/name-style-check.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
local files = require 'files'
local converter = require 'proto.converter'
local log = require 'log'
local nameStyle = require 'provider.name-style'


---@async
return function (uri, callback)
local state = files.getState(uri)
if not state then
return
end
local text = state.originText

local status, diagnosticInfos = nameStyle.nameStyleCheck(uri, text)

if not status then
if diagnosticInfos ~= nil then
log.error(diagnosticInfos)
end

return
end

if diagnosticInfos then
for _, diagnosticInfo in ipairs(diagnosticInfos) do
callback {
start = converter.unpackPosition(state, diagnosticInfo.range.start),
finish = converter.unpackPosition(state, diagnosticInfo.range["end"]),
message = diagnosticInfo.message,
data = diagnosticInfo.data
}
end
end
end
8 changes: 8 additions & 0 deletions script/proto/diagnostic.lua
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,14 @@ m.register {
status = 'None',
}

m.register {
'name-style-check'
} {
group = 'codestyle',
severity = 'Warning',
status = 'None',
}

m.register {
'newline-call',
'newfield-call',
Expand Down
28 changes: 28 additions & 0 deletions script/provider/name-style.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
local suc, codeFormat = pcall(require, 'code_format')
if not suc then
return
end

local config = require 'config'

local m = {}

m.loaded = false

function m.nameStyleCheck(uri, text)
if not m.loaded then
local value = config.get(nil, "Lua.nameStyle.config")
codeFormat.update_name_style_config(value)
m.loaded = true
end

return codeFormat.name_style_analysis(uri, text)
end

config.watch(function (uri, key, value)
if key == "Lua.nameStyle.config" then
codeFormat.update_name_style_config(value)
end
end)

return m