|
| 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 |
0 commit comments