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

feature request: fileExtension type setting for html #703

Open
imthenachoman opened this issue Sep 7, 2019 · 16 comments
Open

feature request: fileExtension type setting for html #703

imthenachoman opened this issue Sep 7, 2019 · 16 comments

Comments

@imthenachoman
Copy link

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
@dustinmichels
Copy link

dustinmichels commented Oct 19, 2021

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
Copy link

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
Copy link
Author

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
Copy link

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
Copy link
Author

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
Copy link

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
Copy link
Author

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
Copy link
Author

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 added a commit to imthenachoman/clasp that referenced this issue Oct 27, 2021
- Fixed issues with `fileExtension` (see google#884)
- Added `htmlExtension` for a custom HTML file extension (see google#703)
@imthenachoman
Copy link
Author

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
Copy link

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

@imthenachoman
Copy link
Author

@TommyJay337 Yes. Why do you ask?

@TommyJay337
Copy link

@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
Copy link
Author

@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
Copy link

TommyJay337 commented Apr 9, 2023

@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
Copy link
Author

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

@imthenachoman
Copy link
Author

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

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

3 participants