cssls: exclude @tailwind and @apply at rule

...diagnostic errors
This commit is contained in:
Oliver Davies 2024-07-09 19:54:45 +01:00
parent c0d156f728
commit 70c8eade7c
2 changed files with 48 additions and 1 deletions

View file

@ -1,5 +1,15 @@
local M = {} local M = {}
local function should_remove_diagnostic(messages_to_filter, message)
for _, filter_message in ipairs(messages_to_filter) do
if message:match(filter_message) then
return true
end
end
return false
end
M.definition = function() M.definition = function()
local params = vim.lsp.util.make_position_params() local params = vim.lsp.util.make_position_params()
@ -32,4 +42,27 @@ M.definition = function()
end) end)
end end
M.on_publish_diagnostics = function(_, result, ctx, config)
local client = vim.lsp.get_client_by_id(ctx.client_id)
if client.name == "cssls" then
local filtered_diagnostics = {}
local messages_to_filter = {
"Unknown at rule @apply",
"Unknown at rule @tailwind",
}
for _, diagnostic in ipairs(result.diagnostics) do
if not should_remove_diagnostic(messages_to_filter, diagnostic.message) then
table.insert(filtered_diagnostics, diagnostic)
end
end
result.diagnostics = filtered_diagnostics
end
vim.lsp.diagnostic.on_publish_diagnostics(_, result, ctx, config)
end
return M return M

View file

@ -1,16 +1,26 @@
local lspconfig = require "lspconfig" local lspconfig = require "lspconfig"
local nvim_status = require "lsp-status" local nvim_status = require "lsp-status"
local handlers = require "opdavies.lsp.handlers"
require("neodev").setup {} require("neodev").setup {}
local servers = { local servers = {
bashls = true, bashls = true,
cssls = true,
cssls = {
on_attach = function(client, bufnr)
vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.with(handlers.on_publish_diagnostics, {})
end,
},
gopls = true, gopls = true,
html = true, html = true,
intelephense = { intelephense = {
filetypes = { "php", "module", "test", "inc" }, filetypes = { "php", "module", "test", "inc" },
}, },
lua_ls = { lua_ls = {
settings = { settings = {
Lua = { Lua = {
@ -36,8 +46,10 @@ local servers = {
}, },
}, },
}, },
marksman = true, marksman = true,
nil_ls = true, nil_ls = true,
tailwindcss = { tailwindcss = {
filetypes = { "html", "javascript", "twig", "typescript", "vue" }, filetypes = { "html", "javascript", "twig", "typescript", "vue" },
@ -49,9 +61,11 @@ local servers = {
}, },
}, },
}, },
terraformls = true, terraformls = true,
tsserver = true, tsserver = true,
vuels = true, vuels = true,
yamlls = { yamlls = {
settings = { settings = {
yaml = { yaml = {