Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Nvim plugin

m2.nvim makes Neovim feel at home with .m2 files and lets you run code from the buffer.

-- lazy.nvim
{
  "AlexanderGolys/m2.nvim",
  dependencies = { "nvim-treesitter/nvim-treesitter" },
  opts = {},
}

Neovim 0.11+.

What you get

  • filetype detection, comments, indentation, :make running the file through M2 with errors in quickfix
  • folding and indentation from the tree-sitter grammar
  • an M2 terminal next to your code, and keys to send code to it

The language server isn’t started by the plugin; it’s a few lines, see here.

Running code

Keys
<leader>moopen M2 in a split
<leader>mcsend the cell under the cursor (or the selection)
<leader>mlsend the current line
<leader>mthide / show the terminal (M2 keeps running)
<leader>mqclose it

A cell is just the top-level expression under the cursor, so no -- %% markers. A multi-line call goes as one piece.

Keys can be changed with opts.term.keys, or switched off with term = false.

Repository