Skip to content

Commit a7a40a5

Browse files
committed
语言设置挪到服务器里
1 parent 011f95c commit a7a40a5

File tree

2 files changed

+98
-0
lines changed

2 files changed

+98
-0
lines changed
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
-- Enumeration of commonly encountered syntax token types.
2+
local SyntaxTokenType = {
3+
Other = 0, -- Everything except tokens that are part of comments, string literals and regular expressions.
4+
Comment = 1, -- A comment.
5+
String = 2, -- A string literal.
6+
RegEx = 3 -- A regular expression.
7+
}
8+
9+
-- Describes what to do with the indentation when pressing Enter.
10+
local IndentAction = {
11+
None = 0, -- Insert new line and copy the previous line's indentation.
12+
Indent = 1, -- Insert new line and indent once (relative to the previous line's indentation).
13+
IndentOutdent = 2, -- Insert two new lines: the first one indented which will hold the cursor, and the second one at the same indentation level.
14+
Outdent = 3 -- Insert new line and outdent once (relative to the previous line's indentation).
15+
}
16+
17+
local languageConfiguration = {
18+
id = 'lua',
19+
configuration = {
20+
autoClosingPairs = {
21+
{ open = "{", close = "}" },
22+
{ open = "[", close = "]" },
23+
{ open = "(", close = ")" },
24+
{ open = "'", close = "'", notIn = { SyntaxTokenType.String } },
25+
{ open = '"', close = '"', notIn = { SyntaxTokenType.String } },
26+
{ open = "[=", close = "=]" },
27+
{ open = "[==", close = "==]" },
28+
{ open = "[===", close = "===]" },
29+
{ open = "[====", close = "====]" },
30+
{ open = "[=====", close = "=====]" },
31+
},
32+
onEnterRules = {
33+
{
34+
beforeText = [[\)\s*$]],
35+
afterText = [[^\s*end\b]],
36+
action = {
37+
indentAction = IndentAction.IndentOutdent,
38+
}
39+
},
40+
{
41+
beforeText = [[\b()\s*$]],
42+
afterText = [[^\s*end\b]],
43+
action = {
44+
indentAction = IndentAction.IndentOutdent,
45+
}
46+
},
47+
{
48+
beforeText = [[\b(repeat)\s*$]],
49+
afterText = [[^\s*until\b]],
50+
action = {
51+
indentAction = IndentAction.IndentOutdent,
52+
}
53+
},
54+
{
55+
beforeText = [[^\s*---@]],
56+
action = {
57+
indentAction = IndentAction.None,
58+
appendText = "---@"
59+
}
60+
},
61+
{
62+
beforeText = [[^\s*--- @]],
63+
action = {
64+
indentAction = IndentAction.None,
65+
appendText = "--- @"
66+
}
67+
},
68+
{
69+
beforeText = [[^\s*--- ]],
70+
action = {
71+
indentAction = IndentAction.None,
72+
appendText = "--- "
73+
}
74+
},
75+
{
76+
beforeText = [[^\s*---]],
77+
action = {
78+
indentAction = IndentAction.None,
79+
appendText = "---"
80+
}
81+
},
82+
},
83+
},
84+
}
85+
86+
return languageConfiguration

script/provider/provider.lua

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1597,6 +1597,18 @@ m.register '$/psi/select' {
15971597
end
15981598
}
15991599

1600+
local function refreshLanguageConfiguration()
1601+
if not client.getOption('languageConfiguration') then
1602+
return
1603+
end
1604+
proto.notify('$/languageConfiguration', require 'provider.language-configuration')
1605+
end
1606+
1607+
config.watch(function (uri, key, value)
1608+
if key == '' then
1609+
refreshLanguageConfiguration()
1610+
end
1611+
end)
16001612

16011613
local function refreshStatusBar()
16021614
if not client.getOption('statusBar') then

0 commit comments

Comments
 (0)