ELP language server seems to ignore .elp_lints.toml (when in IDE)
This is basically a duplicate of #87, but I am opening a new issue, since the original was closed even though the underlying issue is not solved.
I would like some way of selectively enabling/disabling lints project-wide and for all developers working on the project, so I think the workaround of using LSP configuration that was presented in the linked thread does not cut it.
I understand from the thread that some major changes to the configuration mechanism might be needed. @robertoaloi @alanz is this on the roadmap?
@JonathanArns Yes, we expect a lot of config-related changes in Q3 2025, most likely after summer.
I'm using this for Emacs with Eglot
(defvar my/elp-ignored-diagnostic-codes
'("W0038" "W0051")
"List of diagnostic codes to ignore in erlang-mode when elp.")
(defun my/eglot-filter-diagnostics (diagnostics)
"Filter out DIAGNOSTICS with codes in `my/elp-ignored-diagnostic-codes`."
(when diagnostics
(seq-remove
(lambda (fcode)
(let ((dcode (plist-get
(cdr (assoc 'eglot-lsp-diag (flymake-diagnostic-data fcode)))
:code)))
(member dcode my/elp-ignored-diagnostic-codes)))
diagnostics)))
(defun my/eglot-handle-diagnostics-advice (diagnostics)
"Filter DIAGNOSTICS before eglot sends them to flymake."
(let ((filtered (my/eglot-filter-diagnostics (car diagnostics))))
(setf diagnostics (list filtered))
diagnostics))
(with-eval-after-load 'eglot
(advice-add 'eglot--report-to-flymake
:filter-args #'my/eglot-handle-diagnostics-advice))
the .elp_lint.toml file is not effective for elp in neovim, is there any solution?
Here is a workaround for NeoVim:
First of all, install dharmx/toml.nvim. And then add the following config:
local function load_elp_lint()
local result = {
disabled = {},
enabled = {},
}
local cwd = vim.fn.getcwd()
local file_path = cwd .. "/.elp_lint.toml"
local toml = require("toml.engine")
local file = io.open(file_path, "r")
if not file then
return result
end
local content = file:read("*a")
file:close()
local config = toml.decode(content)
if config.disabled_lints then
for _, lint in ipairs(config.disabled_lints) do
table.insert(result.disabled, lint)
end
end
if config.enabled_lints then
for _, lint in ipairs(config.enabled_lints) do
table.insert(result.enabled, lint)
end
end
if #result.disabled > 0 then
local disabled_str = table.concat(result.disabled, ", ")
notify_fun("Loaded ELP lint config from .elp_lint.toml\nDisabled: " .. disabled_str,
vim.log.levels.INFO, { title = "ELP Lint" })
end
if #result.enabled > 0 then
local enabled_str = table.concat(result.enabled, ", ")
notify_fun("Loaded ELP lint config from .elp_lint.toml\nEnabled: " .. enabled_str,
vim.log.levels.INFO, { title = "ELP Lint" })
end
return result
end
require('lspconfig').elp.setup {
on_attach = on_attach,
settings = {
elp = {
diagnostics = load_elp_lint(),
}
}
}
According to the manual-installation