-
-
Notifications
You must be signed in to change notification settings - Fork 68
UI Extensions
elianiva edited this page Feb 27, 2021
·
10 revisions
You can customize the inputlist based picker that is used for code-actions and various other actions by overriding the require('jdtls.ui').pick_one_async
function:
If using nvim-fzy:
lua require('jdtls.ui').pick_one_async = require('fzy').pick_one
If using telescope.nvim:
lua <<
local finders = require'telescope.finders'
local sorters = require'telescope.sorters'
local actions = require'telescope.actions'
local pickers = require'telescope.pickers'
require('jdtls.ui').pick_one_async = function(items, prompt, label_fn, cb)
local opts = {}
pickers.new(opts, {
prompt_title = prompt,
finder = finders.new_table {
results = items,
entry_maker = function(entry)
return {
value = entry,
display = label_fn(entry),
ordinal = label_fn(entry),
}
end,
},
sorter = sorters.get_generic_fuzzy_sorter(),
attach_mappings = function(prompt_bufnr)
actions.select_default:replace(function()
local selection = actions.get_selected_entry(prompt_bufnr)
actions.close(prompt_bufnr)
cb(selection.value)
end)
return true
end,
}):find()
end
EOF
If using nvim-lsputils:
local jdtls_ui = require'jdtls.ui'
function jdtls_ui.pick_one_async(items, _, _, cb)
require'lsputil.codeAction'.code_action_handler(nil, nil, items, nil, nil, nil, cb)
end