Closed beneyal closed 1 year ago
Problem solved, it seems. For posterity:
null-ls
's .setup
has its own on_attach
handler, which (apparently?) doesn't use lspconfig
's on_attach
. So files that were not handled by null-ls
used lsp-format
correctly, but files that are handled by null-ls
did not.
I made my null-ls.lua
file look like this:
local null_ls = require("null-ls")
null_ls.setup({
sources = {
null_ls.builtins.formatting.black,
null_ls.builtins.formatting.isort,
null_ls.builtins.formatting.stylua,
},
on_attach = function(client, _)
require("lsp-format").on_attach(client)
end,
})
and now it seems everything uses lsp-format
as it should 🙂
Hello! 👋
This is probably a silly question, but I just can't seem to format-on-save. I'm using Neovim 0.8.2 on Ubuntu 22.04 (WSL). I couldn't find a similar issue, so I'm submitting this one.
My config looks something like this:
I'm using
null-ls
to provide the formatting to the LSP, and apparently it works, since I can manually format usingvim.lsp.buf.format()
.I checked
:autocmd BufWritePre
and:autocmd BufWritePost
. The first is empty, the second has some autocmds, but none related to formatting.Is there anything else I'm missing here?
Thank you for your help, and for the plugin 🙏