google / clasp

🔗 Command Line Apps Script Projects
https://developers.google.com/apps-script/guides/clasp
Apache License 2.0
4.59k stars 428 forks source link

feature request: fileExtension type setting for html #703

Open imthenachoman opened 5 years ago

imthenachoman commented 5 years ago

I think it would be helpful to be able to specify the local file extension for html files. We can already do this with the gs files using fileExtension and I think we just need one for html files.

The whole purpose of clasp is to make it easier to edit locally. GAS html files are not typical html files but because they have a html extension any editor/IDE will treat them as an html file.

If we could specify our own extension, like gtml then we can use file extension association with our IDEs to treat it differently. For example, to accommodate syntax highlighting for scriptlets and auto-complete.

Expected Behavior

A settings option to specify what file extension html files should be locally.

Actual Behavior

N/A

Steps to Reproduce the Problem

N/A

Specifications

dustinmichels commented 3 years ago

I am also finding it a bit challenging to locally edit html with special GAS syntax. I would love a custom file formatter for VS Code, as a possible new feature?

There is a similar vs-code extension for handling django-html: https://github.com/vscode-django/vscode-django

Additional links: https://code.visualstudio.com/blogs/2016/11/15/formatters-best-practices https://github.com/jrieken/vscode-formatter-sample

dustinmichels commented 3 years ago

Syntax highlighting & formatting specific to GAS-html files would be really awesome, but what I would really like is to not have my editor report GAS scriptlets as errors.

Screen Shot 2021-10-19 at 10 42 02 AM

Any suggested fixes for this?

imthenachoman commented 3 years ago

I don't know how to create a new syntax checker but I know it is possible. Once the file extension is changed there are ways to specify the syntax checker to use.

dustinmichels commented 3 years ago

I took a first stab at this and made a VSCode extension that can be manually installed, which extends the grammar for html files to partially handle GAS syntax. It's a bit clunky and limited, but you can check it out: https://github.com/dustinmichels/gas-html

The better solution would be define a new language, eg, ghtml, with a more robust definition.

Note: I know this doesn't directly relate to clasp but this is tooling that I think would support clasp and would improve the local development experience.

imthenachoman commented 3 years ago

Love it. This is great. I will check it out when I get a moment.

Consider tagging this issue in your README so folks who come across yours can come vote on this. :)

dustinmichels commented 2 years ago

Made some improvements: https://github.com/dustinmichels/vscode-gas-html

Now the extension adds gas-html as a new language, so you can specify certain html files as gas-html (rather than simply extending html as before).

It works a little bit! Bit it's fairly buggy & limited. Help & feedback welcome.

imthenachoman commented 2 years ago

So I was looking through the code and see where (I think) the necessary changes need to be made to support an option to save html files as custom extension. I don't know TypeScript well but I will try to muck around with this.

imthenachoman commented 2 years ago

I got this working for pulling (custom html extension). I'm working on push but have to modify some other code too. See #884 884

imthenachoman commented 2 years ago

So I think I got it. I don't know Typescript that well but it seems to work. I don't want to submit a pull request until someone can help me test?

What I did:

TommyJay337 commented 1 year ago

@imthenachoman just stumbled upon this issue myself and found this feature request. Is the above still your preferred solution?

imthenachoman commented 1 year ago

@TommyJay337 Yes. Why do you ask?

TommyJay337 commented 1 year ago

@imthenachoman Simply curiosity, it seemed like a dead end as your PRs seemed untouched. This may or may not be the correct place to ask, but: If I wanted to test out your version of Clasp, how would one go about doing so? I assume that I would have to initially uninstall google/clasp.

imthenachoman commented 1 year ago

@TommyJay337

Simply curiosity, it seemed like a dead end as your PRs seemed untouched.

To be honest, the entire clasp project seems dead as it hasn't been updated in a while. I'm just waiting for someone to merge my PR. :/

If I wanted to test out your version of Clasp, how would one go about doing so?

You should be able to follow clasp's development instructions using my repo at https://github.com/imthenachoman/clasp.

TommyJay337 commented 1 year ago

@imthenachoman unfortunate. Thank you very much for the instructions, it seems everything works as intended. However, if I attempt to use htmlExtension or fileExtension I get an error: Input: clasp clone "Script ID" --rootDir src htmlExtension "ghtml"

Could not find script. Did you provide the correct scriptId? Are you logged in to the correct account with the script?

Would you happen to have any troubleshooting ideas? Note: clasp clone "Script ID" --rootDir works as intended, so I know the API is enabled, I have permissions, and I am logged in.

imthenachoman commented 1 year ago

htmlExtension goes .clasp.json. https://github.com/imthenachoman/clasp#project-settings-file-claspjson

imthenachoman commented 1 year ago

I don't know TypeScript. It took me a while to reverse engineer clasp's codebase to figure out how to make this work. It's been so long I forgot a lot of the code I wrote. Heh.

Honestly, I've given up on them merging my PR. :/