AutoHotkey v2 Language Support, used in any editor that supports lsp

Scripting and setups with Visual Studio Code (vscode) and AutoHotkey.
User avatar
JoeSchmoe
Posts: 129
Joined: 08 Dec 2014, 08:58

Re: vscode language server for ahk v2

Post by JoeSchmoe » 23 Jan 2022, 12:00

For anyone following along, if you're curious about (neo)vim, here's a video backgrounder. It's not for everyone, obviously, but I'd love to get first-class AHK support into it.

User avatar
thqby
Posts: 397
Joined: 16 Apr 2021, 11:18
Contact:

Re: vscode language server for ahk v2

Post by thqby » 23 Jan 2022, 19:33

JoeSchmoe wrote:
23 Jan 2022, 11:35
So what did you mean by "getDllExport currently implemented on client." Could you clarify that a bit more for us in the GitHub issue? Will it require an update to your LSP server's code? The reason I ask is that because neovim and lspconfig are linux oriented, I'd be surprised if they asked for getDllExport.
I have updated the issue.
ahk2.getDllExport is used to obtain this capability.
3ffe3561700b89b5e2859f09b3f0914.jpg
3ffe3561700b89b5e2859f09b3f0914.jpg (13.2 KiB) Viewed 5601 times

User avatar
JoeSchmoe
Posts: 129
Joined: 08 Dec 2014, 08:58

Re: vscode language server for ahk v2

Post by JoeSchmoe » 23 Jan 2022, 23:02

That's an awesome feature, and it makes total sense. Thanks for the great software.

When the software is updated, hopefully my Neovim skills will be a little stronger. There is also a plugin to automatically install LSP Servers. Ideally, we'd want to get your server on that list eventually, too. Lunarvim, the Neovim distribution I use, integrates all of these so that when I open a new document, and LSP server, linters, and syntax highlighting are automatically installed based on the file extension. For example, here are the options for TypeScript:
https://www.lunarvim.org/languages/typescript.html

Not bad for an open source project. ;) With Windows Subsystem for Linux making it so easy to run Linux and Windows simultaneously on the same box, I'm imagining there will be more demand for this in the future, too.

Helgef
Posts: 4709
Joined: 17 Jul 2016, 01:02
Contact:

Re: vscode language server for ahk v2

Post by Helgef » 04 Nov 2022, 11:41

I tried it, very good. It helped me solve a problem (mastodontic shipwreck error a la helgef :headwall: :oops: :facepalm: )

Thanks for sharing, cheers.

jsong55
Posts: 222
Joined: 30 Mar 2021, 22:02

Re: vscode language server for ahk v2

Post by jsong55 » 13 Nov 2022, 08:26

Is there a way to run v1 on a certain workspace and v2 on another with both using the same .ahk extension?

User avatar
thqby
Posts: 397
Joined: 16 Apr 2021, 11:18
Contact:

Re: vscode language server for ahk v2

Post by thqby » 13 Nov 2022, 19:13

You can disable plug-ins or associate default languages in a workspace using workspace settings.

jsong55
Posts: 222
Joined: 30 Mar 2021, 22:02

Re: vscode language server for ahk v2

Post by jsong55 » 13 Nov 2022, 23:26

Update I think I got it.

I use this in my v2 workspace
Image

and my v1 workspace
Image

----------
Does this look correct?
Image

and my version 2 workspace language should just be Autohotkey2

User avatar
thqby
Posts: 397
Joined: 16 Apr 2021, 11:18
Contact:

Re: vscode language server for ahk v2

Post by thqby » 14 Nov 2022, 00:28

ahk and ahk2

The next version(v1.7.4) will support detecting v1 scripts and automatically switching to ahk v1.

jsong55
Posts: 222
Joined: 30 Mar 2021, 22:02

Re: vscode language server for ahk v2

Post by jsong55 » 14 Nov 2022, 02:26

thqby wrote:
14 Nov 2022, 00:28
ahk and ahk2

The next version(v1.7.4) will support detecting v1 scripts and automatically switching to ahk v1.
AWESOME! can't wait for more and more improvements

greatwhitepine
Posts: 8
Joined: 16 Feb 2023, 01:24

Re: AutoHotkey v2 Language Support, used in any editor that supports lsp

Post by greatwhitepine » 24 Mar 2023, 04:02

I'm using this and it is excellent! ty!

Are you aware of any way to generate the api documentation in html format from the javadoc style comments?


greatwhitepine
Posts: 8
Joined: 16 Feb 2023, 01:24

Re: AutoHotkey v2 Language Support, used in any editor that supports lsp

Post by greatwhitepine » 25 Mar 2023, 11:51

thqby wrote:
25 Mar 2023, 04:17
https://github.com/onury/docma
I get error...
» Unsupported source ignored: C:\AHK\test_gui\main\test_gui.ahk

Forcing to treat ahk files as js files also doesn't work...

"src": [
"./main/**/*.ahk:js"
],

Parsing 32 Javascript file(s)...
» Parsing (_def_): 32 files
Error: Output: There are no input files to process.

Any pointers?

User avatar
thqby
Posts: 397
Joined: 16 Apr 2021, 11:18
Contact:

Re: AutoHotkey v2 Language Support, used in any editor that supports lsp

