Skip to content

Commit 7f89582

Browse files
committed
fix(completion): use proper checks for possible functions in config
Resolve #1648
1 parent 6dcb014 commit 7f89582

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

lua/mini/completion.lua

+2-1
Original file line numberDiff line numberDiff line change
@@ -595,7 +595,8 @@ H.setup_config = function(config)
595595
H.error('`lsp_completion.source_func` should be one of "completefunc" or "omnifunc"')
596596
end
597597
H.check_type('lsp_completion.auto_setup', config.lsp_completion.auto_setup, 'boolean')
598-
H.check_type('lsp_completion.process_items', config.lsp_completion.process_items, 'nil')
598+
H.check_type('lsp_completion.process_items', config.lsp_completion.process_items, 'callable', true)
599+
H.check_type('lsp_completion.snippet_insert', config.lsp_completion.snippet_insert, 'callable', true)
599600

600601
H.check_type('mappings.force_twostep', config.mappings.force_twostep, 'string')
601602
H.check_type('mappings.force_fallback', config.mappings.force_fallback, 'string')

tests/test_completion.lua

+3-1
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ T['setup()']['creates `config` field'] = function()
156156
expect_config('lsp_completion.source_func', 'completefunc')
157157
expect_config('lsp_completion.auto_setup', true)
158158
expect_config('lsp_completion.process_items', vim.NIL)
159+
expect_config('lsp_completion.snippet_insert', vim.NIL)
159160
expect_config('fallback_action', '<C-n>')
160161
expect_config('mappings.force_twostep', '<C-Space>')
161162
expect_config('mappings.force_fallback', '<A-Space>')
@@ -198,7 +199,8 @@ T['setup()']['validates `config` argument'] = function()
198199
'"completefunc" or "omnifunc"'
199200
)
200201
expect_config_error({ lsp_completion = { auto_setup = 'a' } }, 'lsp_completion.auto_setup', 'boolean')
201-
expect_config_error({ lsp_completion = { process_items = 'a' } }, 'lsp_completion.process_items', 'function')
202+
expect_config_error({ lsp_completion = { process_items = 'a' } }, 'lsp_completion.process_items', 'callable')
203+
expect_config_error({ lsp_completion = { snippet_insert = 'a' } }, 'lsp_completion.snippet_insert', 'callable')
202204
expect_config_error({ fallback_action = 1 }, 'fallback_action', 'function or string')
203205
expect_config_error({ mappings = 'a' }, 'mappings', 'table')
204206
expect_config_error({ mappings = { force_twostep = 1 } }, 'mappings.force_twostep', 'string')

0 commit comments

Comments
 (0)