mark-wiemer-org / ahkpp

AutoHotkey Plus Plus (AHK++) - AutoHotkey v1 and v2 support for VS Code
https://marketplace.visualstudio.com/items?itemName=mark-wiemer.vscode-autohotkey-plus-plus
Other
152 stars 10 forks source link

No formatter AHK2 script in VS Code #444

Closed tirosko closed 3 months ago

tirosko commented 3 months ago

Description

After Ctrl+Shilt+P (open palete - Format document. Appear request to install formatter

Please see attached file.

Contact mail: tibor.rosko@hotmail.com Snímka obrazovky 2024-05-26 125746

mark-wiemer commented 3 months ago

Ref #445, let me know if this helps :)

tirosko commented 3 months ago

With rename extension by script name from ahk to ahk1 work formatter.

Thanks for help.

Tibor Roško SNP 23 900 01 Modra mobil: 0903445532

From: Mark Wiemer @.> Sent: nedeľa 26. mája 2024 13:14 To: mark-wiemer-org/ahkpp @.> Cc: Tibor Roško @.>; Author @.> Subject: Re: [mark-wiemer-org/ahkpp] No formatter AHK2 script in VS Code (Issue #444)

Ref #445https://github.com/mark-wiemer-org/ahkpp/discussions/445, let me know if this helps :)

- Reply to this email directly, view it on GitHubhttps://github.com/mark-wiemer-org/ahkpp/issues/444#issuecomment-2132181210, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ALRVEZEEUD3VMCKTUBDA6VLZEG7X7AVCNFSM6AAAAABIJWKZKCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCMZSGE4DCMRRGA. You are receiving this because you authored the thread.Message ID: @.**@.>>

Lootwig commented 3 months ago

That assigns the v1 type though, shouldn't the "ahk2" type still be picked up by VS Code? I can't even assign an unsupported formatter to the type, I still get the "no installed formatter" box

// settings.json
{
  "files.associations": {
    "*.ahk": "ahk2"
  },
  "[ahk2]": {
    "editor.defaultFormatter": "mark-wiemer.vscode-autohotkey-plus-plus" // doesn't even attempt to use, independent of e.g. "prettier" or anything else
  },
}
mark-wiemer commented 3 months ago

@Lootwig, I understand the frustration, and I'll go ahead and enable experimental v2 support to unblock simple scripts, but please be aware that there will be many, many bugs noticeable on larger scripts. Ref #381 for details.

Lootwig commented 3 months ago

@mark-wiemer relax, the frustration is within reasonable limits :D

The main inconvenience isn't really the wip-status of v2, but the fact that the extension recognizes the language, VS code lists ahk++ after offering to search for formatters, and I spent an embarrassing amount of time trying to figure out why the message is "no installed formatter" even after manual assignment, instead of something more specific like when attempting to assign the "dart" formatter:

image

It might be commonly known that "contributing a language" and having "formatters" as one of the categories of an extension may not mean there's a formatter for all contributed languages - I just didn't know and if you feel like language support just isn't ready enough, simply disabling the ahk2 type would be a totally acceptable remedy for the cause of my confusion!

mark-wiemer commented 3 months ago

Let me see if there's an easy way around this. I don't think it's as simple as "disabling the ahk2 type" as I do want to keep that: the extension uses the type to determine which AHK runtime to use and which icon to render (blue for v1, green for v2). I found this and am investigating now:

https://github.com/microsoft/vscode/blob/d2d053d84e2460661c435ac825b1b1895f7efd51/src/vs/workbench/contrib/format/browser/formatActionsMultiple.ts#L130

mark-wiemer commented 3 months ago

Hmm, @Lootwig I'm not able to reproduce your issue:

image

// settings.json
"[ahk2]": {
  "editor.defaultFormatter": "mark-wiemer.vscode-autohotkey-plus-plus"
},

Repro steps: Open a .ahk2 file and try run > Format Document via command palette (Ctrl+P)

I also don't see AHK++ in the list of formatters when I run > Format With...:

image

For now I'm not seeing anything wrong with the extension. There is a bit of AHK v2 support, but I'll try to update the readme to be clearer about the limitations. I am working towards adding full formatting support though :)