[mini.completion] No ctrl-o to escape insert mode when popup is active? #1736
-
Contributing guidelines
Module(s)mini.completion Questionno_ctrl_o.mp4init.lua---@diagnostic disable: undefined-global
local function setup_deps(path_to_site)
local mini_path = path_to_site .. "pack/deps/start/mini.nvim"
if not vim.uv.fs_stat(mini_path) then
vim.cmd('echo "Installing `mini.nvim`" | redraw')
vim.fn.system({ "git", "clone", "--filter=blob:none", "https://github.com/echasnovski/mini.nvim", mini_path })
vim.cmd("packadd mini.nvim | helptags ALL")
vim.cmd('echo "Installed `mini.nvim`" | redraw')
end
require("mini.deps").setup({ path = { package = path_to_site } })
end
local function setup_native_autocompletion()
vim.api.nvim_create_autocmd("LspAttach", {
group = vim.api.nvim_create_augroup("my.lsp", {}),
callback = function(args)
local client = assert(vim.lsp.get_client_by_id(args.data.client_id))
if client:supports_method("textDocument/completion") then
local chars = {} -- optional: trigger autocompletion on EVERY keypress. May be slow!
-- stylua: ignore
for i = 32, 126 do table.insert(chars, string.char(i)) end
client.server_capabilities.completionProvider.triggerCharacters = chars
vim.lsp.completion.enable(true, client.id, args.buf, { autotrigger = true })
end
end,
})
end
local function setup_mini_autocompletion()
require("mini.snippets").setup() -- only using lsp snippets...
require("mini.completion").setup({ lsp_completion = { auto_setup = false, source_func = "omnifunc" } })
end
local function custom_on_attach(_, bufnr) vim.bo[bufnr].omnifunc = "v:lua.MiniCompletion.completefunc_lsp" end
local use_mini = false
vim.g.mapleader = " "
vim.o.shortmess = "CFOSWaco"
vim.o.completeopt = "menuone,noselect,fuzzy"
setup_deps(vim.fn.stdpath("data") .. "/site/")
MiniDeps.now(function()
require("mini.icons").setup()
MiniIcons.tweak_lsp_kind()
MiniDeps.add({ source = "nvim-treesitter/nvim-treesitter", checkout = "master" })
require("nvim-treesitter.configs").setup({ ensure_installed = { "rust" } })
if use_mini then
setup_mini_autocompletion()
else
setup_native_autocompletion()
end
MiniDeps.add("neovim/nvim-lspconfig")
require("lspconfig").rust_analyzer.setup({ -- have rust-analyzer installed...
on_attach = use_mini and custom_on_attach or nil,
})
end)
rust code// start a simple project with "cargo new demo"
// cd demo, and edit src/main.rs
fn main() {
println!("Hello, world!");
}
struct Dog<Breed> {
name: String,
} I like working with the code snippets provided by the In the video, the { body = "PhantomData<$0>" } Inside the When using native autocompletion, I can type With mini, when I type Would it be possible to have Sidenote: A much better { body = "PhantomData<$1>$0" } |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
I am afraid the answer to the particular question is "no, if you want to keep using 'omnifunc'". This is because The reason this doesn't happen with built-in completion is because it uses The are several possible solutions to the problem:
|
Beta Was this translation helpful? Give feedback.
I am afraid the answer to the particular question is "no, if you want to keep using 'omnifunc'". This is because
<C-o>
key is very hard-coded after<C-x><C-o>
is pressed (i.e. 'omnifunc' completion is triggered, which is what 'mini.completion' is doing). As in "it is currently impossible to override in this situation, at all". It is documented in:h i_CTRL-X_CTRL-O
and mentioned in the help (although in a slightly different place).The reason this doesn't happen with built-in completion is because it uses
vim.fn.complete()
directly. The downside of this is that it won't re-trigger on<BS>
and implementing it requires…