Skip to content

Commit

Permalink
added completions for powershell
Browse files Browse the repository at this point in the history
  • Loading branch information
tonysathre authored and strager committed Mar 24, 2022
1 parent b6d1833 commit 88b7e65
Show file tree
Hide file tree
Showing 3 changed files with 88 additions and 0 deletions.
5 changes: 5 additions & 0 deletions completions/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ install(
DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/fish/vendor_completions.d"
)

install(
FILES quick-lint-js.ps1
DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/powershell/completions"
)

# quick-lint-js finds bugs in JavaScript programs.
# Copyright (C) 2020 Matthew "strager" Glazar
#
Expand Down
14 changes: 14 additions & 0 deletions completions/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,17 @@ To install the completions for fish, run
mkdir -p $fish_complete_path[1]
cp completions/quick-lint-js.fish $fish_complete_path[1]/quick-lint-js.fish
```

## PowerShell

To install the completions for powershell, you can `dot source` the `completions/quick-lint-js.ps1` file in your `$profile` file.

```powershell
. completions/quick-lint-js.ps1
```

Or copy the contents of `completions/quick-lint-js.ps1` into your `$profile` file.

```powershell
Get-Content ./completions/quick-lint-js.ps1 | Out-File -Append $profile
```
69 changes: 69 additions & 0 deletions completions/quick-lint-js.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# Copyright (C) 2020 Matthew "strager" Glazar
# See end of file for extended copyright information.

[scriptblock]$ScriptBlock = {
param( $WordToComplete )

$Options = @(
@{
CompletionText = '--help'
ToolTip = 'Print help message'
},
@{
CompletionText = '--version'
ToolTip = 'Print version information'
},
@{
CompletionText = '--lsp-server'
ToolTip = 'Run quick-lint-js in LSP server mode'
},
@{
CompletionText = '--config-file='
ToolTip = 'Read configuration from a JSON file for later input files'
},
@{
CompletionText = '--stdin'
ToolTip = 'Read standard input as a JavaScript file'
},
@{
CompletionText = '--exit-fail-on='
ToolTip = 'Fail with a non-zero exit code if any of these errors are found (default: all)'
},
@{
CompletionText = '--output-format='
ToolTip = "Format to print feedback format`n`nvim-qflist-json: machine-readable JSON which can be given to Vim's setqflist function`ngnu-like: a human-readable format similar to GCC`nemacs-lisp: Emacs Lisp association list format"
},
@{
CompletionText = '--diagnostic-hyperlinks='
ToolTip = "Control whether to hyperlink error codes or not`n`nauto: shows error codes as hyperlinks only if the error output is a terminal`nalways: always shows error codes as hyperlinks`nnever: never shows error codes as hyperlinks"
},
@{
CompletionText = '--vim-file-bufnr='
ToolTip = 'Select a vim buffer for outputting feedback'
}
)

$Options.Where({$_.CompletionText -like "$wordToComplete*"}) | ForEach-Object {
[System.Management.Automation.CompletionResult]::new($_.CompletionText, $_.CompletionText, 'ParameterValue', $_.ToolTip)
}
}

Register-ArgumentCompleter -CommandName quick-lint-js -Native -ScriptBlock $ScriptBlock

# quick-lint-js finds bugs in JavaScript programs.
# Copyright (C) 2020 Matthew "strager" Glazar
#
# This file is part of quick-lint-js.
#
# quick-lint-js is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# quick-lint-js is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with quick-lint-js. If not, see <https://www.gnu.org/licenses/>.

0 comments on commit 88b7e65

Please sign in to comment.