clasp icon indicating copy to clipboard operation
clasp copied to clipboard

feature request: fileExtension type setting for html

Open imthenachoman opened this issue 6 years ago • 16 comments

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

  • Node version (node -v): v10.16.2
  • Version (clasp -v): 2.2.1
  • OS (Mac/Linux/Windows): Windows

imthenachoman avatar Sep 07 '19 12:09 imthenachoman

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 avatar Oct 19 '21 16:10 dustinmichels

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?

dustinmichels avatar Oct 19 '21 16:10 dustinmichels

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.

imthenachoman avatar Oct 20 '21 13:10 imthenachoman

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.

dustinmichels avatar Oct 22 '21 18:10 dustinmichels

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. :)

imthenachoman avatar Oct 22 '21 20:10 imthenachoman

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.

dustinmichels avatar Oct 26 '21 17:10 dustinmichels

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 avatar Oct 27 '21 01:10 imthenachoman

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 avatar Oct 27 '21 03:10 imthenachoman

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?

  • https://github.com/imthenachoman/clasp
  • https://github.com/imthenachoman/clasp/commit/166850af848c82328096b294d43c8b492c3b6c64

What I did:

  • Fixed issues with fileExtension (see #884)
  • Added htmlExtension for a custom HTML file extension (see #703)

imthenachoman avatar Oct 27 '21 04:10 imthenachoman

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

TommyJay337 avatar Apr 07 '23 15:04 TommyJay337

@TommyJay337 Yes. Why do you ask?

imthenachoman avatar Apr 07 '23 20:04 imthenachoman

@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.

TommyJay337 avatar Apr 08 '23 17:04 TommyJay337

@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.

imthenachoman avatar Apr 09 '23 12:04 imthenachoman

@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.

TommyJay337 avatar Apr 09 '23 18:04 TommyJay337

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

imthenachoman avatar Apr 10 '23 03:04 imthenachoman

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. :/

imthenachoman avatar Apr 10 '23 03:04 imthenachoman