Formatter (stylua) doesn't find configuration file outside the folder the file is in #16027
|
Ran into this issue where stylua couldn't find My cwd was the project root where the My From stylua docs:
Question : Does helix run the formatter in the directory where the file is located and not from my cwd / workspace root?
When I added this my problem got solved. However it says :
A bit strange since in neovim everything used to work like you would expect it to. I didn't have to pass any other stuff to stylua. I did try passing filepath to stylua but it made no difference i'm not sure whether it even does anything as they say it's optional: |
Replies: 1 comment 1 reply
|
Yeah, helix runs the formatter with its working directory set to the file's own folder, not your cwd or workspace root. That's the whole reason It's right there in neovim felt different because there the formatter usually runs from the project root, so the search starts right where your config already lives. Keeping |
Yeah, helix runs the formatter with its working directory set to the file's own folder, not your cwd or workspace root. That's the whole reason
--search-parent-directoriesfixes it, so it's not really a hack.It's right there in
format()inhelix-view/src/document.rs: it callsprocess.current_dir(doc_dir)wheredoc_diris the parent of the file being formatted. stylua then starts its config search from that folder, and by default it won't climb any higher, so it never reaches thestylua.tomlat your project root unless the file happens to sit directly in it.neovim felt different because there the formatter usually runs from the project root, so the search starts right where your config a…