MCPcopy Index your code
hub / github.com/LaBatata101/sith-language-server

github.com/LaBatata101/sith-language-server @main

Chat with this repo
repository ↗ · DeepWiki ↗ · + Follow
3,480 symbols 9,392 edges 616 files 567 documented · 16%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

SithLSP

[!WARNING] THIS SOFTWARE IS IN ALPHA STATE EXPECT BUGS, BREAKING CHANGES, CRASHES, EXPLOSIONS AND EVERYTHING IN BETWEEN!

An experimental language server for the Python programming language.

Features

  • 🪲 Syntax checking
  • ↪ Go to definition
  • 🔍 Find references
  • 🖊️ Autocompletion
  • 📝 Element renaming
  • 🗨️ Hover to view details on variables, functions, and more (only shows documentation for now)
  • 💅 Code formatting and linting powered by Ruff
  • 💡 Highlighting of symbol references
  • 🐍 Automatically detect the Python interpreter being used by your project
  • ... and many more!

LSP methods implemented so far

  • textDocument/completion
  • textDocument/publishDiagnostics
  • textDocument/definition
  • textDocument/references
  • textDocument/formatting
  • textDocument/didChange
  • textDocument/documentHighlight
  • textDocument/didOpen
  • textDocument/didClose
  • textDocument/rename
  • textDocument/prepareRename
  • textDocument/hover
  • textDocument/documentSymbol
  • textDocument/codeAction
  • textDocument/signatureHelp
  • workspace/executeCommand
  • workspace/didChangeWorkspaceFolders
  • completionItem/resolve
  • codeAction/resolve

How to use

You can install SithLSP from the main branch with

$ cargo install --git https://github.com/LaBatata101/sith-language-server

To install a specific release use --tag

$ cargo install --git https://github.com/LaBatata101/sith-language-server --tag v0.2.3-alpha

You can also download the latest version of SithLSP from the releases or build it manually following the steps below. The VSCode extension can also be downloaded from the releases page, it's the .vsix file.

Building the project

Download the repository with

$ git clone https://github.com/LaBatata101/sith-language-server

