A small Neovim plugin for editing and running Maple inspired by macaulay2.nvim and SublimeTextMaple.
- Filetype detection for
.mpland.mmMaple language files - Vim syntax highlighting for Maple lexical structure: nested comments, strings, quoted names, unevaluation quotes, preprocessor directives, reserved words, operators, types, packages, built-ins, and delimiter errors (list of keywords may not be exhaustive)
- Integrated Maple REPL using Neovim's terminal
- Send current line, visual selection, whole buffer, or current file to Maple
- Static keyword/function/package completion through
nvim-cmp
- Neovim (tested on 0.12.2 but should work for nvim>=0.8.0)
- Maple installed and available in your PATH
- Linux/macOS default command:
maple - Windows default command:
cmaple
- Linux/macOS default command:
- Optional:
nvim-cmpfor completion
Using Neovim's built-in package manager:
vim.pack.add({ 'https://github.com/shubh688/maple.nvim' })
require('maple').setup()Using lazy.nvim:
{
'shubh688/maple.nvim',
ft = 'maple',
opts = {},
}Default configuration:
require('maple').setup({
repl = {
-- Uses 'maple' on Linux/macOS and 'cmaple' on Windows by default.
cmd = nil,
args = {},
direction = 'vertical', -- 'vertical', 'horizontal', 'float', or 'tab'
size = 0.4,
float_opts = {
border = 'rounded',
width = 0.8,
height = 0.8,
},
auto_start = true,
auto_scroll = true,
autosave_before_read = true,
buffer_name = 'Maple REPL',
},
completion = {
enabled = true,
},
keymaps = {
enabled = true,
prefix = '<localleader>',
enter_sends = true,
},
})All commands are available under :Maple:
| Command | Description |
|---|---|
:Maple |
Toggle the REPL |
:Maple start |
Start the REPL |
:Maple stop |
Stop the REPL |
:Maple toggle |
Toggle REPL visibility |
:Maple show |
Show the REPL window |
:Maple hide |
Hide the REPL window while keeping Maple running |
:Maple focus |
Focus the REPL window |
:Maple send {code} |
Send one command/string to Maple |
:Maple buffer |
Send the whole current buffer to Maple |
:Maple read [file] |
Ask Maple to read a file; defaults to the current file |
:Maple run [file] |
Alias for read |
:Maple restart |
Send restart; |
:Maple help [topic] |
Send ?topic; defaults to word under cursor |
:Maple usage [topic] |
Send ??topic; defaults to word under cursor |
:Maple examples [topic] |
Send ???topic; defaults to word under cursor |
Default keymaps are buffer-local for maple filetype buffers.
| Key | Mode | Description |
|---|---|---|
<CR> |
normal | Send current line to Maple |
<CR> |
visual | Send visual selection to Maple |
K |
normal | Show Maple help for word under cursor |
<localleader>s |
normal | Toggle REPL |
<localleader>o |
normal | Start REPL |
<localleader>c |
normal | Stop REPL |
<localleader>f |
normal | Focus REPL |
<localleader>b |
normal | Send whole buffer |
<localleader>r |
normal | Read current file in Maple |
<localleader>h |
normal | Help for word under cursor |
<localleader>u |
normal | Usage for word under cursor |
<localleader>x |
normal | Examples for word under cursor |
These mappings are available for custom keymaps:
<Plug>(maple-start)<Plug>(maple-stop)<Plug>(maple-toggle)<Plug>(maple-focus)<Plug>(maple-send-line)<Plug>(maple-send-selection)<Plug>(maple-send-buffer)<Plug>(maple-read-file)<Plug>(maple-help-cursor)<Plug>(maple-usage-cursor)<Plug>(maple-examples-cursor)
- The plugin targets plain-text Maple language files (
.mpl, plus.mmfor projects that use that extension), not binary/worksheet files. Because.mmis also used by Objective-C++, setvim.g.maple_nvim_detect_mm = falsebefore loading the plugin if you do not want maple.nvim to claim.mmfiles. - The REPL sends exactly what you give it. Maple commands usually need a trailing
;or:when you want Maple to execute them as complete statements. (If you are someone like me, this warning is absolutely necessary.) - Plotting from command-line Maple depends on your Maple installation and display environment.
- LSP.
- Tree-sitter integration.
MIT