diff options
author | Lewis Russell <lewis6991@gmail.com> | 2024-03-21 15:15:20 +0000 |
---|---|---|
committer | Lewis Russell <me@lewisr.dev> | 2024-03-25 22:21:08 +0000 |
commit | 00e71d3da3464df2b4c4f33bfd5fac6d88e7c867 (patch) | |
tree | 6c7c5cc9ac741fd3e225fdbce793e9d4bbc43af3 /runtime/lua/vim/lsp/client.lua | |
parent | 7e386308746e61cfdf0ca757a40122cbbceb7feb (diff) | |
download | rneovim-00e71d3da3464df2b4c4f33bfd5fac6d88e7c867.tar.gz rneovim-00e71d3da3464df2b4c4f33bfd5fac6d88e7c867.tar.bz2 rneovim-00e71d3da3464df2b4c4f33bfd5fac6d88e7c867.zip |
refactor(lsp): simplify client tracking
- Remove:
- uninitialized_clients
- active_clients
- all_buffer_active_clients
- Add:
- all_clients
- Use `lsp.get_clients()` to get buffer clients.
Diffstat (limited to 'runtime/lua/vim/lsp/client.lua')
-rw-r--r-- | runtime/lua/vim/lsp/client.lua | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/runtime/lua/vim/lsp/client.lua b/runtime/lua/vim/lsp/client.lua index 1259a2f3d1..303fc55982 100644 --- a/runtime/lua/vim/lsp/client.lua +++ b/runtime/lua/vim/lsp/client.lua @@ -185,6 +185,10 @@ local validate = vim.validate --- @field root_dir string --- --- @field attached_buffers table<integer,true> +--- +--- Buffers that should be attached to upon initialize() +--- @field package _buffers_to_attach table<integer,true> +--- --- @field private _log_prefix string --- --- Track this so that we can escalate automatically if we've already tried a @@ -608,8 +612,16 @@ function Client:initialize() self:_notify(ms.workspace_didChangeConfiguration, { settings = self.settings }) end + -- If server is being restarted, make sure to re-attach to any previously attached buffers. + -- Save which buffers before on_init in case new buffers are attached. + local reattach_bufs = vim.deepcopy(self.attached_buffers) + self:_run_callbacks(self._on_init_cbs, lsp.client_errors.ON_INIT_CALLBACK_ERROR, self, result) + for buf in pairs(reattach_bufs) do + self:_on_attach(buf) + end + log.info( self._log_prefix, 'server_capabilities', @@ -761,7 +773,7 @@ function Client:_request_sync(method, params, timeout_ms, bufnr) return request_result end ---- @private +--- @package --- Sends a notification to an LSP server. --- --- @param method string LSP method name. |