Skip to content

Commit e076984

Browse files
committed
chore(sumneko_lua): added '.luarc.json', '.editorconfig',
- enabled code style checking - reformat project with sumneko_lua formatter
1 parent ab510bd commit e076984

9 files changed

Lines changed: 238 additions & 74 deletions

File tree

.editorconfig

Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
# see https://github.com/CppCXY/EmmyLuaCodeStyle
2+
[*.lua]
3+
# [basic]
4+
# optional space/tab
5+
indent_style = space
6+
# if indent_style is space, this is valid
7+
indent_size = 2
8+
# if indent_style is tab, this is valid
9+
tab_width = 2
10+
# none/single/double
11+
quote_style = double
12+
# only support number
13+
continuation_indent_size = 4
14+
15+
# optional crlf/lf/cr/auto, if it is 'auto', in windows it is crlf other platforms are lf
16+
end_of_line = auto
17+
detect_end_of_line = false
18+
19+
# this mean utf8 length , if this is 'unset' then the line width is no longer checked
20+
# this option decides when to chopdown the code
21+
max_line_length = 100
22+
23+
# this will check text end with new line
24+
insert_final_newline = true
25+
26+
# [function]
27+
28+
# function call expression's args will align to first arg
29+
# optional true/false/only_after_more_indention_statement/only_not_exist_cross_row_expression
30+
align_call_args = false
31+
32+
# if true, all function define params will align to first param
33+
align_function_define_params = true
34+
35+
remove_expression_list_finish_comma = true
36+
37+
# keep/remove/remove_table_only/remove_string_only/unambiguous_remove_string_only
38+
call_arg_parentheses = keep
39+
40+
# [table]
41+
42+
#optional none/comma/semicolon
43+
table_separator_style = none
44+
45+
#optional keep/never/always/smart
46+
trailing_table_separator = keep
47+
48+
# see document for detail
49+
continuous_assign_table_field_align_to_equal_sign = true
50+
51+
# if true, format like this "local t = { 1, 2, 3 }"
52+
keep_one_space_between_table_and_bracket = true
53+
54+
# if indent_style is tab, this option is invalid
55+
align_table_field_to_first_field = false
56+
57+
# [statement]
58+
59+
align_chained_expression_statement = false
60+
61+
# continous line distance
62+
max_continuous_line_distance = 1
63+
64+
# see document for detail
65+
continuous_assign_statement_align_to_equal_sign = true
66+
67+
# if statement will align like switch case
68+
if_condition_align_with_each_other = false
69+
70+
# if true, continuation_indent_size for local or assign statement is invalid
71+
# however, if the expression list has cross row expression, it will not be aligned to the first expression
72+
local_assign_continuation_align_to_first_expression = false
73+
74+
statement_inline_comment_space = 1
75+
76+
# [indentation]
77+
78+
# if true, the label loses its current indentation
79+
label_no_indent = false
80+
# if true, there will be no indentation in the do statement
81+
do_statement_no_indent = false
82+
# if true, the conditional expression of the if statement will not be a continuation line indent
83+
if_condition_no_continuation_indent = false
84+
85+
if_branch_comments_after_block_no_indent = false
86+
87+
# [space]
88+
89+
# if true, t[#t+1] will not space wrapper '+'
90+
table_append_expression_no_space = false
91+
92+
long_chain_expression_allow_one_space_after_colon = false
93+
94+
remove_empty_header_and_footer_lines_in_function = true
95+
96+
space_before_function_open_parenthesis = false
97+
space_inside_function_call_parentheses = false
98+
space_inside_function_param_list_parentheses = false
99+
space_before_open_square_bracket = false
100+
space_inside_square_brackets = false
101+
102+
# if true, ormat like this "local t <const> = 1"
103+
keep_one_space_between_namedef_and_attribute = true
104+
105+
# [row_layout]
106+
# The following configuration supports four expressions
107+
# minLine:${n}
108+
# keepLine
109+
# keepLine:${n}
110+
# maxLine:${n}
111+
112+
keep_line_after_if_statement = minLine:0
113+
keep_line_after_do_statement = minLine:0
114+
keep_line_after_while_statement = minLine:0
115+
keep_line_after_repeat_statement = minLine:0
116+
keep_line_after_for_statement = minLine:0
117+
keep_line_after_local_or_assign_statement = keepLine
118+
keep_line_after_function_define_statement = keepLine:1
119+
keep_line_after_expression_statement = keepLine
120+
121+
# [diagnostic]
122+
123+
# the following is code diagnostic options
124+
enable_check_codestyle = true
125+
126+
# [diagnostic.name_style]
127+
enable_name_style_check = false
128+
# the following is name style check rule
129+
# base option off/camel_case/snake_case/upper_snake_case/pascal_case/same(filename/first_param/'<const string>', snake_case/pascal_case/camel_case)
130+
# all option can use '|' represent or
131+
# for example:
132+
# snake_case | upper_snake_case
133+
# same(first_param, snake_case)
134+
# same('m')
135+
local_name_define_style = snake_case
136+
function_param_name_style = snake_case
137+
function_name_define_style = snake_case
138+
local_function_name_define_style = snake_case
139+
table_field_name_define_style = snake_case
140+
global_variable_name_define_style = snake_case|upper_snake_case
141+
module_name_define_style = same('m')|same(filename, snake_case)
142+
require_module_name_style = same(first_param, snake_case)
143+
class_name_define_style = same(filename, snake_case)

