Modules/Neovim: Add hover-nvim to display information from multiple LSPs + Linters simultaneously
This commit is contained in:
@ -571,6 +571,90 @@ in {
|
||||
# Don't call setup!
|
||||
};
|
||||
|
||||
hover = let
|
||||
# Display LSP information and Diagnostics at the same time
|
||||
# https://github.com/lewis6991/hover.nvim/issues/34#issuecomment-1625662866
|
||||
lspWithDiag = ''
|
||||
{
|
||||
name = "LSP",
|
||||
priority = 1000,
|
||||
enabled = function()
|
||||
return true
|
||||
end,
|
||||
|
||||
execute = function(opts, done)
|
||||
local params = vim.lsp.util.make_position_params()
|
||||
local ___ = "\n─────────────────────────────────────────────────────────────────────────────\n"
|
||||
|
||||
vim.lsp.buf_request_all(0, 'textDocument/hover', params, function(responses)
|
||||
local value = ""
|
||||
for _, response in pairs(responses) do
|
||||
local result = response.result
|
||||
if result and result.contents and result.contents.value then
|
||||
if value ~= "" then
|
||||
value = value .. ___
|
||||
end
|
||||
value = value .. result.contents.value
|
||||
end
|
||||
end
|
||||
|
||||
local _, row = unpack(vim.fn.getpos("."))
|
||||
local lineDiag = vim.diagnostic.get(0, { lnum = row - 1 })
|
||||
for _, d in pairs(lineDiag) do
|
||||
if d.message then
|
||||
if value ~= "" then
|
||||
value = value .. ___
|
||||
end
|
||||
value = value .. string.format("*%s* %s", d.source, d.message)
|
||||
end
|
||||
end
|
||||
value = value:gsub("\r", "")
|
||||
|
||||
if value ~= "" then
|
||||
done({ lines = vim.split(value, "\n", true), filetype = "markdown" })
|
||||
else
|
||||
done()
|
||||
end
|
||||
end)
|
||||
end,
|
||||
}
|
||||
'';
|
||||
in rec {
|
||||
name = "hover";
|
||||
pkg = pkgs.vimPlugins.hover-nvim;
|
||||
lazy = true;
|
||||
event = ["BufReadPost" "BufNewFile"];
|
||||
config = mkDefaultConfig name;
|
||||
opts = {
|
||||
init.__raw = ''
|
||||
function()
|
||||
-- Register custom providers
|
||||
require('hover').register(${lspWithDiag})
|
||||
|
||||
-- Require providers
|
||||
-- require("hover.providers.lsp")
|
||||
-- require('hover.providers.diagnostic')
|
||||
require('hover.providers.fold_preview')
|
||||
require('hover.providers.man')
|
||||
|
||||
-- require('hover.providers.gh')
|
||||
-- require('hover.providers.gh_user')
|
||||
-- require('hover.providers.jira')
|
||||
-- require('hover.providers.dap')
|
||||
-- require('hover.providers.dictionary')
|
||||
-- require('hover.providers.highlight')
|
||||
end
|
||||
'';
|
||||
preview_opts = {
|
||||
border = "rounded";
|
||||
};
|
||||
# Whether the contents of a currently open hover window should be moved
|
||||
# to a :h preview-window when pressing the hover keymap.
|
||||
preview_window = false;
|
||||
title = false;
|
||||
};
|
||||
};
|
||||
|
||||
illuminate = rec {
|
||||
name = "illuminate";
|
||||
pkg = pkgs.vimPlugins.vim-illuminate;
|
||||
@ -789,7 +873,7 @@ in {
|
||||
};
|
||||
};
|
||||
}
|
||||
# {name = "nil_ls";} # Conflicts with nixd's hover
|
||||
{name = "nil_ls";}
|
||||
{
|
||||
name = "nixd";
|
||||
extraOptions.cmd = [
|
||||
@ -1859,6 +1943,7 @@ in {
|
||||
flash # Highlight f/F search results
|
||||
gitsigns # Show git line additions/deletions/changes in the gutter
|
||||
haskell-tools # Haskell integration
|
||||
hover # Multiple hover providers
|
||||
illuminate # Highlight usages of word under cursor
|
||||
|
||||
intellitab # Indent to the correct level on blanklines # TODO: Behaves bit fishy sometimes
|
||||
|
Reference in New Issue
Block a user