nvf icon indicating copy to clipboard operation
nvf copied to clipboard

add language HCL

Open ppenguin opened this issue 1 year ago • 3 comments

Terraform doesn't register hcl and doesn't offer good DX if manually set for editing e.g. nomad HCL files.

My first nvf contribution. Maybe somebody could show how to integrate a formatter as well. Other than that it's already an improvement for editing non-Terraform files (e.g. nomad), but it could be probably better. (I vaguely remember the vscode plugin offered some more features).

ppenguin avatar Aug 17 '24 16:08 ppenguin

Looks reasonable. Though, I will need you to format via alejandra and not nixfmt. The formatting check is failing.

Other than that, if there is a known formatter for HCL I can work on getting it added tomorrow. We will need null-ls (or none-ls) to support HCL for proper formatting.

NotAShelf avatar Aug 17 '24 18:08 NotAShelf

Looks reasonable.

Thanks for looking into it so quickly...

Though, I will need you to format via alejandra and not nixfmt. The formatting check is failing.

Ah yes, different than nixpkgs :sweat_smile:

While we're at it, is there a trick that I can (e.g. via direnv) use the active HM config for nvf but override certain attributes (like the formatter) in a devshell (when I'm in the nvf repo)? Or would I need to outsource my "standard" nvf config to a separate flake for that?

ppenguin avatar Aug 17 '24 18:08 ppenguin

Looking at none-ls builtins, I see an formatter source for Terraform. This could be used to add formatter support via terraform fmt. Refer to other language modules on how formatter submodules are added - the process is extremely straightforward but I'll be around if you have questions.

While we're at it, is there a trick that I can (e.g. via direnv) use the active HM config for nvf but override certain attributes (like the formatter) in a devshell (when I'm in the nvf repo)? Or would I need to outsource my "standard" nvf config to a separate flake for that?

Afraid there isn't a way to impurely override configuration per-project, but we do provide a formatter that will format the code for you with nix fmt. I will consider making this a pre-commit hook, or at least have pre-commit warn you before you commit the changes.

NotAShelf avatar Aug 17 '24 19:08 NotAShelf

Looking at none-ls builtins, I see an formatter source for Terraform. This could be used to add formatter support via terraform fmt. Refer to other language modules on how formatter submodules are added - the process is extremely straightforward but I'll be around if you have questions.

I finally got around to finish this one. In hindsight I might have gone a bit overboard with (unnecessary?) extensibility (inspired by the bash setup), but given the fact that terraform-ls is a bit too generic for nomad, there may be more specific solutions in the future that we might then easily integrate.

EDIT: spelling (noticed spelling "funture", I might be on to something :rofl )

ppenguin avatar Oct 31 '24 18:10 ppenguin

Sorry for the delay in my review, I'm very busy with IRL stuff at the moment.

We're currently at the final stretch for merging the next big release (see #355) and I've frozen the main branch to avoid merge conflicts. If you could rebase this around the v0.7 branch, I should be able to provide a final review or/and merge this PR tomorrow.

NotAShelf avatar Nov 25 '24 16:11 NotAShelf

Thanks

If you could rebase this around the v0.7 branch, I should be able to provide a final review or/and merge this PR tomorrow.

Done (just pushed ther rebased one)

ppenguin avatar Nov 26 '24 10:11 ppenguin

Ah, the good old rebase vs merge mess :wink: Should be ok now...

ppenguin avatar Nov 27 '24 15:11 ppenguin

All good, merging once CI passes.

NotAShelf avatar Nov 27 '24 19:11 NotAShelf