Post by thqby » 28 Mar 2023, 10:09

greatwhitepine wrote:
25 Mar 2023, 11:51
Error: Output: There are no input files to process.
This tool only works with javascript, ahk cannot be used directly. You need to convert it to a similar format. And the internal dependency library enforces files with .js suffix

Code: Select all

/** ... */
function fn(){}

DaveT1
Posts: 218
Joined: 07 Oct 2014, 11:23

Re: AutoHotkey v2 Language Support, used in any editor that supports lsp

Post by DaveT1 » 15 Apr 2023, 08:17

Hi @thqby, been using this extension for a while and it's very helpful.

But, I just started getting lots of pop-up messages in vscode like:
image.png
image.png (6.55 KiB) Viewed 3670 times

of course, I just ignored it and carried on unthinkingly :crazy: .

But then I realised that nearly all the code folding on braces "{ }" has disappeared. I know they were there yesterday 'cos I've been working through a very large script adding braces to allow code folding (amongst other things) so as to aid readability. And now hardly any of this folds :( .

Then I saw that 1.9.7 of your extension was release in the last day or 2. So I'm wondering if there is something in this update that is causing me a problem with code folding?

Many thanks for your help.

Edit(15-Apr-23 18:14): Sorry this might help: when I disable your extension, all the code folding at braces "{ }" comes back. Then when I re-enable your extension, the code very briefly (nano secs) shows the folding marks (> and downarrow), before then removing them.

User avatar
thqby
Posts: 397
Joined: 16 Apr 2021, 11:18
Contact:

Re: AutoHotkey v2 Language Support, used in any editor that supports lsp

Post by thqby » 16 Apr 2023, 00:06

The information you provided is not enough for me to find out the problem.

DaveT1
Posts: 218
Joined: 07 Oct 2014, 11:23

Re: AutoHotkey v2 Language Support, used in any editor that supports lsp

Post by DaveT1 » 17 Apr 2023, 14:23

thqby wrote:
16 Apr 2023, 00:06
The information you provided is not enough for me to find out the problem.
Ooppss, sorry. Let me try and explain better. Consider this screenshot from my vscode screen that I made just now. Your extension is enabled. Notice that there are no code folding marks in the left hand column and there is a warning message as shown.

image.png
image.png (23.74 KiB) Viewed 3570 times

Until a few days ago with your extension enabled I had both code folding and no such warning messages. The screenshot below was taken just now but with your extension disabled. It shows full code folding marks in the left hand column.

image.png
image.png (22.58 KiB) Viewed 3570 times

Is it possible that your extension update to 1.9.7 has caused this change of behaviour, or possibly I'm doing something wrong. Do you have any advice?

Many thanks and best regards.

User avatar
thqby
Posts: 397
Joined: 16 Apr 2021, 11:18
Contact:

Re: AutoHotkey v2 Language Support, used in any editor that supports lsp

Post by thqby » 19 Apr 2023, 19:46

The above code alone should not cause any problems, but as this is v1 code, the extension may have different processing methods, resulting in different results.

1.Stop parsing - does not provide most features
2.Continue - Error reported at error point
3.Skipping this line - may not necessarily recognize a line correctly and may result in unexpected results
4.Switch to v1 extension

Therefore, the recommended approach is to install extensions for v1 and v2 separately, set the .ahk default association to ahk2(should be the default behavior), and set the v2 extension to switch to the v1 extension when v1 code is detected.

V2 extension also has commands to switch between v1/v2, which can be bound with hotkeys for use.

DaveT1
Posts: 218
Joined: 07 Oct 2014, 11:23

Re: AutoHotkey v2 Language Support, used in any editor that supports lsp

Post by DaveT1 » 20 Apr 2023, 14:13

Hi @thqby,

Thx so much for getting back.

I was using your v2 extension already alongside a v1 extension. But had managed to set them up so that your 'code folding with zero indents between "{}"' would work in v1 as well as v2.

I've just changed the v1 extension I was using, to a more popular one. It gives me much 'safer' control over running and debugging, but does not allow zero-indented code within "{}" to fold.

I use alot of "{}" to group together various sections of code. This is only for visual convenience, nothing that affects the working of the script. But I can get code folding back between "{}" if I indent the code between the braces. So I'll change my formatting style to adopt this new approach.

Many thanks for taking the time to help.

vmech
Posts: 352
Joined: 25 Aug 2019, 13:03

Re: vscode language server for ahk v2

Post by vmech » 20 Nov 2023, 05:10

thqby wrote:
26 Nov 2021, 07:53
F5 or context menu - debug.
launch.json is not necessary.
If launch.json is abandoned, then how to suppress this debugger output ?
Image

PS. When I use launch.json I no more needs F5 keybinding installed by extension - I just disable it, then the Code themselves suppress output shown above.
Please post your script code inside [code] ... [/code] block. Thank you.

User avatar
thqby
Posts: 397
Joined: 16 Apr 2021, 11:18
Contact:

Re: AutoHotkey v2 Language Support, used in any editor that supports lsp

Post by thqby » 20 Nov 2023, 06:29

Failed to load the picture. If you need custom functions, of course you need launch.json.

Post Reply

Return to “Visual Studio Code”