MCPcopy Index your code
hub / github.com/Leathong/openscad-LSP

github.com/Leathong/openscad-LSP @v2.0.2

Chat with this repo
repository ↗ · DeepWiki ↗ · release v2.0.2 ↗ · + Follow
76 symbols 172 edges 10 files 4 documented · 5%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

NOTICE: Because clang-format produces poor formatting results for OpenSCAD, we have completely removed support for clang-format and switched to the new formatter topiary

openscad-LSP

A LSP (Language Server Protocol) server for OpenSCAD.

inspired by dzhu/openscad-language-server

Tested with VSCode on Mac and Windows. [vscode extension]

Tested with lsp-mode on Emacs on Linux by @Lenbok.

Features

  • builtin function/module documents
  • code and path auto-completion
  • jump to definition
  • code snippets
  • function/module signatures on hover
  • document symbols
  • formatter, utilizing topiary.
  • variable / module renaming
  • hover and suggestion documentation, read from comments before the function/module.

IDE plugins

IDE Plugin Note
Neovim mason.nvim Only tested on Mac and Linux
Neovim nvim-lspconfig Only tested on Mac and Linux
VS Code openscad-language-support Only tested on Mac and Windows
Emacs lsp-bridge Only tested on Mac and Linux

Install

openscad-LSP is written in Rust, in order to use it, you need to install Rust toolchain.

cargo install openscad-lsp

Build

cd openscad-LSP
cargo build --release

Usage

The server communicates over TCP socket (127.0.0.1:3245).

A language(LSP) server for OpenSCAD

Usage: openscad-lsp [OPTIONS]

Options:
  -p, --port <PORT>              [default: 3245]
      --ip <IP>                  [default: 127.0.0.1]
      --builtin <BUILTIN>        external builtin functions file path, if set, the built-in builtin functions file will not be used [default: ]
      --stdio                    use stdio instead of tcp
      --ignore-default           exclude default params in auto-completion
      --depth <DEPTH>            search depth [default: 3]
      --indent <INDENT>          The indentation string used for that particular language. Defaults to "  " if not provided. Any string can be provided, but in most instances will be some whitespace: "  ", "    ", or "\t"
      --query-file <QUERY_FILE>  The query file used for topiary formatting
  -h, --help                     Print help
  -V, --version                  Print version

To change the config at runtime, you can send notification workspace/didChangeConfiguration

// example
{
  "settings": {
    "openscad": {
      "search_paths": "/libs",
      "indent": "    ",
      "query_file": "path/to/my/openscad.scm",
      "default_param": true
    }
  }
}

Extension points exported contracts — how you extend this code

Core symbols most depended-on inside this repo

Shape

Method 50
Function 13
Class 9
Enum 2
Interface 2

Languages

Rust100%

Modules by API surface

src/server/utils.rs17 symbols
src/server/response_item.rs14 symbols
src/server/mod.rs10 symbols
src/server/parse_code.rs8 symbols
src/server/handler/request.rs8 symbols
src/server/handler/notification.rs7 symbols
src/server/code_helper.rs4 symbols
src/topiary.rs3 symbols
src/server/handler/mod.rs3 symbols
src/main.rs2 symbols

For agents

$ claude mcp add openscad-LSP \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page