Move kakoune module
This commit is contained in:
parent
a4494d86d4
commit
05396972fa
12 changed files with 10 additions and 10 deletions
160
user/kakoune/default.nix
Normal file
160
user/kakoune/default.nix
Normal file
|
@ -0,0 +1,160 @@
|
|||
{ config, pkgs, lib, font, ... }:
|
||||
let
|
||||
inherit (pkgs.uservars) key theme accent font dmenu editor;
|
||||
inherit (theme) color;
|
||||
in
|
||||
{
|
||||
config = {
|
||||
programs.kakoune = {
|
||||
enable = true;
|
||||
extraConfig =
|
||||
let
|
||||
colors = lib.mapAttrs (_: lib.replaceStrings [ "#" ] [ "rgb:" ]) {
|
||||
accent_fg = accent.fg;
|
||||
accent_color = accent.color;
|
||||
bg_light = color.bg_light;
|
||||
bg_dark = color.bg_dark;
|
||||
nontxt = color.nontxt;
|
||||
orange = color.normal.orange;
|
||||
brown = color.normal.brown;
|
||||
};
|
||||
in
|
||||
with colors;
|
||||
lib.concatStringsSep "\n"
|
||||
(map (lib.readFile) ([
|
||||
./filetypes.kak
|
||||
./hooks.kak
|
||||
./indent.kak
|
||||
./keys.kak
|
||||
./plug.kak
|
||||
./usermode.kak
|
||||
./git-mode.kak
|
||||
] ++ lib.optional (dmenu == "rofi") ./rofi-commands.kak)) + ''
|
||||
|
||||
set global scrolloff 10,20
|
||||
set global autoreload yes
|
||||
set global startup_info_version 20200901
|
||||
|
||||
'' + ''
|
||||
face global crosshairs_line default,${bg_dark}
|
||||
face global crosshairs_column default+b
|
||||
|
||||
# For Code
|
||||
face global value magenta
|
||||
face global type yellow
|
||||
face global variable blue
|
||||
face global module ${brown}
|
||||
face global function ${orange}
|
||||
face global string green
|
||||
face global keyword ${accent_color}
|
||||
face global operator yellow
|
||||
face global attribute cyan
|
||||
face global comment ${bg_light}
|
||||
face global documentation comment
|
||||
face global meta +i@function
|
||||
face global builtin blue
|
||||
|
||||
# For markup
|
||||
face global title blue
|
||||
face global header cyan
|
||||
face global mono green
|
||||
face global block magenta
|
||||
face global link cyan
|
||||
face global bullet cyan
|
||||
face global list yellow
|
||||
|
||||
# builtin faces
|
||||
face global Default default,default
|
||||
|
||||
face global PrimaryCursor ${accent_fg},${accent_color}+fg
|
||||
face global PrimaryCursorEol PrimaryCursor
|
||||
face global PrimarySelection default,${bg_light}+f
|
||||
|
||||
face global SecondaryCursor default,default+rfg
|
||||
face global SecondaryCursorEol SecondaryCursor
|
||||
face global SecondarySelection PrimarySelection
|
||||
|
||||
face global InactiveCursor ${accent_fg},${bg_light}+fg
|
||||
|
||||
face global MenuForeground ${accent_fg},${accent_color}
|
||||
face global MenuBackground default,${bg_dark}
|
||||
face global MenuInfo cyan
|
||||
|
||||
face global Information default,${bg_dark}
|
||||
face global Error default,red+g
|
||||
|
||||
face global StatusLine %sh{
|
||||
printf "rgb:"
|
||||
head /dev/urandom |
|
||||
base64 |
|
||||
rg --text -o "${color.random_range}" |
|
||||
head -n 6 |
|
||||
sd '\n' ""
|
||||
}
|
||||
face global StatusLineMode StatusLine
|
||||
face global StatusLineInfo StatusLine
|
||||
face global StatusLineValue StatusLine
|
||||
face global StatusCursor ${accent_fg},${accent_color}
|
||||
|
||||
face global Prompt yellow,default
|
||||
try %{add-highlighter global/ show-matching}
|
||||
face global MatchingChar ${accent_color},default+b
|
||||
|
||||
# Goodies
|
||||
try %{add-highlighter global/number-lines number-lines -relative -hlcursor}
|
||||
face global LineNumbers ${bg_light},default
|
||||
face global LineNumberCursor default,${bg_dark}
|
||||
face global LineNumbersWrapped red,default
|
||||
|
||||
try %{add-highlighter global/ show-whitespaces}
|
||||
face global Whitespace ${nontxt},default+f
|
||||
face global BufferPadding ${nontxt},default
|
||||
## highlight trailing whitespace
|
||||
# add-highlighter global/ regex '\h*$' 0:red,red+u
|
||||
|
||||
face global Reference default+bu
|
||||
face global InlayHint ${bg_light}+buif
|
||||
|
||||
# Lsp
|
||||
'' + (lib.concatStringsSep "\n" (lib.mapAttrsToList
|
||||
(name: color: ''
|
||||
face global HighlightDiagnostic${name} ${color},default+bu
|
||||
face global Diagnostic${name} ${color},default+bu
|
||||
face global TextDiagnostic${name} ${color},default+b
|
||||
face global InlayDiagnostic${name} ${color},default+br
|
||||
'')
|
||||
{
|
||||
Error = "red";
|
||||
Warning = "yellow";
|
||||
Hint = "blue";
|
||||
}));
|
||||
};
|
||||
home.file = { ".config/kak-lsp/kak-lsp.toml".source = ./kak-lsp.toml; };
|
||||
home.packages = with pkgs; [
|
||||
kakoune
|
||||
terminal
|
||||
ranger
|
||||
bmenu
|
||||
kak-lsp
|
||||
kak-pager
|
||||
kak-man-pager
|
||||
|
||||
aspell
|
||||
aspellDicts.en
|
||||
aspellDicts.pt_BR
|
||||
];
|
||||
home.activation = {
|
||||
update_kakoune = lib.hm.dag.entryAfter [ "writeBoundary" ] ''
|
||||
$DRY_RUN_CMD kak -clear &&
|
||||
$DRY_RUN_CMD kak -l | xargs -r -n1 kak -e "config-source;quit" -ui dummy -c ||
|
||||
$DRY_RUN_CMD true
|
||||
'';
|
||||
};
|
||||
home.sessionVariables = lib.mkIf (editor == "kakoune") {
|
||||
EDITOR = "kak";
|
||||
# Some plugins(kak_ansi) like to compile stuff
|
||||
CC = "cc";
|
||||
};
|
||||
};
|
||||
}
|
||||
|
259
user/kakoune/filetypes.kak
Normal file
259
user/kakoune/filetypes.kak
Normal file
|
@ -0,0 +1,259 @@
|
|||
|
||||
try %{
|
||||
require-module python
|
||||
add-highlighter shared/python/code/function regex '\b([a-zA-Z_][a-zA-Z0-9_]*)\s*\(' 1:function
|
||||
}
|
||||
|
||||
hook global BufWritePre '.*' %{
|
||||
try format
|
||||
}
|
||||
|
||||
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 WinSetOption filetype=nix %{
|
||||
set buffer formatcmd 'nixpkgs-fmt'
|
||||
}
|
||||
|
||||
hook global BufCreate .*\.rs %{
|
||||
set buffer formatcmd 'rustfmt'
|
||||
}
|
||||
|
||||
hook global BufCreate .*\.html %{
|
||||
set buffer formatcmd 'prettier --parser html'
|
||||
}
|
||||
|
||||
hook global BufCreate .*\.component\.html %{
|
||||
set buffer filetype angular
|
||||
}
|
||||
|
||||
hook global WinSetOption filetype=angular %[
|
||||
set-option buffer extra_word_chars '_' '-'
|
||||
|
||||
require-module html
|
||||
add-highlighter buffer/angular ref 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=rust %[
|
||||
require-module rust
|
||||
|
||||
add-highlighter window/rust-custom regions
|
||||
|
||||
require-module html
|
||||
add-highlighter window/rust-custom/html region -recurse '\{' 'html!\s*\{\K' '(?=\})' ref html
|
||||
|
||||
require-module sql
|
||||
add-highlighter window/rust-custom/sql region 'r#"\K--\s*sql' '"#' group
|
||||
add-highlighter window/rust-custom/sql/ fill white
|
||||
add-highlighter window/rust-custom/sql/ ref sql
|
||||
]
|
||||
|
||||
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-&> ]
|
||||
]
|
||||
]
|
||||
|
||||
§
|
64
user/kakoune/git-mode.kak
Normal file
64
user/kakoune/git-mode.kak
Normal file
|
@ -0,0 +1,64 @@
|
|||
try %{
|
||||
# declare-user-mode surround
|
||||
declare-user-mode git
|
||||
}
|
||||
|
||||
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'
|
||||
|
||||
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"
|
54
user/kakoune/hooks.kak
Normal file
54
user/kakoune/hooks.kak
Normal file
|
@ -0,0 +1,54 @@
|
|||
set global idle_timeout 500
|
||||
|
||||
hook global NormalIdle .* %{ evaluate-commands %sh{
|
||||
hex_with_size() {
|
||||
for i in 3 4 6 8; do
|
||||
printf "[0-9a-f]{$i}|"
|
||||
done
|
||||
}
|
||||
echo "$kak_selection" | grep -P "^#?($(hex_with_size))$" > /dev/null &&
|
||||
echo '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 -1000 --oneline<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
|
||||
|
33
user/kakoune/indent.kak
Normal file
33
user/kakoune/indent.kak
Normal file
|
@ -0,0 +1,33 @@
|
|||
# {{@@ header() @@}}
|
||||
# _ __ _
|
||||
# | |/ /__ _| | _____ _ _ _ __ ___
|
||||
# | ' // _` | |/ / _ \| | | | '_ \ / _ \
|
||||
# | . \ (_| | < (_) | |_| | | | | __/
|
||||
# |_|\_\__,_|_|\_\___/ \__,_|_| |_|\___|
|
||||
|
||||
set global tabstop 4
|
||||
|
||||
hook global BufCreate .*\.py %{
|
||||
set global indentwidth 4
|
||||
}
|
||||
|
||||
hook global BufCreate .*\.nix %{
|
||||
set global indentwidth 2
|
||||
}
|
||||
|
||||
#################################################################
|
||||
# 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
|
||||
}
|
302
user/kakoune/kak-lsp.toml
Normal file
302
user/kakoune/kak-lsp.toml
Normal file
|
@ -0,0 +1,302 @@
|
|||
snippet_support = false
|
||||
verbosity = 2
|
||||
|
||||
[server]
|
||||
# exit session if no requests were received during given period in seconds
|
||||
# works only in unix sockets mode (-s/--session)
|
||||
# set to 0 to disable
|
||||
timeout = 1800 # seconds = 30 minutes
|
||||
|
||||
[language.angular]
|
||||
filetypes = ["angular"]
|
||||
roots = [".angular", ".git"]
|
||||
command = "node"
|
||||
args = [
|
||||
"/home/lelgenio/.config/yarn/global/node_modules/@angular/language-server",
|
||||
"--ngProbeLocations",
|
||||
"/home/lelgenio/.config/yarn/global/node_modules",
|
||||
"--tsProbeLocations",
|
||||
"/home/lelgenio/.config/yarn/global/node_modules",
|
||||
"--stdio",
|
||||
]
|
||||
|
||||
[language.bash]
|
||||
filetypes = ["sh"]
|
||||
roots = [".git", ".hg"]
|
||||
command = "bash-language-server"
|
||||
args = ["start"]
|
||||
|
||||
[language.c_cpp]
|
||||
filetypes = ["c", "cpp"]
|
||||
roots = [ "compile_commands.json", ".clangd", ".git" ]
|
||||
command = "clangd"
|
||||
|
||||
[language.crystal]
|
||||
filetypes = ["crystal"]
|
||||
roots = ["shard.yml"]
|
||||
command = "scry"
|
||||
|
||||
[language.css]
|
||||
filetypes = ["css"]
|
||||
roots = ["package.json"]
|
||||
command = "vscode-css-languageserver"
|
||||
args = ["--stdio"]
|
||||
|
||||
[language.less]
|
||||
filetypes = ["less"]
|
||||
roots = ["package.json", ".git"]
|
||||
command = "vscode-css-languageserver"
|
||||
args = ["--stdio"]
|
||||
|
||||
[language.d]
|
||||
filetypes = ["d", "di"]
|
||||
roots = [".git", "dub.sdl", "dub.json"]
|
||||
command = "dls"
|
||||
|
||||
[language.dart]
|
||||
# start shell to find path to dart analysis server source
|
||||
filetypes = ["dart"]
|
||||
roots = ["pubspec.yaml", ".git"]
|
||||
command = "sh"
|
||||
args = ["-c", "dart $(dirname $(which dart))/snapshots/analysis_server.dart.snapshot --lsp"]
|
||||
|
||||
[language.elm]
|
||||
filetypes = ["elm"]
|
||||
roots = ["elm.json"]
|
||||
command = "elm-language-server"
|
||||
args = ["--stdio"]
|
||||
|
||||
# [language.elm.initialization_options]
|
||||
# runtime = "node"
|
||||
# elmPath = "elm"
|
||||
# elmFormatPath = "elm-format"
|
||||
# elmTestPath = "elm-test"
|
||||
|
||||
[language.go]
|
||||
filetypes = ["go"]
|
||||
roots = ["Gopkg.toml", "go.mod", ".git", ".hg"]
|
||||
command = "gopls"
|
||||
offset_encoding = "utf-8"
|
||||
|
||||
[language.haskell]
|
||||
filetypes = ["haskell"]
|
||||
roots = ["Setup.hs", "stack.yaml", "*.cabal"]
|
||||
command = "haskell-language-server-wrapper"
|
||||
args = ["--lsp"]
|
||||
|
||||
[language.html]
|
||||
filetypes = ["html"]
|
||||
roots = ["package.json"]
|
||||
command = "vscode-html-languageserver"
|
||||
args = ["--stdio"]
|
||||
|
||||
[language.javascript]
|
||||
filetypes = ["javascript"]
|
||||
roots = [".flowconfig"]
|
||||
command = "flow"
|
||||
args = ["lsp"]
|
||||
|
||||
[language.typescript]
|
||||
filetypes = ["typescript"]
|
||||
roots = ["package.json"]
|
||||
command = "typescript-language-server"
|
||||
args = ["--stdio"]
|
||||
|
||||
[language.json]
|
||||
filetypes = ["json"]
|
||||
roots = ["package.json"]
|
||||
command = "vscode-json-languageserver"
|
||||
args = ["--stdio"]
|
||||
|
||||
[language.latex]
|
||||
filetypes = ["latex"]
|
||||
roots = [".git"]
|
||||
command = "texlab"
|
||||
|
||||
[language.nim]
|
||||
filetypes = ["nim"]
|
||||
roots = ["*.nimble", ".git"]
|
||||
command = "nimlsp"
|
||||
|
||||
[language.nix]
|
||||
filetypes = ["nix"]
|
||||
roots = ["flake.nix", "shell.nix", ".git"]
|
||||
command = "rnix-lsp"
|
||||
[language.nix.settings.nil]
|
||||
formatting.command = [ "nixpkgs-fmt" ]
|
||||
|
||||
[language.ocaml]
|
||||
filetypes = ["ocaml"]
|
||||
roots = ["Makefile", "opam", "*.opam", "dune"]
|
||||
command = "ocaml-language-server"
|
||||
args = ["--stdio"]
|
||||
|
||||
[language.php]
|
||||
filetypes = ["php"]
|
||||
roots = [".htaccess", "composer.json"]
|
||||
command = "intelephense"
|
||||
args = ["--stdio"]
|
||||
settings_section = "intelephense"
|
||||
[language.php.settings]
|
||||
intelephense.format.braces = "k&r"
|
||||
intelephense.storagePath = "/tmp/intelephense"
|
||||
intelephense.environment.includePaths = [
|
||||
"./vendor",
|
||||
"./vendor/autoload",
|
||||
"./vendor/laravel/framework/",
|
||||
"./vendor/laravel/framework/src/",
|
||||
"./vendor/laravel/framework/src/Illuminate/"
|
||||
]
|
||||
intelephense.files.exclude = [
|
||||
"**/.git/**",
|
||||
"**/.svn/**",
|
||||
"**/.hg/**",
|
||||
"**/CVS/**",
|
||||
"**/.DS_Store/**",
|
||||
"**/node_modules/**",
|
||||
"**/bower_components/**",
|
||||
"**/resources/views/**"
|
||||
]
|
||||
|
||||
[language.python]
|
||||
filetypes = ["python"]
|
||||
roots = ["requirements.txt", "setup.py", ".git", ".hg"]
|
||||
command = "pyls"
|
||||
offset_encoding = "utf-8"
|
||||
|
||||
[language.reason]
|
||||
filetypes = ["reason"]
|
||||
roots = ["package.json", "Makefile", ".git", ".hg"]
|
||||
command = "ocaml-language-server"
|
||||
args = ["--stdio"]
|
||||
|
||||
[language.ruby]
|
||||
filetypes = ["ruby"]
|
||||
roots = ["Gemfile"]
|
||||
command = "solargraph"
|
||||
args = ["stdio"]
|
||||
|
||||
# [language.rust]
|
||||
# filetypes = ["rust"]
|
||||
# roots = ["Cargo.toml"]
|
||||
# command = "sh"
|
||||
# args = [
|
||||
# "-c",
|
||||
# """
|
||||
# if path=$(rustup which rls 2>/dev/null); then
|
||||
# "$path"
|
||||
# else
|
||||
# rls
|
||||
# fi
|
||||
# """,
|
||||
# ]
|
||||
|
||||
[language.rust]
|
||||
filetypes = ["rust"]
|
||||
roots = ["rust-toolchain.toml", "rust-toolchain", "Cargo.toml"]
|
||||
command = "sh"
|
||||
args = [
|
||||
"-c",
|
||||
"""
|
||||
if path=$(rustup which rust-analyzer 2>/dev/null); then
|
||||
"$path"
|
||||
else
|
||||
rust-analyzer
|
||||
fi
|
||||
""",
|
||||
]
|
||||
[language.rust.settings.rust-analyzer]
|
||||
## this can use too much space and processing power
|
||||
# checkOnSave.extraArgs = ["--target-dir", "./target/check"]
|
||||
hoverActions.enable = false # kak-lsp doesn't support this at the moment
|
||||
# procMacro.enable = true
|
||||
# cargo.loadOutDirsFromCheck = true
|
||||
rustfmt.rangeFormatting.enable = true
|
||||
rustfmt.extraArgs = ["+nightly"]
|
||||
|
||||
[language.terraform]
|
||||
filetypes = ["terraform"]
|
||||
roots = ["*.tf"]
|
||||
command = "terraform-ls"
|
||||
args = ["serve"]
|
||||
|
||||
[language.godot]
|
||||
filetypes = ["gd", "gdscript", "gdscript3"]
|
||||
roots = ["project.godot", ".git/"]
|
||||
command = "nc"
|
||||
args = [ "localhost", "6008"]
|
||||
|
||||
[language.clojure]
|
||||
filetypes = ["clojure"]
|
||||
roots = ["project.clj", ".git/"]
|
||||
command = "clojure-lsp"
|
||||
args = []
|
||||
|
||||
|
||||
|
||||
|
||||
[semantic_scopes]
|
||||
# Map textmate scopes to kakoune faces for semantic highlighting
|
||||
# the underscores are translated to dots, and indicate nesting.
|
||||
# That is, if variable_other_field is omitted, it will try the face for
|
||||
# variable_other and then variable
|
||||
#
|
||||
# To see a list of available scopes in the debug buffer, run lsp-semantic-available-scopes
|
||||
variable = "variable"
|
||||
entity_name_function = "function"
|
||||
entity_name_type = "type"
|
||||
variable_other_enummember = "variable"
|
||||
entity_name_namespace = "module"
|
||||
|
||||
[semantic_modifiers]
|
||||
documentation = "documentation"
|
||||
readonly = "default+d"
|
||||
|
||||
|
||||
|
||||
[[semantic_tokens]]
|
||||
token = "comment"
|
||||
face = "documentation"
|
||||
modifiers = ["documentation"]
|
||||
|
||||
[[semantic_tokens]]
|
||||
token = "comment"
|
||||
face = "comment"
|
||||
|
||||
[[semantic_tokens]]
|
||||
token = "function"
|
||||
face = "function"
|
||||
|
||||
[[semantic_tokens]]
|
||||
token = "keyword"
|
||||
face = "keyword"
|
||||
|
||||
[[semantic_tokens]]
|
||||
token = "namespace"
|
||||
face = "module"
|
||||
|
||||
[[semantic_tokens]]
|
||||
token = "operator"
|
||||
face = "operator"
|
||||
|
||||
[[semantic_tokens]]
|
||||
token = "string"
|
||||
face = "string"
|
||||
|
||||
[[semantic_tokens]]
|
||||
token = "type"
|
||||
face = "type"
|
||||
|
||||
[[semantic_tokens]]
|
||||
token = "variable"
|
||||
face = "default+d"
|
||||
modifiers = ["readonly"]
|
||||
|
||||
[[semantic_tokens]]
|
||||
token = "variable"
|
||||
face = "default+d"
|
||||
modifiers = ["constant"]
|
||||
|
||||
[[semantic_tokens]]
|
||||
token = "variable"
|
||||
face = "variable"
|
20
user/kakoune/kakrc
Normal file
20
user/kakoune/kakrc
Normal file
|
@ -0,0 +1,20 @@
|
|||
# {{@@ 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/git-mode.kak"
|
||||
source "%val{config}/rc/hooks.kak"
|
||||
source "%val{config}/rc/filetypes.kak"
|
||||
source "%val{config}/rc/indent.kak"
|
||||
source "%val{config}/colors.kak"
|
39
user/kakoune/keys.kak
Normal file
39
user/kakoune/keys.kak
Normal file
|
@ -0,0 +1,39 @@
|
|||
# {{@@ header() @@}}
|
||||
|
||||
# For colemak, this is pretty confortable, C-n = down, C-u = up
|
||||
map global normal <c-u> 10k
|
||||
map global normal <c-n> 10j
|
||||
|
||||
# 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'
|
||||
|
103
user/kakoune/plug.kak
Normal file
103
user/kakoune/plug.kak
Normal file
|
@ -0,0 +1,103 @@
|
|||
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>' -docstring 'mirror mode'
|
||||
}
|
||||
|
||||
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 %{
|
||||
rustup target add x86_64-unknown-linux-musl
|
||||
cargo install --locked --force --path . --target x86_64-unknown-linux-musl
|
||||
} 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
|
||||
}
|
||||
decl -hidden -docstring "Timestamp of the last check" int last_modified
|
||||
hook window RawKey .* %{
|
||||
eval %sh{
|
||||
if [ "${kak_opt_last_modified}" != "${kak_timestamp}" ]; then
|
||||
echo "unset-option buffer lsp_inlay_diagnostics"
|
||||
echo "unset-option buffer lsp_inlay_hints"
|
||||
fi
|
||||
}
|
||||
set current last_modified %val{timestamp}
|
||||
}
|
||||
}
|
||||
|
||||
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}"
|
||||
}
|
||||
|
46
user/kakoune/rofi-commands.kak
Normal file
46
user/kakoune/rofi-commands.kak
Normal file
|
@ -0,0 +1,46 @@
|
|||
define-command -override -hidden find_file \
|
||||
%{ evaluate-commands %sh{
|
||||
for line in `rofi -sort -show file-browser-extended -file-browser-depth 0 -file-browser-no-descend -file-browser-stdout -p "File: "`; do
|
||||
echo "edit '$line'"
|
||||
done
|
||||
} }
|
||||
|
||||
define-command -override -hidden find_delete \
|
||||
%{ nop %sh{
|
||||
rofi -sort -show file-browser-extended -file-browser-depth 0 -file-browser-no-descend -file-browser-stdout | xargs -r trash
|
||||
} }
|
||||
|
||||
define-command -override -hidden find_git_file \
|
||||
%{ evaluate-commands %sh{
|
||||
for line in `git ls-files | rofi -sort -show file-browser-extended -file-browser-depth 0 -file-browser-no-descend -file-browser-stdout -file-browser-stdin`; do
|
||||
echo "edit -existing '$line'"
|
||||
done
|
||||
} }
|
||||
|
||||
define-command -override -hidden find_git_modified \
|
||||
%{ evaluate-commands %sh{
|
||||
for line in `git status --porcelain | sd '^.. ' ''| rofi -sort -show file-browser-extended -file-browser-no-descend -file-browser-stdout -file-browser-stdin`; do
|
||||
echo "edit -existing '$line'"
|
||||
done
|
||||
} }
|
||||
|
||||
define-command -override -hidden find_dir \
|
||||
%{ cd %sh{
|
||||
for line in `fd --strip-cwd-prefix -Htd | rofi -sort -show file-browser-extended -file-browser-no-descend -file-browser-stdout -file-browser-stdin`; do
|
||||
echo "edit '$line'"
|
||||
done
|
||||
} }
|
||||
|
||||
define-command -override -hidden find_buffer \
|
||||
%{ evaluate-commands %sh{
|
||||
for line in `printf "%s\n" $kak_buflist | wdmenu -i`; do
|
||||
echo "buffer '$line'"
|
||||
done
|
||||
} }
|
||||
|
||||
define-command -override -hidden tree \
|
||||
%{ evaluate-commands %sh{
|
||||
for line in `rofi -sort -show file-browser-extended -file-browser-stdout`; do
|
||||
echo "edit '$line'"
|
||||
done
|
||||
} }
|
128
user/kakoune/usermode.kak
Normal file
128
user/kakoune/usermode.kak
Normal file
|
@ -0,0 +1,128 @@
|
|||
try %{
|
||||
# declare-user-mode surround
|
||||
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 format-buffer catch lsp-formatting-sync<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 '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'
|
||||
|
||||
map global user 'S' ': find_spell<ret>' -docstring 'pick language for spellchecking'
|
||||
|
||||
define-command -override -hidden find_spell \
|
||||
%{ evaluate-commands %sh{
|
||||
for line in `aspell dump dicts | wdmenu -i -p "Language: "`; do
|
||||
echo "spell '$line'"
|
||||
done
|
||||
} }
|
||||
|
||||
define-command -override -hidden find_file \
|
||||
%{ evaluate-commands %sh{
|
||||
for line in `fd --strip-cwd-prefix -tf -HE .git | wdmenu -i -p "File: "`; do
|
||||
echo "edit '$line'"
|
||||
done
|
||||
} }
|
||||
|
||||
define-command -override -hidden find_delete \
|
||||
%{ nop %sh{
|
||||
fd --strip-cwd-prefix -H -E .git -t f | wdmenu -i | xargs -r trash
|
||||
} }
|
||||
|
||||
define-command -override -hidden find_git_file \
|
||||
%{ evaluate-commands %sh{
|
||||
for line in `git ls-files | wdmenu -i`; do
|
||||
echo "edit -existing '$line'"
|
||||
done
|
||||
} }
|
||||
|
||||
define-command -override -hidden find_git_modified \
|
||||
%{ evaluate-commands %sh{
|
||||
for line in `git status --porcelain | sd '^.. ' ''| wdmenu -i`; do
|
||||
echo "edit -existing '$line'"
|
||||
done
|
||||
} }
|
||||
|
||||
define-command -override -hidden find_dir \
|
||||
%{ cd %sh{
|
||||
for line in `fd --strip-cwd-prefix -Htd | wdmenu -i`; do
|
||||
echo "edit '$line'"
|
||||
done
|
||||
} }
|
||||
|
||||
define-command -override -hidden find_buffer \
|
||||
%{ evaluate-commands %sh{
|
||||
for line in `printf "%s\n" $kak_buflist | wdmenu -i`; do
|
||||
echo "buffer '$line'"
|
||||
done
|
||||
} }
|
||||
|
||||
define-command -override -hidden find_ripgrep \
|
||||
%{ evaluate-commands %sh{
|
||||
patter=$( wdmenu -i -p "Regex")
|
||||
rg --column -n "$patter" | wdmenu -i |
|
||||
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 |
|
||||
wdmenu -i -p "Line" |
|
||||
cut -f1
|
||||
)
|
||||
test -n "$line" && echo "${line}gx"
|
||||
}
|
||||
} }
|
||||
|
||||
define-command -override -hidden tree \
|
||||
%{ evaluate-commands %sh{
|
||||
file=`mktemp`
|
||||
terminal --class file_picker -e 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"
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue