diff --git a/lua/navigator.lua b/lua/navigator.lua index b0f7fc4..732bb37 100644 --- a/lua/navigator.lua +++ b/lua/navigator.lua @@ -24,6 +24,7 @@ _NgConfigValues = { border = 'single', -- border style, can be one of 'none', 'single', 'double', "shadow" lines_show_prompt = 10, -- when the result list items number more than lines_show_prompt, + prompt_mode = 'insert', -- 'normal' | 'insert' -- fuzzy finder prompt will be shown combined_attach = 'both', -- both: use both customized attach and navigator default attach, mine: only use my attach defined in vimrc on_attach = function(client, bufnr) diff --git a/lua/navigator/diagnostics.lua b/lua/navigator/diagnostics.lua index 5565d50..01f09b5 100644 --- a/lua/navigator/diagnostics.lua +++ b/lua/navigator/diagnostics.lua @@ -47,7 +47,9 @@ local function error_marker(result, ctx, config) return end - vim.defer_fn(function() + local async + local uv = vim.uv or vim.loop + async = uv.new_async(vim.schedule_wrap(function() if vim.tbl_isempty(result.diagnostics) then return end @@ -173,7 +175,11 @@ local function error_marker(result, ctx, config) { virt_text = { { s.sign, hl } }, virt_text_pos = 'right_align' } ) end - end, 10) -- defer in 10ms + async:close() + end)) + vim.defer_fn(function() + async:send() + end, 10) end local update_err_marker_async = function() diff --git a/lua/navigator/gui.lua b/lua/navigator/gui.lua index 327a3f0..3adb946 100644 --- a/lua/navigator/gui.lua +++ b/lua/navigator/gui.lua @@ -52,6 +52,7 @@ function M.new_list_view(opts) opts.transparency = config.transparency if #items >= config.lines_show_prompt then opts.prompt = true + opts.enter = _NgConfigValues.prompt_mode == 'insert' end opts.external = config.external diff --git a/lua/navigator/lspwrapper.lua b/lua/navigator/lspwrapper.lua index 6d76557..b749eea 100644 --- a/lua/navigator/lspwrapper.lua +++ b/lua/navigator/lspwrapper.lua @@ -425,7 +425,7 @@ function M.locations_to_items(locations, ctx) end item.display_filename = filename or item.filename item.call_by = context -- find_ts_func_by_range(funcs, item.range) - item.rpath = util.get_relative_path(cwd, item.filename) + item.rpath = util.get_relative_path(cwd, gutil.add_pec(item.filename)) width = math.max(width, #item.text) item.symbol_name = M.get_symbol(item.text, item.range) item.lhs = check_lhs(item.text, item.symbol_name) diff --git a/lua/navigator/util.lua b/lua/navigator/util.lua index 009b517..1181073 100644 --- a/lua/navigator/util.lua +++ b/lua/navigator/util.lua @@ -3,6 +3,7 @@ -- Some of function copied from https://github.com/RishabhRD/nvim-lsputils local M = { log_path = vim.lsp.get_log_path() } -- local is_windows = uv.os_uname().version:match("Windows") +pcall(require, 'guihua') -- lazy load local guihua = require('guihua.util') local nvim_0_8 local vfn = vim.fn @@ -116,6 +117,7 @@ function M.get_base(path) return ret end end + return '' end local function getDir(path) @@ -137,6 +139,7 @@ local function getDir(path) end function M.get_relative_path(base_path, my_path) + M.log('rel path', base_path, my_path) local base_data = getDir(base_path) if base_data == nil then return @@ -186,7 +189,8 @@ function M.setup() elseif _NgConfigValues.debug == 'trace' then level = 'trace' end - local default_config = { use_console = false, use_file = true, level = level, plugin = 'navigator' } + local default_config = + { use_console = false, use_file = true, level = level, plugin = 'navigator' } if _NgConfigValues.debug_console_output then default_config.use_console = true default_config.use_file = false @@ -357,7 +361,13 @@ function M.set_virt_eol(bufnr, lnum, chunks, priority, id) bufnr = bufnr == 0 and api.nvim_get_current_buf() or bufnr bufs[bufnr] = true -- id may be nil - return api.nvim_buf_set_extmark(bufnr, nss, lnum, -1, { id = id, virt_text = chunks, priority = priority }) + return api.nvim_buf_set_extmark( + bufnr, + nss, + lnum, + -1, + { id = id, virt_text = chunks, priority = priority } + ) end function M.clear_buf(bufnr)