Skip to content

olidacombe/makemapper.nvim

Repository files navigation

MakeMapper

This aims to make project-specific keymappings for make targets trivial by means of parsing them from comments affixed to make targets in your Makefile.

There is also a telescope extension to run make targets from a picker.

Example

Annotate your Makefile with comments containing nvim_map(...):

# nvim_map(l)
lint:
	echo linting stuff...

test: # nvim_map(t)
    echo running tests...

no_mapping: # this target doesn't get an automatic keymap
    echo I am harder to run from neovim

Then the following normal-mode keymaps are automatically created:

<leader>ml -> `make lint`
<leader>mt -> `make test`

Installation

Packer

use('olidacombe/makemapper')

Setup

require("makemapper").setup()

Telescope

To register the makemapper telescope extension, load it as follows:

-- Make `:Telescope makemapper` available
require('telescope').load_extension('makemapper')

Configuration

You can override settings in setup:

require("makemapper").setup({
    prefix = "<leader>m", -- the prefix applied to all keymaps generated from annotations
})

Which-key

which-key users may wish to add a description to the prefix:

require("which-key").register({
    m = { name = "make" }
}, { mode = "n", prefix = "<leader>" })

TODO

  • Document requirement for make treesitter parser to be installed
  • Document (and test thoroughly) the "deep Makefiles" feature
  • Other configurable run strategies, not just terminal in a vertical split!
  • Provide an option to change the annotation from nvim_map(.*) to something user-defined.
  • Filter out "special" targets like .PHONY
  • Try to support Windows?

About

Annotate Makefiles to create Neovim key mappings

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published