.luarc.json

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"runtime.version": "LuaJIT",
3+
"diagnostics": {
4+
"enable": true,
5+
"globals": [
6+
"vim",
7+
"describe",
8+
"pending",
9+
"it",
10+
"before_each",
11+
"after_each",
12+
],
13+
"neededFileStatus": {
14+
"codestyle-check": "Any"
15+
}
16+
},
17+
"workspace": {
18+
"library": [
19+
"runtime/lua",
20+
],
21+
"checkThirdParty": false,
22+
"maxPreload": 2000,
23+
"preloadFileSize": 1000
24+
},
25+
"telemetry.enable": false
26+
}

lua/ts-vimdoc/class.lua

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ Object.__index = Object
1717
function Object:new(...)
1818
end
1919

20-
2120
function Object:extend()
2221
local cls = {}
2322
for k, v in pairs(self) do
@@ -31,9 +30,8 @@ function Object:extend()
3130
return cls
3231
end
3332

34-
3533
function Object:implement(...)
36-
for _, cls in pairs({...}) do
34+
for _, cls in pairs({ ... }) do
3735
for k, v in pairs(cls) do
3836
if self[k] == nil and type(v) == "function" then
3937
self[k] = v
@@ -42,7 +40,6 @@ function Object:implement(...)
4240
end
4341
end
4442

45-
4643
function Object:is(T)
4744
local mt = getmetatable(self)
4845
while mt do
@@ -54,17 +51,14 @@ function Object:is(T)
5451
return false
5552
end
5653

57-
5854
function Object:__tostring()
5955
return "Object"
6056
end
6157

62-
6358
function Object:__call(...)
6459
local obj = setmetatable({}, self)
6560
obj:new(...)
6661
return obj
6762
end
6863

69-
7064
return Object

lua/ts-vimdoc/formatting.lua

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
local formatting = {}
22

33
formatting.style_elements = {
4-
header_break = {
5-
string.rep("=", 78), -- atx_h1_marker = 11
6-
string.rep("-", 78), -- atx_h2_marker = 12
7-
string.rep(" ", 78), -- atx_h3_marker = 13
4+
header_break = {
5+
string.rep("=", 78), -- atx_h1_marker = 11
6+
string.rep("-", 78), -- atx_h2_marker = 12
7+
string.rep(" ", 78), -- atx_h3_marker = 13
88
},
99
}
1010

0 commit comments

Comments
 (0)