seunlanlege / vscode-action-buttons

VsCode extension for custom status bar buttons
89 stars 25 forks source link

Command Pallette Button #37

Open momiccioli opened 4 years ago

momiccioli commented 4 years ago

Whats the syntax to configure a button to run a command palette action? For example save current file.

Joey79100 commented 4 years ago

That's a duplicate of #7. However I'm interested as well, because the answer in that other issue seems incomplete: Just putting the VSCode command in "command" is not enough. It tries to run the command in the terminal instead.

Here's a basic example that would open settings on click.


"actionButtons": {
    "defaultColor": "#172c3d", // Can also use string color names.
    "reloadButton": null, // Custom reload button text or icon (default ↻). null value enables automatic reload on configuration change
    "commands": [
        {
            "name": "Settings",
            "color": "#ffffff",
            "command": "workbench.action.openSettings",
        }
    ]
}

What am I missing?

seunlanlege commented 4 years ago

In order to achieve this, we would have to use the vscode.commands.executeCommands api

as stated here: https://code.visualstudio.com/api/extension-guides/command,

happy to provide mentoring if anyone is interested in picking this up.

Joey79100 commented 4 years ago

So that means it's not possible yet without modifying the extension itself? Just to make it clear, because the answer on the previous issue made it sound like it was already possible.

seunlanlege commented 4 years ago

In order to achieve this, we would have to use the vscode.commands.executeCommands API

At the time, this API didn't exist.

Joey79100 commented 4 years ago

I get that, but that means before the API the extension natively executed commands? The other posted asked if it was possible to call a palette command and you said it was possible as long as we knew the actual command. Is it not possible anymore?

tjohnsonhvac commented 4 years ago

@seunlanlege I think I might me willing to tackle this. I am good with js, have not done much with ts. I did go through the vscode extension tutorial for a js extension. Pretty straight forward. I read the command api page. I see the example:

let uri = Uri.file('/some/path/to/folder');
let success = await commands.executeCommand('vscode.openFolder', uri);

Thinking out loud here, the process would be:

Can you think of anything I'm missing?

seunlanlege commented 4 years ago

Can you think of anything I'm missing?

Nope, looks good to me 👌🏾

mbenkmann commented 3 years ago

Maybe merge this extension

https://marketplace.visualstudio.com/items?itemName=geddski.macros

into Action Buttons. It seems to complement Action Buttons nicely because it has exactly the features missing:

Nabav commented 1 year ago

I have the save action button with:

  "actionButtons": {
    "defaultColor": "none",
    "commands": [
      {
        "name": "$(save)",
        "useVsCodeApi": true,
        "command": "workbench.action.files.save"
      },
    ]
  },

@momiccioli, does it solve your problem?

momiccioli commented 1 year ago

Yes ! that works perfectly!

From: Mohammad Nabavi @.> Reply-To: seunlanlege/vscode-action-buttons @.> Date: Wednesday, June 21, 2023 at 11:15 AM To: seunlanlege/vscode-action-buttons @.> Cc: momiccioli @.>, Mention @.***> Subject: Re: [seunlanlege/vscode-action-buttons] Command Pallette Button (#37)

I have the save action button with:

  "actionButtons": {     "defaultColor": "none",     "commands": [       {         "name": "$(save)",         "useVsCodeApi": true,         "command": "workbench.action.files.save"       },     ]   }, @momiccioli, does it solve your problem?

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.Message ID: @.***>

momiccioli commented 1 year ago

Seun,

I use your buttons to run many scripts.  For a few I of my scripts would like to run the save command automatically prior to the script running. is there a way to trigger this save when I run a script from another ActionButton?

I know about running items when I save a file but my needs are not that straight forward unfortunately.

Thought I would ask.

From: Michael Omiccioli @.> Date: Wednesday, June 21, 2023 at 11:43 AM To: seunlanlege/vscode-action-buttons @.>, seunlanlege/vscode-action-buttons @.> Cc: Mention @.> Subject: Re: [seunlanlege/vscode-action-buttons] Command Pallette Button (#37)

Yes ! that works perfectly!

From: Mohammad Nabavi @.> Reply-To: seunlanlege/vscode-action-buttons @.> Date: Wednesday, June 21, 2023 at 11:15 AM To: seunlanlege/vscode-action-buttons @.> Cc: momiccioli @.>, Mention @.***> Subject: Re: [seunlanlege/vscode-action-buttons] Command Pallette Button (#37)

I have the save action button with:

"actionButtons": { "defaultColor": "none", "commands": [ { "name": "$(save)", "useVsCodeApi": true, "command": "workbench.action.files.save" }, ] }, @momiccioli, does it solve your problem?

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.Message ID: @.***>