now build the SithLSP binary (you'll need the latest version of the Rust compiler).

$ cd sith-language-server
$ cargo build --release

The binary will be located in the target/release folder. You should place the binary in $PATH or, if you're using VSCode, you can use the sith.executable setting option.

Building the VSCode extension

It's probably better to disable the Python or Pylance extensions, from Microsoft, to avoid any conflicts when using this extension.

You can build the VSCode extension manually with

# First we need to build the extension package
$ npm install -g @vscode/vsce
$ cd sith-language-server/editors/vscode
# Install dependencies
$ npm install
# Build the extension package
$ npm run compile
$ vsce package
# Now manually install the extension
$ code --install-extension sith-language-server-*.vsix

Neovim Configuration

If you're using nvim-lspconfig add this to your config

local lspconfig = require("lspconfig")
local configs = require("lspconfig.configs")

if not configs.sith_lsp then
  local root_files = {
    "pyproject.toml",
    "requirements.txt",
    "Pipfile",
    "pyrightconfig.json",
    ".git",
  }
  configs.sith_lsp = {
    default_config = {
      cmd = { "/path/to/sith-lsp" },
      root_dir = function(fname)
        return lspconfig.util.root_pattern(unpack(root_files))(fname)
      end,
      single_file_support = true,
      filetypes = { "python" },
      settings = {
          -- Settings for the server goes here.
          -- Config example
          ruff = {
              lint = {
                  enable = true
              }
          }
      },
    },
  }
end

Otherwise, add this to your init.lua config file.

local pwd = vim.loop.cwd()
vim.api.nvim_create_autocmd("FileType", {
  pattern = "python",
  callback = function()
    vim.lsp.start({
      name = "SithLSP",
      filetypes = { "python" },
      root_dir = pwd,
      cmd = { "/path/to/sith-lsp" },
      init_options = {
        settings = {
          -- Settings for the server goes here.
          -- Config example
          ruff = {
            lint = {
              enable = true
            }
          }
        },
      },
    })
  end,
})

Helix Configuration

Add this to your languages.toml config file.

[language-server.sith-lsp]
command = "/path/to/sith-lsp"

# Config example
[language-server.sith-lsp.config.settings.ruff.lint]
enable = true

[[language]]
name = "python"
language-servers = [
  "sith-lsp",
]

Settings

You can ommit the sith prefix from the settings if you are not on VSCode.

sith.executable

NOTE: This setting is only valid in the VSCode extension.

Path to the language server executable.

  • type: string
  • default: sith-lsp

sith-language-server.trace.server

NOTE: This setting is only valid in the VSCode extension.

Traces the communication between VS Code and the language server.

  • type: string
  • default: off
  • options: off, messages, verbose

sith.logLevel

Controls the log level of the language server.

  • type: string
  • default: null
  • options: error, warning, info, debug, trace

sith.logFile

Path to the log file for the language server.

  • type: string
  • default: null

sith.interpreter

Path to a Python interpreter to use to run the LSP server. If this setting is set sith won't search automatically for a Python interpreter.

  • type: string
  • default: null

sith.ruff.enable

Whether to enable Ruff.

  • type: boolean
  • default: true if sith.ruff.path is set, false otherwise.

sith.ruff.path

Path to the ruff executable, e.g., [\"/path/to/ruff\"].

  • type: string
  • default: null

sith.ruff.format.enable

Whether to enable Ruff formatting.

  • type: boolean
  • default: true if sith.ruff.path is set, false otherwise.

sith.ruff.format.args

Additional command-line arguments to pass to ruff format, e.g., \"args\": [\"--config=/path/to/pyproject.toml\"]. Supports a subset of Ruff's command-line arguments, ignoring those that are required to operate the LSP, like --force-exclude and --verbose.

  • type: string[]
  • default: []

sith.ruff.lint.enable

Whether to enable Ruff linting.

  • type: boolean
  • default: true if sith.ruff.path is set, false otherwise.

sith.ruff.lint.args

Additional command-line arguments to pass to ruff check, e.g., \"args\": [\"--config=/path/to/pyproject.toml\"]. Supports a subset of Ruff's command-line arguments, ignoring those that are required to operate the LSP, like --force-exclude and --verbose.

  • type: string[]
  • default: []

sith.ruff.lint.select

Set rule codes to enable. Use ALL to enable all rules. See the documentation for more details.

  • type: string[]
  • default: null

sith.ruff.lint.extendSelect

Enable additional rule codes on top of existing configuration, instead of overriding it. Use ALL to enable all rules.

  • type: string[]
  • default: null

sith.ruff.lint.ignore

Set rule codes to disable. See the documentation for more details.

  • type: string[]
  • default: null

Acknowledgements

  • Ruff - ~~stole~~ borrowed lots of code from them.

Extension points exported contracts — how you extend this code

Ranged (Interface)
A ranged item in the source text. [110 implementers]
crates/ruff_text_size/src/traits.rs
Visitor (Interface)
A trait for AST visitors. Visits all nodes in the AST recursively in evaluation-order. Prefer [`crate::statement_visito [8 …
crates/sith_python_ast/src/visitor.rs
RequestHandler (Interface)
A supertrait for any server request handler. [15 implementers]
crates/sith_server/src/server/api/traits.rs
Notification (Interface)
(no doc) [26 implementers]
crates/lsp-types/src/notification.rs
Host (Interface)
A trait to expose the host environment to the resolver. [2 implementers]
crates/ruff_python_resolver/src/host.rs
UniversalNewlines (Interface)
Extension trait for [`str`] that provides a [`UniversalNewlineIterator`]. [1 implementers]
crates/ruff_source_file/src/newlines.rs
AsMode (Interface)
A type that can be represented as [Mode]. [1 implementers]
crates/sith_python_parser/src/lib.rs
Idx (Interface)
Represents a newtype wrapper used to index into a Vec or a slice. You can use the [`newtype_index`](crate::newtype_inde
crates/ruff_index/src/idx.rs

Core symbols most depended-on inside this repo

join
called by 199
crates/sith_server/src/server/schedule/thread.rs
visit_source_order
called by 178
crates/sith_python_ast/src/node.rs
visit_expr
called by 149
crates/sith_python_ast/src/visitor.rs
expect
called by 145
crates/sith_python_parser/src/parser/mod.rs
as_ref
called by 141
crates/sith_python_ast/src/node.rs
parse_suite
called by 128
crates/sith_python_parser/src/string.rs
add_error
called by 128
crates/sith_python_parser/src/parser/mod.rs
node_range
called by 114
crates/sith_python_parser/src/parser/mod.rs

Shape

Method 1,462
Function 987
Class 720
Enum 270
Interface 27
Route 14

Languages

Rust93%
Python6%
TypeScript1%

Modules by API surface

crates/sith_python_ast/src/nodes.rs253 symbols
crates/lsp-types/src/lib.rs155 symbols
crates/sith_python_parser/src/lexer.rs152 symbols
crates/sith_python_parser/src/parser/expression.rs77 symbols
crates/sith_python_parser/src/parser/statement.rs76 symbols
crates/sith_semantic_model/src/type_inference.rs75 symbols
crates/sith_python_parser/src/string.rs72 symbols
crates/lsp-types/src/request.rs69 symbols
crates/sith_python_ast/src/visitor/source_order.rs67 symbols
crates/sith_python_parser/src/parser/mod.rs59 symbols
crates/sith_python_ast/src/visitor/transformer.rs59 symbols
crates/sith_python_ast/src/visitor.rs59 symbols

For agents

$ claude mcp add sith-language-server \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact