Skip to content

Commit

Permalink
Deprecate custom code_action method
Browse files Browse the repository at this point in the history
With neovim 0.6 it is possible to use the built-in
vim.lsp.buf.code_action function and still have all extensions from
jdtls work.
  • Loading branch information
mfussenegger committed Dec 7, 2021
1 parent 46809aa commit f9aeca2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
6 changes: 0 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -196,12 +196,6 @@ Neovim, so all the functions mentioned in `:help lsp` will work.
mappings:

```vimL
-- `code_action` is a superset of vim.lsp.buf.code_action and you'll be able to
-- use this mapping also with other language servers
nnoremap <A-CR> <Cmd>lua require('jdtls').code_action()<CR>
vnoremap <A-CR> <Esc><Cmd>lua require('jdtls').code_action(true)<CR>
nnoremap <leader>r <Cmd>lua require('jdtls').code_action(false, 'refactor')<CR>
nnoremap <A-o> <Cmd>lua require'jdtls'.organize_imports()<CR>
nnoremap crv <Cmd>lua require('jdtls').extract_variable()<CR>
vnoremap crv <Esc><Cmd>lua require('jdtls').extract_variable(true)<CR>
Expand Down
5 changes: 5 additions & 0 deletions lua/jdtls.lua
Original file line number Diff line number Diff line change
Expand Up @@ -661,6 +661,11 @@ end

-- Similar to https://github.com/neovim/neovim/pull/11607, but with extensible commands
function M.code_action(from_selection, kind)
if from_selection then
vim.notify('jdtls.code_action() is deprecated. You can use vim.lsp.buf.range_code_action in neovim 0.6 for the same functionality')
else
vim.notify('jdtls.code_action() is deprecated. You can use vim.lsp.buf.code_action in neovim 0.6 for the same functionality')
end
local code_action_params = make_code_action_params(from_selection or false, kind)
local function apply_command(action, ctx)
local command
Expand Down

0 comments on commit f9aeca2

Please sign in to comment.