@exercism/codemirror-lang-shell 0.0.0-stage → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,297 @@
1
+ import { LRParser } from '@lezer/lr';
2
+ import { LanguageSupport, LRLanguage } from '@codemirror/language';
3
+ import { CompletionSource } from '@codemirror/autocomplete';
4
+
5
+ declare const parser$2: LRParser
6
+
7
+ /**
8
+ Snippets for the constructs people type most: functions, conditionals,
9
+ loops, `case`, the `[[ ]]` test and arithmetic.
10
+ */
11
+ declare const snippets = [
12
+ snippetCompletion("${name}() {\n\t${}\n}", { label: "function", detail: "definition", type: "keyword" }),
13
+ snippetCompletion("if ${condition}; then\n\t${}\nfi", { label: "if", detail: "block", type: "keyword" }),
14
+ snippetCompletion("if ${condition}; then\n\t${}\nelse\n\t${}\nfi", {
15
+ label: "if",
16
+ detail: "/ else block",
17
+ type: "keyword"
18
+ }),
19
+ snippetCompletion("if ${condition}; then\n\t${}\nelif ${condition}; then\n\t${}\nelse\n\t${}\nfi", {
20
+ label: "if",
21
+ detail: "/ elif / else block",
22
+ type: "keyword"
23
+ }),
24
+ snippetCompletion("elif ${condition}; then\n\t${}", { label: "elif", detail: "branch", type: "keyword" }),
25
+ snippetCompletion("for ${item} in ${list}; do\n\t${}\ndone", { label: "for", detail: "in loop", type: "keyword" }),
26
+ snippetCompletion("for (( ${i} = 0; ${i} < ${n}; ${i}++ )); do\n\t${}\ndone", {
27
+ label: "for",
28
+ detail: "(( )) loop",
29
+ type: "keyword"
30
+ }),
31
+ snippetCompletion("while ${condition}; do\n\t${}\ndone", { label: "while", detail: "loop", type: "keyword" }),
32
+ snippetCompletion("while IFS= read -r ${line}; do\n\t${}\ndone", {
33
+ label: "while",
34
+ detail: "read loop",
35
+ type: "keyword"
36
+ }),
37
+ snippetCompletion("until ${condition}; do\n\t${}\ndone", { label: "until", detail: "loop", type: "keyword" }),
38
+ snippetCompletion("case ${word} in\n\t${pattern})\n\t\t${}\n\t\t;;\n\t*)\n\t\t;;\nesac", {
39
+ label: "case",
40
+ detail: "statement",
41
+ type: "keyword"
42
+ }),
43
+ snippetCompletion("[[ ${condition} ]]", { label: "[[ ]]", detail: "test", type: "keyword" }),
44
+ snippetCompletion("(( ${expression} ))", { label: "(( ))", detail: "arithmetic", type: "keyword" }),
45
+ snippetCompletion("$(( ${expression} ))", { label: "$(( ))", detail: "arithmetic", type: "keyword" }),
46
+ snippetCompletion("$(${command})", { label: "$( )", detail: "command substitution", type: "keyword" })
47
+ ];
48
+ /**
49
+ Completes the names declared in the file and the shell's own variables.
50
+ After `$` or `${` it offers variables and the positional parameters, and
51
+ inside `(( ))` and `$(( ))` the variables. Functions are offered
52
+ everywhere, and a variable set with `local` or `declare` inside a function
53
+ only inside that function.
54
+ */
55
+ declare const localCompletionSource = context => {
56
+ const inner = syntaxTree(context.state).resolveInner(context.pos, -1);
57
+ const place = where(inner, context.pos);
58
+ if (place == "quiet")
59
+ return null;
60
+ const braced = context.matchBefore(/\$\{[#!]?\w*$/);
61
+ if (braced) {
62
+ const from = context.pos - /\w*$/.exec(braced.text)[0].length;
63
+ return {
64
+ from,
65
+ options: [...namesAt(context, "variable"), ...variableOptions, ...parameters],
66
+ validFor: /^\w*$/
67
+ };
68
+ }
69
+ const dollar = context.matchBefore(/\$\w*$/);
70
+ if (dollar) {
71
+ return {
72
+ from: dollar.from + 1,
73
+ options: [...namesAt(context, "variable"), ...variableOptions, ...parameters, ...dollarSnippets],
74
+ validFor: /^\w*$/
75
+ };
76
+ }
77
+ if (place == "string")
78
+ return null;
79
+ const word = context.matchBefore(/[A-Za-z_]\w*$/);
80
+ if (!word && !context.explicit)
81
+ return null;
82
+ const from = word ? word.from : context.pos;
83
+ if (place == "arith")
84
+ return { from, options: [...namesAt(context, "variable"), ...variableOptions], validFor: /^\w*$/ };
85
+ return { from, options: namesAt(context, "any"), validFor: /^\w*$/ };
86
+ };
87
+ /**
88
+ Keywords, snippets, builtins and common commands. It offers them where a
89
+ word is being typed, and nothing after `$`, inside arithmetic, or inside
90
+ strings and comments.
91
+ */
92
+ declare const shellKeywordCompletion = context => {
93
+ const inner = syntaxTree(context.state).resolveInner(context.pos, -1);
94
+ if (where(inner, context.pos) != "word")
95
+ return null;
96
+ if (context.matchBefore(/\$\{?[#!]?\w*$/))
97
+ return null;
98
+ const word = context.matchBefore(/(\[\[?|\(\(?|[A-Za-z_]\w*)$/);
99
+ if (!word && !context.explicit)
100
+ return null;
101
+ return {
102
+ from: word ? word.from : context.pos,
103
+ options: [...wordOptions, ...variableOptions],
104
+ validFor: /^(\[\[?|\(\(?|\w*)$/
105
+ };
106
+ };
107
+
108
+ declare const parser$1: LRParser
109
+
110
+ /**
111
+ A language provider for the C shell, based on the Lezer grammar in
112
+ `csh.grammar`.
113
+ */
114
+ declare const cshLanguage = LRLanguage.define({
115
+ name: "csh",
116
+ parser: cshParser.configure({
117
+ props: [
118
+ indentNodeProp.add({
119
+ Group: delimitedIndent({ closing: "}" }),
120
+ Subshell: delimitedIndent({ closing: ")" }),
121
+ WhileStatement: delimitedIndent({ closing: "end" }),
122
+ ForeachStatement: delimitedIndent({ closing: "end" }),
123
+ SwitchStatement: delimitedIndent({ closing: "endsw" }),
124
+ // `then` sits on the same line as the `if` it belongs to, so what is
125
+ // indented is everything after that line.
126
+ IfStatement: continuedIndent({ except: /^\s*(endif|else)\b/ }),
127
+ CaseClause: continuedIndent({ except: /^\s*(case|default|endsw)\b/ })
128
+ }),
129
+ foldNodeProp.add({
130
+ Group: foldInside,
131
+ Subshell: foldInside,
132
+ WhileStatement: foldInside,
133
+ ForeachStatement: foldInside,
134
+ SwitchStatement: foldInside
135
+ }),
136
+ styleTags({
137
+ "if then else endif": t.controlKeyword,
138
+ "while foreach end repeat": t.controlKeyword,
139
+ "switch case default endsw": t.controlKeyword,
140
+ "set setenv unset alias": t.definitionKeyword,
141
+ Label: t.labelName,
142
+ Comment: t.lineComment,
143
+ String: t.string,
144
+ RawString: t.string,
145
+ HeredocBody: t.special(t.string),
146
+ Escape: t.escape,
147
+ LineContinuation: t.escape,
148
+ Glob: t.special(t.string),
149
+ "SimpleCommand/CommandName ShortCommand/CommandName": t.function(t.variableName),
150
+ VariableName: t.definition(t.variableName),
151
+ SimpleExpansion: t.variableName,
152
+ ParamName: t.variableName,
153
+ ParamOp: t.operator,
154
+ Dollar: t.variableName,
155
+ // `:q` and its relatives say what to do with the word before them,
156
+ // which is what an operator is.
157
+ Modifier: t.operator,
158
+ Number: t.number,
159
+ RedirectOp: t.controlOperator,
160
+ "PipeOp Background": t.controlOperator,
161
+ "AndOp OrOp NotOp": t.logicOperator,
162
+ "AddOp MulOp": t.arithmeticOperator,
163
+ "ShiftOp BitAndOp BitXorOp BitOrOp BitNotOp": t.bitwiseOperator,
164
+ "RelateOp EqualOp MatchOp": t.compareOperator,
165
+ FileTestOp: t.operatorKeyword,
166
+ AssignOp: t.definitionOperator,
167
+ IncDecOp: t.updateOperator,
168
+ // `@` is a command rather than a symbol, and reads as the arithmetic
169
+ // it introduces.
170
+ "@": t.definitionKeyword,
171
+ '"\\""': t.string,
172
+ '"${" "}" "{"': t.brace,
173
+ '"(" ")"': t.paren,
174
+ '"[" "]"': t.squareBracket,
175
+ '";"': t.separator,
176
+ Terminator: t.separator
177
+ })
178
+ ]
179
+ }),
180
+ languageData: {
181
+ commentTokens: { line: "#" },
182
+ closeBrackets: { brackets: ["(", "[", "{", "'", '"', "`"] },
183
+ indentOnInput: /^\s*(endif|end|endsw|else|breaksw|\}|\))$/
184
+ }
185
+ });
186
+ /**
187
+ Autocompletion for the C shell's builtins and the variables it sets.
188
+ */
189
+ declare const cshCompletion = completeFromList([...builtins, ...specials]);
190
+
191
+ declare const parser: LRParser
192
+
193
+ /**
194
+ A language provider for fish, based on the Lezer grammar in `fish.grammar`.
195
+ */
196
+ declare const fishLanguage = LRLanguage.define({
197
+ name: "fish",
198
+ parser: fishParser.configure({
199
+ props: [
200
+ indentNodeProp.add({
201
+ CommandSubstitution: delimitedIndent({ closing: ")" }),
202
+ // Every block ends with the same word, so every block indents the same
203
+ // way, which is the one thing fish made easier than the shell did.
204
+ "IfStatement WhileStatement ForStatement SwitchStatement FunctionDefinition BeginBlock": continuedIndent({ except: /^\s*(end|else)\b/ }),
205
+ CaseClause: continuedIndent({ except: /^\s*(case|end)\b/ })
206
+ }),
207
+ foldNodeProp.add({
208
+ CommandSubstitution: foldInside,
209
+ "IfStatement WhileStatement ForStatement SwitchStatement FunctionDefinition BeginBlock": foldInside
210
+ }),
211
+ styleTags({
212
+ "if else end": t.controlKeyword,
213
+ "while for in switch case begin": t.controlKeyword,
214
+ function: t.definitionKeyword,
215
+ // `and`, `or` and `not` are commands rather than punctuation, and read
216
+ // as the logic they are either way.
217
+ "and or not": t.logicOperator,
218
+ Comment: t.lineComment,
219
+ String: t.string,
220
+ RawString: t.string,
221
+ Escape: t.escape,
222
+ Glob: t.special(t.string),
223
+ "SimpleCommand/CommandName": t.function(t.variableName),
224
+ "FunctionDefinition/FunctionName": t.function(t.definition(t.variableName)),
225
+ VariableName: t.definition(t.variableName),
226
+ SimpleExpansion: t.variableName,
227
+ Dollar: t.variableName,
228
+ RedirectOp: t.controlOperator,
229
+ "PipeOp Background": t.controlOperator,
230
+ "AndOp OrOp": t.logicOperator,
231
+ Terminator: t.separator,
232
+ '"\\""': t.string,
233
+ '"$(" "(" ")"': t.paren,
234
+ "SubscriptOpen SubscriptClose": t.squareBracket
235
+ })
236
+ ]
237
+ }),
238
+ languageData: {
239
+ commentTokens: { line: "#" },
240
+ closeBrackets: { brackets: ["(", "[", "{", "'", '"'] },
241
+ indentOnInput: /^\s*(end|else|case)$/
242
+ }
243
+ });
244
+ /**
245
+ Autocompletion for fish's builtins and the variables it sets.
246
+ */
247
+ declare const fishCompletion = completeFromList([...builtins, ...specials]);
248
+
249
+ /**
250
+ A language provider based on the Lezer shell parser in this package,
251
+ extended with highlighting, folding and indentation information.
252
+ */
253
+ declare const shellLanguage: LRLanguage;
254
+ /**
255
+ Autocompletion for the shell's keywords, snippets, builtin commands,
256
+ common programs and the variables it sets.
257
+ */
258
+ declare const shellCompletion: CompletionSource;
259
+ /**
260
+ The name of a shell this package reads, or any of the aliases above.
261
+ */
262
+ type Shell = "sh" | "csh" | "fish";
263
+ /**
264
+ The language for one shell. `"csh"`, `"tcsh"` and `"fish"` are answered with
265
+ their own grammars, and everything else with the shell command language.
266
+ What a caller does with the result is the same either way.
267
+ */
268
+ declare function shellLanguageFor(shell: string): LRLanguage;
269
+ interface ShellConfig {
270
+ /**
271
+ Whose shell to read. `"sh"`, `"bash"`, `"zsh"` and `"ksh"` are all the one
272
+ grammar; `"csh"`, `"tcsh"` and `"fish"` each have their own. Defaults to
273
+ `"sh"`.
274
+ */
275
+ shell?: Shell | string;
276
+ }
277
+ /**
278
+ Shell language support, with completion for keywords, snippets, builtins,
279
+ the variables the shell sets and the names declared in the file.
280
+ */
281
+ declare function shell(config?: ShellConfig): LanguageSupport;
282
+ /**
283
+ C shell support, for a caller who knows which of the grammars they want.
284
+ */
285
+ declare function csh(): LanguageSupport;
286
+ /**
287
+ fish support, likewise.
288
+ */
289
+ declare function fish(): LanguageSupport;
290
+ /**
291
+ Bash support. This is `shell()`, named for the shell most scripts are
292
+ written for.
293
+ */
294
+ declare function bash(): LanguageSupport;
295
+
296
+ export { bash, csh, cshCompletion, cshLanguage, parser$1 as cshParser, fish, fishCompletion, fishLanguage, parser as fishParser, localCompletionSource, parser$2 as parser, shell, shellCompletion, shellKeywordCompletion, shellLanguage, shellLanguageFor, snippets };
297
+ export type { Shell, ShellConfig };
@@ -0,0 +1,297 @@
1
+ import { LRParser } from '@lezer/lr';
2
+ import { LanguageSupport, LRLanguage } from '@codemirror/language';
3
+ import { CompletionSource } from '@codemirror/autocomplete';
4
+
5
+ declare const parser$2: LRParser
6
+
7
+ /**
8
+ Snippets for the constructs people type most: functions, conditionals,
9
+ loops, `case`, the `[[ ]]` test and arithmetic.
10
+ */
11
+ declare const snippets = [
12
+ snippetCompletion("${name}() {\n\t${}\n}", { label: "function", detail: "definition", type: "keyword" }),
13
+ snippetCompletion("if ${condition}; then\n\t${}\nfi", { label: "if", detail: "block", type: "keyword" }),
14
+ snippetCompletion("if ${condition}; then\n\t${}\nelse\n\t${}\nfi", {
15
+ label: "if",
16
+ detail: "/ else block",
17
+ type: "keyword"
18
+ }),
19
+ snippetCompletion("if ${condition}; then\n\t${}\nelif ${condition}; then\n\t${}\nelse\n\t${}\nfi", {
20
+ label: "if",
21
+ detail: "/ elif / else block",
22
+ type: "keyword"
23
+ }),
24
+ snippetCompletion("elif ${condition}; then\n\t${}", { label: "elif", detail: "branch", type: "keyword" }),
25
+ snippetCompletion("for ${item} in ${list}; do\n\t${}\ndone", { label: "for", detail: "in loop", type: "keyword" }),
26
+ snippetCompletion("for (( ${i} = 0; ${i} < ${n}; ${i}++ )); do\n\t${}\ndone", {
27
+ label: "for",
28
+ detail: "(( )) loop",
29
+ type: "keyword"
30
+ }),
31
+ snippetCompletion("while ${condition}; do\n\t${}\ndone", { label: "while", detail: "loop", type: "keyword" }),
32
+ snippetCompletion("while IFS= read -r ${line}; do\n\t${}\ndone", {
33
+ label: "while",
34
+ detail: "read loop",
35
+ type: "keyword"
36
+ }),
37
+ snippetCompletion("until ${condition}; do\n\t${}\ndone", { label: "until", detail: "loop", type: "keyword" }),
38
+ snippetCompletion("case ${word} in\n\t${pattern})\n\t\t${}\n\t\t;;\n\t*)\n\t\t;;\nesac", {
39
+ label: "case",
40
+ detail: "statement",
41
+ type: "keyword"
42
+ }),
43
+ snippetCompletion("[[ ${condition} ]]", { label: "[[ ]]", detail: "test", type: "keyword" }),
44
+ snippetCompletion("(( ${expression} ))", { label: "(( ))", detail: "arithmetic", type: "keyword" }),
45
+ snippetCompletion("$(( ${expression} ))", { label: "$(( ))", detail: "arithmetic", type: "keyword" }),
46
+ snippetCompletion("$(${command})", { label: "$( )", detail: "command substitution", type: "keyword" })
47
+ ];
48
+ /**
49
+ Completes the names declared in the file and the shell's own variables.
50
+ After `$` or `${` it offers variables and the positional parameters, and
51
+ inside `(( ))` and `$(( ))` the variables. Functions are offered
52
+ everywhere, and a variable set with `local` or `declare` inside a function
53
+ only inside that function.
54
+ */
55
+ declare const localCompletionSource = context => {
56
+ const inner = syntaxTree(context.state).resolveInner(context.pos, -1);
57
+ const place = where(inner, context.pos);
58
+ if (place == "quiet")
59
+ return null;
60
+ const braced = context.matchBefore(/\$\{[#!]?\w*$/);
61
+ if (braced) {
62
+ const from = context.pos - /\w*$/.exec(braced.text)[0].length;
63
+ return {
64
+ from,
65
+ options: [...namesAt(context, "variable"), ...variableOptions, ...parameters],
66
+ validFor: /^\w*$/
67
+ };
68
+ }
69
+ const dollar = context.matchBefore(/\$\w*$/);
70
+ if (dollar) {
71
+ return {
72
+ from: dollar.from + 1,
73
+ options: [...namesAt(context, "variable"), ...variableOptions, ...parameters, ...dollarSnippets],
74
+ validFor: /^\w*$/
75
+ };
76
+ }
77
+ if (place == "string")
78
+ return null;
79
+ const word = context.matchBefore(/[A-Za-z_]\w*$/);
80
+ if (!word && !context.explicit)
81
+ return null;
82
+ const from = word ? word.from : context.pos;
83
+ if (place == "arith")
84
+ return { from, options: [...namesAt(context, "variable"), ...variableOptions], validFor: /^\w*$/ };
85
+ return { from, options: namesAt(context, "any"), validFor: /^\w*$/ };
86
+ };
87
+ /**
88
+ Keywords, snippets, builtins and common commands. It offers them where a
89
+ word is being typed, and nothing after `$`, inside arithmetic, or inside
90
+ strings and comments.
91
+ */
92
+ declare const shellKeywordCompletion = context => {
93
+ const inner = syntaxTree(context.state).resolveInner(context.pos, -1);
94
+ if (where(inner, context.pos) != "word")
95
+ return null;
96
+ if (context.matchBefore(/\$\{?[#!]?\w*$/))
97
+ return null;
98
+ const word = context.matchBefore(/(\[\[?|\(\(?|[A-Za-z_]\w*)$/);
99
+ if (!word && !context.explicit)
100
+ return null;
101
+ return {
102
+ from: word ? word.from : context.pos,
103
+ options: [...wordOptions, ...variableOptions],
104
+ validFor: /^(\[\[?|\(\(?|\w*)$/
105
+ };
106
+ };
107
+
108
+ declare const parser$1: LRParser
109
+
110
+ /**
111
+ A language provider for the C shell, based on the Lezer grammar in
112
+ `csh.grammar`.
113
+ */
114
+ declare const cshLanguage = LRLanguage.define({
115
+ name: "csh",
116
+ parser: cshParser.configure({
117
+ props: [
118
+ indentNodeProp.add({
119
+ Group: delimitedIndent({ closing: "}" }),
120
+ Subshell: delimitedIndent({ closing: ")" }),
121
+ WhileStatement: delimitedIndent({ closing: "end" }),
122
+ ForeachStatement: delimitedIndent({ closing: "end" }),
123
+ SwitchStatement: delimitedIndent({ closing: "endsw" }),
124
+ // `then` sits on the same line as the `if` it belongs to, so what is
125
+ // indented is everything after that line.
126
+ IfStatement: continuedIndent({ except: /^\s*(endif|else)\b/ }),
127
+ CaseClause: continuedIndent({ except: /^\s*(case|default|endsw)\b/ })
128
+ }),
129
+ foldNodeProp.add({
130
+ Group: foldInside,
131
+ Subshell: foldInside,
132
+ WhileStatement: foldInside,
133
+ ForeachStatement: foldInside,
134
+ SwitchStatement: foldInside
135
+ }),
136
+ styleTags({
137
+ "if then else endif": t.controlKeyword,
138
+ "while foreach end repeat": t.controlKeyword,
139
+ "switch case default endsw": t.controlKeyword,
140
+ "set setenv unset alias": t.definitionKeyword,
141
+ Label: t.labelName,
142
+ Comment: t.lineComment,
143
+ String: t.string,
144
+ RawString: t.string,
145
+ HeredocBody: t.special(t.string),
146
+ Escape: t.escape,
147
+ LineContinuation: t.escape,
148
+ Glob: t.special(t.string),
149
+ "SimpleCommand/CommandName ShortCommand/CommandName": t.function(t.variableName),
150
+ VariableName: t.definition(t.variableName),
151
+ SimpleExpansion: t.variableName,
152
+ ParamName: t.variableName,
153
+ ParamOp: t.operator,
154
+ Dollar: t.variableName,
155
+ // `:q` and its relatives say what to do with the word before them,
156
+ // which is what an operator is.
157
+ Modifier: t.operator,
158
+ Number: t.number,
159
+ RedirectOp: t.controlOperator,
160
+ "PipeOp Background": t.controlOperator,
161
+ "AndOp OrOp NotOp": t.logicOperator,
162
+ "AddOp MulOp": t.arithmeticOperator,
163
+ "ShiftOp BitAndOp BitXorOp BitOrOp BitNotOp": t.bitwiseOperator,
164
+ "RelateOp EqualOp MatchOp": t.compareOperator,
165
+ FileTestOp: t.operatorKeyword,
166
+ AssignOp: t.definitionOperator,
167
+ IncDecOp: t.updateOperator,
168
+ // `@` is a command rather than a symbol, and reads as the arithmetic
169
+ // it introduces.
170
+ "@": t.definitionKeyword,
171
+ '"\\""': t.string,
172
+ '"${" "}" "{"': t.brace,
173
+ '"(" ")"': t.paren,
174
+ '"[" "]"': t.squareBracket,
175
+ '";"': t.separator,
176
+ Terminator: t.separator
177
+ })
178
+ ]
179
+ }),
180
+ languageData: {
181
+ commentTokens: { line: "#" },
182
+ closeBrackets: { brackets: ["(", "[", "{", "'", '"', "`"] },
183
+ indentOnInput: /^\s*(endif|end|endsw|else|breaksw|\}|\))$/
184
+ }
185
+ });
186
+ /**
187
+ Autocompletion for the C shell's builtins and the variables it sets.
188
+ */
189
+ declare const cshCompletion = completeFromList([...builtins, ...specials]);
190
+
191
+ declare const parser: LRParser
192
+
193
+ /**
194
+ A language provider for fish, based on the Lezer grammar in `fish.grammar`.
195
+ */
196
+ declare const fishLanguage = LRLanguage.define({
197
+ name: "fish",
198
+ parser: fishParser.configure({
199
+ props: [
200
+ indentNodeProp.add({
201
+ CommandSubstitution: delimitedIndent({ closing: ")" }),
202
+ // Every block ends with the same word, so every block indents the same
203
+ // way, which is the one thing fish made easier than the shell did.
204
+ "IfStatement WhileStatement ForStatement SwitchStatement FunctionDefinition BeginBlock": continuedIndent({ except: /^\s*(end|else)\b/ }),
205
+ CaseClause: continuedIndent({ except: /^\s*(case|end)\b/ })
206
+ }),
207
+ foldNodeProp.add({
208
+ CommandSubstitution: foldInside,
209
+ "IfStatement WhileStatement ForStatement SwitchStatement FunctionDefinition BeginBlock": foldInside
210
+ }),
211
+ styleTags({
212
+ "if else end": t.controlKeyword,
213
+ "while for in switch case begin": t.controlKeyword,
214
+ function: t.definitionKeyword,
215
+ // `and`, `or` and `not` are commands rather than punctuation, and read
216
+ // as the logic they are either way.
217
+ "and or not": t.logicOperator,
218
+ Comment: t.lineComment,
219
+ String: t.string,
220
+ RawString: t.string,
221
+ Escape: t.escape,
222
+ Glob: t.special(t.string),
223
+ "SimpleCommand/CommandName": t.function(t.variableName),
224
+ "FunctionDefinition/FunctionName": t.function(t.definition(t.variableName)),
225
+ VariableName: t.definition(t.variableName),
226
+ SimpleExpansion: t.variableName,
227
+ Dollar: t.variableName,
228
+ RedirectOp: t.controlOperator,
229
+ "PipeOp Background": t.controlOperator,
230
+ "AndOp OrOp": t.logicOperator,
231
+ Terminator: t.separator,
232
+ '"\\""': t.string,
233
+ '"$(" "(" ")"': t.paren,
234
+ "SubscriptOpen SubscriptClose": t.squareBracket
235
+ })
236
+ ]
237
+ }),
238
+ languageData: {
239
+ commentTokens: { line: "#" },
240
+ closeBrackets: { brackets: ["(", "[", "{", "'", '"'] },
241
+ indentOnInput: /^\s*(end|else|case)$/
242
+ }
243
+ });
244
+ /**
245
+ Autocompletion for fish's builtins and the variables it sets.
246
+ */
247
+ declare const fishCompletion = completeFromList([...builtins, ...specials]);
248
+
249
+ /**
250
+ A language provider based on the Lezer shell parser in this package,
251
+ extended with highlighting, folding and indentation information.
252
+ */
253
+ declare const shellLanguage: LRLanguage;
254
+ /**
255
+ Autocompletion for the shell's keywords, snippets, builtin commands,
256
+ common programs and the variables it sets.
257
+ */
258
+ declare const shellCompletion: CompletionSource;
259
+ /**
260
+ The name of a shell this package reads, or any of the aliases above.
261
+ */
262
+ type Shell = "sh" | "csh" | "fish";
263
+ /**
264
+ The language for one shell. `"csh"`, `"tcsh"` and `"fish"` are answered with
265
+ their own grammars, and everything else with the shell command language.
266
+ What a caller does with the result is the same either way.
267
+ */
268
+ declare function shellLanguageFor(shell: string): LRLanguage;
269
+ interface ShellConfig {
270
+ /**
271
+ Whose shell to read. `"sh"`, `"bash"`, `"zsh"` and `"ksh"` are all the one
272
+ grammar; `"csh"`, `"tcsh"` and `"fish"` each have their own. Defaults to
273
+ `"sh"`.
274
+ */
275
+ shell?: Shell | string;
276
+ }
277
+ /**
278
+ Shell language support, with completion for keywords, snippets, builtins,
279
+ the variables the shell sets and the names declared in the file.
280
+ */
281
+ declare function shell(config?: ShellConfig): LanguageSupport;
282
+ /**
283
+ C shell support, for a caller who knows which of the grammars they want.
284
+ */
285
+ declare function csh(): LanguageSupport;
286
+ /**
287
+ fish support, likewise.
288
+ */
289
+ declare function fish(): LanguageSupport;
290
+ /**
291
+ Bash support. This is `shell()`, named for the shell most scripts are
292
+ written for.
293
+ */
294
+ declare function bash(): LanguageSupport;
295
+
296
+ export { bash, csh, cshCompletion, cshLanguage, parser$1 as cshParser, fish, fishCompletion, fishLanguage, parser as fishParser, localCompletionSource, parser$2 as parser, shell, shellCompletion, shellKeywordCompletion, shellLanguage, shellLanguageFor, snippets };
297
+ export type { Shell, ShellConfig };