diff --git a/runtime/lua/vim/lsp/_tagfunc.lua b/runtime/lua/vim/lsp/_tagfunc.lua index f1eb6a3fdb..a0791c78b1 100644 --- a/runtime/lua/vim/lsp/_tagfunc.lua +++ b/runtime/lua/vim/lsp/_tagfunc.lua @@ -84,6 +84,10 @@ local function query_workspace_symbols(pattern) end local function tagfunc(pattern, flags) + -- avoid definition/symbol queries for insert completion + if string.match(flags, 'i') then + return vim.NIL + end local matches = string.match(flags, 'c') and query_definition(pattern) or query_workspace_symbols(pattern) -- fall back to tags if no matches diff --git a/test/functional/plugin/lsp_spec.lua b/test/functional/plugin/lsp_spec.lua index 27e04b5ff6..7c82ffd37e 100644 --- a/test/functional/plugin/lsp_spec.lua +++ b/test/functional/plugin/lsp_spec.lua @@ -5680,6 +5680,14 @@ describe('LSP', function() }, }, result) end) + + it('with flags including i, returns NIL', function() + exec_lua(function() + local result = vim.lsp.tagfunc('foobar', 'cir') + assert(result == vim.NIL, 'should not issue LSP requests') + return {} + end) + end) end) describe('cmd', function()