Closed fegyi001 closed 1 year ago
Add the following:
{
"neovim/nvim-lspconfig",
opts = {
servers = { eslint = {} },
setup = {
eslint = function()
require("lazyvim.util").on_attach(function(client)
if client.name == "eslint" then
client.server_capabilities.documentFormattingProvider = true
elseif client.name == "tsserver" then
client.server_capabilities.documentFormattingProvider = false
end
end)
end,
},
},
},
Hi @folke, is this still the way to disable the formatting done by tsserver
?
I digged through the issues/commits and found that in response to this other issue https://github.com/LazyVim/LazyVim/issues/249#issuecomment-1426998926 you pushed some changes to disable formatting if the client had it disable.
That code is gone since https://github.com/LazyVim/LazyVim/commit/f1a8f24a361d0de198f6b1458168652a6835c932 (or even earlier) so I'm wondering if now we should be using another way to fix this interference between the two format attempts.
Did you check docs and existing issues?
Neovim version (nvim -v)
v0.9.0-dev-1001+gcbd4480f9
Operating system/version
MacOS 13.2.1
Describe the bug
(Foreword: I'm quite beginner with neovim/lazyvim etc, just switched to lazyvim from nvchad.)
While eslint errors are shown correctly, on save lazyvim does not seem to use eslint rules (e.g. delete extra lines, remove whitespaces when needed etc). So my file is fine, no eslint errors, hit save, and reformatted somehow, and now shows eslint errors.
An example: this is a file BEFORE saving:
And when I save this is how it looks like after auto formatting:
It has a prettier-related problem which is fine, I have prettier rules in my .eslintrc conf file. lazyvim recognizes the problem just fine:
How could I tell lazyvim to use my eslintrc config file when saving a typescript/javascript file?
Steps To Reproduce
Expected Behavior
lazyvim should be able to use existing eslint config files when possible.
Repro