Skip to content

Commit 3f0d26e

Browse files
committed
cleanup
1 parent 5ad56c9 commit 3f0d26e

File tree

12 files changed

+127
-34
lines changed

12 files changed

+127
-34
lines changed

.editorconfig

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
# see https://github.com/CppCXY/EmmyLuaCodeStyle
2+
[*.lua]
3+
# [basic code reformat option]
4+
# optional space/tab
5+
indent_style = space
6+
# if indent_style is space, this is valid
7+
indent_size = 4
8+
# if indent_style is tab, this is valid
9+
tab_width = 4
10+
# only support number
11+
continuation_indent_size = 4
12+
# if true, continuation_indent_size for local or assign statement is invalid
13+
# however, if the expression list has cross row expression, it will not be aligned to the first expression
14+
local_assign_continuation_align_to_first_expression = false
15+
# function call expression's args will align to first arg
16+
# however, if the args has cross row arg, it will not be aligned to the first arg
17+
align_call_args = false
18+
# if true, format like this "print( "123", 456 )"
19+
keep_one_space_between_call_args_and_parentheses = false
20+
# if true, all function define params will align to first param
21+
align_function_define_params = true
22+
# if true, format like this "local t = { 1, 2, 3 }"
23+
keep_one_space_between_table_and_bracket = true
24+
# if indent_style is tab, this option is invalid
25+
align_table_field_to_first_field = false
26+
# if true, ormat like this "local t <const> = 1"
27+
keep_one_space_between_namedef_and_attribute = false
28+
# continous line distance
29+
max_continuous_line_distance = 1
30+
# if true, iff any one of the consecutive rows meets the condition of aligning to the equal sign,
31+
# the consecutive rows will be aligned to the equal sign
32+
weak_alignment_rule = true
33+
# see document for detail
34+
continuous_assign_statement_align_to_equal_sign = true
35+
# see document for detail
36+
continuous_assign_table_field_align_to_equal_sign = true
37+
# if true, the label loses its current indentation
38+
label_no_indent = false
39+
# if true, there will be no indentation in the do statement
40+
do_statement_no_indent = false
41+
# if true, the conditional expression of the if statement will not be a continuation line indent
42+
if_condition_no_continuation_indent = false
43+
44+
45+
# optional crlf/lf
46+
end_of_line = crlf
47+
48+
# [line layout]
49+
# The following configuration supports three expressions
50+
# minLine:${n}
51+
# keepLine
52+
# KeepLine:${n}
53+
54+
keep_line_after_if_statement = minLine:0
55+
keep_line_after_do_statement = minLine:0
56+
keep_line_after_while_statement = minLine:0
57+
keep_line_after_repeat_statement = minLine:0
58+
keep_line_after_for_statement = minLine:0
59+
keep_line_after_local_or_assign_statement = keepLine
60+
keep_line_after_function_define_statement = keepLine:1
61+
62+
# [diagnostic]
63+
# the following is code diagnostic options
64+
enable_check_codestyle = true
65+
# this mean utf8 length
66+
max_line_length = 120
67+
# this will check text end with new line(format always end with new line)
68+
insert_final_newline = true
69+
70+
# [name style check]
71+
enable_name_style_check = true
72+
# the following is name style check rule
73+
# base option off/camel_case/snake_case/upper_snake_case/pascal_case/same(filename/first_param/'<const string>', snake_case/pascal_case/camel_case)
74+
# all option can use '|' represent or
75+
# for example:
76+
# snake_case | upper_snake_case
77+
# same(first_param, snake_case)
78+
# same('m')
79+
local_name_define_style = camel_case
80+
function_param_name_style = camel_case
81+
function_name_define_style = camel_case
82+
local_function_name_define_style = camel_case
83+
table_field_name_define_style = camel_case
84+
global_variable_name_define_style = camel_case|upper_snake_case
85+
module_name_define_style = camel_case
86+
require_module_name_style = camel_case
87+
class_name_define_style = camel_case

debugger.lua

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ end
55
local fs = require 'bee.filesystem'
66
local luaDebugs = {}
77

8-
for _, vscodePath in ipairs {'.vscode', '.vscode-insiders', '.vscode-server-insiders'} do
8+
for _, vscodePath in ipairs { '.vscode', '.vscode-insiders', '.vscode-server-insiders' } do
99
local extensionPath = fs.path(os.getenv 'USERPROFILE' or os.getenv 'HOME') / vscodePath / 'extensions'
1010
log.debug('Search extensions at:', extensionPath:string())
1111

@@ -39,8 +39,8 @@ table.sort(luaDebugs, function (a, b)
3939
end)
4040

4141
local debugPath = luaDebugs[1]
42-
local cpath = "/runtime/win64/lua54/?.dll;/runtime/win64/lua54/?.so"
43-
local path = "/script/?.lua"
42+
local cpath = "/runtime/win64/lua54/?.dll;/runtime/win64/lua54/?.so"
43+
local path = "/script/?.lua"
4444

4545
local function tryDebugger()
4646
local entry = assert(package.searchpath('debugger', debugPath .. path))

main.lua

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ end
2727
loadArgs()
2828

2929
local currentPath = debug.getinfo(1, 'S').source:sub(2)
30-
local rootPath = currentPath:gsub('[/\\]*[^/\\]-$', '')
30+
local rootPath = currentPath:gsub('[/\\]*[^/\\]-$', '')
31+
3132
rootPath = (rootPath == '' and '.' or rootPath)
3233
ROOT = fs.path(util.expandPath(rootPath))
3334
LOGPATH = LOGPATH and util.expandPath(LOGPATH) or (ROOT:string() .. '/log')

make.lua

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ local exe = platform.OS == 'Windows' and ".exe" or ""
44

55
lm.bindir = "bin"
66

7+
---@diagnostic disable-next-line: codestyle-check
78
lm.EXE_DIR = ""
89

910
if platform.OS == 'macOS' then
@@ -49,7 +50,7 @@ lm:source_set 'lpeglabel' {
4950
}
5051

5152
lm:executable "lua-language-server" {
52-
deps = {"lpeglabel", "source_bootstrap", "code_format"},
53+
deps = { "lpeglabel", "source_bootstrap", "code_format" },
5354
includes = {
5455
"3rd/bee.lua",
5556
"3rd/bee.lua/3rd/lua",
@@ -67,7 +68,7 @@ lm:executable "lua-language-server" {
6768

6869
lm:copy "copy_bootstrap" {
6970
input = "make/bootstrap.lua",
70-
output = lm.bindir.."/main.lua",
71+
output = lm.bindir .. "/main.lua",
7172
}
7273

7374
lm:build 'copy_vcrt' {

make/bootstrap.lua

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ if main then
3535
end
3636
end
3737

38-
local root; do
38+
local root
39+
do
3940
if main then
4041
local fs = require 'bee.filesystem'
4142
local mainPath = fs.path(arg[0])
@@ -44,21 +45,21 @@ local root; do
4445
root = '.'
4546
end
4647
else
47-
local sep = package.config:sub(1,1)
48+
local sep = package.config:sub(1, 1)
4849
if sep == '\\' then
4950
sep = '/\\'
5051
end
51-
local pattern = "["..sep.."]+[^"..sep.."]+"
52-
root = package.cpath:match("([^;]+)"..pattern..pattern.."$")
53-
arg[0] = root .. package.config:sub(1,1) .. 'main.lua'
52+
local pattern = "[" .. sep .. "]+[^" .. sep .. "]+"
53+
root = package.cpath:match("([^;]+)" .. pattern .. pattern .. "$")
54+
arg[0] = root .. package.config:sub(1, 1) .. 'main.lua'
5455
end
55-
root = root:gsub('[/\\]', package.config:sub(1,1))
56+
root = root:gsub('[/\\]', package.config:sub(1, 1))
5657
end
5758

5859
package.path = table.concat({
5960
root .. "/script/?.lua",
6061
root .. "/script/?/init.lua",
61-
}, ";"):gsub('/', package.config:sub(1,1))
62+
}, ";"):gsub('/', package.config:sub(1, 1))
6263

6364
package.searchers[2] = function (name)
6465
local filename, err = package.searchpath(name, package.path)

script/brave/init.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
local brave = require 'brave.brave'
1+
local brave = require 'brave.brave'
22
require 'brave.work'
33

44
return brave

script/client.lua

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,9 @@ local function tryModifyRC(uri, finalChanges, create)
250250
end
251251
local scp = scope.getScope(uri)
252252
local rc = scp:get('lastRCConfig') or {
253-
['$schema'] = lang.id == 'zh-cn' and [[https://raw.githubusercontent.com/sumneko/vscode-lua/master/setting/schema-zh-cn.json]] or [[https://raw.githubusercontent.com/sumneko/vscode-lua/master/setting/schema.json]]
253+
['$schema'] = lang.id == 'zh-cn'
254+
and [[https://raw.githubusercontent.com/sumneko/vscode-lua/master/setting/schema-zh-cn.json]]
255+
or [[https://raw.githubusercontent.com/sumneko/vscode-lua/master/setting/schema.json]]
254256
}
255257
local suc = applyConfig(rc, uri, finalChanges)
256258
if not suc then

script/core/code-action.lua

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,13 @@ local function checkDisableByLuaDocInsert(uri, row, mode, code)
4343
end
4444

4545
local function disableDiagnostic(uri, code, start, results)
46-
local row = guide.rowColOf(start)
46+
local row = guide.rowColOf(start)
4747
results[#results+1] = {
4848
title = lang.script('ACTION_DISABLE_DIAG', code),
4949
kind = 'quickfix',
5050
command = {
51-
title = lang.script.COMMAND_DISABLE_DIAG,
52-
command = 'lua.setConfig',
51+
title = lang.script.COMMAND_DISABLE_DIAG,
52+
command = 'lua.setConfig',
5353
arguments = {
5454
{
5555
key = 'Lua.diagnostics.disable',
@@ -174,7 +174,6 @@ local function solveSyntaxByChangeVersion(uri, err, results)
174174
end
175175

176176
local function solveSyntaxByAddDoEnd(uri, err, results)
177-
local text = files.getText(uri)
178177
results[#results+1] = {
179178
title = lang.script.ACTION_ADD_DO_END,
180179
kind = 'quickfix',

script/core/command/jsonToLua.lua

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ return function (data)
1414
if not text then
1515
return
1616
end
17-
local start = guide.positionToOffset(state, data.start)
18-
local finish = guide.positionToOffset(state, data.finish)
19-
local jsonStr = text:sub(start + 1, finish)
17+
local start = guide.positionToOffset(state, data.start)
18+
local finish = guide.positionToOffset(state, data.finish)
19+
local jsonStr = text:sub(start + 1, finish)
2020
local suc, res = pcall(json.decode, jsonStr)
2121
if not suc then
2222
proto.notify('window/showMessage', {

script/core/command/setConfig.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
local client = require 'client'
22

33
return function (data)
4-
client.setConfig {data}
4+
client.setConfig { data }
55
end

0 commit comments

Comments
 (0)