Delete deprecated hover.lua, update floating win width, refresh diagnostic errors

neovim_0.6
ray-x 3 years ago
parent 79fee5dda8
commit 69578d6a3c

@ -7,7 +7,6 @@ local util = require "navigator.util"
local log = util.log
local trace = require"guihua.log".trace
local error = util.error
local path_sep = require"navigator.util".path_sep()
local mk_handler = require"navigator.util".mk_handler
local path_cur = require"navigator.util".path_cur()
@ -61,7 +60,7 @@ local function error_marker(result, ctx, config)
end
trace('schedule callback', result, ctx, config)
-- trace(result, bufnr)
log('total diag ', #result.diagnostics, bufnr)
if result == nil or result.diagnostics == nil or #result.diagnostics == 0 then
local diag_cnt = get_count(bufnr, [[Error]]) + get_count(bufnr, [[Warning]])
@ -167,8 +166,7 @@ local diag_hdlr = mk_handler(function(err, result, ctx, config)
local mode = vim.api.nvim_get_mode().mode
if mode ~= 'n' and config.update_in_insert == false then
log("skip in insert mode")
return
log("skip sign update in insert mode")
end
local cwd = vim.loop.cwd()
local ft = vim.bo.filetype
@ -177,14 +175,7 @@ local diag_hdlr = mk_handler(function(err, result, ctx, config)
end
local client_id = ctx.client_id
-- not sure if I should do this hack
if vim.tbl_isempty(result.diagnostics) then
if vim.api.nvim_buf_is_loaded(ctx.bufnr) then
-- diagnostic.reset(ctx.client_id)
-- clear_diag_VT(ctx.bufnr)
end
return
end
log('diagnostic', #result.diagnostics, ctx, config)
if util.nvim_0_6() then
trace(err, result, ctx, config)

@ -1,24 +0,0 @@
-- TODO: change background and use TextView?
local lsp = require("vim.lsp")
local mk_handler = require"navigator.util".mk_handler
return {
hover_handler = mk_handler(function(_, result, ctx, cfg)
vim.lsp.util.focusable_float(ctx.method or "Hover", function()
if not (result and result.contents) then
return
end
local markdown_lines = lsp.util.convert_input_to_markdown_lines(result.contents)
markdown_lines = lsp.util.trim_empty_lines(markdown_lines)
if vim.tbl_isempty(markdown_lines) then
return
end
local bnr, contents_winid, _, border_winid =
vim.lsp.util.fancy_floating_markdown(markdown_lines)
lsp.util.close_preview_autocmd({"CursorMoved", "BufHidden", "InsertCharPre"}, contents_winid)
lsp.util.close_preview_autocmd({"CursorMoved", "BufHidden", "InsertCharPre"}, border_winid)
return bnr, contents_winid
end)
end)
}

@ -18,11 +18,11 @@ local key_maps = {
{key = "g0", func = "document_symbol()"},
{key = "gW", func = "workspace_symbol()"},
{key = "<c-]>", func = "definition()"},
{key = "gD", func = "declaration({ border = 'single' })"},
{key = "gD", func = "declaration({ border = 'rounded', max_width = 80 })"},
{key = "gp", func = "require('navigator.definition').definition_preview()"},
{key = "gT", func = "require('navigator.treesitter').buf_ts()"},
{key = "<Leader>gT", func = "require('navigator.treesitter').bufs_ts()"},
{key = "K", func = "hover({ popup_opts = { border = single }})"},
{key = "K", func = "hover({ popup_opts = { border = single, max_width = 80 }})"},
{key = "<Space>ca", mode = "n", func = "code_action()"},
{key = "<Space>cA", mode = "v", func = "range_code_action()"},
{key = "<Leader>re", func = "rename()"},
@ -33,8 +33,8 @@ local key_maps = {
{key = "<Space>D", func = "type_definition()"},
{key = "gL", func = "require('navigator.diagnostics').show_line_diagnostics()"},
{key = "gG", func = "require('navigator.diagnostics').show_diagnostic()"},
{key = "]d", func = "diagnostic.goto_next({ border = 'single' })"},
{key = "[d", func = "diagnostic.goto_prev({ border = 'single' })"},
{key = "]d", func = "diagnostic.goto_next({ border = 'rounded', max_width = 80})"},
{key = "[d", func = "diagnostic.goto_prev({ border = 'rounded', max_width = 80})"},
{key = "]r", func = "require('navigator.treesitter').goto_next_usage()"},
{key = "[r", func = "require('navigator.treesitter').goto_previous_usage()"},
{key = "<C-LeftMouse>", func = "definition()"},
@ -58,24 +58,23 @@ local ccls_mappings = {
local check_cap = function()
-- log(vim.lsp.buf_get_clients(0))
local rsv, fmt, rfmt, ccls
local fmt, rfmt, ccls
for _, value in pairs(vim.lsp.buf_get_clients(0)) do
if value == nil or value.resolved_capabilities == nil then
return
end
if value.resolved_capabilities.document_formatting then
fmt = true
end
if value.resolved_capabilities.document_range_formatting then
rfmt = true
end
if value ~= nil and value.resolved_capabilities == nil then
if value.resolved_capabilities.document_formatting then
fmt = true
end
if value.resolved_capabilities.document_range_formatting then
rfmt = true
end
-- log("override ccls", value.config)
if value.config.name == "ccls" then
ccls = true
-- log("override ccls", value.config)
if value.config.name == "ccls" then
ccls = true
end
end
end
return rsv, fmt, rfmt, ccls
return fmt, rfmt, ccls
end
local function set_mapping(user_opts)
@ -95,7 +94,7 @@ local function set_mapping(user_opts)
-- local function buf_set_option(...)
-- vim.api.nvim_buf_set_option(bufnr, ...)
-- end
local rsv, doc_fmt, range_fmt, ccls = check_cap()
local doc_fmt, range_fmt, ccls = check_cap()
if ccls then
vim.list_extend(key_maps, ccls_mappings)

Loading…
Cancel
Save