From 351d55648ea26335b713140bfc0c4f69e2d70489 Mon Sep 17 00:00:00 2001 From: Akshay Nair Date: Mon, 13 Oct 2025 15:25:24 +0530 Subject: Add grep-write command --- autoload/files.kak | 7 ------- autoload/git.kak | 2 +- autoload/grep.kak | 14 ++++++++++++++ 3 files changed, 15 insertions(+), 8 deletions(-) create mode 100644 autoload/grep.kak (limited to 'autoload') diff --git a/autoload/files.kak b/autoload/files.kak index 3f5d7b1..09477c1 100644 --- a/autoload/files.kak +++ b/autoload/files.kak @@ -1,5 +1,3 @@ -set-option global grepcmd "rg -S --vimgrep --hidden -g '!**/.git/**'" - def find -docstring "find files" -menu -params 1 %{ edit -existing %arg{1} } \ -shell-script-candidates %{ fd -t f --hidden --color=never -E .git } @@ -14,9 +12,4 @@ map global buffer s ':write' -docstring 'Save' declare-user-mode file map global user f ':enter-user-mode file' -docstring 'File mode' map global file f ':find ' -docstring 'Find files' -map global file g ':grep ' -docstring 'Grep' map global file n ':file-manager %val{buffile}' -docstring 'File manager' - -# TODO: Proper mappings for next/prev on results -hook global -always BufOpenFifo '\*grep\*' %{ map global normal ': grep-next-match' } -hook global -always BufOpenFifo '\*make\*' %{ map global normal ': make-next-error' } diff --git a/autoload/git.kak b/autoload/git.kak index 90e5f75..86f6d76 100644 --- a/autoload/git.kak +++ b/autoload/git.kak @@ -2,7 +2,7 @@ define-command gitui -params .. %{ connect terminal env "EDITOR=kcr edit" gitu % declare-user-mode git map global user g ':enter-user-mode git' -docstring 'Git mode' -map global git s ':gitu' -docstring 'Gitu tui' +map global git s ':gitui' -docstring 'Git tui' map global git A ':git add %val{buffile}' -docstring 'Add file' map global git c ':git add commit' -docstring 'Commit' map global git C ':git add commit --amend' -docstring 'Amend commit' diff --git a/autoload/grep.kak b/autoload/grep.kak new file mode 100644 index 0000000..cef77ee --- /dev/null +++ b/autoload/grep.kak @@ -0,0 +1,14 @@ +set-option global grepcmd "rg -S --vimgrep --hidden -g '!**/.git/**'" + +map global file g ':grep ' -docstring 'Grep' + +define-command grep-write %{ + execute-keys '%' # Consider selecting manually + evaluate-commands %sh{ + echo "$kak_selections" | "$kak_config/scripts/apply_vimgrep_updates.js" | xargs -i echo "info '{}'" + } +} + +# TODO: Proper mappings for next/prev on results +hook global -always BufOpenFifo '\*grep\*' %{ map global normal ': grep-next-match' } +hook global -always BufOpenFifo '\*make\*' %{ map global normal ': make-next-error' } -- cgit v1.3.1