Skip to content
This repository was archived by the owner on Dec 15, 2022. It is now read-only.

Commit 8b67413

Browse files
committed
add syntax switch
1 parent fb5e912 commit 8b67413

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

lib/snippet-body-parser.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
1+
const syntax = atom.config.get("snippets.snippetSyntax");
2+
const parserName = syntax === "LSP" ? "snippet-body" : "snippet-body-old";
3+
14
let parser
25
try {
3-
parser = require('./snippet-body')
6+
parser = require(`./${parserName}`)
47
} catch (error) {
58
const {allowUnsafeEval} = require('loophole')
69
const fs = require('fs-plus')
710
const PEG = require('pegjs')
811

9-
const grammarSrc = fs.readFileSync(require.resolve('./snippet-body.pegjs'), 'utf8')
12+
const grammarSrc = fs.readFileSync(require.resolve(`./${parserName}.pegjs`), 'utf8')
1013
parser = null
1114
allowUnsafeEval(() => parser = PEG.buildParser(grammarSrc))
1215
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
"configSchema": {
3434
"snippetSyntax": {
3535
"type": "string",
36-
"description": "Configures the syntax used for snippets. LSP is mostly a superset of original, with support for more features (but not all features may be implemented yet).",
36+
"description": "(Requires restart) Configures the syntax used for snippets. LSP is mostly a superset of original, with support for more features (but not all features may be implemented yet).",
3737
"default": "LSP",
3838
"enum": [
3939
"LSP",

0 commit comments

Comments
 (0)