~xigoi/nvim-summon

Neovim plugin for adding standerd library imports
Updated location table
Saner behavior for adding empty lines
Improved C++ scraper

refs

master
browse  log 

clone

read-only
https://git.sr.ht/~xigoi/nvim-summon
read/write
git@git.sr.ht:~xigoi/nvim-summon

You can also use your local clone with git send-email.

#nvim-summon

nvim-summon is a Neovim plugin for automatically adding import statements from the standard library of a language. Simply hover over a symbol, activate a keymap and the library/module containing the symbol will be imported. nvim-summon tries to be smart about placing the import, skipping empty lines and whitespace and blending it into existing imports in a configurable way.

#Supported languages

  • C++
  • Nim

If you'd like support for another language, let me know.

#Usage

nvim-summon is used through a Lua API.

To add the import for a given symbol:

require("summon").summon(symbol, opts)

To add the import for the symbol below the cursor:

require("summon").summon_cursor(opts)

Obviously, you can bind this to a keymap of your choice:

vim.keymap.set("n", "<whatever>", function()
  require("summon").summon_cursor(opts)
end)

opts is an optional table with the following structure:

local default_opts = {

  -- The buffer into which to add the import
  buffer = 0,

  -- Suppress error messages
  silent = false,

  -- Where to add the import when there are already some imports
  -- "sorted" = try to keep the imports sorted (only works if they're already sorted)
  -- "first" = always add the new import before other imports
  -- "last" = always add the new import after other imports
  import_position = "sorted",

  -- Add the import even if it already exists
  add_if_already_exists = false,

}
Do not follow this link