add kakoune config
This commit is contained in:
		
							parent
							
								
									e9e6b6f76a
								
							
						
					
					
						commit
						4153759a74
					
				
					 8 changed files with 738 additions and 1 deletions
				
			
		
							
								
								
									
										19
									
								
								user/kak/kakrc
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										19
									
								
								user/kak/kakrc
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,19 @@
 | 
			
		|||
# {{@@ header() @@}}
 | 
			
		||||
#  _  __     _
 | 
			
		||||
# | |/ /__ _| | _____  _   _ _ __   ___
 | 
			
		||||
# | ' // _` | |/ / _ \| | | | '_ \ / _ \
 | 
			
		||||
# | . \ (_| |   < (_) | |_| | | | |  __/
 | 
			
		||||
# |_|\_\__,_|_|\_\___/ \__,_|_| |_|\___|
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
set global scrolloff 10,20
 | 
			
		||||
set global autoreload yes
 | 
			
		||||
set global startup_info_version 20200901
 | 
			
		||||
 | 
			
		||||
source "%val{config}/rc/plug.kak"
 | 
			
		||||
source "%val{config}/rc/keys.kak"
 | 
			
		||||
source "%val{config}/rc/usermode.kak"
 | 
			
		||||
source "%val{config}/rc/hooks.kak"
 | 
			
		||||
source "%val{config}/rc/filetypes.kak"
 | 
			
		||||
source "%val{config}/rc/indent.kak"
 | 
			
		||||
source "%val{config}/colors.kak"
 | 
			
		||||
							
								
								
									
										226
									
								
								user/kak/rc/filetypes.kak
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										226
									
								
								user/kak/rc/filetypes.kak
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,226 @@
 | 
			
		|||
 | 
			
		||||
