home: vim: rely on built-in diagnostic jump config
This reduces the surface area of my configuration.
This commit is contained in:
parent
2583cc6c12
commit
36aa641ec0
3 changed files with 8 additions and 38 deletions
|
|
@ -31,8 +31,6 @@ local keys = {
|
||||||
{ "[u", desc = "URL encode" },
|
{ "[u", desc = "URL encode" },
|
||||||
{ "[x", desc = "XML encode" },
|
{ "[x", desc = "XML encode" },
|
||||||
{ "[y", desc = "C string encode" },
|
{ "[y", desc = "C string encode" },
|
||||||
-- Custom
|
|
||||||
{ "[d", lsp.goto_prev_diagnostic, desc = "Previous diagnostic" },
|
|
||||||
|
|
||||||
-- Next
|
-- Next
|
||||||
{ "]", group = "Next" },
|
{ "]", group = "Next" },
|
||||||
|
|
@ -62,8 +60,6 @@ local keys = {
|
||||||
{ "]u", desc = "URL decode" },
|
{ "]u", desc = "URL decode" },
|
||||||
{ "]x", desc = "XML decode" },
|
{ "]x", desc = "XML decode" },
|
||||||
{ "]y", desc = "C string decode" },
|
{ "]y", desc = "C string decode" },
|
||||||
-- Custom
|
|
||||||
{ "]d", lsp.goto_next_diagnostic, desc = "Next diagnostic" },
|
|
||||||
|
|
||||||
-- Enable option
|
-- Enable option
|
||||||
{ "[o", group = "Enable option" },
|
{ "[o", group = "Enable option" },
|
||||||
|
|
|
||||||
|
|
@ -3,40 +3,6 @@ local M = {}
|
||||||
-- Simplified LSP formatting configuration
|
-- Simplified LSP formatting configuration
|
||||||
local lsp_format = require("lsp-format")
|
local lsp_format = require("lsp-format")
|
||||||
|
|
||||||
--- Move to the next/previous diagnostic, automatically showing the diagnostics
|
|
||||||
--- float if necessary.
|
|
||||||
--- @param count number whether to go count or backwards
|
|
||||||
local function goto_diagnostic(count)
|
|
||||||
vim.validate({
|
|
||||||
count = { count, "number" },
|
|
||||||
})
|
|
||||||
|
|
||||||
local opts = {
|
|
||||||
float = false,
|
|
||||||
count = count,
|
|
||||||
}
|
|
||||||
|
|
||||||
-- Only show floating diagnostics if they are otherwise not displayed
|
|
||||||
local config = vim.diagnostic.config()
|
|
||||||
if not (config.virtual_text or config.virtual_lines) then
|
|
||||||
opts.float = true
|
|
||||||
end
|
|
||||||
|
|
||||||
vim.diagnostic.jump(opts)
|
|
||||||
end
|
|
||||||
|
|
||||||
--- Move to the next diagnostic, automatically showing the diagnostics float if
|
|
||||||
--- necessary.
|
|
||||||
M.goto_next_diagnostic = function()
|
|
||||||
goto_diagnostic(vim.v.count1)
|
|
||||||
end
|
|
||||||
|
|
||||||
--- Move to the previous diagnostic, automatically showing the diagnostics float
|
|
||||||
--- if necessary.
|
|
||||||
M.goto_prev_diagnostic = function()
|
|
||||||
goto_diagnostic(-vim.v.count1)
|
|
||||||
end
|
|
||||||
|
|
||||||
--- shared LSP configuration callback
|
--- shared LSP configuration callback
|
||||||
--- @param client native client configuration
|
--- @param client native client configuration
|
||||||
--- @param bufnr int? buffer number of the attached client
|
--- @param bufnr int? buffer number of the attached client
|
||||||
|
|
@ -76,6 +42,10 @@ M.on_attach = function(client, bufnr)
|
||||||
vim.diagnostic.config({
|
vim.diagnostic.config({
|
||||||
virtual_text = text,
|
virtual_text = text,
|
||||||
virtual_lines = lines,
|
virtual_lines = lines,
|
||||||
|
jump = {
|
||||||
|
-- Show float on jump if no diagnostic text is otherwise shown
|
||||||
|
float = not (text or lines),
|
||||||
|
},
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,10 @@ vim.diagnostic.config({
|
||||||
update_in_insert = false,
|
update_in_insert = false,
|
||||||
-- Show highest severity first
|
-- Show highest severity first
|
||||||
severity_sort = true,
|
severity_sort = true,
|
||||||
|
jump = {
|
||||||
|
-- Show float on diagnostic jumps
|
||||||
|
float = true,
|
||||||
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
-- Inform servers we are able to do completion, snippets, etc...
|
-- Inform servers we are able to do completion, snippets, etc...
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue