clasp
clasp copied to clipboard
feature request: fileExtension type setting for html
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
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
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.
Any suggested fixes for this?
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.
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.
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. :)
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.
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.
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
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
htmlExtensionfor a custom HTML file extension (see #703)
@imthenachoman just stumbled upon this issue myself and found this feature request. Is the above still your preferred solution?
@TommyJay337 Yes. Why do you ask?
@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
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 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.
htmlExtension goes .clasp.json. https://github.com/imthenachoman/clasp#project-settings-file-claspjson
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. :/