kakoune: open using nnn and open/create in dir

This commit is contained in:
2026-05-08 10:54:42 +02:00
parent 5f37235a4c
commit c5c64b9247
2 changed files with 16 additions and 0 deletions

View File

@@ -16,11 +16,15 @@ declare-user-mode file-mode
declare-user-mode options-mode declare-user-mode options-mode
map global -docstring "File" user 'f' ': enter-user-mode file-mode<ret>' map global -docstring "File" user 'f' ': enter-user-mode file-mode<ret>'
map global -docstring "Buffer" user ' ' ': b '
map global -docstring "Open (git)" file-mode 'a' ': file-open-git<ret>' map global -docstring "Open (git)" file-mode 'a' ': file-open-git<ret>'
map global -docstring "Git diff file" file-mode 'd' ': git diff %val{buffile}<ret>' map global -docstring "Git diff file" file-mode 'd' ': git diff %val{buffile}<ret>'
map global -docstring "Open (fd)" file-mode 'f' ': file-open<ret>' map global -docstring "Open (fd)" file-mode 'f' ': file-open<ret>'
map global -docstring "Git grep" file-mode 'g' ': git grep ' map global -docstring "Git grep" file-mode 'g' ': git grep '
map global -docstring "Open (nnn)" file-mode 'n' ': nnn-open %val{buffile}<ret>'
map global -docstring "Open (nnn)" file-mode 'N' ': nnn-open .<ret>'
map global -docstring "Open/create in dir" file-mode 'c' ': open-create-in-dir<ret>'
map global -docstring "Options" user 'o' ': enter-user-mode options-mode<ret>' map global -docstring "Options" user 'o' ': enter-user-mode options-mode<ret>'
@@ -40,6 +44,14 @@ define-command -override file-open-git %{
prompt -menu -shell-script-candidates %{ git ls-files } 'File (git): ' %{ edit -- %val{text} } prompt -menu -shell-script-candidates %{ git ls-files } 'File (git): ' %{ edit -- %val{text} }
} }
define-command -override -params 1 nnn-open %{
terminal nnn-kak-edit %arg{1} %val{session} %val{client}
}
define-command -override open-create-in-dir %{
execute-keys ': edit ' %sh{dirname "$kak_buffile"}/
}
# ODIN # ODIN
hook global BufSetOption filetype=odin %{ hook global BufSetOption filetype=odin %{

4
kakoune/bin/nnn-kak-edit Executable file
View File

@@ -0,0 +1,4 @@
#!/bin/sh
cd "$(dirname $1)"
exec nnn -A -p - | awk "{print \"evaluate-commands -client $3 edit\", \$1 }" | kak -p "$2"