|
80 | 80 | --- `vim.b.minicompletion_config` which should have same structure as
|
81 | 81 | --- `MiniCompletion.config`. See |mini.nvim-buffer-local-config| for more details.
|
82 | 82 | ---
|
| 83 | +--- # Suggested option values ~ |
| 84 | +--- |
| 85 | +--- Some options are set automatically (if not set before |MiniCompletion.setup()|): |
| 86 | +--- - 'completeopt' is set to "menuone,noselect" for less intrusive popup. |
| 87 | +--- To enable fuzzy matching, manually set to "menuone,noselect,fuzzy". |
| 88 | +--- - 'shortmess' is appended with "c" flag for silent <C-n> fallback. |
| 89 | +--- |
83 | 90 | --- # Snippets ~
|
84 | 91 | ---
|
85 | 92 | --- As per LSP specification, some completion items can be supplied in the form of
|
@@ -342,10 +349,6 @@ MiniCompletion.config = {
|
342 | 349 | scroll_down = '<C-f>',
|
343 | 350 | scroll_up = '<C-b>',
|
344 | 351 | },
|
345 |
| - |
346 |
| - -- Whether to set Vim's settings for better experience (modifies |
347 |
| - -- `shortmess` and `completeopt`) |
348 |
| - set_vim_settings = true, |
349 | 352 | }
|
350 | 353 | --minidoc_afterlines_end
|
351 | 354 |
|
@@ -711,7 +714,6 @@ H.setup_config = function(config)
|
711 | 714 | H.error('`fallback_action` should be function or string, not ' .. type(config.fallback_action))
|
712 | 715 | end
|
713 | 716 | H.check_type('mappings', config.mappings, 'table')
|
714 |
| - H.check_type('set_vim_settings', config.set_vim_settings, 'boolean') |
715 | 717 |
|
716 | 718 | H.check_type('delay.completion', config.delay.completion, 'number')
|
717 | 719 | H.check_type('delay.info', config.delay.info, 'number')
|
@@ -762,14 +764,16 @@ H.apply_config = function(config)
|
762 | 764 | map_scroll(config.mappings.scroll_down, 'down')
|
763 | 765 | map_scroll(config.mappings.scroll_up, 'up')
|
764 | 766 |
|
765 |
| - if config.set_vim_settings then |
766 |
| - -- Don't give ins-completion-menu messages |
767 |
| - vim.opt.shortmess:append('c') |
768 |
| - if vim.fn.has('nvim-0.9') == 1 then vim.opt.shortmess:append('C') end |
| 767 | + -- Try setting suggested option values |
| 768 | + -- TODO: use `nvim_get_option_info2` after Neovim=0.8 support is dropped |
| 769 | + -- - More common completion behavior |
| 770 | + local was_set = vim.api.nvim_get_option_info('completeopt').was_set |
| 771 | + if not was_set then vim.o.completeopt = 'menuone,noselect' end |
769 | 772 |
|
770 |
| - -- More common completion behavior |
771 |
| - vim.o.completeopt = 'menuone,noselect' |
772 |
| - end |
| 773 | + -- - Don't show ins-completion-menu messages ("C" is default on Neovim>=0.10) |
| 774 | + local shortmess_flags = 'c' .. ((vim.fn.has('nvim-0.9') == 1 and vim.fn.has('nvim-0.10') == 0) and 'C' or '') |
| 775 | + was_set = vim.api.nvim_get_option_info('shortmess').was_set |
| 776 | + if not was_set then vim.opt.shortmess:append(shortmess_flags) end |
773 | 777 | end
|
774 | 778 |
|
775 | 779 | H.create_autocommands = function(config)
|
|
0 commit comments