#compdef _quick-lint-js quick-lint-js

# Copyright (C) 2020  Matthew "strager" Glazar
# See end of file for extended copyright information.

# This script is used to provide command line completion for
# quick-lint-js when using zsh shell

typeset -A opt_args

function _quick-lint-js() {
        local curcontext="$curcontext" state line
        local -i ret=1
        local -a args

        args+=(
        '(- *)'--help'[Print a help message and exit]'
        '(- *)'--version'[Print version information and exit]'
        '(--lsp-server)*:file:_files'
        '(--config-file --stdin --exit-fail-on --diagnostic-hyperlinks --output-format --path-for-config-search --language *)'--lsp-server'[Run quick-lint-js in LSP server mode]'
        '(--lsp-server)--config-file=[Read configuration from a JSON file for later input files]:file:_files'
        '(--lsp-server)--stdin[Read standard input as a JavaScript file]'
        '(--lsp-server)--exit-fail-on=[Fail with a non-zero exit code if any of these errors are found (default\: "all")]'
        '(--lsp-server)--output-format=[Format to print feedback]:format:((vim-qflist-json\:"machine-readable JSON which can be given to Vim'\''s setqflist function" gnu-like\:"a human-readable format similar to GCC" emacs-lisp\:"Emacs Lisp association list format"))'
        '(--lsp-server)--diagnostic-hyperlinks=[Control whether to hyperlink error codes or not]:when:((auto\:"shows error codes as hyperlinks only if the error output is a terminal" always\:"always shows error codes as hyperlinks" never\:"never shows error codes as hyperlinks"))'
        '(--lsp-server)--path-for-config-search=[Use path as the file\’s path when searching for a configuration file]:file:_path_files'
        '(--lsp-server)--language=[Interpret input files which are given later in the command line]:when:((default\:"infer the languageid from the file’s extension" javascript\:"the latest ECMAScript standard with proposed features" javascript-jsx\:"like javascript but with JSX (React) extensions" experimental-typescript\:"the latest TypeScript version. (EXPERIMENTAL)" experimental-typescript-jsx\:"like experimental-typescript but with JSX (React) extensions. (EXPERIMENTAL)"))'
        '--snarky[Add spice to your failures]'
        '--debug-apps[Print a list of running quick-lint-js instances which have the debug app enabled]'
        '--vim-file-bufnr=[Select a vim buffer for outputting feedback]')

        _arguments -M "r:|[_]=* r:|=*" -S "${args[@]}" && ret=0

        return ret
}

# 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/>.
