mirror of
https://github.com/RGBCube/nu_scripts
synced 2025-08-02 07:07:46 +00:00
merge nvdc into nvc (#764)
use a unified nvc to start the neovim client, and then have a flag --gui to start the neovim gui program. And collect some common GUI startup methods, detect which one exists and start which one. --------- Co-authored-by: nash <nash@iffy.me>
This commit is contained in:
parent
da6fb3e800
commit
d177037ed2
1 changed files with 27 additions and 15 deletions
|
@ -51,17 +51,18 @@ export-env {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
def edit [action file] {
|
def edit [action ...file] {
|
||||||
if ($env.NVIM? | is-empty) {
|
if ($env.NVIM? | is-empty) {
|
||||||
nvim $file
|
nvim ...$file
|
||||||
} else {
|
} else {
|
||||||
let af = ($file | each {|f|
|
let af = $file
|
||||||
|
| each {|f|
|
||||||
if ($f|str substring ..1) in ['/', '~'] {
|
if ($f|str substring ..1) in ['/', '~'] {
|
||||||
$f
|
$f
|
||||||
} else {
|
} else {
|
||||||
$"($env.PWD)/($f)"
|
$"($env.PWD)/($f)"
|
||||||
}
|
}
|
||||||
})
|
}
|
||||||
let cmd = $"<cmd>($action) ($af|str join ' ')<cr>"
|
let cmd = $"<cmd>($action) ($af|str join ' ')<cr>"
|
||||||
nvim --headless --noplugin --server $env.NVIM --remote-send $cmd
|
nvim --headless --noplugin --server $env.NVIM --remote-send $cmd
|
||||||
}
|
}
|
||||||
|
@ -81,7 +82,7 @@ export def e [...file: string] {
|
||||||
if ($file|is-empty) {
|
if ($file|is-empty) {
|
||||||
nvim
|
nvim
|
||||||
} else {
|
} else {
|
||||||
edit vsplit $file
|
edit vsplit ...$file
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -89,7 +90,7 @@ export def c [...file: string] {
|
||||||
if ($file|is-empty) {
|
if ($file|is-empty) {
|
||||||
nvim
|
nvim
|
||||||
} else {
|
} else {
|
||||||
edit split $file
|
edit split ...$file
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -97,7 +98,7 @@ export def v [...file: string] {
|
||||||
if ($file|is-empty) {
|
if ($file|is-empty) {
|
||||||
nvim
|
nvim
|
||||||
} else {
|
} else {
|
||||||
edit vsplit $file
|
edit vsplit ...$file
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -105,7 +106,7 @@ export def x [...file: string] {
|
||||||
if ($file|is-empty) {
|
if ($file|is-empty) {
|
||||||
nvim
|
nvim
|
||||||
} else {
|
} else {
|
||||||
edit tabnew $file
|
edit tabnew ...$file
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -134,14 +135,25 @@ export def opwd [] {
|
||||||
nvim-lua 'OppositePwd()'
|
nvim-lua 'OppositePwd()'
|
||||||
}
|
}
|
||||||
|
|
||||||
export def nvim-srv [port: int=9999] {
|
export def nvs [port: int=9999] {
|
||||||
nvim --headless --listen $"0.0.0.0:($port)"
|
nvim --headless --listen $"0.0.0.0:($port)"
|
||||||
}
|
}
|
||||||
|
|
||||||
export def nvc [addr: string] {
|
export def nvc [
|
||||||
|
addr: string
|
||||||
|
--gui(-g)
|
||||||
|
] {
|
||||||
|
if $gui {
|
||||||
|
let gs = {
|
||||||
|
neovide: [--maximized --server $addr]
|
||||||
|
}
|
||||||
|
for g in ($gs | transpose prog args) {
|
||||||
|
if not (which $g.prog | is-empty) {
|
||||||
|
^$g.prog ...$g.args
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
nvim --remote-ui --server $addr
|
nvim --remote-ui --server $addr
|
||||||
}
|
}
|
||||||
|
|
||||||
export def nvdc [addr: string] {
|
|
||||||
neovide --maximized --server $addr
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue