Differentiate warnings from errors
Is it possible to have efm differentiate between warnings and errors? For example, with eslint, some rules can be marked as errors, and others as warnings. But since efm doesn't know how to tell the difference, it marks every lint as an error.
efm actually knows the difference just fine, if you tell it to. Though, quickly glancing at the README, it is indeed not obvious, maybe that can be improved.
You can take a look at my config here: https://github.com/alexaandru/nvim-config/blob/master/lua/config/efm.lua#L29-L32 for Go or here for Terraform: https://github.com/alexaandru/nvim-config/blob/master/lua/config/efm.lua#L24 or here for Fennel: https://github.com/alexaandru/nvim-config/blob/master/lua/config/efm.lua#L41-L45
As you can quickly see, the idea is to map %t to one of E, W, I or H... though, now that I look at it, I'm not so sure about the last one (Hint)... but I definitely get the different types of Error/Warning or Info as expected, so it does work.
IIRC, the ESLint default output format does not include the severity, so I wrote my own simple output formatter: https://github.com/JoosepAlviste/dotfiles/blob/master/resources/eslint-formatter-vim.js
With this new format, I could configure EFM lintFormats for ESLint:
local eslint_lint = {
lintCommand = 'eslint_d -f ~/dotfiles/resources/eslint-formatter-vim.js --stdin --stdin-filename ${INPUT}',
lintIgnoreExitCode = true,
lintStdin = true,
lintFormats = {'%f:%l:%c:%t: %m'},
}
Now, EFM can correctly detect the severity of ESLint errors. Hopefully that helps!
Nothing stops you from using a formatter that does support severity, for example visualstudio does that: https://eslint.org/docs/user-guide/formatters/#visualstudio
Here's how I use it: https://github.com/alexaandru/nvim-config/blob/master/lua/config/efm.lua#L18-L22