mirror of
https://github.com/LazyVim/LazyVim.git
synced 2025-06-23 01:08:59 +02:00
fix(lsp): better support for diagnostics icons on Neovim nightly/stable
This commit is contained in:
parent
64f86147f9
commit
aaa10e717d
1 changed files with 4 additions and 11 deletions
|
@ -12,6 +12,7 @@ return {
|
||||||
---@class PluginLspOpts
|
---@class PluginLspOpts
|
||||||
opts = {
|
opts = {
|
||||||
-- options for vim.diagnostic.config()
|
-- options for vim.diagnostic.config()
|
||||||
|
---@type vim.diagnostic.Opts
|
||||||
diagnostics = {
|
diagnostics = {
|
||||||
underline = true,
|
underline = true,
|
||||||
update_in_insert = false,
|
update_in_insert = false,
|
||||||
|
@ -101,12 +102,6 @@ return {
|
||||||
-- setup autoformat
|
-- setup autoformat
|
||||||
LazyVim.format.register(LazyVim.lsp.formatter())
|
LazyVim.format.register(LazyVim.lsp.formatter())
|
||||||
|
|
||||||
-- deprecated options
|
|
||||||
if opts.autoformat ~= nil then
|
|
||||||
vim.g.autoformat = opts.autoformat
|
|
||||||
LazyVim.deprecate("nvim-lspconfig.opts.autoformat", "vim.g.autoformat")
|
|
||||||
end
|
|
||||||
|
|
||||||
-- setup keymaps
|
-- setup keymaps
|
||||||
LazyVim.lsp.on_attach(function(client, buffer)
|
LazyVim.lsp.on_attach(function(client, buffer)
|
||||||
require("lazyvim.plugins.lsp.keymaps").on_attach(client, buffer)
|
require("lazyvim.plugins.lsp.keymaps").on_attach(client, buffer)
|
||||||
|
@ -115,10 +110,9 @@ return {
|
||||||
local register_capability = vim.lsp.handlers["client/registerCapability"]
|
local register_capability = vim.lsp.handlers["client/registerCapability"]
|
||||||
|
|
||||||
vim.lsp.handlers["client/registerCapability"] = function(err, res, ctx)
|
vim.lsp.handlers["client/registerCapability"] = function(err, res, ctx)
|
||||||
|
---@diagnostic disable-next-line: no-unknown
|
||||||
local ret = register_capability(err, res, ctx)
|
local ret = register_capability(err, res, ctx)
|
||||||
local client_id = ctx.client_id
|
local client = vim.lsp.get_client_by_id(ctx.client_id)
|
||||||
---@type lsp.Client
|
|
||||||
local client = vim.lsp.get_client_by_id(client_id)
|
|
||||||
local buffer = vim.api.nvim_get_current_buf()
|
local buffer = vim.api.nvim_get_current_buf()
|
||||||
require("lazyvim.plugins.lsp.keymaps").on_attach(client, buffer)
|
require("lazyvim.plugins.lsp.keymaps").on_attach(client, buffer)
|
||||||
return ret
|
return ret
|
||||||
|
@ -126,8 +120,7 @@ return {
|
||||||
|
|
||||||
-- diagnostics signs
|
-- diagnostics signs
|
||||||
if vim.fn.has("nvim-0.10.0") == 0 then
|
if vim.fn.has("nvim-0.10.0") == 0 then
|
||||||
local text = vim.tbl_get(opts, "diagnostics", "signs", "text") or {}
|
for severity, icon in pairs(opts.diagnostics.signs.text) do
|
||||||
for severity, icon in pairs(text) do
|
|
||||||
local name = vim.diagnostic.severity[severity]:lower():gsub("^%l", string.upper)
|
local name = vim.diagnostic.severity[severity]:lower():gsub("^%l", string.upper)
|
||||||
name = "DiagnosticSign" .. name
|
name = "DiagnosticSign" .. name
|
||||||
vim.fn.sign_define(name, { text = icon, texthl = name, numhl = "" })
|
vim.fn.sign_define(name, { text = icon, texthl = name, numhl = "" })
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue