diff options
author | Lewis Russell <lewis6991@gmail.com> | 2024-11-05 17:34:21 +0000 |
---|---|---|
committer | Lewis Russell <me@lewisr.dev> | 2024-11-18 17:09:53 +0000 |
commit | 989a37a594649528f28432388c0e7e28e8be2753 (patch) | |
tree | 995df7bc856bc61d69d6666d3c569b5bb1a1f905 /runtime/lua/vim/lsp/_watchfiles.lua | |
parent | e2ad251c8d01726ecd54d925b5280ab32b448c13 (diff) | |
download | rneovim-989a37a594649528f28432388c0e7e28e8be2753.tar.gz rneovim-989a37a594649528f28432388c0e7e28e8be2753.tar.bz2 rneovim-989a37a594649528f28432388c0e7e28e8be2753.zip |
refactor(lsp): fold in dynamic_registration code into the client
Problem:
Capability register logic is spread across 3 files.
Solution:
- Consolidate (and simplify) logic into the client.
- Teach client.supports_method about resolve methods
Diffstat (limited to 'runtime/lua/vim/lsp/_watchfiles.lua')
-rw-r--r-- | runtime/lua/vim/lsp/_watchfiles.lua | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/runtime/lua/vim/lsp/_watchfiles.lua b/runtime/lua/vim/lsp/_watchfiles.lua index 98e9818bcd..c4cdb5aea8 100644 --- a/runtime/lua/vim/lsp/_watchfiles.lua +++ b/runtime/lua/vim/lsp/_watchfiles.lua @@ -44,9 +44,8 @@ M._poll_exclude_pattern = glob.to_lpeg('**/.git/{objects,subtree-cache}/**') --- Registers the workspace/didChangeWatchedFiles capability dynamically. --- ---@param reg lsp.Registration LSP Registration object. ----@param ctx lsp.HandlerContext Context from the |lsp-handler|. -function M.register(reg, ctx) - local client_id = ctx.client_id +---@param client_id integer Client ID. +function M.register(reg, client_id) local client = assert(vim.lsp.get_client_by_id(client_id), 'Client must be running') -- Ill-behaved servers may not honor the client capability and try to register -- anyway, so ignore requests when the user has opted out of the feature. @@ -155,9 +154,8 @@ end --- Unregisters the workspace/didChangeWatchedFiles capability dynamically. --- ---@param unreg lsp.Unregistration LSP Unregistration object. ----@param ctx lsp.HandlerContext Context from the |lsp-handler|. -function M.unregister(unreg, ctx) - local client_id = ctx.client_id +---@param client_id integer Client ID. +function M.unregister(unreg, client_id) local client_cancels = cancels[client_id] local reg_cancels = client_cancels[unreg.id] while #reg_cancels > 0 do |