Skip to content
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

Completion for parameter aliases #2211

Open
2 tasks done
sharpchen opened this issue Dec 19, 2024 · 5 comments
Open
2 tasks done

Completion for parameter aliases #2211

sharpchen opened this issue Dec 19, 2024 · 5 comments
Labels
Issue-Enhancement A feature request (enhancement). Needs: Triage Maintainer attention needed!

Comments

@sharpchen
Copy link

Prerequisites

  • I have written a descriptive issue title.
  • I have searched all issues to ensure it has not already been requested.

Summary

It appears that it does not provide prompt for parameter aliases such as -Target as an alias for -Value in New-Item command.

Proposed Design

No response

@sharpchen sharpchen added Issue-Enhancement A feature request (enhancement). Needs: Triage Maintainer attention needed! labels Dec 19, 2024
@MartinGC94
Copy link
Contributor

The completion values comes from PowerShell itself and it intentionally leaves out parameter aliases if the real parameter is available in the completion result list. If you type in New-Item -T<Tab> you should get Target as one of the available options.

The idea behind this design is simple: It declutters the completion result list and it encourages the use of the real parameter names. Why do you want to use the alias over the real value?

@sharpchen
Copy link
Author

I just think it should be available anyway. Sometimes alias is more readable such as when you create a symlink with -Target instead of -Value. And I wonder how could I do -T<Tab> in neovim, is it builtin for vscode extension or ISE? I'm not familiar with lsp, I guess it should be a trigger character or something?

@MartinGC94
Copy link
Contributor

<Tab> represents hitting the tab key to tab complete the text. So whatever method you use to trigger completions in neovim should be triggered after you've typed -T.

@sharpchen
Copy link
Author

Yeah, there's no -Target in the list when after -T so I thought maybe I missed something

@MartinGC94
Copy link
Contributor

PS C:\> (TabExpansion2 'New-Item -t').CompletionMatches

CompletionText ListItemText    ResultType ToolTip
-------------- ------------    ---------- -------
-Type          Type         ParameterName [string] Type
-Target        Target       ParameterName [Object] Target

PS C:\>

Most likely the completion request is triggered by neovim when you type - and then it filters the results locally, which would give you this:

PS C:\> (TabExpansion2 'New-Item -').CompletionMatches

CompletionText       ListItemText           ResultType ToolTip
--------------       ------------           ---------- -------
-Path                Path                ParameterName [string[]] Path
-Name                Name                ParameterName [string] Name
-ItemType            ItemType            ParameterName [string] ItemType
-Value               Value               ParameterName [Object] Value
-Force               Force               ParameterName [switch] Force
-Credential          Credential          ParameterName [pscredential] Credential
-WhatIf              WhatIf              ParameterName [switch] WhatIf
-Confirm             Confirm             ParameterName [switch] Confirm
-Verbose             Verbose             ParameterName [switch] Verbose
-Debug               Debug               ParameterName [switch] Debug
-ErrorAction         ErrorAction         ParameterName [ActionPreference] ErrorAction
-WarningAction       WarningAction       ParameterName [ActionPreference] WarningAction
-InformationAction   InformationAction   ParameterName [ActionPreference] InformationAction
-ProgressAction      ProgressAction      ParameterName [ActionPreference] ProgressAction
-ErrorVariable       ErrorVariable       ParameterName [string] ErrorVariable
-WarningVariable     WarningVariable     ParameterName [string] WarningVariable
-InformationVariable InformationVariable ParameterName [string] InformationVariable
-OutVariable         OutVariable         ParameterName [string] OutVariable
-OutBuffer           OutBuffer           ParameterName [int] OutBuffer
-PipelineVariable    PipelineVariable    ParameterName [string] PipelineVariable

PS C:\>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Issue-Enhancement A feature request (enhancement). Needs: Triage Maintainer attention needed!
Projects
None yet
Development

No branches or pull requests

2 participants