Allow to set custom omnifunc or completefunc in config and describe it. #588
Replies: 5 comments
-
Hello, Pawel! Would you mind clarifying a bit on what functionality you want to have in the end? Like, in the form of "Here is an example of text. I would like to press this key and see this result.". The 'mini.completion' module will only trigger lsp completion if source function is set to the one from 'mini.completion'. So simply setting custom 'omnifunc' or 'sourcefunc' will not be enough. It is not really designed for anything else outside its two-stage setup. If you really want to have some custom completion being autotriggered only in certain files, then I would suggest trying to go the route 1 with 'after/ftplugin/xxx.lua' file. Inside it, I'd create |
Beta Was this translation helpful? Give feedback.
-
Evgeni,
I tried the following: require(mini.completion').setup({
lsp_completion = {
source_func = 'omnifunc',
auto_setup = false
},
})
-- Use custom omnifunc.
vim.bo.omnifunc = 'v:lua.bufferOmnifunc' The Unfortunately it looks like it is not being picked. The require call is in the Thank you for your time and effort... |
Beta Was this translation helpful? Give feedback.
-
Yeah, sorry, but plugging custom omnifunction instead of the one from 'mini.completion' wouldn't work for reasons I described earlier ('mini.completion' checks for source function to be appropriately set to one from this module). My best suggestion here would be to sacrifice the fallback and essentially use one-step completion with your omnifunc as active. Here is an example of what to put inside 'after/ftplugin/xxxx.lua': -- Define buffer-local config.
-- This will skip LSP step and fallback on calling 'omnifunc'.
vim.b.minicompletion_config = {
lsp_completion = { auto_setup = false },
fallback_action = '<C-x><C-o>',
}
-- Setup omnifunc. This should be a function reachable from
-- global namespace `_G` (not necessarily directly in it),
-- because it is the only reasonable way to set it as omnifunc.
_G.my_filetype_omnifunc = function()
-- Your code for omnifunc goes here. Ideally it should result into showing
-- built-in completion popup menu.
-- Beware that 'mini.completion' is not designed to handle this use case.
end
vim.bo.omnifunc = 'v:lua._G.my_filetype_omnifunc' |
Beta Was this translation helpful? Give feedback.
-
Dear Evgeni, I will try to take small steps practicing with a plaintext file. Will it disable the mechanism or I need to apply the config you suggested to disable automatic setup. We would need to handle the fallback case as well for it uses the standard keys. All the best, |
Beta Was this translation helpful? Give feedback.
-
Sorry, not quite. The best approach I can think of is the one from previous comment.
Setting this variable to Also, as this seems out of scope for 'mini.completion' features right now, I'll move this to Discussions. Feel free to continue asking question, though. Happy to help! |
Beta Was this translation helpful? Give feedback.
-
Contributing guidelines
Module(s)
Mini.completion
Description
Dear Evgeni,
I've setup Mini.completion and it is working fantasticly well with hte LSP integration. Since I have the need and work on a completion provider for a custom format, I wanted to go down the custom omnifunc or completefunc path.
After studying the sources I see the following potential options, which I would like to confirm with you:
** Disable automatic setup, which is an autocommand that sets up the default omnifunc,
** Assign, for example: fource_func = 'v:lua.customFormatOmnifunc' in the config values,
** The omnifunc setup function uses vim.bo[config.lsp_completion.source_func] key - should I use it verbatim?
** Will returning just the regular completion items be enough or I should get a handle to the plugin to copy the hints with results and sent somehow?
All the best from Warsaw,
Pawel
Beta Was this translation helpful? Give feedback.
All reactions