โก
nvim-compleet
This plugin is still in early development.
๐
Table of Contents
๐ฆ
Installation
nvim-compleet
requires Neovim 0.7+. Also, since the Rust code has to be compiled it needs the rustup
toolchain to be available (follow this guide for instructions on how to install Rust) with rustc
version 1.58+, together with the make
and ar
utilities.
Then installing the plugin is as easy as
require("packer").startup(function()
use({
"noib3/nvim-compleet",
config = function()
require("compleet").setup()
end,
run = "./install.sh release",
})
end)
๐
Features
Config validation
๐ง
Configuration
nvim-compleet
is configured by passing a table to the setup
function. The default config is
require('compleet').setup({
ui = {
menu = {
-- Where to anchor the completion menu, either "cursor" or "match".
anchor = "cursor",
-- Whether to automatically show the menu every time there are
-- completions available.
autoshow = true,
-- The maximum height (in rows) of the completion menu.
max_height = nil,
border = {
-- Whether to add a border to the completion menu's floating window.
enable = false,
-- Any of the style formats listed in `:h nvim_open_win`.
style = "single"
},
},
details = {
border = {
-- Whether to add a border to the details's floating window.
enable = true,
-- Same as `ui.menu.border.style`.
style = {
"",
"",
"",
{" ", "CompleetDetails"},
}
},
},
hint = {
-- Whether to show completion hints.
enable = false,
}
},
completion = {
-- Whether to enable completion while deleting characters.
while_deleting = false,
},
sources = {
lipsum = {
enable = false,
},
}
})
โ
Commands
nvim-compleet
provides two commands: CompleetStop{!}
to stop the completion and CompleetStart{!}
to restart it. The versions with the bang !
stop/start the completion in all the buffers, the ones without it only affect the current buffer.
๐น
Mappings
The following key mappings are exposed:
-
: selects the next item in the completion menu;(compleet-next-completion) -
: selects the previous item in the completion menu;(compleet-prev-completion) -
: inserts the currently selected completion item into the buffer;(compleet-insert-selected-completion) -
: inserts the first completion into the buffer. Useful when hints are enabled and(compleet-insert-first-completion) ui.menu.autoshow
is set tofalse
; -
: shows all the available completions at the current cursor position.(compleet-show-completions)
A possible configuration could be:
local compleet = require('compleet') local keymap = vim.keymap local tab = function() return (compleet.is_menu_open() and "(compleet-next-completion)" ) or (compleet.has_completions() and "(compleet-show-completions)" ) or "" end local s_tab = function() return compleet.is_menu_open() and "(compleet-prev-completion)" or "" end local right = function() return compleet.is_hint_visible() and "(compleet-insert-first-completion)" or "" end local cr = function() return compleet.is_completion_selected() and "(compleet-insert-selected-completion)" or "" end local opts = { expr = true, remap = true } keymap.set("i", "" , tab, opts) keymap.set("i", "" , s_tab, opts) keymap.set("i", "" , right, opts) keymap.set("i", "" , cr, opts)
๐
Roadmap
- Add LSP source;
- Add Filepath source;
- Add Treesitter source;
- Integrate with snippets engines;
- Stabilize api, document how to add sources in Rust, add option to provide user-defined sources in Lua;
- ...