SageMath Language Server Protocol
Project description
sage-lsp
Description
SageMath Language Server Protocol
[!TIP] This project may work well with SageMath 10.8+. Other versions lack stubs for Cython files, so they may have limited functionality.
However, until now (2026-2-13), SageMath 10.8 is not accessible from conda-forge (but it released on github). Meanwhile, maintainer doesn't include
.pyifiles in the build system, so you can't simply install it from pip either.You may need to install it from source code. And edit some code.
git clone --branch 10.8 --single-branch https://github.com/sagemath/sage.git cd sage mamba env create --file environment-3.12-linux.yml --name sage10.8 mamba activate sage10.8Edit
./tools/update-meson.pylike this@@ -93,3 +93,3 @@ python_files = sorted( - list(folder.glob("*.py")) + list(folder.glob('*.pxd')) + list(folder.glob('*.pyx')) + list(folder.glob("*.py")) + list(folder.glob('*.pxd')) + list(folder.glob('*.pyx')) + list(folder.glob('*.pyi')) ) # + list(folder.glob('*.pxd')) + list(folder.glob('*.h')))Run
./tools/update-meson.pyto regeneratemeson.buildfiles. Then you can install it.python ./tools/update-meson.py pip install .Using
sage --versionto check if successfully installed.
[!WARNING] If raising error about
ImportError: cysignals.signals does not export expected C function _do_raise_exception, using following command to fix it.pip uninstall cysignals conda install cysignals
Features
Supported from plugins(very thanks to those projects, they finished a lot of work):
- pygls basic LSP server framework
- pycodestyle linter for style checking
- autopep8 formatter for code formatting
- pyflakes linter for error checking
- jedi definition, type definiton, hover, references provider
- parso(dependency of jedi) for folding
- docstring-to-markdown praser for converting docstrings to markdown for hover information
Supported from native code:
- Only support using
from sage.xxx import xxxorimport sage.xxx(no alias) - Local symbols cache for Sage
- Custom formatting rules for Sage
- Custom error checking for Sage
- Custom definition for Sage symbols
- Custom hover information for Sage symbols
- Check references for Sage (only in current file)
- Jump to definiton in Cython files (
.pyx) from Stubs (.pyi) in Sage 10.8+ - Support type inference for Sage (depend on
.pyiin Sage 10.8+) - Support type hints hover info for unfollowed variables
- Quick fix for undefined name in Sage
- Completion for Sage (depend on
.pyiin Sage 10.8+)
Install
From source code:
git clone https://github.com/SeanDictionary/sage-lsp && cd sage-lsp
pip install .
From pip: (not released yet)
pip install sage-lsp
Usage
Directly run the server
sagelsp --help // print usage information
sagelsp --sage // print if SageMath is available and its version
sagelsp -l // set log level (default: INFO)
sagelsp --clear // clear local symbols cache and exit
Support global config file ~/.config/pycodestyle or local config file in project root .pycodestyle, setup.cfg, tox.ini for pycodestyle and autopep8, see more details in pycodestyle docs
Both pycodestyle and autopep8 config write in the same file under [pycodestyle] section, for example:
[pycodestyle]
max-line-length = 100
...
Using with extension SageMath-for-VScode
not released yet
Change Logs
See CHANGELOG.md
Contributing
See CONTRIBUTING.md
License
This project is licensed under the GPL-3.0 License. See the LICENSE file for details.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file sage_lsp-1.0.1.tar.gz.
File metadata
- Download URL: sage_lsp-1.0.1.tar.gz
- Upload date:
- Size: 38.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bf66bb5115491b749abfab8d8a8066d92c89ccec99e0c0a56b3065ed04933afc
|
|
| MD5 |
c2dc79668ce94b309904f3d894b4867a
|
|
| BLAKE2b-256 |
9b4ee3e8f1fef648682490b83e44b66bb081de11cc404a5b27a18a1210c3d1a5
|
Provenance
The following attestation bundles were made for sage_lsp-1.0.1.tar.gz:
Publisher:
publish.yml on SeanDictionary/sage-lsp
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
sage_lsp-1.0.1.tar.gz -
Subject digest:
bf66bb5115491b749abfab8d8a8066d92c89ccec99e0c0a56b3065ed04933afc - Sigstore transparency entry: 983146880
- Sigstore integration time:
-
Permalink:
SeanDictionary/sage-lsp@7dda78ce809b44a98024c4b198bae775b943a502 -
Branch / Tag:
refs/tags/1.0.1 - Owner: https://github.com/SeanDictionary
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@7dda78ce809b44a98024c4b198bae775b943a502 -
Trigger Event:
push
-
Statement type:
File details
Details for the file sage_lsp-1.0.1-py3-none-any.whl.
File metadata
- Download URL: sage_lsp-1.0.1-py3-none-any.whl
- Upload date:
- Size: 45.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
678a80df2a182ee63fdccc70ccce9ae25eabe2d432c4e4a071f06e31c70c884d
|
|
| MD5 |
1067935bb56f8b64f888087116209a89
|
|
| BLAKE2b-256 |
96d345cf00dea39e6830a9904b467dd3db6afe4ffd868a3a85e4ef20e3aa7e03
|
Provenance
The following attestation bundles were made for sage_lsp-1.0.1-py3-none-any.whl:
Publisher:
publish.yml on SeanDictionary/sage-lsp
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
sage_lsp-1.0.1-py3-none-any.whl -
Subject digest:
678a80df2a182ee63fdccc70ccce9ae25eabe2d432c4e4a071f06e31c70c884d - Sigstore transparency entry: 983146903
- Sigstore integration time:
-
Permalink:
SeanDictionary/sage-lsp@7dda78ce809b44a98024c4b198bae775b943a502 -
Branch / Tag:
refs/tags/1.0.1 - Owner: https://github.com/SeanDictionary
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@7dda78ce809b44a98024c4b198bae775b943a502 -
Trigger Event:
push
-
Statement type: