MCPcopy Index your code
hub / github.com/IWANABETHATGUY/tower-lsp-boilerplate

github.com/IWANABETHATGUY/tower-lsp-boilerplate @v1.0.0

Chat with this repo
repository ↗ · DeepWiki ↗ · release v1.0.0 ↗ · + Follow
75 symbols 113 edges 11 files 4 documented · 5% updated 4mo ago★ 2862 open issues

Browse by type

Functions 55 Types & classes 20
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

boilerplate for a rust language server powered by tower-lsp

[!note] This repo use a language which is a very small subset of rust called nano rust

A valid program in nano rust

fn factorial(x) {
    // Conditionals are supported!
    if x == 0 {
        1
    } else {
        x * factorial(x - 1)
    }
}

// The main function
fn main() {
    let three = 3;
    let meaning_of_life = three * 14 + 1;

    print("Hello, world!");
    print("The meaning of life is...");

    if meaning_of_life == 42 {
        print(meaning_of_life);
    } else {
        print("...something we cannot know");

        print("However, I can tell you that the factorial of 10 is...");
        // Function calling
        print(factorial(10));
    }
}

Introduction

This repo is a template for tower-lsp, a useful github project template which makes writing new language servers easier.

Development using VSCode

  1. pnpm i
  2. cargo build
  3. Open the project in VSCode: code .
  4. In VSCode, press F5 or change to the Debug panel and click Launch Client.
  5. In the newly launched VSCode instance, open the file examples/test.nrs from this project.
  6. If the LSP is working correctly you should see syntax highlighting and the features described below should work.

[!note] If encountered errors like Cannot find module '/xxx/xxx/dist/extension.js' please try run command tsc -b manually, you could refer https://github.com/IWANABETHATGUY/tower-lsp-boilerplate/issues/6 for more details

Preview and test extension locally with VsCode

  1. Make sure all dependency are installed.
  2. Make sure the nrs-language-server is under your PATH
  3. pnpm run package
  4. code --install-extension nrs-language-server-${version}.vsix, the version you could inspect in file system.
  5. Restart the VsCode, and write a minimal nano rust file, then inspect the effect.

For other editor, please refer the related manual, you could skip steps above.

Features

This repo use a language nano rust which first introduced by chumsky . Most common language feature has been implemented, you could preview via the video below.

  • [x] InlayHint for LiteralType inlay hint

  • [x] semantic token
    make sure your semantic token is enabled, you could enable your semantic token by adding this line to your settings.json

{
 "editor.semanticHighlighting.enabled": true,
}
  • [x] syntactic error diagnostic

https://user-images.githubusercontent.com/17974631/156926382-a1c4c911-7ea1-4d3a-8e08-3cf7271da170.mp4

  • [x] code completion

https://user-images.githubusercontent.com/17974631/156926355-010ef2cd-1d04-435b-bd1e-8b0dab9f44f1.mp4

  • [x] go to definition

https://user-images.githubusercontent.com/17974631/156926103-94d90bd3-f31c-44e7-a2ce-4ddfde89bc33.mp4

  • [x] find reference

https://user-images.githubusercontent.com/17974631/157367235-7091a36c-631a-4347-9c1e-a3b78db81714.mp4

  • [x] rename

https://user-images.githubusercontent.com/17974631/157367229-99903896-5583-4f67-a6da-1ae1cf206876.mp4

Core symbols most depended-on inside this repo

Shape

Method 30
Function 25
Class 11
Enum 9

Languages

Rust89%
TypeScript11%

Modules by API surface

src/main.rs27 symbols
src/nrs_lang.rs18 symbols
src/semantic_analyze.rs12 symbols
client/src/extension.ts6 symbols
src/symbol_table.rs4 symbols
src/completion.rs3 symbols
src/semantic_token.rs2 symbols
esbuild.js2 symbols
examples/index.rs1 symbols

For agents

$ claude mcp add tower-lsp-boilerplate \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page