WIP LSP for C3 language
Writing a Language Server Protocol (LSP) can be a complex and challenging task. To manage this complexity, our initial focus is on covering the basic yet essential needs of a typical LSP implementation.
The main current target, is to cover the most essential feature which is to scan precise information about symbols used within the source code of a project.
This information can then be used by an IDE to enable the following features:
- Go to Definition: Navigate to the exact location where a symbol is defined.
- Hover Information: Display detailed information about symbols when hovering over them.
- Autocomplete: Suggest relevant symbols and code completions as you type.
These features will significantly improve the developer experience by providing accurate and efficient code navigation and assistance.
Once these initial objectives are completed, we will explore additional functionalities that can be added to the project, further enhancing its capabilities and usefulness.
Project is written in Golang, so in theory it could be built to any OS supported by Golang.
Simply run c3-lsp
to start the server.
It supports the following options:
- help: Display accepted options.
- send-reports: If enabled (disabled by default) will send crash reports to Sentry so bugs can be debugged easily.
- lang-version: Use it to specify a specific c3 language version. By default
c3-lsp
will select the last version supported.
Precompiled binaries for the following operating systems are available:
You can also build from source:
- Download and install golang: https://go.dev/
- Clone this repo
- Run
make build
: This will createc3-lsp
inserver/bin
folder.
- TextDocumentCompletion. Suggests symbols located in project's source code. See notes.
- Go to declaration.
- Go to definition.
- Hover Displays information about symbol under cursor.
- Stdlib Offers symbol information of stdlib (0.5.5)
There's a simple vscode extension available for download here: download vix
Be sure to configure it with the path of the lsp server binary.
Current status
Index status
- [~] Attributes (Module privacy)
- Variables & type
- Global constants
- Functions
- Function parameters
- Function return type
- Enums + Enumerators
- base type
- enum methods
- Faults
- Structs
- Struct members
- Struct methods
- Struct implementing interface
- Anonymous bitstructs
- [~] Struct subtyping: Only for those subtypes defined in same file.
- bitstruct
- Unions
- Union members
- [~] defines
- Interfaces
- [~] Macros
- return type
- imports
- modules
- multiple modules per file
- implicit module name is assumed to be the file name, converted to lower case, with any invalid characters replaced by underscore (_).
- Generics
- Language Builtins
LSP Features Status
- Index scopes and its hierarchy to improve hover and Auto Completion.
- Complete Go to declaration
- Find symbol in same scope
- Find symbol in parent scope
- Find symbol present in same module, but different file
- Find symbol in imported module
- Find symbol in implicit parent module.
- Find symbol in stdlib
- [~] TextDocumentCompletion:
- Struct methods are not suggested until first letter is written.
- LSP specification: https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/
- treesitter
- Queries docs: https://tree-sitter.github.io/tree-sitter/using-parsers#pattern-matching-with-queries
- Queries: https://emacs-tree-sitter.github.io/syntax-highlighting/queries/
- Tree-sitter - a new parsing system for programming tools (video) https://www.thestrangeloop.com/2018/tree-sitter---a-new-parsing-system-for-programming-tools.html