~xigoi/nvim-summon

Neovim plugin for adding standerd library imports

67b3b3d Improved C++ scraper

~xigoi pushed to ~xigoi/nvim-summon git

2 months ago

fd533f8 add_if_already_exists option

~xigoi pushed to ~xigoi/nvim-summon git

2 months ago

#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,

}