Closed Saveljeffjonatan closed 8 months ago
Update: might be related to how prettier formats the code. If I install Eslint LSP and do a EslintFixAll then the problem goes away and it formats correctly.
Managed to solve this issue, turns our that I wasn't looking at typescriptreact
but just typescript...
Managed to solve this issue, turns our that I wasn't looking at
typescriptreact
but just typescript...
For the documentation authors of this plugin: Is there any way to see what sort of file types are accepted? I mean, there are many ways to type "javascript":
With react too:
???
@Saveljeffjonatan, how did you solve your problem?
In my case I have two LSP: typescript-language-server
(ts server) and client-lsp
(eslint). In ConformInfo
I see that tsserver
LSP is used. So by pressing <leader>cf
code formatting not in according to .eslintrc
. But in case use EslintFixAll
formatting works correctly.
I finally just set empty list of formatters for typescript
and javascript
. After that formatting works correct.
I solved it by also adding typescriptreact and javascriptreact
like this:
return {
"stevearc/conform.nvim",
event = { "BufReadPre", "BufNewFile" },
config = function()
local conf = require("conform")
conf.setup({
log_level = vim.log.levels.DEBUG,
formatters_by_ft = {
lua = { "stylua" },
typescript = { { "prettierd", "prettier" } },
typescriptreact = { { "prettierd", "prettier" } },
javascript = { { "prettierd", "prettier" } },
javascriptreact = { { "prettierd", "prettier" } },
go = { "goimports", "gofmt" },
["*"] = { "codespell" },
-- Use the "_" filetype to run formatters on filetypes that don't
-- have other formatters configured.
["_"] = { "trim_whitespace" },
},
})
vim.api.nvim_create_autocmd("BufWritePre", {
pattern = "*",
callback = function(args)
require("conform").format({ bufnr = args.buf, lsp_fallback = true })
end,
})
end,
}
Neovim version (nvim -v)
0.9.5
Operating system/version
Macos Sonoma 14.3
Add the debug logs
log_level = vim.log.levels.DEBUG
and pasted the log contents below.Log file
Log file: /Users/quacksensei/.local/state/nvim/conform.log 19:16:12[DEBUG] Running LSP formatter on /Users/quacksensei/git/work/Phoenix/src/pages/Appointments/Appointments.tsx 19:16:14[DEBUG] Running LSP formatter on /Users/quacksensei/git/work/Phoenix/src/pages/Appointments/Appointments.tsx 19:16:15[DEBUG] Running LSP formatter on /Users/quacksensei/git/work/Phoenix/src/pages/Appointments/Appointments.tsx 19:16:16[DEBUG] Running LSP formatter on /Users/quacksensei/git/work/Phoenix/src/pages/Appointments/Appointments.tsx 19:17:18[DEBUG] Running LSP formatter on /Users/quacksensei/git/work/Phoenix/src/pages/Appointments/Appointments.tsx 19:17:28[DEBUG] Running LSP formatter on /Users/quacksensei/git/work/Phoenix/src/pages/Appointments/Appointments.tsx 19:18:17[DEBUG] Running LSP formatter on /Users/quacksensei/git/work/Phoenix/src/pages/Appointments/Appointments.tsx 19:18:18[DEBUG] Running LSP formatter on /Users/quacksensei/git/work/Phoenix/src/pages/Appointments/Appointments.tsx
Formatters for this buffer: LSP: tsserver trimwhitespace ready () /usr/bin/awk codespell unavailable: Command not found
Other formatters: gofmt ready (go) /usr/local/go/bin/gofmt goimports unavailable: Command not found prettier ready (javascript, typescript) /Users/quacksensei/git/work/Phoenix/node_modules/.bin/prettier prettierd unavailable: Command not found stylua ready (lua) /Users/quacksensei/.local/share/nvim/mason/bin/stylua
Describe the bug
Doesn't seem to listen to my eslint settings.
What is the severity of this bug?
minor (annoyance)
Steps To Reproduce
Expected Behavior
Format according to prettier with eslint as linted format in mind
Minimal example file
No response
Minimal init.lua
Additional context
One is before save (proper syntax on my formatting) The one with errors is what happen when I do :w