mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-25 08:41:05 +00:00
format
This commit is contained in:
parent
5e804a0b21
commit
1e3835a2fb
9 changed files with 20 additions and 233 deletions
|
|
@ -1,32 +1,32 @@
|
|||
[package]
|
||||
name = "app"
|
||||
name = "app"
|
||||
version = "0.1.5"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
adaptor = { path = "../adaptor" }
|
||||
config = { path = "../config" }
|
||||
core = { path = "../core" }
|
||||
plugin = { path = "../plugin" }
|
||||
shared = { path = "../shared" }
|
||||
config = { path = "../config" }
|
||||
core = { path = "../core" }
|
||||
plugin = { path = "../plugin" }
|
||||
shared = { path = "../shared" }
|
||||
|
||||
# External dependencies
|
||||
ansi-to-tui = "^3"
|
||||
anyhow = "^1"
|
||||
crossterm = { version = "^0", features = ["event-stream"] }
|
||||
futures = "^0"
|
||||
ratatui = "^0"
|
||||
tokio = { version = "^1", features = ["parking_lot"] }
|
||||
ansi-to-tui = "^3"
|
||||
anyhow = "^1"
|
||||
crossterm = { version = "^0", features = [ "event-stream" ] }
|
||||
futures = "^0"
|
||||
ratatui = "^0"
|
||||
tokio = { version = "^1", features = [ "parking_lot" ] }
|
||||
unicode-width = "^0"
|
||||
|
||||
# Logging
|
||||
tracing = "^0"
|
||||
tracing-appender = "^0"
|
||||
tracing = "^0"
|
||||
tracing-appender = "^0"
|
||||
tracing-subscriber = "^0"
|
||||
|
||||
[target."cfg(unix)".dependencies]
|
||||
libc = "^0"
|
||||
signal-hook-tokio = { version = "^0", features = ["futures-v0_3"] }
|
||||
libc = "^0"
|
||||
signal-hook-tokio = { version = "^0", features = [ "futures-v0_3" ] }
|
||||
|
||||
[[bin]]
|
||||
name = "yazi"
|
||||
|
|
|
|||
|
|
@ -1,39 +0,0 @@
|
|||
#compdef yazi
|
||||
|
||||
autoload -U is-at-least
|
||||
|
||||
_yazi() {
|
||||
typeset -A opt_args
|
||||
typeset -a _arguments_options
|
||||
local ret=1
|
||||
|
||||
if is-at-least 5.2; then
|
||||
_arguments_options=(-s -S -C)
|
||||
else
|
||||
_arguments_options=(-s -C)
|
||||
fi
|
||||
|
||||
local context curcontext="$curcontext" state line
|
||||
_arguments "${_arguments_options[@]}" \
|
||||
'--cwd-file=[Write the cwd on exit to this file]:CWD_FILE:_files' \
|
||||
'--chooser-file=[Write the selected files on open emitted by the chooser mode]:CHOOSER_FILE:_files' \
|
||||
'--clear-cache[Clear the cache directory]' \
|
||||
'-h[Print help]' \
|
||||
'--help[Print help]' \
|
||||
'-V[Print version]' \
|
||||
'--version[Print version]' \
|
||||
'::cwd -- Set the current working directory:_files' \
|
||||
&& ret=0
|
||||
}
|
||||
|
||||
(( $+functions[_yazi_commands] )) ||
|
||||
_yazi_commands() {
|
||||
local commands; commands=()
|
||||
_describe -t commands 'yazi commands' commands "$@"
|
||||
}
|
||||
|
||||
if [ "$funcstack[1]" = "_yazi" ]; then
|
||||
_yazi "$@"
|
||||
else
|
||||
compdef _yazi yazi
|
||||
fi
|
||||
|
|
@ -1,37 +0,0 @@
|
|||
|
||||
using namespace System.Management.Automation
|
||||
using namespace System.Management.Automation.Language
|
||||
|
||||
Register-ArgumentCompleter -Native -CommandName 'yazi' -ScriptBlock {
|
||||
param($wordToComplete, $commandAst, $cursorPosition)
|
||||
|
||||
$commandElements = $commandAst.CommandElements
|
||||
$command = @(
|
||||
'yazi'
|
||||
for ($i = 1; $i -lt $commandElements.Count; $i++) {
|
||||
$element = $commandElements[$i]
|
||||
if ($element -isnot [StringConstantExpressionAst] -or
|
||||
$element.StringConstantType -ne [StringConstantType]::BareWord -or
|
||||
$element.Value.StartsWith('-') -or
|
||||
$element.Value -eq $wordToComplete) {
|
||||
break
|
||||
}
|
||||
$element.Value
|
||||
}) -join ';'
|
||||
|
||||
$completions = @(switch ($command) {
|
||||
'yazi' {
|
||||
[CompletionResult]::new('--cwd-file', 'cwd-file', [CompletionResultType]::ParameterName, 'Write the cwd on exit to this file')
|
||||
[CompletionResult]::new('--chooser-file', 'chooser-file', [CompletionResultType]::ParameterName, 'Write the selected files on open emitted by the chooser mode')
|
||||
[CompletionResult]::new('--clear-cache', 'clear-cache', [CompletionResultType]::ParameterName, 'Clear the cache directory')
|
||||
[CompletionResult]::new('-h', 'h', [CompletionResultType]::ParameterName, 'Print help')
|
||||
[CompletionResult]::new('--help', 'help', [CompletionResultType]::ParameterName, 'Print help')
|
||||
[CompletionResult]::new('-V', 'V ', [CompletionResultType]::ParameterName, 'Print version')
|
||||
[CompletionResult]::new('--version', 'version', [CompletionResultType]::ParameterName, 'Print version')
|
||||
break
|
||||
}
|
||||
})
|
||||
|
||||
$completions.Where{ $_.CompletionText -like "$wordToComplete*" } |
|
||||
Sort-Object -Property ListItemText
|
||||
}
|
||||
|
|
@ -1,46 +0,0 @@
|
|||
_yazi() {
|
||||
local i cur prev opts cmd
|
||||
COMPREPLY=()
|
||||
cur="${COMP_WORDS[COMP_CWORD]}"
|
||||
prev="${COMP_WORDS[COMP_CWORD-1]}"
|
||||
cmd=""
|
||||
opts=""
|
||||
|
||||
for i in ${COMP_WORDS[@]}
|
||||
do
|
||||
case "${cmd},${i}" in
|
||||
",$1")
|
||||
cmd="yazi"
|
||||
;;
|
||||
*)
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
case "${cmd}" in
|
||||
yazi)
|
||||
opts="-h -V --cwd-file --chooser-file --clear-cache --help --version [CWD]"
|
||||
if [[ ${cur} == -* || ${COMP_CWORD} -eq 1 ]] ; then
|
||||
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
|
||||
return 0
|
||||
fi
|
||||
case "${prev}" in
|
||||
--cwd-file)
|
||||
COMPREPLY=($(compgen -f "${cur}"))
|
||||
return 0
|
||||
;;
|
||||
--chooser-file)
|
||||
COMPREPLY=($(compgen -f "${cur}"))
|
||||
return 0
|
||||
;;
|
||||
*)
|
||||
COMPREPLY=()
|
||||
;;
|
||||
esac
|
||||
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
|
||||
return 0
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
complete -F _yazi -o nosort -o bashdefault -o default yazi
|
||||
|
|
@ -1,31 +0,0 @@
|
|||
|
||||
use builtin;
|
||||
use str;
|
||||
|
||||
set edit:completion:arg-completer[yazi] = {|@words|
|
||||
fn spaces {|n|
|
||||
builtin:repeat $n ' ' | str:join ''
|
||||
}
|
||||
fn cand {|text desc|
|
||||
edit:complex-candidate $text &display=$text' '(spaces (- 14 (wcswidth $text)))$desc
|
||||
}
|
||||
var command = 'yazi'
|
||||
for word $words[1..-1] {
|
||||
if (str:has-prefix $word '-') {
|
||||
break
|
||||
}
|
||||
set command = $command';'$word
|
||||
}
|
||||
var completions = [
|
||||
&'yazi'= {
|
||||
cand --cwd-file 'Write the cwd on exit to this file'
|
||||
cand --chooser-file 'Write the selected files on open emitted by the chooser mode'
|
||||
cand --clear-cache 'Clear the cache directory'
|
||||
cand -h 'Print help'
|
||||
cand --help 'Print help'
|
||||
cand -V 'Print version'
|
||||
cand --version 'Print version'
|
||||
}
|
||||
]
|
||||
$completions[$command]
|
||||
}
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
complete -c yazi -l cwd-file -d 'Write the cwd on exit to this file' -r -F
|
||||
complete -c yazi -l chooser-file -d 'Write the selected files on open emitted by the chooser mode' -r -F
|
||||
complete -c yazi -l clear-cache -d 'Clear the cache directory'
|
||||
complete -c yazi -s h -l help -d 'Print help'
|
||||
complete -c yazi -s V -l version -d 'Print version'
|
||||
|
|
@ -1,14 +0,0 @@
|
|||
module completions {
|
||||
|
||||
export extern yazi [
|
||||
cwd?: string # Set the current working directory
|
||||
--cwd-file: string # Write the cwd on exit to this file
|
||||
--chooser-file: string # Write the selected files on open emitted by the chooser mode
|
||||
--clear-cache # Clear the cache directory
|
||||
--help(-h) # Print help
|
||||
--version(-V) # Print version
|
||||
]
|
||||
|
||||
}
|
||||
|
||||
export use completions *
|
||||
|
|
@ -1,45 +0,0 @@
|
|||
const completion: Fig.Spec = {
|
||||
name: "yazi",
|
||||
description: "",
|
||||
options: [
|
||||
{
|
||||
name: "--cwd-file",
|
||||
description: "Write the cwd on exit to this file",
|
||||
isRepeatable: true,
|
||||
args: {
|
||||
name: "cwd_file",
|
||||
isOptional: true,
|
||||
template: "filepaths",
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "--chooser-file",
|
||||
description: "Write the selected files on open emitted by the chooser mode",
|
||||
isRepeatable: true,
|
||||
args: {
|
||||
name: "chooser_file",
|
||||
isOptional: true,
|
||||
template: "filepaths",
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "--clear-cache",
|
||||
description: "Clear the cache directory",
|
||||
},
|
||||
{
|
||||
name: ["-h", "--help"],
|
||||
description: "Print help",
|
||||
},
|
||||
{
|
||||
name: ["-V", "--version"],
|
||||
description: "Print version",
|
||||
},
|
||||
],
|
||||
args: {
|
||||
name: "cwd",
|
||||
isOptional: true,
|
||||
template: "filepaths",
|
||||
},
|
||||
};
|
||||
|
||||
export default completion;
|
||||
|
|
@ -18,7 +18,11 @@ pub enum MimeKind {
|
|||
|
||||
impl MimeKind {
|
||||
pub fn new(s: &str) -> Self {
|
||||
if s.starts_with("text/") || s.ends_with("/xml") || s.ends_with("/javascript") || s.ends_with("/x-wine-extension-ini") {
|
||||
if s.starts_with("text/")
|
||||
|| s.ends_with("/xml")
|
||||
|| s.ends_with("/javascript")
|
||||
|| s.ends_with("/x-wine-extension-ini")
|
||||
{
|
||||
Self::Text
|
||||
} else if s.starts_with("image/") {
|
||||
Self::Image
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue