-
Notifications
You must be signed in to change notification settings - Fork 792
Buf: formatting not working anymore #1002
Comments
This works for me, and I don't think it's an issue with null-ls. I have no idea what this error message means, but its presence is what's causing formatting to fail:
Do you get the same error when you run the formatter from the command line? Either way I think you'll need to look into this on the |
I've tried to run I'll post the issue on the |
I'll mention that looking at the commit history, we haven't made any changes that should affect this (the only change we've made to the built-in definition was one that made it work in the first place, and there haven't been any changes to null-ls core in this area). |
Thanks for the details! So according to Is it possible to override the temp file location for a specific generator directly from the config? It'd allow me to work with |
It's not currently possible to override the temporary directory, though from an architectural point of view it shouldn't be that hard to do so. I don't plan on working on this myself, since I think having to use a temp file for formatters and linters is an unpleasant workaround, and if there's any chance of getting |
Okay thanks! I'll close this one as it is mostly resolved. |
@Ganitzsh I was able to get this working correctly with the following: null_ls.builtins.formatting.buf.with(
{
extra_args = function(params)
local scan = require("plenary.scandir")
local paths = scan.scan_dir(params.root, {search_pattern = "buf.yaml"})
local config = paths[1]
if config then
return {"--config=" .. config, "--path=" .. params.bufname, "-o" .. params.temp_path}
end
return {}
end,
args = {"format"}
}
) @jose-elias-alvarez I can open a PR if you want. One thing I wasn't sure about is if to_temp_file and from_temp_file could be omitted and the bufname could be used for the output path. Also, when -o or -w aren't specified, it does write the output to stdout, can null-ls redirect it to the buffer? |
@kyle-mccarthy This seems like a reasonable workaround for now, but I would rather wait until we merge #1021. |
FAQ
Issues
Neovim Version
v0.7.2
Operating System
macOS 12.4
Minimal config
You also need to install https://github.com/bufbuild/buf
Steps to reproduce
Open the following file:
run
:lua vim.lsp.buf.formatting()
Expected behavior
The file should get formatted
Actual behavior
Nothing happens
Debug log
Not sure why it's trying to access a vnc file which is nowhere near the file I'm editing
Help
No
Implementation help
No response
Requirements
The text was updated successfully, but these errors were encountered: