Browse Source

Kakoune plugin updates. Goodbye webshit. Misc elvish changes. Kitty marks.

master
SolitudeSF 2 years ago
parent
commit
75ab7950cf
No known key found for this signature in database
GPG Key ID: 789B06817C385387
  1. 46
      elvish/lib/completers.elv
  2. 39
      elvish/lib/util.elv
  3. 127
      kak.kak
  4. 22
      kitty/kitty.conf
  5. 7
      ntr/templates/kitty-colors
  6. 16
      splug.toml

46
elvish/lib/completers.elv

@ -30,7 +30,7 @@ fn complete-directory [a]{ @@ -30,7 +30,7 @@ fn complete-directory [a]{
} else {
dir = ''
}
for x [(put $dir*[match-hidden][nomatch-ok]$a*[match-hidden][nomatch-ok])] {
for x [$dir*[match-hidden][nomatch-ok]$a*[match-hidden][nomatch-ok]] {
if (-is-dir $x) { edit:complex-candidate &code-suffix=/ &style='blue;bold' $x }
}
}
@ -62,11 +62,11 @@ edit:completion:arg-completer[waifu2x-converter-cpp] = [@cmd]{ @@ -62,11 +62,11 @@ edit:completion:arg-completer[waifu2x-converter-cpp] = [@cmd]{
}
}
kitty-cmds = []
kitty-kittens = []
kitty-cmds = $nil
kitty-kittens = $nil
edit:completion:arg-completer[kitty] = [@cmd]{
if (== (count $kitty-cmds) 0) {
if (not $kitty-cmds) {
@kitty-cmds = (kitty @ --help | peach [x]{ if (re:match '^ \w' $x) { put $x[2:] } })
@kitty-kittens = (pwd=/usr/lib/kitty/kittens fd main.py | peach [x]{ path-dir $x })
}
@ -109,17 +109,21 @@ edit:completion:arg-completer[nimble] = [@cmd]{ @@ -109,17 +109,21 @@ edit:completion:arg-completer[nimble] = [@cmd]{
} elif (eq $cmd[-2] install) {
for x (from-json <~/.nimble/packages_official.json) { put $x[name] }
} elif (eq $cmd[-2] uninstall) {
pkgs = [&]
nimble list -i | eawk [_ n @v]{
@ver = $@v[:-1]
ver[0] = $ver[0][1:]
pkgs[$n] = $ver
}
if (has-suffix $cmd[-1] '@') {
for v $pkgs[$cmd[-1][:-1]] {
put $cmd[-1]$v
idx = (util:index-of $cmd[-1] '@')
if (== $idx -1) {
nimble list -i | eawk [_ n @_]{ put $n }
} else {
pkgs = [&]
nimble list -i | eawk [_ n @v]{
@ver = $@v[:-1]
ver[0] = $ver[0][1:]
pkgs[$n] = $ver
}
} else { keys $pkgs }
pkg = $cmd[-1][:$idx]
if (has-key $pkgs $pkg) {
for v $pkgs[$pkg] { put $pkg@$v }
}
}
}
}
@ -134,10 +138,10 @@ edit:completion:arg-completer[pijul] = [@cmd]{ @@ -134,10 +138,10 @@ edit:completion:arg-completer[pijul] = [@cmd]{
}
neofetch-img = [ascii caca iterm2 jp2a kitty pixterm sixel termpix tycat w3m off]
neofetch-opts = []
neofetch-opts = $nil
edit:completion:arg-completer[neofetch] = [@cmd]{
if (== (count $neofetch-opts) 0) {
if (not $neofetch-opts) {
neofetch-opts = [(_ = ?(neofetch --help | each [x]{
if (has-prefix $x ' --') {
put $x | eawk [_ a @_]{ put $a }
@ -180,11 +184,11 @@ edit:completion:arg-completer[xi] = [@cmd]{ @@ -180,11 +184,11 @@ edit:completion:arg-completer[xi] = [@cmd]{
pwd=$E:XBPS_DISTDIR/srcpkgs put *
}
xbps-src-cmds = []
xbps-src-arch = []
xbps-src-cmds = $nil
xbps-src-arch = $nil
edit:completion:arg-completer[xbps-src] = [@cmd]{
if (== (count $xbps-src-cmds) 0) {
if (not $xbps-src-cmds) {
@xbps-src-cmds = (xbps-src -h | take 129 | drop 4 | each [x]{ put (re:find &max=1 '^\w+(\-\w+)*' $x)[text] })
@xbps-src-arch = (xbps-src -h | take 162 | drop 136)[1:]
}
@ -209,10 +213,10 @@ edit:completion:arg-completer[strat] = [@cmd]{ @@ -209,10 +213,10 @@ edit:completion:arg-completer[strat] = [@cmd]{
}
}
brl-cmds = []
brl-cmds = $nil
edit:completion:arg-completer[brl] = [@cmd]{
if (== (count $brl-cmds) 0) {
if (not $brl-cmds) {
@brl-cmds = (brl -h | take 35 | drop 5 | each [x]{ put (re:find &max=1 '^ \w+' $x)[text][2:] })
}
len = (count $cmd)

39
elvish/lib/util.elv

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
fn abort [&code=1 a]{
echo (styled $a red)
echo (styled $a red) >&2
exit $code
}
@ -7,22 +7,18 @@ fn set-title [a]{ @@ -7,22 +7,18 @@ fn set-title [a]{
print "\e]0;"$a"\e\\"
}
fn merge-list [a b]{
for c $b { a = [$@a $c] }
put $a
}
fn merge-map [a b]{
for k $b { a[$k] = $b[$k] }
keys $b | each [k]{ a[$k] = $b[$k] }
put $a
}
fn if-not-zero [a b]{
if (not-eq $a 0) { $b }
}
fn switch [a b]{
$b[$a]
fn index-of [a b]{
r = 0
for val $a {
if (eq $val $b) { put $r; return }
r = (+ $r 1)
}
float64 -1
}
fn pad [a b &with=' ' &left=$true]{
@ -51,17 +47,8 @@ fn add-after-readline [@hooks]{ @@ -51,17 +47,8 @@ fn add-after-readline [@hooks]{
}
}
fn fold [a b]{
s = $a[0]
for i [(range 1 (count $a))] {
s = ($b $s $a[$i])
}
put $s
}
fn randselect [a]{
put $a[(randint 0 (count $a))]
}
fn is-upper-ascii [a]{ and (< (ord $a) 91) (> (ord $a) 64) }
fn is-lower-ascii [a]{ and (< (ord $a) 123) (> (ord $a) 96) }
fn to-upper-ascii [a]{ if (and (< (ord $a) 123) (> (ord $a) 96)) { chr (- (ord $a) 32) } else { put $a } }
fn to-lower-ascii [a]{ if (and (< (ord $a) 91 ) (> (ord $a) 64)) { chr (+ (ord $a) 32) } else { put $a } }
fn to-upper-ascii [a]{ if (is-lower-ascii $a) { chr (- (ord $a) 32) } else { put $a } }
fn to-lower-ascii [a]{ if (is-upper-ascii $a) { chr (+ (ord $a) 32) } else { put $a } }

127
kak.kak

@ -1,4 +1,5 @@ @@ -1,4 +1,5 @@
# Manually merge and source plugins
# External plugins
eval %sh{
kak-lsp --kakoune -s $kak_session
colorcol
@ -16,11 +17,6 @@ set global modelinefmt '%opt{modeline_git_branch} %val{bufname} @@ -16,11 +17,6 @@ set global modelinefmt '%opt{modeline_git_branch} %val{bufname}
%val{cursor_line}:%val{cursor_char_column} {{mode_info}}
{{context_info}}◂%val{client}⊙%val{session}▸'
alias global bd delete-buffer
alias global bf buffer-first
alias global bl buffer-last
alias global bo buffer-only
alias global bo! buffer-only-force
alias global sw sudo-write
alias global cdb change-directory-current-buffer
alias global f find
@ -48,6 +44,13 @@ map global normal -docstring 'yank to end of line' Y <a-l> @@ -48,6 +44,13 @@ map global normal -docstring 'yank to end of line' Y <a-l>
map global user -docstring 'replay macro' . q
map global user -docstring 'record macro' <a-.> Q
map global normal w ': word-select-next-word<ret>'
map global normal <a-w> ': word-select-next-big-word<ret>'
map global normal q ': word-select-previous-word<ret>'
map global normal <a-q> ': word-select-previous-big-word<ret>'
map global normal Q B
map global normal <a-Q> <a-B>
map global user -docstring 'add phantom selection' <a-f> ': phantom-selection-add-selection<ret>'
map global user -docstring 'clear all phantom selections' <a-F> ': phantom-selection-select-all<ret>: phantom-selection-clear<ret>'
map global user -docstring 'next phantom selection' f ': phantom-selection-iterate-next<ret>'
@ -56,16 +59,11 @@ map global user -docstring 'previous phantom selection' F ': phantom-selection-i @@ -56,16 +59,11 @@ map global user -docstring 'previous phantom selection' F ': phantom-selection-i
map global normal -docstring 'select view' <a-%> ': select-view<ret>'
map global view -docstring 'select view' s '<esc>: select-view<ret>'
map global user -docstring 'select selection on each line' <a-s> ': keep-selection-each-line<ret>'
map global user -docstring 'drop selection on each line' S ': drop-selection-each-line<ret>'
map global user -docstring 'add mark' m ': mark-word<ret>'
map global user -docstring 'clear marks' M ': mark-clear<ret>'
map global user -docstring 'replace mode' r ': replace<ret>'
map global normal <a-space> ': fzf-mode<ret>'
map global user -docstring 'expand selection' e ': expand<ret>'
map global user -docstring 'expand repeat' E ': expand-repeat<ret>'
@ -75,22 +73,6 @@ map global normal -docstring 'buffers (lock)…' B ': enter-user-mode -lock buff @@ -75,22 +73,6 @@ map global normal -docstring 'buffers (lock)…' B ': enter-user-mode -lock buff
map global user -docstring "next error" l ': lint-next-error<ret>'
map global user -docstring "previous error" L ': lint-previous-error<ret>'
word-movement-map previous q
word-movement-map next w
word-movement-map skip e
declare-user-mode surround
map global user -docstring 'surround mode' s ': enter-user-mode surround<ret>'
map global surround -docstring 'surround' s ': surround<ret>'
map global surround -docstring 'change' c ': change-surround<ret>'
map global surround -docstring 'delete' d ': delete-surround<ret>'
map global surround -docstring 'select surround' <a-s> ': select-surround<ret>'
map global surround -docstring 'surround tag' S ': surrounding-tag<ret>'
map global surround -docstring 'change tag' C ': change-surrounding-tag<ret>'
map global surround -docstring 'delete tag' D ': delete-surrounding-tag<ret>'
map global surround -docstring 'select surrounding tag' <a-S> ': select-surrounding-tag<ret>'
map global surround -docstring 'auto-pairs surround' a ': auto-pairs-surround<ret>'
declare-user-mode anchor
map global normal ';' ': enter-user-mode anchor<ret>'
map global anchor -docstring 'ensure anchor after cursor' h '<a-:><a-;>'
@ -106,20 +88,11 @@ map global clipboard -docstring 'clip-paste after' p '<a-!>xsel -b -o<ret>' @@ -106,20 +88,11 @@ map global clipboard -docstring 'clip-paste after' p '<a-!>xsel -b -o<ret>'
map global clipboard -docstring 'clip-paste before' P '!xsel -b -o<ret>'
map global clipboard -docstring 'clip-paste replace' R '|xsel -b -o<ret>'
map global clipboard -docstring 'clip-yank' y '<a-|>xclip -i -f -sel c<ret>'
map global clipboard -docstring 'clip-cut' d '<a-|>xclip -i -f -sel c<ret><a-d>'
map global clipboard -docstring 'clip-cut -> insert mode' c '<a-|>xclip -i -f -sel c<ret><a-c>'
# Functions
def toggle-highlighter -params .. -docstring 'Toggle highlighter' %{
try %{
addhl window/%arg{@} %arg{@}
echo -markup {green} %arg{@}
} catch %{
rmhl window/%arg{@}
echo -markup {red} %arg{@}
}
}
def type -params 1 -docstring 'Set buffer filetype' %{
set buffer filetype %arg{1}
}
@ -135,17 +108,13 @@ def lsp-engage -docstring 'Enable language server' %{ @@ -135,17 +108,13 @@ def lsp-engage -docstring 'Enable language server' %{
map global user -docstring 'Enter lsp user mode' <a-l> ': enter-user-mode lsp<ret>'
}
def no-tabs -params 0..1 -docstring 'Indent with spaces' %{
def no-tabs -params 1 -docstring 'Indent with spaces' %{
expandtab
eval %sh{ [ -n "$1" ] && printf %s "
set buffer indentwidth $1
set buffer tabstop $1
set buffer softtabstop $1
" }
set buffer indentwidth %arg{1}
hook buffer InsertKey <space> %{ try %{
exec -draft h<a-i><space><a-k>^\h+<ret>
exec -with-hooks <tab>
} }
}}
}
def clean-trailing-whitespace -docstring 'Remove trailing whitespace' %{
@ -154,6 +123,14 @@ def clean-trailing-whitespace -docstring 'Remove trailing whitespace' %{ @@ -154,6 +123,14 @@ def clean-trailing-whitespace -docstring 'Remove trailing whitespace' %{
# Hooks
hook global WinCreate .* %{
smarttab
readline-enable
colorcol-enable
colorcol-auto-refresh
discord-presence-enable
}
hook global KakBegin .* %{
state-save-reg-sync colon
state-save-reg-sync pipe
@ -166,31 +143,11 @@ hook global KakEnd .* %{ @@ -166,31 +143,11 @@ hook global KakEnd .* %{
state-save-reg-sync slash
}
hook global ModuleLoaded kitty %{
set global kitty_window_type kitty
}
hook global ModuleLoaded fzf %{
set global fzf_implementation sk
set global fzf_file_command fd
set global fzf_highlight_command bat
set global fzf_sk_grep_command 'rg -LHn'
}
hook global WinDisplay .* info-buffers
hook global NormalIdle .* %{ try %{ exec -draft '<a-i>w: palette-status<ret>' } }
eval %sh{ git rev-parse --is-inside-work-tree 2>/dev/null 1>/dev/null && printf %s "
hook global BufWritePost .* %{ git show-diff }
hook global BufReload .* %{ git show-diff }
"}
hook global WinCreate .* %{
auto-pairs-enable
search-highlighter-enable
colorcol-enable
colorcol-auto-refresh
discord-presence-enable
hook global BufCreate .* %{
set buffer tabstop %opt{indentwidth}
}
hook global BufWritePre .* %{ nop %sh{
@ -203,7 +160,22 @@ hook global NormalIdle .* %{ @@ -203,7 +160,22 @@ hook global NormalIdle .* %{
set buffer curword "\b\Q%val{selection}\E\b"
} catch %{
set buffer curword ''
} }
}}
}
eval %sh{ git rev-parse --is-inside-work-tree 2>/dev/null 1>/dev/null && printf %s "
hook global BufWritePost .* %{ git show-diff }
hook global BufReload .* %{ git show-diff }
"}
hook global ModuleLoaded kitty %{
set global kitty_window_type kitty
}
hook global ModuleLoaded smarttab %{
hook global BufCreate .* %{
set buffer softtabstop %opt{indentwidth}
}
}
# Filetype detection
@ -233,27 +205,6 @@ hook global WinSetOption filetype=(go|rust|c|cpp) %{ @@ -233,27 +205,6 @@ hook global WinSetOption filetype=(go|rust|c|cpp) %{
lsp-engage
}
hook global WinSetOption filetype=html %{
set buffer formatcmd 'prettier --parser html'
set buffer lintcmd 'htmlhint -f unix'
lint-on-write
lsp-engage
}
hook global WinSetOption filetype=css %{
set buffer formatcmd 'prettier --parser css'
set buffer lintcmd 'stylelint -f unix'
lint-on-write
lsp-engage
}
hook global WinSetOption filetype=scss %{
set buffer formatcmd 'prettier --parser scss'
set buffer lintcmd 'stylelint -f unix'
lint-on-write
lsp-engage
}
hook global WinSetOption filetype=markdown %{
set buffer formatcmd 'prettier --parser markdown'
def -docstring 'render current buffer' render %{

22
kitty/kitty.conf

@ -179,19 +179,23 @@ map kitty_mod+backspace change_font_size all 0 @@ -179,19 +179,23 @@ map kitty_mod+backspace change_font_size all 0
# Open a currently visible URL using the keyboard. The program used to open the
# URL is specified in open_url_with.
map kitty_mod+e kitten hints
# Select a path/filename and insert it into the terminal. Useful, for instance to
# run git commands on a filename output from a previous git command.
map kitty_mod+p>f kitten hints --type path --program -
# Select a path/filename and insert it into the terminal.
map kitty_mod+p>f kitten hints --type=path --program=-
# Select a path/filename and open it with the default open program.
map kitty_mod+p>shift+f kitten hints --type path
# Select a line of text and insert it into the terminal. Use for the
# output of things like: ls -1
map kitty_mod+p>l kitten hints --type line --program -
map kitty_mod+p>shift+f kitten hints --type=path
# Select a line of text and insert it into the terminal.
map kitty_mod+p>l kitten hints --type=line --program=-
# Select words and insert into terminal.
map kitty_mod+p>w kitten hints --type word --program -
map kitty_mod+p>w kitten hints --type=word --program=-
# Open selected file at the selected line
map kitty_mod+p>n kitten hints --type=linenum --linenum-action=tab kak -e 'exec {line}g' {path}
map f1 create_marker
map shift+f1 remove_marker
map kitty_mod+n scroll_to_mark next
map kitty_mod+f11 toggle_fullscreen
map kitty_mod+u input_unicode_character
# Open the kitty shell in a new window/tab/overlay/os_window to control kitty using commands.
map kitty_mod+escape kitty_shell overlay
map kitty_mod+a>m set_background_opacity +0.1

7
ntr/templates/kitty-colors

@ -19,6 +19,13 @@ color13 <{color13}> @@ -19,6 +19,13 @@ color13 <{color13}>
color14 <{color14}>
color15 <{color15}>
mark1_foreground black
mark1_background #98d3cb
mark2_foreground black
mark2_background #f2dcd3
mark3_foreground black
mark3_background #f274bc
selection_foreground <{color.bg}>
selection_background <{color.fg}>

16
splug.toml

@ -11,8 +11,8 @@ files = ["rc/search-highlighter.kak"] @@ -11,8 +11,8 @@ files = ["rc/search-highlighter.kak"]
["https://github.com/alexherbo2/replace.kak"]
files = ["rc/replace-mode.kak"]
["https://github.com/alexherbo2/word-movement.kak"]
files = ["rc/word-movement.kak"]
["https://github.com/alexherbo2/word-select.kak"]
files = ["rc/word-select.kak"]
["https://github.com/alexherbo2/explore.kak"]
files = ["rc/explore/files.kak", "rc/explore/buffers.kak"]
@ -38,12 +38,6 @@ files = ["select-view.kak"] @@ -38,12 +38,6 @@ files = ["select-view.kak"]
["https://github.com/Delapouite/kakoune-palette"]
files = ["palette.kak"]
["https://github.com/h-youhei/kakoune-each-line-selection"]
files = ["each-line-selection.kak"]
["https://github.com/h-youhei/kakoune-surround"]
files = ["surround.kak"]
["https://github.com/occivink/kakoune-expand"]
files = ["expand.kak"]
@ -62,18 +56,12 @@ files = ["vertical-selection.kak"] @@ -62,18 +56,12 @@ files = ["vertical-selection.kak"]
["https://github.com/occivink/kakoune-sort-selections"]
files = ["sort-selections.kak"]
["https://gitlab.com/notramo/elvish.kak"]
files = ["elvish.kak"]
["https://github.com/andreyorst/smarttab.kak"]
files = ["rc/smarttab.kak"]
["https://github.com/chambln/kakoune-readline"]
files = ["readline.kak"]
["https://github.com/laelath/kakoune-show-matching-insert"]
files = ["matching-insert.kak"]
["https://gitlab.com/Screwtapello/kakoune-state-save"]
files = ["state-save.kak"]

Loading…
Cancel
Save