try %{
 | 
			
		||||
    require-module python
 | 
			
		||||
    add-highlighter shared/python/code/function regex '\b([a-zA-Z_][a-zA-Z0-9_]*)\s*\(' 1:function
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
hook global WinSetOption filetype=sh %{
 | 
			
		||||
    set buffer formatcmd 'shfmt -s -ci -i "4"'
 | 
			
		||||
}
 | 
			
		||||
hook global WinSetOption filetype=c %{
 | 
			
		||||
    set buffer formatcmd 'clang-format'
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
hook global BufCreate .*\.rs %{
 | 
			
		||||
    set buffer formatcmd 'rustfmt'
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
hook global BufCreate .*\.html %{
 | 
			
		||||
    set buffer formatcmd 'prettier --parser html'
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
hook global BufCreate .*\.js %{
 | 
			
		||||
    set buffer formatcmd 'prettier --parser babel'
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
hook global BufCreate .*\.vue %{
 | 
			
		||||
    set buffer formatcmd 'prettier --parser vue'
 | 
			
		||||
    hook buffer InsertCompletionHide {
 | 
			
		||||
      execute-keys 'Ghs$1<ret>c'
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
# Highlight Dotdrop templating syntax
 | 
			
		||||
hook global WinCreate .* %{
 | 
			
		||||
    require-module python
 | 
			
		||||
    add-highlighter window/dotdrop regions
 | 
			
		||||
 | 
			
		||||
    add-highlighter window/dotdrop/expression region '\{\{@[@]' '[@]@\}\}' group
 | 
			
		||||
    add-highlighter window/dotdrop/statement  region  '\{%@[@]' '[@]@%\}' group
 | 
			
		||||
    add-highlighter window/dotdrop/comment    region  '\{#@[@]' '[@]@#\}' fill comment
 | 
			
		||||
 | 
			
		||||
    add-highlighter window/dotdrop/expression/ fill variable
 | 
			
		||||
    add-highlighter window/dotdrop/statement/  fill variable
 | 
			
		||||
 | 
			
		||||
    add-highlighter window/dotdrop/expression/ ref python
 | 
			
		||||
    add-highlighter window/dotdrop/statement/  ref python
 | 
			
		||||
 | 
			
		||||
    add-highlighter window/dotdrop/expression/ regex '\{\{@[@]|[@]@\}\}' 0:block
 | 
			
		||||
    add-highlighter window/dotdrop/statement/  regex  '\{%@[@]|[@]@%\}' 0:block
 | 
			
		||||
    add-highlighter window/dotdrop/statement/  regex 'endfor|endif' 0:keyword
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
hook global BufCreate .*\.jsonc %[ set buffer filetype jsonc ]
 | 
			
		||||
hook global BufCreate .*\.blade.php %[ set buffer filetype blade ]
 | 
			
		||||
hook global BufCreate .*\.less %[ set buffer filetype less ]
 | 
			
		||||
hook global BufCreate .*\.(tera|askama)\.?.* %[
 | 
			
		||||
    require-module jinja
 | 
			
		||||
    add-highlighter buffer/jinja ref jinja
 | 
			
		||||
]
 | 
			
		||||
 | 
			
		||||
hook global WinSetOption filetype=sql %[
 | 
			
		||||
    set buffer comment_line '--'
 | 
			
		||||
]
 | 
			
		||||
 | 
			
		||||
hook global WinSetOption filetype=jsonc %[
 | 
			
		||||
    set buffer comment_line '//'
 | 
			
		||||
 | 
			
		||||
    require-module json
 | 
			
		||||
    add-highlighter buffer/jsonc regions
 | 
			
		||||
    add-highlighter buffer/jsonc/base default-region ref json
 | 
			
		||||
    add-highlighter buffer/jsonc/double_string region ["] ["] fill string
 | 
			
		||||
    add-highlighter buffer/jsonc/line-comment region // $ fill comment
 | 
			
		||||
]
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
hook global WinSetOption filetype=blade %[
 | 
			
		||||
    set buffer formatcmd 'blade-formatter \
 | 
			
		||||
            --end-with-newline \
 | 
			
		||||
            --indent-size "4" \
 | 
			
		||||
            --wrap-line-length "80" \
 | 
			
		||||
            --stdin'
 | 
			
		||||
    set-option buffer extra_word_chars '_' '-'
 | 
			
		||||
 | 
			
		||||
    hook window ModeChange pop:insert:.* -group blade-trim-indent  blade-trim-indent
 | 
			
		||||
    hook window InsertChar .* -group blade-indent blade-indent-on-char
 | 
			
		||||
    hook window InsertChar \n -group blade-indent blade-indent-on-new-line
 | 
			
		||||
 | 
			
		||||
    hook -once -always window WinSetOption filetype=.* %{ remove-hooks window blade-.+ }
 | 
			
		||||
 | 
			
		||||
    require-module php
 | 
			
		||||
 | 
			
		||||
    add-highlighter buffer/blade regions
 | 
			
		||||
    add-highlighter buffer/blade/base default-region group
 | 
			
		||||
 | 
			
		||||
    add-highlighter buffer/blade/string region '"' '"' regions
 | 
			
		||||
    add-highlighter buffer/blade/string/base default-region fill string
 | 
			
		||||
    add-highlighter buffer/blade/string/expression region '\{\{(?!--)' '(?!--)\}\}' ref php
 | 
			
		||||
    add-highlighter buffer/blade/string/raw-expression region '\{!!' '!!\}' ref php
 | 
			
		||||
 | 
			
		||||
    add-highlighter buffer/blade/base/ ref html
 | 
			
		||||
 | 
			
		||||
    add-highlighter buffer/blade/php  region '@php' '@endphp' group
 | 
			
		||||
    add-highlighter buffer/blade/php/ ref php
 | 
			
		||||
    add-highlighter buffer/blade/php/ regex '@((end)?php)' 1:block
 | 
			
		||||
 | 
			
		||||
    add-highlighter buffer/blade/expression region '\{\{(?!--)' '(?!--)\}\}' ref php
 | 
			
		||||
    add-highlighter buffer/blade/statement  region -recurse '\(' '@(if|for|foreach|section|yield|include)\s*\(' '\)' ref php
 | 
			
		||||
    add-highlighter buffer/blade/base/      regex '@(else(if)?|include|case|break)' 1:keyword
 | 
			
		||||
    add-highlighter buffer/blade/base/      regex '@((end)?(if|isset|for|foreach|section|switch))' 1:keyword
 | 
			
		||||
 | 
			
		||||
    add-highlighter buffer/blade/comment    region '\{\{--' '--\}\}' fill comment
 | 
			
		||||
    set-option buffer comment_block_begin '{{-- '
 | 
			
		||||
    set-option buffer comment_block_end   ' --}}'
 | 
			
		||||
 | 
			
		||||
    map buffer user 'c' '<a-x>_: comment-block<ret><a-;>;' -docstring 'comment block'
 | 
			
		||||
]
 | 
			
		||||
 | 
			
		||||
try %§
 | 
			
		||||
 | 
			
		||||
define-command -hidden blade-trim-indent %{
 | 
			
		||||
    # remove trailing white spaces
 | 
			
		||||
    try %{ execute-keys -draft -itersel <a-x> s \h+$ <ret> d }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
define-command -hidden blade-indent-on-char %<
 | 
			
		||||
    evaluate-commands -draft -itersel %<
 | 
			
		||||
        # align closer token to its opener when alone on a line
 | 
			
		||||
        try %/ execute-keys -draft <a-h> <a-k> ^\h+[\]}]$ <ret> m s \A|.\z <ret> 1<a-&> /
 | 
			
		||||
    >
 | 
			
		||||
>
 | 
			
		||||
 | 
			
		||||
define-command -hidden blade-indent-on-new-line %<
 | 
			
		||||
    evaluate-commands -draft -itersel %<
 | 
			
		||||
        # copy // comments or docblock * prefix and following white spaces
 | 
			
		||||
        try %{ execute-keys -draft s [^/] <ret> k <a-x> s ^\h*\K(?://|[*][^/])\h* <ret> y gh j P }
 | 
			
		||||
        # preserve previous line indent
 | 
			
		||||
        try %{ execute-keys -draft <semicolon> K <a-&> }
 | 
			
		||||
        # filter previous line
 | 
			
		||||
        try %{ execute-keys -draft k : blade-trim-indent <ret> }
 | 
			
		||||
        # indent after lines beginning / ending with opener token
 | 
			
		||||
        try %_ execute-keys -draft k <a-x> <a-k> ^\h*[[{]|[[{]$ <ret> j <a-gt> _
 | 
			
		||||
        # append " * " on lines starting a multiline /** or /* comment
 | 
			
		||||
    	try %{ execute-keys -draft k <a-x> s ^\h*/[*][* ]? <ret> j gi i <space>*<space> }
 | 
			
		||||
    	# deindent closer token(s) when after cursor
 | 
			
		||||
    	try %_ execute-keys -draft <a-x> <a-k> ^\h*[})] <ret> gh / [})] <ret> m <a-S> 1<a-&> _
 | 
			
		||||
    >
 | 
			
		||||
>
 | 
			
		||||
§
 | 
			
		||||
 | 
			
		||||
hook global WinSetOption filetype=less  %[
 | 
			
		||||
    set buffer formatcmd 'prettier \
 | 
			
		||||
            --tab-width "4" \
 | 
			
		||||
            --print-width "80" \
 | 
			
		||||
        	--parser less'
 | 
			
		||||
 | 
			
		||||
    set-option buffer extra_word_chars '_' '-'
 | 
			
		||||
 | 
			
		||||
    set buffer comment_line '//'
 | 
			
		||||
    set buffer comment_block_begin '/*'
 | 
			
		||||
    set buffer comment_block_end   '*/'
 | 
			
		||||
 | 
			
		||||
    hook window ModeChange pop:insert:.* -group less-trim-indent  less-trim-indent
 | 
			
		||||
    hook window InsertChar \n -group less-indent less-indent-on-new-line
 | 
			
		||||
    hook window InsertChar \} -group less-indent less-indent-on-closing-curly-brace
 | 
			
		||||
 | 
			
		||||
    map buffer insert <c-k> '<esc>xs\$\d+<ret>) c'
 | 
			
		||||
 | 
			
		||||
    hook -once -always window WinSetOption filetype=.* %{ remove-hooks window less-.+ }
 | 
			
		||||
 | 
			
		||||
    add-highlighter buffer/less regions
 | 
			
		||||
    add-highlighter buffer/less/code default-region group
 | 
			
		||||
 | 
			
		||||
    add-highlighter buffer/less/line-comment region // $ fill comment
 | 
			
		||||
    add-highlighter buffer/less/comment region /[*] [*]/ fill comment
 | 
			
		||||
    add-highlighter buffer/less/double_string region ["] ["] fill string
 | 
			
		||||
    add-highlighter buffer/less/single_string region ['] ['] fill string
 | 
			
		||||
 | 
			
		||||
    add-highlighter buffer/less/code/ regex ([A-Za-z][A-Za-z0-9_-]*)\h*: 1:keyword
 | 
			
		||||
    add-highlighter buffer/less/code/ regex ::?(\w+) 0:attribute
 | 
			
		||||
    add-highlighter buffer/less/code/ regex !important 0:keyword
 | 
			
		||||
 | 
			
		||||
    add-highlighter buffer/less/code/selector   group
 | 
			
		||||
    add-highlighter buffer/less/code/selector/ regex         [A-Za-z][A-Za-z0-9_-]* 0:keyword
 | 
			
		||||
    add-highlighter buffer/less/code/selector/ regex [*]|[#.][A-Za-z][A-Za-z0-9_-]* 0:variable
 | 
			
		||||
    add-highlighter buffer/less/code/selector/ regex &([A-Za-z0-9_-]*) 1:variable
 | 
			
		||||
    add-highlighter buffer/less/code/selector/ regex & 0:operator
 | 
			
		||||
    add-highlighter buffer/less/code/selector/ regex (\.?[A-Za-z][A-Za-z0-9_-]*)\s*\( 1:function
 | 
			
		||||
 | 
			
		||||
    add-highlighter buffer/less/code/ regex (\b(\d*\.)?\d+(ch|cm|em|ex|mm|pc|pt|px|rem|vh|vmax|vmin|vw|%|s|ms)?) 0:value 3:type
 | 
			
		||||
    add-highlighter buffer/less/code/ regex (#)[0-9A-Fa-f]{3}([0-9A-Fa-f]{3}([0-9A-Fa-f]{2})?)?\b 0:value 1:operator
 | 
			
		||||
 | 
			
		||||
    add-highlighter buffer/less/code/ regex (?i)\b(AliceBlue|AntiqueWhite|Aqua|Aquamarine|Azure|Beige|Bisque|Black|BlanchedAlmond|Blue|BlueViolet|Brown|BurlyWood|CadetBlue|Chartreuse|Chocolate|Coral|CornflowerBlue|Cornsilk|Crimson|Cyan|DarkBlue|DarkCyan|DarkGoldenRod|DarkGray|DarkGrey|DarkGreen|DarkKhaki|DarkMagenta|DarkOliveGreen|DarkOrange|DarkOrchid|DarkRed|DarkSalmon|DarkSeaGreen|DarkSlateBlue|DarkSlateGray|DarkSlateGrey|DarkTurquoise|DarkViolet|DeepPink|DeepSkyBlue|DimGray|DimGrey|DodgerBlue|FireBrick|FloralWhite|ForestGreen|Fuchsia|Gainsboro|GhostWhite|Gold|GoldenRod|Gray|Grey|Green|GreenYellow|HoneyDew|HotPink|IndianRed|Indigo|Ivory|Khaki|Lavender|LavenderBlush|LawnGreen|LemonChiffon|LightBlue|LightCoral|LightCyan|LightGoldenRodYellow|LightGray|LightGrey|LightGreen|LightPink|LightSalmon|LightSeaGreen|LightSkyBlue|LightSlateGray|LightSlateGrey|LightSteelBlue|LightYellow|Lime|LimeGreen|Linen|Magenta|Maroon|MediumAquaMarine|MediumBlue|MediumOrchid|MediumPurple|MediumSeaGreen|MediumSlateBlue|MediumSpringGreen|MediumTurquoise|MediumVioletRed|MidnightBlue|MintCream|MistyRose|Moccasin|NavajoWhite|Navy|OldLace|Olive|OliveDrab|Orange|OrangeRed|Orchid|PaleGoldenRod|PaleGreen|PaleTurquoise|PaleVioletRed|PapayaWhip|PeachPuff|Peru|Pink|Plum|PowderBlue|Purple|RebeccaPurple|Red|RosyBrown|RoyalBlue|SaddleBrown|Salmon|SandyBrown|SeaGreen|SeaShell|Sienna|Silver|SkyBlue|SlateBlue|SlateGray|SlateGrey|Snow|SpringGreen|SteelBlue|Tan|Teal|Thistle|Tomato|Turquoise|Violet|Wheat|White|WhiteSmoke|Yellow|YellowGreen)\b 0:value
 | 
			
		||||
 | 
			
		||||
    add-highlighter buffer/less/code/ regex ([\w-_]+)\s*: 1:attribute
 | 
			
		||||
    add-highlighter buffer/less/code/ regex @[\w\d-_]+ 0:variable
 | 
			
		||||
 | 
			
		||||
]
 | 
			
		||||
 | 
			
		||||
try %§
 | 
			
		||||
 | 
			
		||||
define-command -hidden less-trim-indent %{
 | 
			
		||||
    # remove trailing white spaces
 | 
			
		||||
    try %{ execute-keys -draft -itersel <a-x> s \h+$ <ret> d }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
define-command -hidden less-indent-on-new-line %[
 | 
			
		||||
    evaluate-commands -draft -itersel %[
 | 
			
		||||
        # preserve previous line indent
 | 
			
		||||
        try %[ execute-keys -draft <semicolon> K <a-&> ]
 | 
			
		||||
        # filter previous line
 | 
			
		||||
        try %[ execute-keys -draft k : less-trim-indent <ret> ]
 | 
			
		||||
        # indent after lines ending with with {
 | 
			
		||||
        try %[ execute-keys -draft k <a-x> <a-k> \{$ <ret> j <a-gt> ]
 | 
			
		||||
        # deindent closing brace when after cursor
 | 
			
		||||
        try %[ execute-keys -draft <a-x> <a-k> ^\h*\} <ret> gh / \} <ret> m <a-S> 1<a-&> ]
 | 
			
		||||
    ]
 | 
			
		||||
]
 | 
			
		||||
 | 
			
		||||
define-command -hidden less-indent-on-closing-curly-brace %[
 | 
			
		||||
    evaluate-commands -draft -itersel %[
 | 
			
		||||
        # align to opening curly brace when alone on a line
 | 
			
		||||
        try %[ execute-keys -draft <a-h> <a-k> ^\h+\}$ <ret> m s \A|.\z <ret> 1<a-&> ]
 | 
			
		||||
    ]
 | 
			
		||||
]
 | 
			
		||||
 | 
			
		||||
§
 | 
			
		||||
							
								
								
									
										48
									
								
								user/kak/rc/hooks.kak
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										48
									
								
								user/kak/rc/hooks.kak
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,48 @@
 | 
			
		|||
set global idle_timeout 500
 | 
			
		||||
 | 
			
		||||
hook global NormalIdle .* %{ try %{
 | 
			
		||||
    palette-status
 | 
			
		||||
} }
 | 
			
		||||
 | 
			
		||||
define-command -hidden -override git-try-show-diff %{
 | 
			
		||||
    evaluate-commands -draft %sh{
 | 
			
		||||
        test -f "$kak_buffile" || exit 0
 | 
			
		||||
        cd $(dirname "$kak_buffile")
 | 
			
		||||
        git rev-parse --git-dir > /dev/null &&
 | 
			
		||||
        echo "git show-diff"
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
evaluate-commands %sh{
 | 
			
		||||
    for hook in NormalIdle FocusIn FocusOut BufWritePost BufOpenFile; do
 | 
			
		||||
        printf "hook global %s .* 'git-try-show-diff'\n" "$hook"
 | 
			
		||||
    done
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
define-command -override diffr %{ try %{
 | 
			
		||||
    execute-keys -draft 'ggxsdiff<ret>'
 | 
			
		||||
    execute-keys -draft '%<a-;>J| _diffr<ret>'
 | 
			
		||||
    ansi-render
 | 
			
		||||
} }
 | 
			
		||||
 | 
			
		||||
hook global BufOpenFile .* diffr
 | 
			
		||||
 | 
			
		||||
hook global BufOpenFile .* %{
 | 
			
		||||
    modeline-parse
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
hook global BufOpenFile .*/COMMIT_EDITMSG %{
 | 
			
		||||
    execute-keys -draft 'ge<a-!>git log<ret>'
 | 
			
		||||
    write
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
hook global RegisterModified '"' %{ nop %sh{ {
 | 
			
		||||
    printf %s "$kak_reg_dquote" | wl-copy -n
 | 
			
		||||
    printf %s "$kak_reg_dquote" | xclip -i -selection clipboard
 | 
			
		||||
} > /dev/null 2>&1 < /dev/null & }}
 | 
			
		||||
 | 
			
		||||
# Trim trailing whitespace
 | 
			
		||||
hook global BufWritePre .* %{ try %{
 | 
			
		||||
    execute-keys -draft \%s\h+$<ret>d
 | 
			
		||||
} } -group remove-whitespace
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										29
									
								
								user/kak/rc/indent.kak
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										29
									
								
								user/kak/rc/indent.kak
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,29 @@
 | 
			
		|||
# {{@@ header() @@}}
 | 
			
		||||
#  _  __     _
 | 
			
		||||
# | |/ /__ _| | _____  _   _ _ __   ___
 | 
			
		||||
# | ' // _` | |/ / _ \| | | | '_ \ / _ \
 | 
			
		||||
# | . \ (_| |   < (_) | |_| | | | |  __/
 | 
			
		||||
# |_|\_\__,_|_|\_\___/ \__,_|_| |_|\___|
 | 
			
		||||
 | 
			
		||||
set global tabstop 4
 | 
			
		||||
 | 
			
		||||
hook global BufCreate .*\.py %{
 | 
			
		||||
    set global indentwidth 4
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#################################################################
 | 
			
		||||
# Spaces
 | 
			
		||||
#################################################################
 | 
			
		||||
 | 
			
		||||
set global indentwidth 4
 | 
			
		||||
 | 
			
		||||
# use spaces insted of tabs
 | 
			
		||||
hook global BufCreate .* %{
 | 
			
		||||
    hook buffer InsertChar \t %{
 | 
			
		||||
        exec -draft -itersel h@
 | 
			
		||||
    } -group replace-tabs-with-spaces
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
hook global WinSetOption filetype=makefile %{
 | 
			
		||||
    remove-hooks buffer replace-tabs-with-spaces
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										38
									
								
								user/kak/rc/keys.kak
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										38
									
								
								user/kak/rc/keys.kak
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,38 @@
 | 
			
		|||
# {{@@ header() @@}}
 | 
			
		||||
 | 
			
		||||
map global normal <c-d> 10j
 | 
			
		||||
map global normal <c-u> 10k
 | 
			
		||||
 | 
			
		||||
# alt i makes searches case insensitive
 | 
			
		||||
map global prompt <a-i> '<c-a>(?i)<c-e>'
 | 
			
		||||
 | 
			
		||||
######################################################
 | 
			
		||||
# Emacs-like insert
 | 
			
		||||
######################################################
 | 
			
		||||
 | 
			
		||||
map global insert <c-b> "<a-;>h"
 | 
			
		||||
map global insert <c-f> "<a-;>l"
 | 
			
		||||
 | 
			
		||||
map global insert <a-b> "<a-;>b"
 | 
			
		||||
map global insert <a-f> "<a-;>w"
 | 
			
		||||
 | 
			
		||||
map global insert <c-a> "<a-;>gi"
 | 
			
		||||
map global insert <c-e> "<a-;>gh<a-;>gl<right>"
 | 
			
		||||
map global insert <c-w> "<a-;>b<a-;>d"
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
######################################################
 | 
			
		||||
# Other insert binds
 | 
			
		||||
######################################################
 | 
			
		||||
 | 
			
		||||
map global insert <a-k> "<esc>"
 | 
			
		||||
map global insert <c-t> "<esc>"
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
######################################################
 | 
			
		||||
# Objects
 | 
			
		||||
######################################################
 | 
			
		||||
 | 
			
		||||
map global object m %{c^[<lt>=|]{4\,}[^\n]*\n,^[<gt>=|]{4\,}[^\n]*\n<ret>} -docstring 'git conflict markers'
 | 
			
		||||
map global object M %{c^<lt>{4\,}[^\n]*\n,^<gt>{4\,}[^\n]*\n<ret>} -docstring 'git conflict'
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										92
									
								
								user/kak/rc/plug.kak
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										92
									
								
								user/kak/rc/plug.kak
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,92 @@
 | 
			
		|||
nop %sh{
 | 
			
		||||
    PLUG_DIR="${HOME}/.cache/kakoune_plugins"
 | 
			
		||||
    REPO="https://github.com/andreyorst/plug.kak.git"
 | 
			
		||||
 | 
			
		||||
    mkdir -p "$PLUG_DIR"
 | 
			
		||||
 | 
			
		||||
    test -d "${PLUG_DIR}/plug.kak" ||
 | 
			
		||||
        git clone "$REPO" "${PLUG_DIR}/plug.kak"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
source %sh{ echo "${HOME}/.cache/kakoune_plugins/plug.kak/rc/plug.kak" }
 | 
			
		||||
 | 
			
		||||
plug "andreyorst/plug.kak" noload config %{
 | 
			
		||||
    # Auto install every pluging
 | 
			
		||||
    set-option global plug_always_ensure true
 | 
			
		||||
    set-option global plug_install_dir %sh{ echo "${HOME}/.cache/kakoune_plugins" }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
plug 'eraserhd/kak-ansi'
 | 
			
		||||
 | 
			
		||||
plug 'alexherbo2/auto-pairs.kak' config %{
 | 
			
		||||
    enable-auto-pairs
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
plug 'lelgenio/kakoune-mirror-colemak' config %{
 | 
			
		||||
    map global user "s" ': enter-user-mode mirror<ret>'
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
plug 'delapouite/kakoune-palette'
 | 
			
		||||
plug 'greenfork/active-window.kak'
 | 
			
		||||
plug 'lelgenio/kak-crosshairs' config %{
 | 
			
		||||
    crosshairs-enable
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
# Search and replace, for every buffer
 | 
			
		||||
plug "natasky/kakoune-multi-file"
 | 
			
		||||
 | 
			
		||||
plug "lelgenio/kakoune-colemak-neio"
 | 
			
		||||
 | 
			
		||||
plug 'kak-lsp/kak-lsp' do %{
 | 
			
		||||
    cargo install --locked --force --path .
 | 
			
		||||
} config %{
 | 
			
		||||
    map global normal <F2> ': lsp-rename-prompt<ret>'
 | 
			
		||||
    set global lsp_hover_max_lines 10
 | 
			
		||||
    set global lsp_auto_highlight_references true
 | 
			
		||||
    set global lsp_inlay_diagnostic_sign "●"
 | 
			
		||||
    set global lsp_diagnostic_line_error_sign "●"
 | 
			
		||||
 | 
			
		||||
    hook global BufCreate   .* %{try lsp-enable}
 | 
			
		||||
 | 
			
		||||
    define-command -override -hidden lsp-next-placeholder-bind %{
 | 
			
		||||
        map global normal <tab> ': try lsp-snippets-select-next-placeholders catch %{ execute-keys -with-hooks <lt>tab> }<ret>' -docstring 'Select next snippet placeholder'
 | 
			
		||||
        map global insert <tab> '<a-;>: try lsp-snippets-select-next-placeholders catch %{ execute-keys -with-hooks <lt>tab> }<ret>' -docstring 'Select next snippet placeholder'
 | 
			
		||||
    }
 | 
			
		||||
    lsp-next-placeholder-bind
 | 
			
		||||
    map global insert <c-o> "<esc>: lsp-code-action-sync Fill<ret>"
 | 
			
		||||
 | 
			
		||||
    define-command -override -hidden lsp-enable-decals %{
 | 
			
		||||
        lsp-inlay-diagnostics-enable global
 | 
			
		||||
        lsp-inlay-hints-enable global
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    define-command -override -hidden lsp-disable-decals %{
 | 
			
		||||
        lsp-inlay-diagnostics-disable global
 | 
			
		||||
        lsp-inlay-hints-disable global
 | 
			
		||||
    }
 | 
			
		||||
    lsp-enable-decals
 | 
			
		||||
 | 
			
		||||
    hook global ModeChange '.*:insert:normal' %{lsp-enable-decals}
 | 
			
		||||
    hook global ModeChange '.*:normal:insert' %{lsp-disable-decals}
 | 
			
		||||
 | 
			
		||||
    hook global WinSetOption filetype=(c|cpp|rust) %{
 | 
			
		||||
        hook window -group semantic-tokens BufReload .* lsp-semantic-tokens
 | 
			
		||||
        hook window -group semantic-tokens NormalIdle .* lsp-semantic-tokens
 | 
			
		||||
        hook window -group semantic-tokens InsertIdle .* lsp-semantic-tokens
 | 
			
		||||
        hook -once -always window WinSetOption filetype=.* %{
 | 
			
		||||
            remove-hooks window semantic-tokens
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    declare-option -hidden str modeline_progress ""
 | 
			
		||||
    define-command -hidden -params 6 -override lsp-handle-progress %{
 | 
			
		||||
        set global modeline_progress %sh{
 | 
			
		||||
            if ! "$6"; then
 | 
			
		||||
                echo "$2${5:+" ($5%)"}${4:+": $4"}"
 | 
			
		||||
            fi
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    set global modelinefmt "%%opt{modeline_progress} %opt{modelinefmt}"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										180
									
								
								user/kak/rc/usermode.kak
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										180
									
								
								user/kak/rc/usermode.kak
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,180 @@
 | 
			
		|||
try %{
 | 
			
		||||
    # declare-user-mode surround
 | 
			
		||||
    declare-user-mode git
 | 
			
		||||
    declare-user-mode find
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
map global user 'w' ': w<ret>' -docstring 'write buffer'
 | 
			
		||||
map global user 'u' ': config-source<ret>' -docstring 'source configuration'
 | 
			
		||||
map global user 'g' ': enter-user-mode lsp<ret>' -docstring 'lsp mode'
 | 
			
		||||
map global user 'z' ':zoxide ' -docstring 'zoxide'
 | 
			
		||||
map global user 'n' ': new<ret>' -docstring 'new window'
 | 
			
		||||
 | 
			
		||||
map global user 'e' 'x|emmet<ret>@' -docstring 'process line with emmet'
 | 
			
		||||
map global user 'm' ': try lsp-formatting-sync catch format-buffer<ret>' -docstring 'format document'
 | 
			
		||||
map global user 'M' ': try lsp-range-formatting-sync catch format-selections<ret>' -docstring 'format selection'
 | 
			
		||||
 | 
			
		||||
map global user 'c' ': comment-line<ret>' -docstring 'comment line'
 | 
			
		||||
map global user 'C' '_: comment-block<ret>' -docstring 'comment block'
 | 
			
		||||
 | 
			
		||||
map global user 'p' '! wl-paste -n<ret>' -docstring 'clipboard paste'
 | 
			
		||||
map global user 'P' '<a-o>j! wl-paste -n<ret>' -docstring 'clipboard paste on next line'
 | 
			
		||||
map global user 'R' '"_d! wl-paste -n <ret>' -docstring 'clipboard replace'
 | 
			
		||||
 | 
			
		||||
map global user 'b' ': find_buffer<ret>' -docstring 'switch buffer'
 | 
			
		||||
 | 
			
		||||
map global user 'l' ': lsp-enable-decals<ret>' -docstring 'LSP enable decals'
 | 
			
		||||
map global user 'L' ': lsp-disable-decals<ret>' -docstring 'LSP disable decals'
 | 
			
		||||
 | 
			
		||||
map global user 'v'    ': enter-user-mode git<ret>' -docstring 'git vcs mode'
 | 
			
		||||
map global user 'V'    ': enter-user-mode -lock git<ret>' -docstring 'git vcs mode'
 | 
			
		||||
map global git 's'     ': git status<ret>' -docstring 'status'
 | 
			
		||||
map global git 'S'     '_: git show %val{selection} --<ret>' -docstring 'show'
 | 
			
		||||
map global git 'a'     ': git add<ret>' -docstring 'add current'
 | 
			
		||||
map global git 'd'     ': git diff %reg{%}<ret>' -docstring 'diff current'
 | 
			
		||||
map global git 'r'     ': git checkout %reg{%}<ret>' -docstring 'restore current'
 | 
			
		||||
map global git 'A'     ': git add --all<ret>' -docstring 'add all'
 | 
			
		||||
map global git 'D'     ': git diff<ret>' -docstring 'diff all'
 | 
			
		||||
map global git '<a-d>' ': git diff --staged<ret>' -docstring 'diff staged'
 | 
			
		||||
map global git 'c'     ': git commit -v<ret>' -docstring 'commit'
 | 
			
		||||
map global git 'u'     ': git update-diff<ret>' -docstring 'update gutter diff'
 | 
			
		||||
map global git 'n'     ': git next-hunk <ret>' -docstring 'next hunk'
 | 
			
		||||
map global git 'p'     ': git prev-hunk <ret>' -docstring 'previous hunk'
 | 
			
		||||
map global git 'm'     ': git-merge-head <ret>' -docstring 'merge using head'
 | 
			
		||||
map global git 'M'     ': git-merge-new <ret>' -docstring 'merge using new'
 | 
			
		||||
map global git '<a-m>' ': git-merge-original <ret>' -docstring 'merge using original'
 | 
			
		||||
 | 
			
		||||
map global user 'f' ': enter-user-mode find<ret>' -docstring 'find mode'
 | 
			
		||||
map global find 't' ': tree<ret>' -docstring 'file tree'
 | 
			
		||||
map global find 'f' ': find_file<ret>' -docstring 'file'
 | 
			
		||||
map global find 'l' ': find_line<ret>' -docstring 'jump to line'
 | 
			
		||||
map global find 'r' ': find_ripgrep<ret>' -docstring 'ripgrep all file'
 | 
			
		||||
map global find 'g' ': find_git_file<ret>' -docstring 'git files'
 | 
			
		||||
map global find 'm' ': find_git_modified<ret>' -docstring 'git modified files'
 | 
			
		||||
map global find 'c' ': find_dir<ret>' -docstring 'change dir'
 | 
			
		||||
map global find 'd' ': find_delete<ret>' -docstring 'file to delete'
 | 
			
		||||
 | 
			
		||||
define-command -override -hidden find_file \
 | 
			
		||||
%{ evaluate-commands %sh{
 | 
			
		||||
    for line in `fd --strip-cwd-prefix -tf -HE .git | bmenu`; do
 | 
			
		||||
        echo "edit '$line'"
 | 
			
		||||
    done
 | 
			
		||||
} }
 | 
			
		||||
 | 
			
		||||
define-command -override -hidden find_delete \
 | 
			
		||||
%{ nop %sh{
 | 
			
		||||
    fd --strip-cwd-prefix -H -E .git -t f | bmenu | xargs -r trash
 | 
			
		||||
} }
 | 
			
		||||
 | 
			
		||||
define-command -override -hidden find_git_file \
 | 
			
		||||
%{ evaluate-commands %sh{
 | 
			
		||||
    for line in `git ls-files | bmenu`; do
 | 
			
		||||
        echo "edit -existing '$line'"
 | 
			
		||||
    done
 | 
			
		||||
} }
 | 
			
		||||
 | 
			
		||||
define-command -override -hidden find_git_modified \
 | 
			
		||||
%{ evaluate-commands %sh{
 | 
			
		||||
    for line in `git status --porcelain | sd '^.. ' ''| bmenu`; do
 | 
			
		||||
        echo "edit -existing '$line'"
 | 
			
		||||
    done
 | 
			
		||||
} }
 | 
			
		||||
 | 
			
		||||
define-command -override -hidden find_dir \
 | 
			
		||||
%{ cd %sh{
 | 
			
		||||
    for line in `fd --strip-cwd-prefix -Htd | bmenu`; do
 | 
			
		||||
        echo "edit '$line'"
 | 
			
		||||
    done
 | 
			
		||||
} }
 | 
			
		||||
 | 
			
		||||
define-command -override -hidden find_buffer \
 | 
			
		||||
%{ evaluate-commands %sh{
 | 
			
		||||
    for line in `printf "%s\n" $kak_buflist | bmenu`; do
 | 
			
		||||
        echo "buffer '$line'"
 | 
			
		||||
    done
 | 
			
		||||
} }
 | 
			
		||||
 | 
			
		||||
define-command -override -hidden find_ripgrep \
 | 
			
		||||
%{ evaluate-commands %sh{
 | 
			
		||||
    patter=$( bmenu -p "Regex")
 | 
			
		||||
    rg --column -n "$patter" | bmenu |
 | 
			
		||||
        perl -ne 'print "edit \"$1\" \"$2\" \"$3\" " if /(.+):(\d+):(\d+):/'
 | 
			
		||||
} }
 | 
			
		||||
 | 
			
		||||
define-command -override -hidden find_line \
 | 
			
		||||
%{ evaluate-commands -save-regs a %{
 | 
			
		||||
        execute-keys %{Z%"ayz}
 | 
			
		||||
        execute-keys %sh{
 | 
			
		||||
            line=$(
 | 
			
		||||
                printf "%s\n" "$kak_reg_a" |
 | 
			
		||||
                nl -ba -w1 |
 | 
			
		||||
                bmenu -p "Line" |
 | 
			
		||||
                cut -f1
 | 
			
		||||
            )
 | 
			
		||||
            test -n "$line" && echo "${line}gx"
 | 
			
		||||
        }
 | 
			
		||||
} }
 | 
			
		||||
 | 
			
		||||
define-command -override -hidden tree \
 | 
			
		||||
%{ evaluate-commands %sh{
 | 
			
		||||
    file=`mktemp`
 | 
			
		||||
    terminal --class file_picker ranger --selectfile="$kak_buffile" --choosefiles="$file"
 | 
			
		||||
    for line in `cat "$file"`; do
 | 
			
		||||
        echo "edit '$line'"
 | 
			
		||||
    done
 | 
			
		||||
    rm "$file"
 | 
			
		||||
} }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
define-command -override -params .. \
 | 
			
		||||
-shell-script-candidates 'zoxide query -l' \
 | 
			
		||||
zoxide %{
 | 
			
		||||
    cd %sh{ zoxide query -- "$@" || echo "$@" }
 | 
			
		||||
    echo %sh{ pwd | sed "s|$HOME|~|" }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
define-command -override  config-source %{
 | 
			
		||||
    source "%val{config}/kakrc"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
define-command -override git-merge-head %{
 | 
			
		||||
    evaluate-commands -draft %{
 | 
			
		||||
        # delete head marker
 | 
			
		||||
        execute-keys <a-/>^<lt>{4,}<ret><a-x>d
 | 
			
		||||
        try %{
 | 
			
		||||
            # select original marker
 | 
			
		||||
            execute-keys /^[|]{4,}<ret>
 | 
			
		||||
            # extend to theirs marker
 | 
			
		||||
            execute-keys ?^={4,}<ret><a-x>
 | 
			
		||||
        } catch %{
 | 
			
		||||
            # select theirs marker
 | 
			
		||||
            execute-keys /^={4,}<ret><a-x>
 | 
			
		||||
        }
 | 
			
		||||
        # extend to end marker
 | 
			
		||||
        execute-keys ?^<gt>{4,}<ret><a-x>d
 | 
			
		||||
    }
 | 
			
		||||
} -docstring "merge using head"
 | 
			
		||||
 | 
			
		||||
define-command -override git-merge-original %{
 | 
			
		||||
    evaluate-commands -draft %{
 | 
			
		||||
        # select head marker
 | 
			
		||||
        execute-keys <a-/>^<lt>{4,}<ret>
 | 
			
		||||
        # select to middle of conflict
 | 
			
		||||
        execute-keys ?^[|]{4,}<ret><a-x>d
 | 
			
		||||
        # select theirs marker
 | 
			
		||||
        execute-keys /^={4,}<ret>
 | 
			
		||||
        # extend to end marker
 | 
			
		||||
        execute-keys ?^<gt>{4,}<ret><a-x>d
 | 
			
		||||
    }
 | 
			
		||||
} -docstring "merge using original"
 | 
			
		||||
 | 
			
		||||
define-command -override git-merge-new %{
 | 
			
		||||
    evaluate-commands -draft %{
 | 
			
		||||
        # select head marker
 | 
			
		||||
        execute-keys <a-/>^<lt>{4,}<ret>
 | 
			
		||||
        # extend to theirs marker
 | 
			
		||||
        execute-keys ?^={4,}\n<ret>d
 | 
			
		||||
        # delete end marker
 | 
			
		||||
        execute-keys /^<gt>{4,}<ret><a-x>d
 | 
			
		||||
    }
 | 
			
		||||
} -docstring "merge using new"
 | 
			
		||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue