Skip to content

Commit df5a93f

Browse files
committed
feat(plugin.completion): use tiny inline diagnostics to manage virtual text.
1 parent 0297e90 commit df5a93f

File tree

5 files changed

+22
-23
lines changed

5 files changed

+22
-23
lines changed

lua/core/settings.lua

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,7 @@ settings["server_formatting_block_list"] = {
5555
---@type boolean
5656
settings["lsp_inlayhints"] = false
5757

58-
-- Set it to false if diagnostics virtual text is annoying.
59-
-- If disabled, you may browse lsp diagnostics using trouble.nvim (press `gt` to toggle it).
60-
---@type boolean
61-
settings["diagnostics_virtual_text"] = true
62-
6358
-- Set it to false if diagnostics virtual lines is annoying.
64-
-- NOTE: This entry is an alternative form to `diagnostics_virtual_text`.
6559
---@type boolean
6660
settings["diagnostics_virtual_lines"] = false
6761

lua/keymap/helpers.lua

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -56,17 +56,6 @@ _G._toggle_inlayhint = function()
5656
end
5757

5858
_G._toggle_virtualtext = function()
59-
local _vt_enabled = require("core.settings").diagnostics_virtual_text
60-
if _vt_enabled then
61-
local vt_config = not vim.diagnostic.config().virtual_text
62-
vim.diagnostic.config({ virtual_text = vt_config })
63-
vim.notify(
64-
(vt_config and "Virtual text is now displayed" or "Virtual text is now hidden"),
65-
vim.log.levels.INFO,
66-
{ title = "LSP Diagnostic" }
67-
)
68-
end
69-
7059
local _vl_enabled = require("core.settings").diagnostics_virtual_lines
7160
if _vl_enabled then
7261
local vl_config = not vim.diagnostic.config().virtual_lines

lua/modules/configs/completion/mason-lspconfig.lua

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
local M = {}
22

33
M.setup = function()
4-
local diagnostics_virtual_text = require("core.settings").diagnostics_virtual_text
54
local diagnostics_virtual_lines = require("core.settings").diagnostics_virtual_lines
65
local diagnostics_level = require("core.settings").diagnostics_level
76

@@ -16,11 +15,7 @@ M.setup = function()
1615
vim.diagnostic.config({
1716
signs = true,
1817
underline = true,
19-
virtual_text = diagnostics_virtual_text and {
20-
severity = {
21-
min = vim.diagnostic.severity[diagnostics_level],
22-
},
23-
} or false,
18+
virtual_text = false,
2419
virtual_lines = diagnostics_virtual_lines and {
2520
severity = {
2621
min = vim.diagnostic.severity[diagnostics_level],
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
return function()
2+
require("modules.utils").load_plugin("tiny-inline-diagnostic", {
3+
preset = "modern",
4+
options = {
5+
show_source = {
6+
enabled = true,
7+
if_many = true,
8+
},
9+
use_icons_from_diagnostic = true,
10+
break_line = {
11+
enabled = true,
12+
},
13+
},
14+
})
15+
end

lua/modules/plugins/completion.lua

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,12 @@ completion["nvimtools/none-ls.nvim"] = {
3535
"jay-babu/mason-null-ls.nvim",
3636
},
3737
}
38+
completion["rachartier/tiny-inline-diagnostic.nvim"] = {
39+
lazy = true,
40+
event = "VeryLazy",
41+
priority = 1000, -- needs to be loaded in first
42+
config = require("completion.tiny-inline-diagnostic"),
43+
}
3844

3945
completion["Saghen/blink.cmp"] = {
4046
lazy = true,

0 commit comments

Comments
 (0)