Closed Dkendal closed 3 years ago
I plan to deprecate this in favor of formatter.nvim Probably once this PR is merged. I am maintainer of formatter.nvim as well now and been working on moving all the features over.
Thanks for the clarification!
Hey @lukas-reineke, thanks for the clarification! Could we please pin this GitHub issue so that future users of this library could know about this?
Also you once posted about async formatting using EFM on Reddit. Are you still preferring EFM or the efforts have now been shifted to formatter.nvim
?
Good idea, I pinned the issue.
I personally use EFM instead of either format.nvim or formatter.nvim. That works best for me, and I would probably recommend that first. But there is a place for formatter.nvim, it has no dependencies, can do stdin and non-stdin, and once the above-mentioned PR is merged it can also do embedded syntax.
In the end, use whatever works best for you. I will continue to contribute to formatter.nvim even though I don't use it myself.
hey @lukas-reineke I've read a lot of your posts regarding formatting. There is a lot to absorb, and there are a significant amount of points that are still unclear.
My goal is to do both linting + formatting in Neovim.
Linting:
Formatting:
The main part I'm confused on is what EFM is, and does it only help with formatting but not linting? I understand the difference between formatting and linting, but specifically in terms of some kind of generalized language server, they seem to be roughly the same (read code, write code)
Is EFM still the best choice in your opinion? How might one manage both formatting and linting with EFM, say... eslint + prettier?
EFM does linting too, you just need to specify the lintCommand
and lintFormats
so EFM understand the output. lintFormats
is the same as :help errorformat
(that's also where EFM gets its name from btw).
My setup for prettier and go looks like this
local prettier = {
formatCommand = "prettier --stdin-filepath ${INPUT}",
formatStdin = true,
}
local eslint = {
lintCommand = "eslint_d -f visualstudio --stdin --stdin-filename ${INPUT}",
lintIgnoreExitCode = true,
lintStdin = true,
lintFormats = {
"%f(%l,%c): %tarning %m",
"%f(%l,%c): %rror %m",
},
lintSource = "eslint",
}
local govet = {
lintCommand = "go vet",
lintIgnoreExitCode = true,
lintFormats = { "%f:%l:%c: %m" },
lintSource = "go vet",
}
local goimports = {
formatCommand = "goimports",
formatStdin = true,
}
local staticcheck = {
lintCommand = "staticcheck",
lintIgnoreExitCode = true,
lintFormats = { "%f:%l:%c: %m" },
lintSource = "staticcheck",
}
local languages = {
typescript = { prettier, eslint },
go = { staticcheck, goimports, govet },
}
require("lspconfig").efm.setup {
init_options = { documentFormatting = true },
root_dir = vim.loop.cwd,
filetypes = vim.tbl_keys(languages),
settings = {
rootMarkers = { ".git/" },
lintDebounce = "500ms",
languages = languages,
},
}
awesome,... thats very helpful. Thank you!
Hey, just curious what your view is on plans to develop this vs steering people to formatter.nvim? The readme states that this started out as a PR to formatter.nvim, but I also see that you have commits in formatter.nvim that are newer than the most recent commits here.
Thanks!