Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to integrate JuliaFormatter with Helix #868

Open
arunoruto opened this issue Aug 29, 2024 · 3 comments
Open

How to integrate JuliaFormatter with Helix #868

arunoruto opened this issue Aug 29, 2024 · 3 comments

Comments

@arunoruto
Copy link

I am currently using helix as my main "IDE" and I wanted to use it for Julia too. Configuring a formatter in helix is really straight forward: the contents will be passed to a command as stdin and the output is expected on stdout, as explained in this discussion. There are example in the README.md for formatting folders recursively and files. It would be nice if an example for stdin and stdout would be provided, if possible. If not, adding this feature would benefit. An example for an abstract language is also provided here by helix.

@arunoruto
Copy link
Author

Well, after digging more into this (I am a bit new to Julia and its ecosystem), I found a suitable solution!
The following configuration of helix works for me:

[[language]]
name = "julia"
...

[language.formatter]
args = ["--startup-file=no", "--history-file=no", "--quiet", "-e", "using JuliaFormatter; println(format_text(join(readlines(stdin), '\\n')))"]
command = "julia"

This will work for now, but it is a bit slowish. I am not sure if I am doing something wrong, so if there is a better/faster way, I am eager to learn it :)

I will keep the issue open for now, but if no one replies to it, I will close it.

@domluna
Copy link
Owner

domluna commented Sep 2, 2024

that's probably the way to do it but it would probably be better if you used format(filename) because if you call format_text(...) then any configuration in your directory, such as a .JuliaFormatter.toml file won't be detected.

@arunoruto
Copy link
Author

I will have to look into how or if helix provides a filename too. To my knowledge, only the to be formated text is provided via stdin and returned in stdout.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants