aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAkshay Nair <phenax5@gmail.com>2025-10-25 14:25:00 +0530
committerAkshay Nair <phenax5@gmail.com>2025-10-25 14:25:00 +0530
commit593e775e9ccbdca3360f1bd0c6883c7973dcb46f (patch)
treef7ec2fe94b385b255bd5e920eeb8d3b2b8fa4ee5
parentc23cf6dc9c2dd0968562adb47de085ba9761daf5 (diff)
downloadkakoune-config-593e775e9ccbdca3360f1bd0c6883c7973dcb46f.tar.gz
kakoune-config-593e775e9ccbdca3360f1bd0c6883c7973dcb46f.zip
Add module for refactoring
-rw-r--r--autoload/+init.kak6
-rw-r--r--autoload/refactor/+default.kak4
-rw-r--r--autoload/refactor/javascript.kak11
3 files changed, 17 insertions, 4 deletions
diff --git a/autoload/+init.kak b/autoload/+init.kak
index 497e5a3..aa105f5 100644
--- a/autoload/+init.kak
+++ b/autoload/+init.kak
@@ -18,7 +18,7 @@ set-option global startup_info_version 20250603
set-option global scrolloff 10,3
set-option -add global ui_options terminal_enable_mouse=false terminal_set_title=true
set-option global modelinefmt \
- '{StatusLineDetails}{{context_info}} {{mode_info}}
+'{StatusLineDetails}{{context_info}} {{mode_info}}
%val{cursor_line}/%val{buf_line_count}:%val{cursor_char_column}
{StatusLineBufname}%sh{echo "$kak_bufname" | awk -F/ "{if (NF >= 2) {print \$(NF-1) \"/\" \$NF} else {print \$NF}}"}'
@@ -36,16 +36,14 @@ hook global RegisterModified '/' %{
add-highlighter -override global/search regex "%reg{/}" 0:search
}
-# System keys
+# Misc keys
map global user '<esc>' ': set-register slash ""<ret>' -docstring 'Clear search highlighting'
map global normal '/' '/(?i)' # Remap / to case-insensitive search
map global user '/' '/'
-map global user r '*%s<ret>' -docstring 'Replace selection'
map global user s ': w<ret>' -docstring 'Save'
map global normal <c-j> 15j -docstring '15 down'
map global normal <c-k> 15k -docstring '15 up'
-# Clipboard management mappings
map global user y "<a-|> xclip -selection clipboard<ret>" -docstring "yank the selection into the clipboard"
map global user p "<a-!> xclip -selection clipboard -o<ret>" -docstring "paste the clipboard"
diff --git a/autoload/refactor/+default.kak b/autoload/refactor/+default.kak
new file mode 100644
index 0000000..4e645d3
--- /dev/null
+++ b/autoload/refactor/+default.kak
@@ -0,0 +1,4 @@
+declare-user-mode refactor
+map global user r ': enter-user-mode refactor<ret>' -docstring 'Refactor mode'
+
+map global refactor w '*%s<ret>' -docstring 'Select all selections'
diff --git a/autoload/refactor/javascript.kak b/autoload/refactor/javascript.kak
new file mode 100644
index 0000000..51797de
--- /dev/null
+++ b/autoload/refactor/javascript.kak
@@ -0,0 +1,11 @@
+hook global BufSetOption filetype=(?:javascript|typescript|jsx|tsx) %{
+ map global refactor o ': js-test-toggle-it-state<ret>' -docstring 'Toggle it/it.only'
+}
+
+define-command js-test-toggle-it-state %{
+ try %{
+ execute-keys 'Z<a-;><a-i>imxsit\(<ret>cit.only(<esc>z'
+ } catch %{
+ execute-keys 'Z<a-;><a-i>imxsit\.only\(<ret>cit(<esc>z'
+ }
+}