Skip to content

shubh688/maple.nvim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

maple.nvim

A small Neovim plugin for editing and running Maple inspired by macaulay2.nvim and SublimeTextMaple.

Features

  • Filetype detection for .mpl and .mm Maple 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

Requirements

  • 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
  • Optional: nvim-cmp for completion

Installation

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 = {},
}

Configuration

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,
  },
})

Commands

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

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

Plug mappings

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)

Notes

  • The plugin targets plain-text Maple language files (.mpl, plus .mm for projects that use that extension), not binary/worksheet files. Because .mm is also used by Objective-C++, set vim.g.maple_nvim_detect_mm = false before loading the plugin if you do not want maple.nvim to claim .mm files.
  • 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.

To-do

  • LSP.
  • Tree-sitter integration.

License

MIT

About

A small Neovim plugin for editing and running Maple inspired by macaulay2.nvim and SublimeTextMaple

Resources

License

Stars

1 star

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors