Quickstart
Language server
| Requires | cargo |
| Platforms | linux, macOS, Windows |
| Successfully tested on | Arch |
| Documentation | spectralflux.dev/decs/m2-ls.html |
| Repository | github.com/AlexanderGolys/m2-ls.git |
| crates.io | crates.io/crates/m2-ls |
The m2-ls language server is cross platform binary Rust crate with no additional dependencies needed to run the binary.
To install it from cargo toolchain run
cargo install m2-ls
To run it from source code, clone the repository and run
cargo run --bin m2-ls
To configure the client in code editors, see LSP setup
Linting and formatting
Linter and formatter used in
m2-lsare also available as standalone binaries. After installing the crate, you can run them in terminal usingm2-fmt [file] m2-lint [file]
VS Code extension
Search for the Macaulay2 LSP extension and you’re done.
Documentation · Marketplace · Repository
m2.nvim
| Requires | Neovim 0.11+, M2 for running code |
| Platforms | linux, macOS, Windows |
| Successfully tested on | Arch |
| Documentation | Nvim plugin |
| Repository | github.com/AlexanderGolys/m2.nvim |
With lazy.nvim add
{
"AlexanderGolys/m2.nvim",
dependencies = { "nvim-treesitter/nvim-treesitter" },
opts = {},
}
The plugin doesn’t start the language server by itself, see LSP in Nvim for the few lines that do.
Running code
<leader>moopens M2 in a split,<leader>mcsends the expression under the cursor (or the selection) to it.
spectral-m2
| Requires | cargo, M2 |
| Platforms | linux, macOS |
| Successfully tested on | Arch |
| Documentation | spectral-m2 |
| Repository | github.com/AlexanderGolys/spectral-m2 |
| crates.io | crates.io/crates/spectral-m2 |
spectral-m2 runs your installed M2 underneath, so M2 needs to be on the PATH.
To install it run
cargo install spectral-m2 --locked
and start it with spectral-m2 (or just sp2) instead of M2. Typing / on an empty line lists all commands.
Fonts
Icons need a Nerd Font. Without one, set
SPECTRAL_M2_BASIC_GLYPHS=1.
MarkdownDocs
| Requires | M2, mdbook |
| Platforms | linux, macOS |
| Successfully tested on | Arch |
| Documentation | MarkdownDocs |
| Repository | github.com/AlexanderGolys/MarkdownDocs |
Clone the repository and install the package from M2
installPackage("MarkdownDocs", FileName => "/path/to/MarkdownDocs.m2")
mdbook-tsitter
| Requires | cargo, mdbook 0.5, git, C compiler |
| Platforms | linux, macOS, Windows |
| Successfully tested on | Arch |
| Documentation | spectralflux.dev/mdbook-tsitter |
| Repository | github.com/AlexanderGolys/mdbook-tsitter |
| crates.io | crates.io/crates/mdbook-tsitter |
To install it run
cargo install mdbook-tsitter
and enable it in book.toml
[preprocessor.tsitter]
First build
Grammars are compiled on first use, which is why
gitand a C compiler are needed. After that they’re cached.
ProceduralMacros
| Requires | M2 1.26.05+ |
| Platforms | linux, macOS |
| Successfully tested on | Arch |
| Documentation | ProceduralMacros |
| Repository | github.com/AlexanderGolys/ProceduralMacros |
Clone the repository and install the package from M2
installPackage("ProceduralMacros", FileName => "/path/to/ProceduralMacros.m2")
m2-syn
| Requires | cargo |
| Platforms | linux, macOS, Windows |
| Successfully tested on | Arch |
| Documentation | docs.rs/m2-syn |
| Repository | github.com/AlexanderGolys/m2-syn |
| crates.io | crates.io/crates/m2-syn |
m2-syn is a library crate. To add it to your Rust project run
cargo add m2-syn
Inspecting a file
To see the syntax tree of a file, clone the repository and run
cargo run --example inspect -- file.m2
tree-sitter-macaulay2
| Requires | cargo, npm or pip |
| Platforms | linux, macOS, Windows |
| Successfully tested on | Arch |
| Documentation | tree-sitter-macaulay2 |
| Repository | github.com/AlexanderGolys/tree-sitter-macaulay2 |
| crates.io | crates.io/crates/tree-sitter-macaulay2 |
| npm | npmjs.com/package/tree-sitter-macaulay2 |
| PyPI | pypi.org/project/tree-sitter-macaulay2 |
The grammar is published for Rust, Node and Python
cargo add tree-sitter tree-sitter-macaulay2
npm install tree-sitter-macaulay2
pip install tree-sitter-macaulay2
Editors
To use the grammar for highlighting in an editor, see Setting up tree-sitter.