[mini.completion] Retrigger file path completion #1995
-
Contributing guidelines
Module(s)mini.completion QuestionIs there a way to retrigger file path completion? ( When I'm completing file paths, I usually want to keep autocomplete open until I reach a file. So currently, I have to keep triggering the autocompletion with I think a better workflow would be to automatically retrigger (file path) autocompletion, and require users to manually close. |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 3 replies
-
Oops, I mistakenly read your title as "register file path completion." 😂 Sorry for bothering! But I tried that plugin, and you can always trigger path completion using |
Beta Was this translation helpful? Give feedback.
-
I don't think in its current form this is a 'mini.completion' question, unless you have But the general idea from @loichyan is the best approach though when it comes to 'mini.completion': somehow create an in-process LSP server that would 1) provide path completion and 2) have path separator be a dedicated completion trigger. This way 'mini.completion' will be automatically triggered until user presses path separators. If 'nvimdev/phoenix.nvim' works, then it is probably a good way to achieve that. |
Beta Was this translation helpful? Give feedback.
-
@echasnovski's answer just inspired me that auto retriggering could be done through an autocommand :D vim.api.nvim_create_autocmd("InsertCharPre", {
callback = function()
-- It's better to use a more robust logic to check
-- whether the leaing path-like string is a real path,
-- for example, check if it exits on the disk.
if vim.v.char ~= "/" then return end
-- Avoid duplicate `/`
local line, cur = vim.api.nvim_get_current_line(), vim.api.nvim_win_get_cursor(0)
local prev_char = line:sub(cur[2], cur[2])
if prev_char == "/" then vim.v.char = "" end
-- Force path completion
local keys = vim.api.nvim_replace_termcodes("<C-x><C-f>", true, true, true)
vim.api.nvim_feedkeys(keys, "n", false)
end,
}) |
Beta Was this translation helpful? Give feedback.
-
I got it working like this: local function simulate_keypress(key)
local termcodes = vim.api.nvim_replace_termcodes(key, true, false, true)
vim.api.nvim_feedkeys(termcodes, 'm', false)
end
vim.api.nvim_create_autocmd('CompleteDone', {
callback = function()
if vim.v.event.complete_type == 'files' and vim.v.event.reason == 'accept' then
simulate_keypress '<c-x>'
simulate_keypress '<c-f>'
end
end,
})
|
Beta Was this translation helpful? Give feedback.
Did you mean something like this?
Screen_Recording_20250910_100553_Termux.mp4
This is when phoenix.nvim is enabled. As long as the leading path is valid, the completion will automatically show up.