-
Notifications
You must be signed in to change notification settings - Fork 11
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
Fix formatting and syntax highlighting #123
Comments
I spent a few reading all of your recent comments, I'm glad you are back in the game and certainly very grateful. Looking forward to enjoy whatever comes out of this new effort. However when I see this issue I can only think that you are going to just improve over the existing rather than go from scratch. With vscode-lsp you can do wonders... among the most useful things you can do is: better code formatting, improved symbol detection (which leads to simplified refactoring) and above all semantic highlighting (for me this one alone does it). Given the beta status of the v2 I don't do anything on it, but seems is gaining popularity and I actually enjoyed the improvements, so I know as soon as it hits a stable release I'll ditch everything to go after the shinny new thing... and I guess I'm not the only one, many people will do the same. The AutoHotkey2 Language Support extension by thqby is already built like this and is very compelling. Most likely the research on the LSP/LSIF will be a better investment than go trough AHK's Syntax Tree and C++ itself. And if you go the route you have planned I started (never finished) a rewrite of the syntax highlight as there were many issues, if you keep things the way they are I'll be sure to spend some time finishing it. However I never touched a TextMate syntax files, so most of what I did was just intuition, if you have some some resources I'll be sure to put them to use. Thanks! for past and new efforts, all the best. |
Hey @anonymous1184, don't worry, I definitely plan to take advantage of existing frameworks whenever possible, including I've also completed C++ essential training which has helped me understand the basics of C++ (turns out it's just C with classes, and I've written plenty of C!). Next step is to follow some of the basic VS Code extension tutorials :) |
I've started a new repo, |
This is still very much in the research phase. We're currently entering the formatting step in the standard way as documented in Format Source Code in an Editor - VS Code, but we're definitely not following the "smallest possible" rule:
Oh well. Hopefully AST work here will mitigate the issue. Next step is probably looking to existing AHK formatters to see how they're implemented |
Writing a Prettier plugin could be a great option |
Looks like the syntax definition was part of @stef-levesque's initial commit to vscode-autohotkey. Wild. @cweijan changed it to JSON later, and that's the version I'm using now. This seems to be a TextMate grammar, as doc'd in Syntax Highlight Guide - VS Code. So... I already have one? I just need to translate this into a |
Reading list: |
Thanks for the info. The the JSON has the same as the same data as the XML, just a different presentation (less verbose) but in the end the regular expressions work the same. ahk.tmLanguage:37
Well is not like mad hard but cumbersome, as Lexikos said, v1 presents many hidden complexities. From the top of my head: commands normally take one line or if split at the parameters/arguments more lines with an extra level of indentation if they are split, however the MsgBox 0x40, Test, Hello World!
MsgBox 0x40
, Test
, Hello World
MsgBox 0x42, Question, If foo`, bar?
IfMsgBox No
ExitApp ; This must be indented
IfMsgBox Yes ; Block below, indented
{
OutputDebug Foo
OutputDebug Bar
} Things like that might make it less easy but not impossible. Next week I'll dust the old project where I started the rewrite of the highlighter, I'll keep you posted. |
Issues will be tracked in specific issues and labels, not with an epic issue like this one. |
There are currently many issues with formatting, and a few with syntax highlighting. The AHK documentation doesn't have any syntax highlighting issues, and presumably AHK has a much more consistent parser somewhere that correctly determines how the code is structured (what text is an "if" condition, what text is a command, what text is a string literal, etc.)
The parser should copy the behavior of the AHK's own parser. It will probably generate an AST like any standard compiler.
As of opening this bug, I've never even read C++ (which AHK is written in) but I have studied compilers.
Understand AHK implementation at a high levelI don't need to know how AHK works to know how to parse it 😄Sub-issues:
References:
Prettier
to create a pluginThe text was updated successfully, but these errors were encountered: