From 13f132129e140366281361e56fb882c2c6023560 Mon Sep 17 00:00:00 2001 From: Chris Antos Date: Fri, 8 Mar 2024 02:54:16 -0800 Subject: [PATCH] Add completions for rg and fd. These completions were auto-generated from the official rg.fish and fd.fish completion files. --- completions/fd.lua | 199 ++++++++++++++++++++++++++ completions/rg.lua | 341 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 540 insertions(+) create mode 100644 completions/fd.lua create mode 100644 completions/rg.lua diff --git a/completions/fd.lua b/completions/fd.lua new file mode 100644 index 0000000..110c5fc --- /dev/null +++ b/completions/fd.lua @@ -0,0 +1,199 @@ +------------------------------------------------------------------------------ +-- FD + +local function try_require(module) + local r + pcall(function() r = require(module) end) + return r +end + +try_require("arghelper") + +local fd_exclude = clink.argmatcher():addarg({}) +local fd_size = clink.argmatcher():addarg({}) +local fd_mindepth = clink.argmatcher():addarg({}) +local fd_extension = clink.argmatcher():addarg({}) +local fd_maxdepth = clink.argmatcher():addarg({}) +local fd_ignorefile = clink.argmatcher():addarg({}) +local fd_exec = clink.argmatcher():addarg({}) +local fd_color = clink.argmatcher():addarg({"auto", "always", "never"}):adddescriptions({ + ["auto"] = "show colors if the output goes to an interactive console (default)", + ["always"] = "always use colorized output", + ["never"] = "do not use colorized output", +}) +local fd_changedbefore = clink.argmatcher():addarg({}) +local fd_gencompletions = clink.argmatcher():addarg({"bash", "elvish", "fish", "powershell", "zsh"}) +local fd_execbatch = clink.argmatcher():addarg({}) +local fd_searchpath = clink.argmatcher():addarg({}) +local fd_maxresults = clink.argmatcher():addarg({}) +local fd_threads = clink.argmatcher():addarg({}) +local fd_exactdepth = clink.argmatcher():addarg({}) +local fd_and = clink.argmatcher():addarg({}) +local fd_pathseparator = clink.argmatcher():addarg({}) +local fd_basedirectory = clink.argmatcher():addarg({}) +local fd_maxbuffertime = clink.argmatcher():addarg({}) +local fd_changedwithin = clink.argmatcher():addarg({}) +local fd_batchsize = clink.argmatcher():addarg({}) +local fd_type = clink.argmatcher():addarg({"file", "directory", "symlink", "block-device", "char-device", "executable", "empty", "socket", "pipe"}):adddescriptions({ + ["executable"] = "A file which is executable by the current effective user", +}) + +clink.argmatcher("fd") +:adddescriptions({ + ["--changed-within"] = { " arg", "Filter by file modification time (newer than)" }, + ["--no-global-ignore-file"] = { "Do not respect the global ignore file" }, + ["--show-errors"] = { "Show filesystem errors" }, + ["--fixed-strings"] = { "Treat pattern as literal string stead of regex" }, + ["--no-ignore"] = { "Do not respect .(git|fd)ignore files" }, + ["--list-details"] = { "Use a long listing format with file metadata" }, + ["--gen-completions"] = { " arg", "" }, + ["-l"] = { "Use a long listing format with file metadata" }, + ["--unrestricted"] = { "Unrestricted search, alias for '--no-ignore --hidden'" }, + ["--max-results"] = { " arg", "Limit the number of search results" }, + ["-t"] = { " arg", "Filter by type: file (f), directory (d), symlink (l), executable (x), empty (e), socket (s), pipe (p), char-device (c), block-device (b)" }, + ["-h"] = { "Print help (see more with '--help')" }, + ["--case-sensitive"] = { "Case-sensitive search (default: smart case)" }, + ["-d"] = { " arg", "Set maximum search depth (default: none)" }, + ["--extension"] = { " arg", "Filter by file extension" }, + ["--ignore-vcs"] = { "Overrides --no-ignore-vcs" }, + ["-I"] = { "Do not respect .(git|fd)ignore files" }, + ["--base-directory"] = { " arg", "Change current working directory" }, + ["--absolute-path"] = { "Show absolute instead of relative paths" }, + ["--exec"] = { " arg", "Execute a command for each search result" }, + ["--max-depth"] = { " arg", "Set maximum search depth (default: none)" }, + ["-0"] = { "Separate search results by the null character" }, + ["--threads"] = { " arg", "Set number of threads to use for searching & executing (default: number of available CPU cores)" }, + ["--max-buffer-time"] = { " arg", "Milliseconds to buffer before streaming search results to console" }, + ["-a"] = { "Show absolute instead of relative paths" }, + ["--color"] = { " arg", "When to use colors" }, + ["--and"] = { " arg", "Additional search patterns that need to be matched" }, + ["-e"] = { " arg", "Filter by file extension" }, + ["-s"] = { "Case-sensitive search (default: smart case)" }, + ["--ignore-file"] = { " arg", "Add a custom ignore-file in '.gitignore' format" }, + ["--search-path"] = { " arg", "Provides paths to search as an alternative to the positional argument" }, + ["--relative-path"] = { "Overrides --absolute-path" }, + ["--ignore-case"] = { "Case-insensitive search (default: smart case)" }, + ["-V"] = { "Print version" }, + ["--quiet"] = { "Print nothing, exit code 0 if match found, 1 otherwise" }, + ["-j"] = { " arg", "Set number of threads to use for searching & executing (default: number of available CPU cores)" }, + ["-S"] = { " arg", "Limit results based on the size of files" }, + ["--version"] = { "Print version" }, + ["--help"] = { "Print help (see more with '--help')" }, + ["--exact-depth"] = { " arg", "Only show search results at the exact given depth" }, + ["--regex"] = { "Regular-expression based search (default)" }, + ["--strip-cwd-prefix"] = { "By default, relative paths are prefixed with './' when -x/--exec, -X/--exec-batch, or -0/--print0 are given, to reduce the risk of a path starting with '-' being treated as a command line option. Use this flag to disable this behaviour" }, + ["--no-require-git"] = { "Do not require a git repository to respect gitignores. By default, fd will only respect global gitignore rules, .gitignore rules, and local exclude rules if fd detects that you are searching inside a git repository. This flag allows you to relax this restriction such that fd will respect all git related ignore rules regardless of whether you're searching in a git repository or not" }, + ["--path-separator"] = { " arg", "Set path separator when printing file paths" }, + ["--size"] = { " arg", "Limit results based on the size of files" }, + ["-1"] = { "Limit search to a single result" }, + ["--exclude"] = { " arg", "Exclude entries that match the given glob pattern" }, + ["--prune"] = { "Do not traverse into directories that match the search criteria. If you want to exclude specific directories, use the '--exclude=…' option" }, + ["-X"] = { " arg", "Execute a command with all search results at once" }, + ["--no-ignore-vcs"] = { "Do not respect .gitignore files" }, + ["--one-file-system"] = { "By default, fd will traverse the file system tree as far as other options dictate. With this flag, fd ensures that it does not descend into a different file system than the one it started in. Comparable to the -mount or -xdev filters of find(1)" }, + ["-p"] = { "Search full abs. path (default: filename only)" }, + ["--ignore"] = { "Overrides --no-ignore" }, + ["--follow"] = { "Follow symbolic links" }, + ["-g"] = { "Glob-based search (default: regular expression)" }, + ["--hidden"] = { "Search hidden files and directories" }, + ["--no-follow"] = { "Overrides --follow" }, + ["--min-depth"] = { " arg", "Only show search results starting at the given depth." }, + ["-x"] = { " arg", "Execute a command for each search result" }, + ["--exec-batch"] = { " arg", "Execute a command with all search results at once" }, + ["--print0"] = { "Separate search results by the null character" }, + ["-F"] = { "Treat pattern as literal string stead of regex" }, + ["-E"] = { " arg", "Exclude entries that match the given glob pattern" }, + ["--full-path"] = { "Search full abs. path (default: filename only)" }, + ["--changed-before"] = { " arg", "Filter by file modification time (older than)" }, + ["--glob"] = { "Glob-based search (default: regular expression)" }, + ["--type"] = { " arg", "Filter by type: file (f), directory (d), symlink (l), executable (x), empty (e), socket (s), pipe (p), char-device (c), block-device (b)" }, + ["-i"] = { "Case-insensitive search (default: smart case)" }, + ["-u"] = { "Unrestricted search, alias for '--no-ignore --hidden'" }, + ["-L"] = { "Follow symbolic links" }, + ["--batch-size"] = { " arg", "Max number of arguments to run as a batch size with -X" }, + ["-c"] = { " arg", "When to use colors" }, + ["--require-git"] = { "Overrides --no-require-git" }, + ["-q"] = { "Print nothing, exit code 0 if match found, 1 otherwise" }, + ["--no-hidden"] = { "Overrides --hidden" }, + ["--no-ignore-parent"] = { "Do not respect .(git|fd)ignore files in parent directories" }, + ["-H"] = { "Search hidden files and directories" }, +}) +:addflags({ + "--and"..fd_and, + "-d"..fd_maxdepth, + "--max-depth"..fd_maxdepth, + "--min-depth"..fd_mindepth, + "--exact-depth"..fd_exactdepth, + "-E"..fd_exclude, + "--exclude"..fd_exclude, + "-t"..fd_type, + "--type"..fd_type, + "-e"..fd_extension, + "--extension"..fd_extension, + "-S"..fd_size, + "--size"..fd_size, + "--changed-within"..fd_changedwithin, + "--changed-before"..fd_changedbefore, + "-x"..fd_exec, + "--exec"..fd_exec, + "-X"..fd_execbatch, + "--exec-batch"..fd_execbatch, + "--batch-size"..fd_batchsize, + "--ignore-file"..fd_ignorefile, + "-c"..fd_color, + "--color"..fd_color, + "-j"..fd_threads, + "--threads"..fd_threads, + "--max-buffer-time"..fd_maxbuffertime, + "--max-results"..fd_maxresults, + "--base-directory"..fd_basedirectory, + "--path-separator"..fd_pathseparator, + "--search-path"..fd_searchpath, + "--gen-completions"..fd_gencompletions, + "-H", + "--hidden", + "--no-hidden", + "-I", + "--no-ignore", + "--ignore", + "--no-ignore-vcs", + "--ignore-vcs", + "--no-require-git", + "--require-git", + "--no-ignore-parent", + "--no-global-ignore-file", + "-u", + "--unrestricted", + "-s", + "--case-sensitive", + "-i", + "--ignore-case", + "-g", + "--glob", + "--regex", + "-F", + "--fixed-strings", + "-a", + "--absolute-path", + "--relative-path", + "-l", + "--list-details", + "-L", + "--follow", + "--no-follow", + "-p", + "--full-path", + "-0", + "--print0", + "--prune", + "-1", + "-q", + "--quiet", + "--show-errors", + "--strip-cwd-prefix", + "--one-file-system", + "-h", + "--help", + "-V", + "--version", +}) diff --git a/completions/rg.lua b/completions/rg.lua new file mode 100644 index 0000000..8673121 --- /dev/null +++ b/completions/rg.lua @@ -0,0 +1,341 @@ +------------------------------------------------------------------------------ +-- RG + +local function try_require(module) + local r + pcall(function() r = require(module) end) + return r +end + +try_require("arghelper") + +local rg_sortr = clink.argmatcher():addarg({"path", "modified", "accessed", "created", "none"}) +local rg_sort = clink.argmatcher():addarg({"path", "modified", "accessed", "created", "none"}) +local rg_engine = clink.argmatcher():addarg({"default", "pcre2", "auto"}) +local rg_color = clink.argmatcher():addarg({"never", "auto", "always", "ansi"}) + +clink.argmatcher("rg") +:adddescriptions({ + ["-u"] = { "Reduce the level of "smart" searching." }, + ["-g"] = { "Include or exclude files." }, + ["--before-context"] = { "Show NUM lines before each match." }, + ["-m"] = { "Limit the number of matches." }, + ["--crlf"] = { "Support CRLF line terminators (useful on Windows)." }, + ["--max-columns-preview"] = { "Print a preview for lines exceeding the limit." }, + ["--max-columns"] = { "Don't print lines longer than this limit." }, + ["--auto-hybrid-regex"] = { "Dynamically use PCRE2 if necessary." }, + ["--no-unicode"] = { "Disable Unicode mode." }, + ["-0"] = { "Print a NUL byte after file paths." }, + ["-x"] = { "Only show matches surrounded by line boundaries." }, + ["-h"] = { "Prints help information. Use --help for more details." }, + ["-p"] = { "Alias for --color always --heading --line-number." }, + ["--pre"] = { "search outputs of COMMAND FILE for each FILE" }, + ["--colors"] = { "Configure color settings and styles." }, + ["--dfa-size-limit"] = { "The upper size limit of the regex DFA." }, + ["--max-filesize"] = { "Ignore files larger than NUM in size." }, + ["--case-sensitive"] = { "Search case sensitively (default)." }, + ["--pcre2-version"] = { "Print the version of PCRE2 that ripgrep uses." }, + ["--no-ignore-parent"] = { "Don't respect ignore files in parent directories." }, + ["--pre-glob"] = { "Include or exclude files from a preprocessing command." }, + ["-w"] = { "Only show matches surrounded by word boundaries." }, + ["-e"] = { "A pattern to search for." }, + ["--no-require-git"] = { "Do not require a git repository to use gitignores." }, + ["--follow"] = { "Follow symbolic links." }, + ["--files"] = { "Print each file that would be searched." }, + ["--only-matching"] = { "Print only matched parts of a line." }, + ["--line-buffered"] = { "Force line buffering." }, + ["--unrestricted"] = { "Reduce the level of "smart" searching." }, + ["-M"] = { "Don't print lines longer than this limit." }, + ["--invert-match"] = { "Invert matching." }, + ["--stats"] = { "Print statistics about this ripgrep search." }, + ["-U"] = { "Enable matching across multiple lines." }, + ["--count"] = { "Only show the count of matching lines for each file." }, + ["-E"] = { "Specify the text encoding of files to search." }, + ["--replace"] = { "Replace matches with the given text." }, + ["--threads"] = { "The approximate number of threads to use." }, + ["--regex-size-limit"] = { "The upper size limit of the compiled regex." }, + ["-f"] = { "Search for patterns from the given file." }, + ["-r"] = { "Replace matches with the given text." }, + ["-j"] = { "The approximate number of threads to use." }, + ["--engine"] = { " arg", "Specify which regexp engine to use." }, + ["--file"] = { "Search for patterns from the given file." }, + ["--type"] = { "Only search files matching TYPE." }, + ["--type-clear"] = { "Clear globs for a file type." }, + ["-V"] = { "Prints version information" }, + ["--no-pcre2-unicode"] = { "Disable Unicode mode for PCRE2 matching." }, + ["-z"] = { "Search in compressed files." }, + ["--block-buffered"] = { "Force block buffering." }, + ["--glob-case-insensitive"] = { "Process all glob patterns case insensitively." }, + ["--one-file-system"] = { "Do not descend into directories on other file systems." }, + ["-c"] = { "Only show the count of matching lines for each file." }, + ["--regexp"] = { "A pattern to search for." }, + ["-q"] = { "Do not print anything to stdout." }, + ["-i"] = { "Case insensitive search." }, + ["--version"] = { "Prints version information" }, + ["--type-not"] = { "Do not search files matching TYPE." }, + ["--debug"] = { "Show debug messages." }, + ["--glob"] = { "Include or exclude files." }, + ["--count-matches"] = { "Only show the count of individual matches for each file." }, + ["--no-config"] = { "Never read configuration files." }, + ["--smart-case"] = { "Smart case search." }, + ["--type-list"] = { "Show all supported file types." }, + ["--multiline-dotall"] = { "Make '.' match new lines when multiline is enabled." }, + ["-C"] = { "Show NUM lines before and after each match." }, + ["--line-number"] = { "Show line numbers." }, + ["--search-zip"] = { "Search in compressed files." }, + ["--json"] = { "Show search results in a JSON Lines format." }, + ["-S"] = { "Smart case search." }, + ["--context"] = { "Show NUM lines before and after each match." }, + ["-t"] = { "Only search files matching TYPE." }, + ["--no-filename"] = { "Never print the file path with the matched lines." }, + ["-l"] = { "Print the paths with at least one match." }, + ["--max-depth"] = { "Descend at most NUM directories." }, + ["--heading"] = { "Print matches grouped by each file." }, + ["--context-separator"] = { "Set the context separator string." }, + ["-L"] = { "Follow symbolic links." }, + ["--encoding"] = { "Specify the text encoding of files to search." }, + ["--pretty"] = { "Alias for --color always --heading --line-number." }, + ["--sortr"] = { " arg", "Sort results in descending order. Implies --threads=1." }, + ["-T"] = { "Do not search files matching TYPE." }, + ["-F"] = { "Treat the pattern as a literal string." }, + ["--null"] = { "Print a NUL byte after file paths." }, + ["--column"] = { "Show column numbers." }, + ["--fixed-strings"] = { "Treat the pattern as a literal string." }, + ["--iglob"] = { "Include or exclude files case insensitively." }, + ["-s"] = { "Search case sensitively (default)." }, + ["--line-regexp"] = { "Only show matches surrounded by line boundaries." }, + ["--no-heading"] = { "Don't group matches by each file." }, + ["--sort-files"] = { "DEPRECATED" }, + ["--mmap"] = { "Search using memory maps when possible." }, + ["--include-zero"] = { "Include files with zero matches in summary" }, + ["--help"] = { "Prints help information. Use --help for more details." }, + ["--word-regexp"] = { "Only show matches surrounded by word boundaries." }, + ["-I"] = { "Never print the file path with the matched lines." }, + ["--with-filename"] = { "Print the file path with the matched lines." }, + ["--no-ignore"] = { "Don't respect ignore files." }, + ["-H"] = { "Print the file path with the matched lines." }, + ["--vimgrep"] = { "Show results in vim compatible format." }, + ["--trim"] = { "Trim prefixed whitespace from matches." }, + ["--files-with-matches"] = { "Print the paths with at least one match." }, + ["-a"] = { "Search binary files as if they were text." }, + ["--multiline"] = { "Enable matching across multiple lines." }, + ["--field-context-separator"] = { "Set the field context separator." }, + ["-A"] = { "Show NUM lines after each match." }, + ["--max-count"] = { "Limit the number of matches." }, + ["--color"] = { " arg", "Controls when to use color." }, + ["--no-ignore-exclude"] = { "Don't respect local exclusion files." }, + ["--quiet"] = { "Do not print anything to stdout." }, + ["--binary"] = { "Search binary files." }, + ["-v"] = { "Invert matching." }, + ["-b"] = { "Print the 0-based byte offset for each matching line." }, + ["--passthru"] = { "Print both matching and non-matching lines." }, + ["--pcre2"] = { "Enable PCRE2 matching." }, + ["-P"] = { "Enable PCRE2 matching." }, + ["--no-messages"] = { "Suppress some error messages." }, + ["-o"] = { "Print only matched parts of a line." }, + ["--ignore-file"] = { "Specify additional ignore files." }, + ["--null-data"] = { "Use NUL as a line terminator instead of \n." }, + ["--no-ignore-vcs"] = { "Don't respect VCS ignore files." }, + ["-n"] = { "Show line numbers." }, + ["-B"] = { "Show NUM lines before each match." }, + ["--no-ignore-messages"] = { "Suppress gitignore parse error messages." }, + ["--no-ignore-global"] = { "Don't respect global ignore files." }, + ["--no-ignore-files"] = { "Don't respect --ignore-file arguments." }, + ["--path-separator"] = { "Set the path separator." }, + ["--sort"] = { " arg", "Sort results in ascending order. Implies --threads=1." }, + ["--text"] = { "Search binary files as if they were text." }, + ["--ignore-case"] = { "Case insensitive search." }, + ["--no-ignore-dot"] = { "Don't respect .ignore files." }, + ["--field-match-separator"] = { "Set the match separator." }, + ["--no-line-number"] = { "Suppress line numbers." }, + ["--after-context"] = { "Show NUM lines after each match." }, + ["--no-mmap"] = { "Never use memory maps." }, + ["-N"] = { "Suppress line numbers." }, + ["--hidden"] = { "Search hidden files and directories." }, + ["--ignore-file-case-insensitive"] = { "Process ignore files case insensitively." }, + ["--files-without-match"] = { "Print the paths that contain zero matches." }, + ["--type-add"] = { "Add a new glob for a file type." }, + ["-."] = { "Search hidden files and directories." }, + ["--byte-offset"] = { "Print the 0-based byte offset for each matching line." }, +}) +:addflags({ + "-A", + "--after-context", + "-B", + "--before-context", + "--color"..rg_color, + "--colors", + "-C", + "--context", + "--context-separator", + "--dfa-size-limit", + "-E", + "--encoding", + "--engine"..rg_engine, + "--field-context-separator", + "--field-match-separator", + "-f", + "--file", + "-g", + "--glob", + "--iglob", + "--ignore-file", + "-M", + "--max-columns", + "-m", + "--max-count", + "--max-depth", + "--max-filesize", + "--path-separator", + "--pre", + "--pre-glob", + "--regex-size-limit", + "-e", + "--regexp", + "-r", + "--replace", + "--sort"..rg_sort, + "--sortr"..rg_sortr, + "-j", + "--threads", + "-t", + "--type", + "--type-add", + "--type-clear", + "-T", + "--type-not", + "--auto-hybrid-regex", + "--no-auto-hybrid-regex", + "--binary", + "--no-binary", + "--block-buffered", + "--no-block-buffered", + "-b", + "--byte-offset", + "-s", + "--case-sensitive", + "--column", + "--no-column", + "--no-context-separator", + "-c", + "--count", + "--count-matches", + "--crlf", + "--no-crlf", + "--debug", + "--trace", + "--no-encoding", + "--files", + "-l", + "--files-with-matches", + "--files-without-match", + "-F", + "--fixed-strings", + "--no-fixed-strings", + "-L", + "--follow", + "--no-follow", + "--glob-case-insensitive", + "--no-glob-case-insensitive", + "--heading", + "--no-heading", + "-.", + "--hidden", + "--no-hidden", + "-i", + "--ignore-case", + "--ignore-file-case-insensitive", + "--no-ignore-file-case-insensitive", + "--include-zero", + "-v", + "--invert-match", + "--json", + "--no-json", + "--line-buffered", + "--no-line-buffered", + "-n", + "--line-number", + "-N", + "--no-line-number", + "-x", + "--line-regexp", + "--max-columns-preview", + "--no-max-columns-preview", + "--mmap", + "--no-mmap", + "-U", + "--multiline", + "--no-multiline", + "--multiline-dotall", + "--no-multiline-dotall", + "--no-config", + "--no-ignore", + "--ignore", + "--no-ignore-dot", + "--ignore-dot", + "--no-ignore-exclude", + "--ignore-exclude", + "--no-ignore-files", + "--ignore-files", + "--no-ignore-global", + "--ignore-global", + "--no-ignore-messages", + "--ignore-messages", + "--no-ignore-parent", + "--ignore-parent", + "--no-ignore-vcs", + "--ignore-vcs", + "--no-messages", + "--messages", + "--no-pcre2-unicode", + "--pcre2-unicode", + "--no-require-git", + "--require-git", + "--no-unicode", + "--unicode", + "-0", + "--null", + "--null-data", + "--one-file-system", + "--no-one-file-system", + "-o", + "--only-matching", + "--passthru", + "-P", + "--pcre2", + "--no-pcre2", + "--pcre2-version", + "--no-pre", + "-p", + "--pretty", + "-q", + "--quiet", + "-z", + "--search-zip", + "--no-search-zip", + "-S", + "--smart-case", + "--sort-files", + "--no-sort-files", + "--stats", + "--no-stats", + "-a", + "--text", + "--no-text", + "--trim", + "--no-trim", + "--type-list", + "-u", + "--unrestricted", + "--vimgrep", + "-H", + "--with-filename", + "-I", + "--no-filename", + "-w", + "--word-regexp", + "-h", + "--help", + "-V", + "--version", +})