diff --git a/lua/navigator/codeAction.lua b/lua/navigator/codeAction.lua index d8c6d2f..1200c05 100644 --- a/lua/navigator/codeAction.lua +++ b/lua/navigator/codeAction.lua @@ -138,9 +138,16 @@ local code_action_req = function(_call_back_fn, diagnostics) vim.lsp.buf_request(0, 'textDocument/codeAction', params, callback) end +local function sort_select(action_tuples, opts, on_user_choice) + table.sort(action_tuples, function(a, b) + return a[1] > b[1] + end) + require('guihua.gui').select(action_tuples, opts, on_user_choice) +end + code_action.code_action = function() local original_select = vim.ui.select - vim.ui.select = require('guihua.gui').select + vim.ui.select = sort_select log('codeaction') diff --git a/lua/navigator/diagnostics.lua b/lua/navigator/diagnostics.lua index 1e71714..e40c158 100644 --- a/lua/navigator/diagnostics.lua +++ b/lua/navigator/diagnostics.lua @@ -33,6 +33,29 @@ if vim.diagnostic then } end +local diagnostic_cfg = { + -- Enable underline, use default values + underline = _NgConfigValues.lsp.diagnostic.underline, + -- Enable virtual text, override spacing to 3 (prevent overlap) + virtual_text = { + spacing = _NgConfigValues.lsp.diagnostic.virtual_text.spacing, + prefix = _NgConfigValues.icons.diagnostic_virtual_text, + }, + -- Use a function to dynamically turn signs off + -- and on, using buffer local variables + signs = true, + update_in_insert = _NgConfigValues.lsp.diagnostic.update_in_insert or false, + severity_sort = _NgConfigValues.lsp.diagnostic.severity_sort, + float = { + focusable = false, + style = 'minimal', + border = 'rounded', + source = 'always', + header = '', + prefix = '', + }, +} + local function get_count(bufnr, level) if vim.diagnostic ~= nil then return #diagnostic.get(bufnr, { severity = diag_map[level] }) @@ -182,6 +205,7 @@ end local diag_hdlr = mk_handler(function(err, result, ctx, config) require('navigator.lspclient.highlight').diagnositc_config_sign() + config = config or diagnostic_cfg if err ~= nil then log(err, config, result) return @@ -303,21 +327,6 @@ local diag_hdlr_async = function() end local M = {} -local diagnostic_cfg = { - -- Enable underline, use default values - underline = _NgConfigValues.lsp.diagnostic.underline, - -- Enable virtual text, override spacing to 3 (prevent overlap) - virtual_text = { - spacing = _NgConfigValues.lsp.diagnostic.virtual_text.spacing, - prefix = _NgConfigValues.icons.diagnostic_virtual_text, - }, - -- Use a function to dynamically turn signs off - -- and on, using buffer local variables - signs = true, - update_in_insert = _NgConfigValues.lsp.diagnostic.update_in_insert or false, - severity_sort = _NgConfigValues.lsp.diagnostic.severity_sort, -} - if _NgConfigValues.lsp.diagnostic.virtual_text == false then diagnostic_cfg.virtual_text = false end @@ -474,6 +483,6 @@ function M.config(cfg) end if not util.nvim_0_6_1() then - util.warn('Navigator 0.3.1+ only support nvim-0.6+, please use 0.3.0') + util.warn('Navigator 0.4+ only support nvim-0.6+, please use 0.3.x') end return M diff --git a/lua/navigator/lspclient/mapping.lua b/lua/navigator/lspclient/mapping.lua index 6eab760..16e55d6 100644 --- a/lua/navigator/lspclient/mapping.lua +++ b/lua/navigator/lspclient/mapping.lua @@ -14,8 +14,8 @@ local single = { '╭', '─', '╮', '│', '╯', '─', '╰', '│' } -- TODO https://github.com/neovim/neovim/pull/16591 use vimkeymap.set/del -- LuaFormatter off local key_maps = { - { key = 'gr', func = "require('navigator.reference').reference()" }, - { key = 'Gr', func = "require('navigator.reference').async_ref()" }, + { key = 'gr', func = "require('navigator.reference').async_ref()" }, + { key = 'gr', func = "require('navigator.reference').reference()" }, -- reference deprecated { mode = 'i', key = '', func = 'signature_help()' }, { key = '', func = 'signature_help()' }, { key = 'g0', func = "require('navigator.symbols').document_symbols()" }, @@ -181,7 +181,6 @@ local function set_mapping(user_opts) log('formatting enabled', user_opts.cap) end - if not range_fmt and rfmtkey then del_keymap('v', rfmtkey) end