-
-
Notifications
You must be signed in to change notification settings - Fork 54
Development
Srinesh Nisala edited this page Jan 20, 2025
·
1 revision
Details
-
There are
java.*
actions that's being called by Language Servers. Following are the defined commands in VSCode -
As client, nvim-java-refactor registers client commands to
vim.lsp.commands
at jdtls LS attach live we have done here -
God knows where is the documentation that defines the approach to handle the action on client side but we could try to replicate what VSCode is doing.
- First of all, I would start by grep searching the command in VSCode Java project. Ex:-
java.action.overrideMethodsPrompt
- Commands are defined as constants in commands.ts file
- Do a reference check and find the client command implementation. Ex:- source
- Sometimes we might have to send some LSP requests to complete the command. source
- Some functions such as
apply_workspace_edit
is available throughvim.lsp.util
- First of all, I would start by grep searching the command in VSCode Java project. Ex:-
Details
We are using request
function of vim.lsp.Client
function to communicate with
the jdtls
.
fun(method: string, params: table?, handler: lsp.Handler?, bufnr: integer?): boolean, integer?`)
This has almost 1 to 1 mapping with vscode
APIs most of the time.
await this.languageClient.sendRequest(
method: string,
params: any,
// handler is not passed since there is async / await
// buffer I'm guessing is set to current buffer by default???
);
However, some APIs sends more arguments, to which we don't have a Neovim lua equivalent I'm guessing. Following is an example.
await this.languageClient.sendRequest(
CompileWorkspaceRequest.type,
isFullCompile,
token,
);
To make this request, probably client.rpc.request
should be used without
request()
wrapper.