aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGregory Anders <8965202+gpanders@users.noreply.github.com>2021-11-18 11:31:31 -0700
committerGitHub <noreply@github.com>2021-11-18 11:31:31 -0700
commita42a9accab39705776ac9ed1455f9650c29210f3 (patch)
tree08e6639d77b80f361ebeafcfd64d0f9ad4127c29
parentf940e7a5b9919a0494fbd07e39856bd01dfbf840 (diff)
parent8081a30ca8efbd23ae5f67d9756f8d0183177ee4 (diff)
downloadrneovim-a42a9accab39705776ac9ed1455f9650c29210f3.tar.gz
rneovim-a42a9accab39705776ac9ed1455f9650c29210f3.tar.bz2
rneovim-a42a9accab39705776ac9ed1455f9650c29210f3.zip
Merge pull request #16355 from mjlbach/fix/docgen-again
-rw-r--r--runtime/lua/vim/lsp.lua14
-rw-r--r--runtime/lua/vim/lsp/tagfunc.lua4
-rwxr-xr-xscripts/gen_vimdoc.py1
3 files changed, 16 insertions, 3 deletions
diff --git a/runtime/lua/vim/lsp.lua b/runtime/lua/vim/lsp.lua
index 6254bb542a..88dcb38dd1 100644
--- a/runtime/lua/vim/lsp.lua
+++ b/runtime/lua/vim/lsp.lua
@@ -1587,9 +1587,17 @@ function lsp.formatexpr(opts)
return 0
end
--- Provides an interface between the built-in client and `tagfunc`
---
--- Used via `set tagfunc=v:lua.vim.lsp.tagfunc`
+--- Provides an interface between the built-in client and 'tagfunc'.
+---
+--- When used with normal mode commands (e.g. |CTRL-]|) this will invoke
+--- the "textDocument/definition" LSP method to find the tag under the cursor.
+--- Otherwise, uses "workspace/symbol". If no results are returned from
+--- any LSP servers, falls back to using built-in tags.
+---
+---@param pattern Pattern used to find a workspace symbol
+---@param flags See |tag-function|
+---
+---@returns A list of matching tags
function lsp.tagfunc(...)
return require('vim.lsp.tagfunc')(...)
end
diff --git a/runtime/lua/vim/lsp/tagfunc.lua b/runtime/lua/vim/lsp/tagfunc.lua
index a18397623b..5c55e8559f 100644
--- a/runtime/lua/vim/lsp/tagfunc.lua
+++ b/runtime/lua/vim/lsp/tagfunc.lua
@@ -1,6 +1,7 @@
local lsp = vim.lsp
local util = vim.lsp.util
+---@private
local function mk_tag_item(name, range, uri, offset_encoding)
local bufnr = vim.uri_to_bufnr(uri)
-- This is get_line_byte_from_position is 0-indexed, call cursor expects a 1-indexed position
@@ -12,6 +13,7 @@ local function mk_tag_item(name, range, uri, offset_encoding)
}
end
+---@private
local function query_definition(pattern)
local params = lsp.util.make_position_params()
local results_by_client, err = lsp.buf_request_sync(0, 'textDocument/definition', params, 1000)
@@ -40,6 +42,7 @@ local function query_definition(pattern)
return results
end
+---@private
local function query_workspace_symbols(pattern)
local results_by_client, err = lsp.buf_request_sync(0, 'workspace/symbol', { query = pattern }, 1000)
if err then
@@ -58,6 +61,7 @@ local function query_workspace_symbols(pattern)
return results
end
+---@private
local function tagfunc(pattern, flags)
local matches
if string.match(flags, 'c') then
diff --git a/scripts/gen_vimdoc.py b/scripts/gen_vimdoc.py
index 2d2d46d1bd..89fc14121e 100755
--- a/scripts/gen_vimdoc.py
+++ b/scripts/gen_vimdoc.py
@@ -162,6 +162,7 @@ CONFIG = {
'buf.lua',
'diagnostic.lua',
'codelens.lua',
+ 'tagfunc.lua',
'handlers.lua',
'util.lua',
'log.lua',