-
Notifications
You must be signed in to change notification settings - Fork 19
feat: handle commands on the client side #50
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -80,7 +80,24 @@ function CodeAction:execute() | |
if self:is_workspace_edit() then | ||
vim.lsp.util.apply_workspace_edit(self.server_data.edit, 'utf-8') | ||
elseif self:is_command() then | ||
vim.lsp.buf.execute_command(self.server_data.command) | ||
local client = vim.lsp.get_client_by_id(self.client_id) | ||
local fn = client.commands[self.server_data.command.command] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In my tests, this is not correct and also not how the native implementation does it. According to the specification this is just There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you share your tests? The navite implementation: local fn = client.commands[command.command] or vim.lsp.commands[command.command] |
||
or vim.lsp.commands[self.server_data.command.command] | ||
if fn then | ||
local context = {} | ||
context.diagnostic = vim.lsp.diagnostic.get_line_diagnostics() | ||
local params = vim.lsp.util.make_range_params() | ||
params.context = context | ||
|
||
fn(self.server_data.command, { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Related to the above comment: we just need to pass There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nope, Add the following code at line 91 print(vim.inspect('here --> ' .. type(self.server_data.command))) See the output #49 (comment) |
||
bufnr = vim.api.nvim_get_current_buf(), | ||
client_id = self.client_id, | ||
method = 'textDocument/codeAction', | ||
params = params, | ||
}) | ||
else | ||
vim.lsp.buf.execute_command(self.server_data.command) | ||
end | ||
else | ||
vim.api.nvim_notify( | ||
'Failed to execute code action of unknown kind!', | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did you rename this here. Is it somehow related to the feature? 🤔