openscad-lsp

Crates.ioopenscad-lsp
lib.rsopenscad-lsp
version2.0.1
created_at2022-05-27 09:30:50.719391+00
updated_at2025-05-28 02:09:09.030716+00
descriptionA language(LSP) server for OpenSCAD
homepage
repositoryhttps://github.com/Leathong/openscad-LSP
max_upload_size
id594984
size274,303
Leathong (Leathong)

documentation

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
    }
  }
}
Commit count: 185

cargo fmt