3

Im trying to run "puppet-lint -f (currently open file)

The Puppet extenstion provides puppet-lint check, but doesnt auto fix any issues, it just gives warnings. How can I add a keyboard shortcut to run "puppet-lint -f" on a file Im currently editing?

Thanks

perfecto25
  • 772
  • 9
  • 13

2 Answers2

6

I don't know anything about the Puppet extension but in general here is how you can bind a shell command to a keychord:

Make a task for it (.vscode/tasks.json):

{
    "version": "2.0.0",
    "tasks": [{
         "label": "node version",
         "command": "node",
         "args": [
             "-v"
         ],
         "type": "shell"
    }]
}

In the args you may use ${file} for the current file.

Then add this option to your keybindings.json (you can find them in Command Palette under “Preferences: Open keyboard shortcuts (JSON)”):

{
    "key": "shift+escape",
    "command": "workbench.action.tasks.runTask",
    "args": "node version"
  },
m93a
  • 8,866
  • 9
  • 40
  • 58
Mark
  • 143,421
  • 24
  • 428
  • 436
  • 1
    configured it like this, (for some reason my code markdown isnt adding line breaks here) tasks.json `{ "version": "2.0.0", "tasks": [ { "label": "puppetlint", "type": "shell", "command": "puppet-lint", "args": ["-f", "${file}"] } ] }` Keybindings.json `[ { "key":"Alt+L", "command":"workbench.action.tasks.runTask", "args": "puppetlint" } ]` working perfectly. thanks! – perfecto25 Jun 08 '18 at 13:11
1

co-author of the extension here. You can have the Puppet VSCode Extension run puppet-lint fix on the current file by using the Format Document command. You can then configure VSCode to run format on save.

James Pogran
  • 4,279
  • 2
  • 31
  • 23