aboutsummaryrefslogtreecommitdiff
path: root/runtime/lua/vim/lsp/_watchfiles.lua
diff options
context:
space:
mode:
authorChristian Clason <c.clason@uni-graz.at>2023-08-09 11:06:13 +0200
committerGitHub <noreply@github.com>2023-08-09 11:06:13 +0200
commitc43c745a14dced87a23227d7be4f1c33d4455193 (patch)
tree0cd5cf1cbbfa20be7fffbad696ba5ee97181847e /runtime/lua/vim/lsp/_watchfiles.lua
parent8afdc1f3867a620c8235b3d3964b019b94657190 (diff)
downloadrneovim-c43c745a14dced87a23227d7be4f1c33d4455193.tar.gz
rneovim-c43c745a14dced87a23227d7be4f1c33d4455193.tar.bz2
rneovim-c43c745a14dced87a23227d7be4f1c33d4455193.zip
fix(lua): improve annotations for stricter luals diagnostics (#24609)
Problem: luals returns stricter diagnostics with bundled luarc.json Solution: Improve some function and type annotations: * use recognized uv.* types * disable diagnostic for global `vim` in shared.lua * docs: don't start comment lines with taglink (otherwise LuaLS will interpret it as a type) * add type alias for lpeg pattern * fix return annotation for `vim.secure.trust` * rename local Range object in vim.version (shadows `Range` in vim.treesitter) * fix some "missing fields" warnings * add missing required fields for test functions in eval.lua * rename lsp meta files for consistency
Diffstat (limited to 'runtime/lua/vim/lsp/_watchfiles.lua')
-rw-r--r--runtime/lua/vim/lsp/_watchfiles.lua8
1 files changed, 5 insertions, 3 deletions
diff --git a/runtime/lua/vim/lsp/_watchfiles.lua b/runtime/lua/vim/lsp/_watchfiles.lua
index 5dbd4a7199..1a4909b3f3 100644
--- a/runtime/lua/vim/lsp/_watchfiles.lua
+++ b/runtime/lua/vim/lsp/_watchfiles.lua
@@ -6,11 +6,13 @@ local lpeg = vim.lpeg
local M = {}
+---@alias lpeg userdata
+
--- Parses the raw pattern into an |lpeg| pattern. LPeg patterns natively support the "this" or "that"
--- alternative constructions described in the LSP spec that cannot be expressed in a standard Lua pattern.
---
---@param pattern string The raw glob pattern
----@return userdata An |lpeg| representation of the pattern, or nil if the pattern is invalid.
+---@return lpeg An |lpeg| representation of the pattern, or nil if the pattern is invalid.
local function parse(pattern)
local l = lpeg
@@ -109,7 +111,7 @@ local to_lsp_change_type = {
--- Default excludes the same as VSCode's `files.watcherExclude` setting.
--- https://github.com/microsoft/vscode/blob/eef30e7165e19b33daa1e15e92fa34ff4a5df0d3/src/vs/workbench/contrib/files/browser/files.contribution.ts#L261
----@type Lpeg pattern
+---@type lpeg parsed Lpeg pattern
M._poll_exclude_pattern = parse('**/.git/{objects,subtree-cache}/**')
+ parse('**/node_modules/*/**')
+ parse('**/.hg/store/**')
@@ -132,7 +134,7 @@ function M.register(reg, ctx)
if not has_capability or not client.workspace_folders then
return
end
- local watch_regs = {} --- @type table<string,{pattern:userdata,kind:integer}>
+ local watch_regs = {} --- @type table<string,{pattern:lpeg,kind:integer}>
for _, w in ipairs(reg.registerOptions.watchers) do
local relative_pattern = false
local glob_patterns = {} --- @type {baseUri:string, pattern: string}[]