Skip to content

Commit 0206a70

Browse files
committed
refactor!: remove diagnostics and signs configuration (moved to AstroCore)
1 parent 1f71195 commit 0206a70

File tree

4 files changed

+0
-85
lines changed

4 files changed

+0
-85
lines changed

README.md

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ local opts = {
5252
features = {
5353
autoformat = true, -- enable or disable auto formatting on start
5454
codelens = true, -- enable/disable codelens refresh on start
55-
diagnostics_mode = 3, -- diagnostic mode on start (0 = off, 1 = no signs/virtual text, 2 = no virtual text, 3 = off)
5655
inlay_hints = false, -- enable/disable inlay hints on start
5756
semantic_tokens = true, -- enable/disable semantic token highlighting
5857
},
@@ -112,10 +111,6 @@ local opts = {
112111
},
113112
},
114113
},
115-
-- Configure diagnostics options (`:h vim.diagnostic.config()`)
116-
diagnostics = {
117-
update_in_insert = false,
118-
},
119114
-- A custom flags table to be passed to all language servers (`:h lspconfig-setup`)
120115
flags = {
121116
exit_timeout = 5000,

lua/astrolsp/config.lua

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727

2828
---@class AstroLSPFeatureOpts
2929
---@field codelens boolean? enable/disable codelens refresh on start (boolean; default = true)
30-
---@field diagnostics_mode integer? diagnostic mode on start (0 = off, 1 = no signs/virtual text, 2 = no virtual text, 3 = off; default = 3)
3130
---@field inlay_hints boolean? enable/disable inlay hints on start (boolean; default = false)
3231
---@field semantic_tokens boolean? enable/disable semantic token highlighting (boolean; default = true)
3332

@@ -99,7 +98,6 @@
9998
---```lua
10099
---features = {
101100
--- codelens = true,
102-
--- diagnostics_mode = 3,
103101
--- inlay_hints = false,
104102
--- semantic_tokens = true,
105103
---}
@@ -132,13 +130,6 @@
132130
---}
133131
---```
134132
---@field config lspconfig.options?
135-
---Configure diagnostics options (`:h vim.diagnostic.config()`)
136-
---Example:
137-
--
138-
---```lua
139-
---diagnostics = { update_in_insert = false },
140-
---```
141-
---@field diagnostics vim.diagnostic.Opts?
142133
---A custom flags table to be passed to all language servers (`:h lspconfig-setup`)
143134
---Example:
144135
--
@@ -253,15 +244,6 @@
253244
---servers = { "dartls" }
254245
---```
255246
---@field servers string[]?
256-
---Configure signs (`:h sign_define()`)
257-
---Example:
258-
--
259-
---```lua
260-
---signs = {
261-
--- { name = "DapBreakPoint", text = "", texthl = "DiagnosticInfo" },
262-
---},
263-
---```
264-
---@field signs table<string,vim.fn.sign_define.dict|false>?
265247
---A custom `on_attach` function to be run after the default `on_attach` function, takes two parameters `client` and `bufnr` (`:h lspconfig-setup`)
266248
---Example:
267249
--
@@ -278,14 +260,12 @@ local M = {
278260
commands = {},
279261
features = {
280262
codelens = true,
281-
diagnostics_mode = 3,
282263
inlay_hints = false,
283264
semantic_tokens = true,
284265
},
285266
capabilities = {},
286267
---@diagnostic disable-next-line: missing-fields
287268
config = {},
288-
diagnostics = {},
289269
flags = {},
290270
formatting = { format_on_save = { enabled = true }, disabled = {} },
291271
handlers = {},

lua/astrolsp/init.lua

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -32,31 +32,6 @@ local function check_cond(cond, client, bufnr)
3232
return true
3333
end
3434

35-
--- A table of settings for different levels of diagnostics
36-
M.diagnostics = { [0] = {}, {}, {}, {} }
37-
38-
local function setup_diagnostics()
39-
for name, dict in pairs(M.config.signs or {}) do
40-
if dict then vim.fn.sign_define(name, dict) end
41-
end
42-
M.diagnostics = {
43-
-- diagnostics off
44-
[0] = vim.tbl_deep_extend(
45-
"force",
46-
M.config.diagnostics,
47-
{ underline = false, virtual_text = false, signs = false, update_in_insert = false }
48-
),
49-
-- status only
50-
vim.tbl_deep_extend("force", M.config.diagnostics, { virtual_text = false, signs = false }),
51-
-- virtual text off, signs on
52-
vim.tbl_deep_extend("force", M.config.diagnostics, { virtual_text = false }),
53-
-- all diagnostics on
54-
M.config.diagnostics,
55-
}
56-
57-
vim.diagnostic.config(M.diagnostics[M.config.features.diagnostics_mode])
58-
end
59-
6035
--- Helper function to set up a given server with the Neovim LSP client
6136
---@param server string The name of the server to be setup
6237
function M.lsp_setup(server)
@@ -224,25 +199,6 @@ end
224199
function M.setup(opts)
225200
M.config = vim.tbl_deep_extend("force", M.config, opts)
226201

227-
-- TODO: Remove when dropping support for Neovim v0.9
228-
-- Backwards compatibility of new diagnostic sign API to Neovim v0.9
229-
if vim.fn.has "nvim-0.10" ~= 1 then
230-
local signs = vim.tbl_get(M.config, "diagnostics", "signs") or {}
231-
if not M.config.signs then M.config.signs = {} end
232-
for _, type in ipairs { "Error", "Hint", "Info", "Warn" } do
233-
local name, severity = "DiagnosticSign" .. type, vim.diagnostic.severity[type:upper()]
234-
if M.config.signs[name] == nil then M.config.signs[name] = { text = "" } end
235-
if M.config.signs[name] then
236-
if not M.config.signs[name].texthl then M.config.signs[name].texthl = name end
237-
for attribute, severities in pairs(signs) do
238-
if severities[severity] then M.config.signs[name][attribute] = severities[severity] end
239-
end
240-
end
241-
end
242-
end
243-
244-
setup_diagnostics()
245-
246202
-- normalize format_on_save to table format
247203
if vim.tbl_get(M.config, "formatting", "format_on_save") == false then
248204
M.config.formatting.format_on_save = { enabled = false }

lua/astrolsp/toggles.lua

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -79,20 +79,4 @@ function M.codelens(silent)
7979
ui_notify(silent, ("CodeLens %s"):format(bool2str(features.codelens)))
8080
end
8181

82-
--- Toggle diagnostics
83-
---@param silent? boolean if true then don't sent a notification
84-
function M.diagnostics(silent)
85-
features.diagnostics_mode = (features.diagnostics_mode - 1) % 4
86-
vim.diagnostic.config(require("astrolsp").diagnostics[features.diagnostics_mode])
87-
if features.diagnostics_mode == 0 then
88-
ui_notify(silent, "diagnostics off")
89-
elseif features.diagnostics_mode == 1 then
90-
ui_notify(silent, "only status diagnostics")
91-
elseif features.diagnostics_mode == 2 then
92-
ui_notify(silent, "virtual text off")
93-
else
94-
ui_notify(silent, "all diagnostics on")
95-
end
96-
end
97-
9882
return M

0 commit comments

Comments
 (0)