thqby / vscode-autohotkey2-lsp

Autohotkey v2 Language Support using vscode-lsp.
https://marketplace.visualstudio.com/items?itemName=thqby.vscode-autohotkey2-lsp
GNU Lesser General Public License v3.0
219 stars 21 forks source link

Can curly braces characters be used with parameter autocomplete? #546

Closed GroggyOtter closed 3 months ago

GroggyOtter commented 4 months ago

Addon version: v2.4.8

When creating an @param JSDoc tags, the addon allows for different selections, delimited by pipes.
It works well but I cannot find a way to produce literal curly brace characters: { and } Example:

@param {'{Alt}'|'{Shift}'|'{Control}'} ModKeys

Expected menu text:

{Alt}
{Shift}
{Control}

Actual menu text:

Alt
Shift
Control

I also tried different types of escapes.
None of these worked:

'{{}Alt{}}'
'`{Alt`}'
'\{Alt\}'

Please advise how to create literal curly braces.


Going a step further, can you please provide guidance or instructions on how to correctly utilize the @Param {} syntax?
Or some kind of documentation that explains it.

I don't understand why adding this 'Alt' and an Intellisense type of "value/enum".
But '{Alt}' has an Intellisense type of "keyword".
And '{Blind}' has a type of "text".

Why does {} change the type and not produce actual characters?
What are the rules for this syntax?

thqby commented 4 months ago

But '{Alt}' has an Intellisense type of "keyword". And '{Blind}' has a type of "text".

They should be provided by built-in completions.

thqby commented 4 months ago

Can't reproduce the problem, it works normally in my place.

image

GroggyOtter commented 4 months ago

There's an X factor here somewhere.
One of the other keys must be causing this problem.
Give me a second to find out which it is.
What you're showing on your image post is EXACTLY what I was striving for.

Also, xie xie for taking time to respond to my questions and helping me learn more about all this.

GroggyOtter commented 4 months ago

I think I figured out the problem.
The issue was the parameter name and the fact that I didn't understand you could apply definitions from the json file to the def file (I feel like I don't know anything about how this addon works...)

I trimmed my test case down to this:

@param {String|'{Alt}'|'{AppsKey}'|'{Backspace}'|'{Browser_Back}'} Keys

And this is the what was showing up: Code_kR2gQ7hbSD

I realized that the only place some of those key names appears is in the ahk.json file.

Is that how this works? Send() parameter's tag name is keys so it applies the information from the keys object in the json file?

thqby commented 4 months ago

Yes, similar to WinTitle, etc., because they appear in many built-in functions and reuse these completions

RaptorX commented 4 months ago

Also keep in mind that if you press Ctrl + Space withouth adding the quotes first you might get the text suggestions instead of what you are looking for:



When you add the quotes first and then use Ctrl + Space I get what you were expecting:

GroggyOtter commented 4 months ago

Yes, similar to WinTitle, etc., because they appear in many built-in functions and reuse these completions

Thanks.
I'm currently struggling with making use of the JSON file like I want.
There's a structuring rule or something I'm not following and IDK what it is.

First, here's a link to the ahk2.json file I'm working with.
It's primarily the same as the original, with some minor changes.
The two big changes I recently made were the addition of 2 properties:
keysend is added to the root object and was based off of the keys entry.
There's also an mboptions entry in the options property of the object.

If I use the default keys as a name for an @param tag in the definition file, the keys show up in the autocomplete as expected.
I have keys applied to SendEvent() and it works.
It even knows to identify key names as "keywords" and the modes, like blind/raw/text, as "text" words.
Code_BQbiN97rzU

But when I apply my keysend property to an @param tag, it doesn't work at all.
Instead, it gives me a huge list of words that have nothing to do with the list items provided (and some words don't even exist in the json text)
Code_hPCKOZaWGI

I've tried various things and can't get it to work correctly.

I also tested another scenario.
I chose MsgBox's "options" parameter and made an "mboptions" entry under the "options" property of the JSON file.
It contains all the different text options message box's 3rd parameter can use.

"mboptions": [
    {
        "body":"OK"
    },
    {
        "body":"OKCancel"
    },
    {
        "body":"AbortRetryIgnore"
    },
    {
        "body":"YesNoCancel"
    },
    {
        "body":"YesNo"
    },
    {
        "body":"RetryCancel"
    },
    {
        "body":"CancelTryAgainContinue"
    },
    {
        "body":"IconX"
    },
    {
        "body":"Icon?"
    },
    {
        "body":"Icon!"
    },
    {
        "body":"Iconi"
    },
    {
        "body":"Default2"
    },
    {
        "body":"Default3"
    },
    {
        "body":"Default4"
    }
],

In the definition file, I set the 3rd @param to mboptions.

 @param {String} [MBOptions]  

And just like keysend, I get a list full of words that have nothing to do with MsgBox.
It's the exact same malformed list that keysend produced:
Code_VzDLe634r0

I love the functionality of having wrapped key names when using send, but I can't stand that my current tooltips have this huge, ridiculous line of keys displayed:
Code_XueKTjFNqT

This does not happen when using the keys option.
Which is why I want to import a lot of my autocomplete lists into the json file.

Can you please help me out with this?
What is the correct format or structure to do this?
Can it be done?? Or does this require altering the server files to work?
Last question: can you please explain what the differences between options vs texts in the JSON file?

Thanks so much for your time and effort.

thqby commented 4 months ago
/**
 * @typedef {...} typename
 */

I plan to group option strings by function, but I haven't started yet, so they're all in texts right now.

GroggyOtter commented 4 months ago

I'm sorry, but I don't understand.

I tried implementing a @typedef tag (in a few different ways) and couldn't get it to work as intended.

Also, the main question I asked wasn't addressed.
How do I correctly add option lists to the ahk2.json file so that it can be used in the definition file?
Similar to how Keys works.

Or is this not currently possible?

I plan to group option strings by function

Check out my current definition file.
I added options for almost everything that accepts a pre-defined value.
With a few regex replacements, you can scrape and format all of it and save yourself a lot of typing.

thqby commented 4 months ago

I forgot, it hasn't happened yet.

GroggyOtter commented 4 months ago

I plan to group option strings by function, but I haven't started yet, so they're all in texts right now.

This might help: https://pastebin.com/9p8kdduC

It's a list of all function and method parameters that have "auto complete" lists in my def file.

You can parse through it/check against it/whatever you want.

thqby commented 4 months ago

This is a private link and cannot display its content.

GroggyOtter commented 4 months ago

It's "pending moderation" I guess.
Posted it to GitHub:

https://github.com/GroggyOtter/GroggyRepo/blob/master/temp/ahkv2%20options%20list.txt

RaptorX commented 4 months ago
/**
 * @typedef {...} typename
 */

I plan to group option strings by function, but I haven't started yet, so they're all in texts right now.

hope this gets implemented at some point, really handy.