Skip to content

pherrymason/c3-lsp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Language Server for the C3 language.

Go

WIP LSP for C3 language

Project Goals

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.

Current target

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.

Future plans

Once these initial objectives are completed, we will explore additional functionalities that can be added to the project, further enhancing its capabilities and usefulness.

Server

Supported OS

Project is written in Golang, so in theory it could be built to any OS supported by Golang.

Usage

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.

Installation

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 create c3-lsp in server/bin folder.

Features

  • 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)

IDE extensions

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.

Useful links: