How can I map <c-j> to be completion instead of snippet #1852
-
Contributing guidelines
Module(s)mini.completion, mini.snippets QuestionI tried to have the mini completion work together and be toggled on
Here is my config with lazy and mini: {
"echasnovski/mini.completion",
version = "*",
dependencies = {
{
"echasnovski/mini.snippets",
version = "*",
opts = function(mod)
local gen_loader = require(mod.name).gen_loader
return {
{
-- Array of snippets and loaders (see |MiniSnippets.config| for details).
-- Nothing is defined by default. Add manually to have snippets to match.
snippets = {
-- gen_loader.from_file("~/.config/nvim/snippets/package.json"),
gen_loader.from_lang(),
},
-- Module mappings. Use `''` (empty string) to disable one.
mappings = { expand = "", jump_next = "", jump_prev = "" },
-- Functions describing snippet expansion. If `nil`, default values
-- are `MiniSnippets.default_<field>()`.
expand = {
-- Resolve raw config snippets at context
prepare = nil,
-- Match resolved snippets at cursor position
match = nil,
-- Possibly choose among matched snippets
select = nil,
-- Insert selected snippet
insert = nil,
},
},
}
end,
},
},
keys = {
{ "<C-j>", "<C-n>", mode = { "i" }, expr = false },
{ "<C-k>", "<C-p>", mode = { "i" }, expr = false },
},
opts = {
-- Delay (debounce type, in ms) between certain Neovim event and action.
-- This can be used to (virtually) disable certain automatic actions by
-- setting very high delay time (like 10^7).
delay = { completion = 100, info = 100, signature = 50 },
-- Configuration for action windows:
-- - `height` and `width` are maximum dimensions.
-- - `border` defines border (as in `nvim_open_win()`; default "single").
window = {
info = { height = 25, width = 80, border = nil },
signature = { height = 25, width = 80, border = nil },
},
-- Way of how module does LSP completion
lsp_completion = {
-- `source_func` should be one of 'completefunc' or 'omnifunc'.
source_func = "completefunc",
-- `auto_setup` should be boolean indicating if LSP completion is set up
-- on every `BufEnter` event.
auto_setup = true,
-- A function which takes LSP 'textDocument/completion' response items
-- (each with `client_id` field for item's server) and word to complete.
-- Output should be a table of the same nature as input. Common use case
-- is custom filter/sort. Default: `default_process_items`
process_items = nil,
-- A function which takes a snippet as string and inserts it at cursor.
-- Default: `default_snippet_insert` which tries to use 'mini.snippets'
-- and falls back to `vim.snippet.expand` (on Neovim>=0.10).
snippet_insert = nil,
},
-- Fallback action as function/string. Executed in Insert mode.
-- To use built-in completion (`:h ins-completion`), set its mapping as
-- string. Example: set '<C-x><C-l>' for 'whole lines' completion.
fallback_action = "<C-n>",
-- Module mappings. Use `''` (empty string) to disable one. Some of them
-- might conflict with system mappings.
mappings = {
-- Force two-step/fallback completions
force_twostep = "<C-Space>",
force_fallback = "<A-Space>",
-- Scroll info/signature window down/up. When overriding, check for
-- conflicts with built-in keys for popup menu (like `<C-u>`/`<C-o>`
-- for 'completefunc'/'omnifunc' source function; or `<C-n>`/`<C-p>`).
scroll_down = "<C-f>",
scroll_up = "<C-b>",
},
},
}, |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
The It looks like the And if you want |
Beta Was this translation helpful? Give feedback.
-
@echasnovski Thanks! |
Beta Was this translation helpful? Give feedback.
The
mappings = { expand = "", jump_next = "", jump_prev = "" }
is indeed the correct way to have 'mini.snippets' not automatically create its mappings (including default<C-j>
for to expand mappings).It looks like the
opts
function for 'mini.snippets' config returns incorrect data: it returns{ { ..., mappings = {} } }
(i.e. array with single config element) when it should return config table directly. Remove extra{
/}
nesting and it should work.And if you want
<C-j>
to have 'mini.completion' force its completion, setforce_twostep = "<C-j>"
.