VSCode Language Server Extension Notes - DevOps-MBSE/AaC GitHub Wiki
This wiki page is set-up containing information about possible AaC features and capabilities for writing a VSCode Language Server plugin, and what it would take to bring that functionality to AaC.
The VSCode docs include a Language Server Extension Guide that describes Language Servers and Clients and how they interoperate.
Capabilities
This section focuses on what capabilities VSCode Language Server extensions provide and how we might leverage those capabilities to provide language features for AaC users.
Completion
Provide possible completion items at the specified text document position. This could be function names, variable names, etc.
Context
Provide contextual information about the item at the specified text document position. This can include signature information, symbol locations, etc.
Formatting
Provide the ability to format documents, regions of code, etc.
Navigation
Several facilities exist for jumping to different parts of the code including jump to definition, implementation, declaration, etc.
Refactoring
Depending on the language and its needs, refactoring options such as renaming symbols, etc can be available.
Validation
Provide information regarding the validity of a specific file, based on the language compiler, interpreter, etc.
Technical Requirements
Language Server
Any programming language can be used to implement a language server and, commonly, the language for which the server is being implemented is usually used. For example, a Python language extension might likely be implemented in Python. That said, this isn't a requirement - as long as the server can communicate with the VSCode client using JSON-RPC, it will work.
Language Client
The language client is a standard VSCode extension which, it seems, would need to be written using JavaScript/TypeScript.
Technical Considerations
Single-Language Server
A single language server is intended to provide the aformentioned capabilities for a single language corresponding to a specific file.
Multi-Language Server
A multi-language server provides completion, highlighting, etc for multiple languages in the same file. A common case where a multi-language server would be needed is when writing CSS and/or JavaScript inside an HTML file. More closely related to AaC, we might think of including Jinja templating constructs in an AaC YAML file.
High-Level Implementation
High-level suggestions for implementation of a language server plugin include:
- Create a VSCode Plugin to act as the client.
- Create a module in the AaC project that will act as the server interface (recommend using pygls for this).
Resources
Documentation
- Language Server Protocol
- Language Extensions Overview
- Language Server Extension Guide
- Programmatic Language Features
Examples
- lsp-sample
- lsp-sample: server.ts
- lsp-multi-server-sample
- github: lextm/ansi-c-antlr
- github: lextm/vscode-ansic