diff options
Diffstat (limited to 'config/kakoune/kakrc.nix')
-rw-r--r-- | config/kakoune/kakrc.nix | 96 |
1 files changed, 96 insertions, 0 deletions
diff --git a/config/kakoune/kakrc.nix b/config/kakoune/kakrc.nix new file mode 100644 index 000000000000..2168b37a6b26 --- /dev/null +++ b/config/kakoune/kakrc.nix @@ -0,0 +1,96 @@ +{ fzf, tmux }: + +'' +# Highlight any files whose names start with "zsh" as sh +hook global BufCreate (.*/)?\.?zsh.* %{ + set-option buffer filetype sh +} + +# Highlight files ending in .conf as ini +# (Will probably be close enough) +hook global BufCreate .*\.conf %{ + set-option buffer filetype ini +} + +# Highlight files ending in .html.erb as html +hook global BufCreate .*\.html.erb %{ + set-option buffer filetype html +} + +# Strip trailing whitespace on save +hook global BufWritePre .*(?<!\.diff)$ %{ + try %{execute-keys -draft %{%s\h+$<ret>d}} + echo +} + +define-command -docstring "import from the system clipboard" clipboard-import %{ + set-register dquote %sh{pbpaste} + echo -markup "{Information}imported system clipboard to register """ +} + +define-command -docstring "export to the system clipboard" clipboard-export %{ + nop %sh{ printf "%s" "$kak_main_reg_dquote" | pbcopy } + echo -markup "{Information}exported register "" to system clipboard" +} + +define-command -docstring "open a file using fzf" open %{ + edit %sh{ + git ls-files -oc --exclude-standard | + ${fzf}/bin/fzf-tmux -r 80 --reverse + } +} +alias global o open + +define-command -params 1.. -docstring "change file modes" chmod %{ + nop %sh{ chmod $@ "$kak_buffile" } +} + +declare-option str last_test +define-command -docstring "intelligently run code" run %{ + evaluate-commands -save-regs x %{ + write + nop %sh{${tmux}/bin/tmux split-window -hl 80 "$kak_buffile; read"} + } +} + +define-command mkdirp %{ + nop %sh{mkdir -p "$(dirname "$kak_buffile")"} +} + +define-command mkdirpw %{ + mkdirp + write +} + +map global normal <a-Y> :clipboard-import<ret> +map global normal <a-y> :clipboard-export<ret> + +map global normal / /(?i) + +# Allow indenting from any position in the line, with the correct indentation. +map global insert <tab> '<a-;><a-gt>' +map global insert <s-tab> '<a-;><lt>' + +map -docstring "Remove Symbol hashrockets" global user \ + <gt> 's:\S+<space>+=<gt><ret>;<a-?><space>+<ret>c:<esc>h<a-/>:<ret>d' + +map -docstring "Convert single quotes to double quotes" global user \ + %{'} %{s'<ret>r"} + +map -docstring "Toggle line comments" global user \ + %{#} %{:comment-line<ret>} + +declare-user-mode bookmarks +map -docstring "Edit bookmarked file" global user b \ + %{:enter-user-mode bookmarks<ret>} + +map -docstring "wiki" global bookmarks w %{:edit-wiki-index<ret>} + +set-option global indentwidth 2 +set-option global ui_options ncurses_assistant=none +set-option global scrolloff 5,5 +set-option global autoreload yes + +add-highlighter global/ number-lines -hlcursor -separator "│" +add-highlighter global/ show-matching +'' |