-
-
Notifications
You must be signed in to change notification settings - Fork 90
Tips & Tricks
Srinesh Nisala edited this page Oct 22, 2024
·
10 revisions
Caution
Telescope doesn't seem to work stably for symbol search. We highly recommend using Fzf-lua instead!
Solution
- Using Fzf-lua
:FzfLua lsp_live_workspace_symbols
- Using telescope
:Telescope lsp_dynamic_workspace_symbols
Warning
We are still working on some of the code actions. If a code actions is missing you really want, request the feature here. This helps us to prioritize the most requested features first.
Solution
Code actions can be run using the vim.lsp.buf.code_action() but if you want to perform a specific code action, you can use following.
vim.lsp.buf.code_action({
context = { only = { "<code_action>" } },
-- ^^^^^^^^^^^^^ Replace the actual code action you want to perform
apply = true,
-- ^^ if there is only one action, directly apply it without selection prompt
})quickassistrefactor.assign.fieldrefactor.assign.variablerefactor.change.signaturerefactor.extract.constantrefactor.extract.fieldrefactor.extract.functionrefactor.extract.interfacerefactor.extract.variablerefactor.introduce.parameterrefactor.movesource.generatesource.generate.accessorssource.generate.constructorssource.generate.delegateMethodssource.generate.finalModifierssource.generate.hashCodeEqualssource.generate.toStringsource.organizeImportssource.overrideMethodssource.sortMembers
Following will set leader + c + o.
By registering the keymap on jdtls on_attach event, we can make sure it's only added within Java projects.
vim.keymap.set('n', '<leader>co', function()
vim.lsp.buf.code_action({
context = { only = { 'source.organizeImports' } },
apply = true,
})
end)