package.json
- this is the manifest file in which you declare your language support and define the location of the grammar file that has been copied into your extension.syntaxes/vcl.tmLanguage.json
- this is the Text mate grammar file that is used for tokenization.language-configuration.json
- this is the language configuration, defining the tokens that are used for comments and brackets.client/
- this is the Language Server Protocol client that talks to the LSP server (fastly-vcl-lsp
).
brew install npm
npm i node@lts
To develop this extension on your machine, clone this repository and install its dependencies:
gh repo clone fastly/vscode-fastly-vcl
cd vscode-fastly-vcl
npm i
- Open this folder in VS Code.
- Run
Cmd+Shift+B
to start compiling the client in watch mode. - Press
Cmd+Shift+D
to switch to the Run and Debug View in the sidebar. - Select
Fastly VCL Client
from the drop down. - Press ▷ to run the launch config with the debugger attached (
F5
). - In the Extension Development Host instance of VSCode, open a document in
Fastly VCL
language mode. - Save the file with a
.vcl
extension. - Use it as a scratchpad to try out all the features!
To run the grammar tests:
npm test
The test cases are stored as markdown files under test/colorize-fixtures
. Grammar test results are stored under test/colorize-results
, which are automatically generated from the fixtures.
To run the LSP tests:
npm run test-client
Run the following command to compile the VSCode extension as a .vsix
file.
npm run package
Then, either run code --install-extension vscode-fastly-vcl-{VERSION}.vsix
or follow the steps below to install the extension:
- Press
Cmd+Shift+X
to go to the VS Code extension tab. - Click the ellipsis (above "Search Extensions in Marketplace") and pick
Install from VSIX...
from the dropdown. - Install the
.vsix
file you created.
Please open a pull request with your changes.
This uses a JSON TextMate language grammar: syntaxes/vcl.tmLanguage.json, a structured collection of regular expressions, to tokenize the text into scopes such as:
keyword.control.vcl
variable.other.vcl
string.quoted.double.vcl
comment.line.number-sign.vcl
For example, the extension scopes Fastly code macros as control keywords using a regular expression in JSON:
{
"name": "keyword.control.vcl",
"match": "^\\s*#FASTLY\\s+(deliver|error|fetch|hash|hit|log|miss|pass|recv)\\s*$"
}
Visual Studio Code themes such as GitHub Dark Default or the default Light+ map scopes to colours and styles.
The GitHub Dark default theme maps the keyword scope to red using a JavaScript object:
{
scope: "keyword",
settings: {
foreground: lightDark(scale.red[5], scale.red[3])
}
}
The Fastly VCL Language Server Protocol (LSP) server works for .vcl
files. The server is still in an early state. The following list tracks the protocol features that are supported:
-
textDocument/codeAction
-
textDocument/completion
(incl.completion/resolve
) -
textDocument/definition
-
textDocument/didChange (incremental)
-
textDocument/didClose
-
textDocument/didOpen
-
textDocument/didSave
-
textDocument/documentHighlight
-
textDocument/documentSymbol
-
textDocument/executeCommand
-
textDocument/formatting
-
textDocument/hover
-
textDocument/inlayHint
-
textDocument/prepareCallHierarchy
-
callHierarchy/incomingCalls
-
callHierarchy/outgoingCalls
-
textDocument/prepareRename
-
textDocument/rangeFormatting
-
textDocument/references
-
textDocument/rename
-
textDocument/selectionRange
-
textDocument/signatureHelp
-
workspace/symbol
-
workspace/didChangeConfiguration
-
workspace/executeCommand