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

feat: add awk formatter #286

Merged
merged 1 commit into from
Feb 3, 2024
Merged

feat: add awk formatter #286

merged 1 commit into from
Feb 3, 2024

Conversation

trevarj
Copy link
Contributor

@trevarj trevarj commented Feb 1, 2024

Add formatter for awk programs. Surprise! It's awk!

Add formatter for awk programs. Surprise! It's awk!
@github-actions github-actions bot requested a review from stevearc February 1, 2024 07:51
@stevearc
Copy link
Owner

stevearc commented Feb 3, 2024

Love it 😆

@stevearc stevearc merged commit 338c307 into stevearc:master Feb 3, 2024
8 checks passed
@Givo29
Copy link

Givo29 commented Sep 18, 2024

Hi guys,

I know this has been closed, but would it be possible to add an additional formatter for awk, likely being prettier-plugin-awk?

Two main reasons why I'm asking this.

  1. Not everyone will be using gawk (gnu awk), other versions (like mawk) come installed as the default on a lot of systems such as Debian and Ubuntu, it would be nice for there to be an option for these systems without installing gawk
  2. Gawk pretty printing (as you have here) uses profiling behind the scenes, the output of which can differ a lot from what you're trying to write.. Especially in the case where you're using @include to import functions from another awk file, which gawk pretty-print does not like at all. prettier-plugin-awk does a much better job of this. (I can provide examples if you like).

I hope this is considered as I believe that prettier-plugin-awk is a better formatter than using gawk's pretty-print feature. It's more universal across all awk versions and also does a better job in general.

Regards,
Joel

@trevarj
Copy link
Contributor Author

trevarj commented Sep 18, 2024

@Givo29 maybe you can just add a separate "awk-prettier" formatter. Seems better since people may not be using prettier and have this extension installed.

@Givo29
Copy link

Givo29 commented Sep 18, 2024

I have done that for now @trevarj, I just thought I'd also make the suggestion here.

You make a valid point though, not everyone will have prettier installed either.

What I've done:

formatters = {
    awk_prettier = {
        command = "~/.nvm/versions/node/v20.17.0/bin/prettier",
        args = { "--stdin-filepath", "$FILENAME" }
    }
},

The only unfortunate part is I have to globally install prettier and prettier-plugin-awk as it won't work using the mason installed prettier instance...

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

Successfully merging this pull request may close these issues.

3 participants