diff options
| -rw-r--r-- | .gitignore | 1 | ||||
| -rw-r--r-- | autoload/git.kak | 64 | ||||
| -rw-r--r-- | autoload/orgmode/orgmode.kak | 102 | ||||
| -rw-r--r-- | colors/phenax.kak | 100 |
4 files changed, 196 insertions, 71 deletions
diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3f1b426 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +dummy/ diff --git a/autoload/git.kak b/autoload/git.kak index 6f4015c..e0db3c4 100644 --- a/autoload/git.kak +++ b/autoload/git.kak @@ -3,12 +3,16 @@ define-command gitui -params .. %{ } declare-user-mode git +declare-user-mode git-r map global user g ': enter-user-mode git<ret>' -docstring 'Git mode' map global git s ': gitui<ret>' -docstring 'Git tui' map global git A ': git add %val{buffile}<ret>' -docstring 'Add file' map global git c ': git add commit<ret>' -docstring 'Commit' map global git C ': git add commit --amend<ret>' -docstring 'Amend commit' +map global git r ': enter-user-mode git-r<ret>' -docstring 'Git re(base/set) mode' +map global git-r f ': git reset HEAD^1 -- %val{buffile}<ret>' -docstring 'Split file out of last commit' + # Hunk map global git n ': git next-hunk<ret>' -docstring 'Next hunk' map global git p ': git prev-hunk<ret>' -docstring 'Previous hunk' @@ -20,56 +24,22 @@ set-option global git_diff_mod_char "~" set-option global git_diff_top_char "^" define-command git-toggle-diff %{ - try %{ remove-highlighter window/git-diff } catch %{ git show-diff } + try %{ remove-highlighter window/git-diff } catch %{ git show-diff } catch %{ } } # TODO: Toggle this -hook global -group git-diff-if-repo EnterDirectory .* %{ - remove-hooks global git-diff - evaluate-commands %sh{ - if (git rev-parse --is-inside-work-tree >/dev/null 2>&1); then - echo " - hook global -group git-diff ModeChange .*:.*:normal %{ try %{git update-diff} } - hook global -group git-diff WinCreate .* %{ try %{git update-diff} } - hook global -group git-diff BufReload .* %{ try %{git update-diff} } - " - fi - } -} - -# Git window actions - -# declare-option -hidden str git_file -# define-command -hidden git-eval-status-line %{ -# evaluate-commands %sh{ -# file=$(echo "$kak_selection" | sed 's/^\s*[A-Z?]\+\s\+//') -# echo "set-option window git_file '$file'" +# hook global -group git-diff-if-repo EnterDirectory .* %{ +# remove-hooks global git-diff +# try %{ +# evaluate-commands %sh{ +# if (git rev-parse --is-inside-work-tree >/dev/null 2>&1); then +# echo " +# hook global -group git-diff ModeChange .*:.*:normal %{ try %{git update-diff} } +# hook global -group git-diff WinCreate .* %{ try %{git update-diff} } +# hook global -group git-diff BufReload .* %{ try %{git update-diff} } +# " +# fi +# } # } # } -# declare-user-mode git-status-commit -# declare-user-mode git-status-log -# map global git s ':git status -bs<ret>' -docstring 'Git status UI' -# hook -group git-status global WinSetOption filetype=git-status %{ -# set-option buffer readonly true -# map window normal R ':git status -bs<ret>' -# map window normal q ': delete-buffer %val{buffile}<ret>' - -# map window user l ': enter-user-mode git-status-log<ret>' -# map window git-status-log l ': git log --oneline<ret>' -# map window normal d 'x: git-eval-status-line<ret>: git diff -- %opt{git_file}' - -# map window normal c ': enter-user-mode git-status-commit<ret>' -# map window git-status-commit c ': git commit<ret>' -# map window git-status-commit a ': git commit --amend<ret>' -# } - -# hook -group git-log global WinSetOption filetype=git-log %{ -# set-option buffer readonly true -# map window normal q ': git status -bs<ret>' -# } - -# hook -group git-diff global WinSetOption filetype=git-diff %{ -# set-option buffer readonly true -# map window normal q ': git status -bs<ret>' -# } diff --git a/autoload/orgmode/orgmode.kak b/autoload/orgmode/orgmode.kak new file mode 100644 index 0000000..15e3ba3 --- /dev/null +++ b/autoload/orgmode/orgmode.kak @@ -0,0 +1,102 @@ +hook global BufCreate .*[.]org %{ + set-option buffer filetype org +} + +declare-user-mode org +hook global WinSetOption filetype=org %{ + add-highlighter window/org ref org + require-module orgmode-highlight + + map window normal <ret> ': orgmode-jump-link<ret>' + map window user o ': enter-user-mode org<ret>' -docstring 'Org mode' + map window org <tab> ': orgmode-toggle<ret>' -docstring 'Toggle checkbox/task' +} + +define-command orgmode-toggle %{ + evaluate-commands -save-regs '#/' %{ + try %{ orgmode-toggle-checkbox } catch %{ orgmode-toggle-task-state } catch %{ } + } +} + +define-command orgmode-jump-link %{ + # TODO: support multiple links in single line + evaluate-commands -draft %{ try %{ + execute-keys ',xs\[\[([^\n\]]+)\]<ret>' + set-register a %reg{1} + } } + evaluate-commands %sh{ + [ -z "$kak_reg_a" ] && exit 0 + case "$kak_reg_a" in + https://*|http://*) xdg-open "$kak_reg_a" >/dev/null 2>&1 ;; + /*|~/*) echo "edit %{$kak_reg_a}" ;; + *) + current_path="${kak_buffile:-"$kak_bufname"}" + path="$(realpath -s "$(dirname "$kak_buffile")/$kak_reg_a")" + echo "edit %{$path}" + ;; + esac + } +} + +define-command orgmode-toggle-checkbox %{ + evaluate-commands %{ + execute-keys ',xs^(\h*-\h+)\[([Xx\- ])\]<ret>' + evaluate-commands %sh{ + next="$kak_reg_2" + case "$kak_reg_2" in + X|x) next=" " ;; + -) next="X" ;; + *) next="-" ;; + esac + echo "execute-keys 'c<c-r>1[$next]<esc>'" + } + } +} + +define-command orgmode-toggle-task-state %{ + evaluate-commands %{ + execute-keys ',xs^(\*+\h+)(TODO|ACTIVE|DONE)?<ret>' + evaluate-commands %sh{ + next="TODO " # Add space at end when no state + case "$kak_reg_2" in + TODO) next="ACTIVE" ;; + ACTIVE) next="DONE" ;; + DONE) next="TODO" ;; + esac + echo "execute-keys 'c<c-r>1$next<esc>'" + } + } +} + +provide-module orgmode-highlight %{ + add-highlighter shared/org regions + add-highlighter shared/org/inline default-region regions + add-highlighter shared/org/inline/text default-region group + + add-highlighter shared/org/inline/text/ regex \*[^\n*]+\* 0:inlineBold + add-highlighter shared/org/inline/text/ regex /[^\n/]+/ 0:inlineItalic + add-highlighter shared/org/inline/text/ regex _[^\n_]+_ 0:inlineUnderline + add-highlighter shared/org/inline/text/ regex \+[^\n+]+\+ 0:inlineStrikethrough + add-highlighter shared/org/inline/text/ regex ~[^\n~]+~ 0:inlineCode + add-highlighter shared/org/inline/text/ regex \[\[[^\n]+\]\] 0:inlineLink + add-highlighter shared/org/codeblock region -match-capture \ + ^\h*#\+(?:begin|BEGIN)_([a-zA-Z]*)[^\n]*$ \ + ^\h*#\+(?:end|END)_([a-zA-Z]*)[^\n]*$ \ + regions + add-highlighter shared/org/codeblock/ default-region fill orgCodeBlock + + add-highlighter shared/org/inline/text/ regex ^[*]{1}[^\n]* 0:header1 + add-highlighter shared/org/inline/text/ regex ^[*]{2}[^\n]* 0:header2 + add-highlighter shared/org/inline/text/ regex ^[*]{3}[^\n]* 0:header3 + add-highlighter shared/org/inline/text/ regex ^[*]{4}[^\n]* 0:header4 + add-highlighter shared/org/inline/text/ regex ^[*]{5}[^\n]* 0:header5 + add-highlighter shared/org/inline/text/ regex ^[*]{6}[^\n]* 0:header6 + + add-highlighter shared/org/inline/text/ regex ^[*]*\s+(TODO) 1:orgTaskStateTodo + add-highlighter shared/org/inline/text/ regex ^[*]*\s+(DONE) 1:orgTaskStateDone + add-highlighter shared/org/inline/text/ regex ^[*]*\s+(ACTIVE) 1:orgTaskStateActive + + add-highlighter shared/org/inline/text/ regex ^\s*-\s*(\[[xX]\])\h([^\n]+)$ 1:checkboxChecked 2:checkboxCheckedText + add-highlighter shared/org/inline/text/ regex ^\s*-\s*(\[[\s]\]) 1:checkboxTodo + add-highlighter shared/org/inline/text/ regex ^\s*-\s*(\[[-]\]) 1:checkboxPending +} diff --git a/colors/phenax.kak b/colors/phenax.kak index 2501e23..f12c454 100644 --- a/colors/phenax.kak +++ b/colors/phenax.kak @@ -1,52 +1,78 @@ evaluate-commands %sh{ foreground="rgb:c5c8c6" foreground2="rgb:90a0a0" + foreground3="rgb:709090" background="default" accent1="rgb:007070" accent2="rgb:009090" + accent3="rgb:2dd4bf" selection="rgb:373b41" window="rgb:282a2e" linenr_bg="default" linenr_fg="rgb:606262" linenr_fg_cur="rgb:ffffff" menu="rgb:101414" - mildhighlight="rgb:101414" + mildhighlight1="rgb:101414" + mildhighlight2="rgb:202424" comment="rgb:434545" red="rgb:cc6666" orange="rgb:de935f" yellow="rgb:f0c674" green="rgb:b3f6c0" - lightblue="rgb:81a2be" - brightblue="rgb:82aaff" + blue1="rgb:81a2be" + blue2="rgb:81dad9" + blue3="rgb:82aaff" aqua="rgb:8abeb7" purple="rgb:b294bb" + black="rgb:000000" ## code echo " - face global value ${lightblue} - face global type ${yellow} - face global variable ${lightblue} - face global module ${lightblue} - face global function ${lightblue} + face global value ${blue1} + face global type ${blue1} + face global variable ${blue1} + face global module ${blue1} + face global function ${blue2} face global string ${green} face global keyword ${accent2} face global operator ${aqua} - face global attribute ${lightblue} + face global attribute ${blue1} face global comment ${comment} face global documentation comment face global meta ${foreground} face global builtin ${yellow} + face global const_variable ${blue1} " ## markup echo " - face global title ${lightblue} - face global header ${aqua} + face global title ${blue1} + face global header ${accent2} face global mono ${green} face global block ${orange} - face global link ${lightblue} + face global link ${blue1} face global bullet ${red} face global list ${red} + face global inlineBold ${green}+b + face global inlineItalic +i + face global inlineStrikethrough ${foreground3}+fs + face global inlineUnderline ${foreground}+fu + face global inlineCode ${foreground2},${mildhighlight2}+a + face global inlineLink ${accent2}+a + face global header1 ${accent2}+b + face global header2 ${accent3}+b + face global header3 ${blue1}+b + face global header4 ${green}+b + face global header5 ${purple}+b + face global header6 ${aqua}+b + face global checkboxChecked ${foreground3} + face global checkboxCheckedText ${foreground3}+s + face global checkboxPending ${orange} + face global checkboxTodo ${red} + face global orgTaskStateTodo ${black},${red}+b + face global orgTaskStateDone ${black},${green}+b + face global orgTaskStateActive ${black},${orange}+b + face global orgCodeBlock ${foreground2},${mildhighlight1}+a " ## Custom @@ -57,28 +83,33 @@ evaluate-commands %sh{ face global RowLine default,rgb:101010 face global WrapLine default,rgb:101010 face global StatusLineBufname ${accent1},default+b - face global StatusLineDetails ${comment},default+b + face global WrapLine default,rgb:101010 + " + + # Cursor + echo " + face global PrimaryCursor black,${foreground}+fg + face global SecondaryCursor black,${foreground3}+fg + face global PrimaryCursorEol ${background},${green} + face global SecondaryCursorEol ${background},${green} + face global InsertCursor black,${orange}+fg " ## builtin echo " face global Default ${foreground},${background} - face global PrimarySelection ${foreground},${selection}+fg - face global SecondarySelection ${foreground},${window}+fg - face global PrimaryCursor ${background},${foreground}+fg - face global SecondaryCursor ${background},${aqua}+fg - face global PrimaryCursorEol ${background},${green}+fg - face global SecondaryCursorEol ${background},${green}+fg + face global PrimarySelection default,${selection} + face global SecondarySelection default,${window} face global LineNumbers ${linenr_fg},${linenr_bg} face global LineNumberCursor ${linenr_fg_cur},${linenr_bg}+b - face global LineNumbersWrapped ${mildhighlight},${linenr_bg}+b + face global LineNumbersWrapped ${mildhighlight1},${linenr_bg}+b face global MenuForeground ${background},${accent1} face global MenuBackground ${foreground},${menu} face global MenuInfo ${red} face global Information ${foreground2},${background} face global Error ${foreground},${red} - face global DiagnosticError ${red} - face global DiagnosticWarning ${yellow} + face global DiagnosticError ${red}+u + face global DiagnosticWarning ${yellow}+u face global StatusLine ${foreground},${background} face global StatusLineMode ${yellow}+b face global StatusLineInfo ${aqua},default @@ -87,10 +118,10 @@ evaluate-commands %sh{ face global Prompt ${accent1},${background} face global MatchingChar ${yellow},${background}+b face global BufferPadding ${aqua},${background} - face global Whitespace ${comment}+f + face global Whitespace ${mildhighlight2}+f " - ## code + ## treesitter echo " face global ts_value value face global ts_type type @@ -106,4 +137,25 @@ evaluate-commands %sh{ face global ts_meta meta face global ts_builtin builtin " + + ## lsp + echo " + face global LineFlagError ${red},default + face global LineFlagWarning ${orange},default + face global LineFlagHint ${purple},default + face global LineFlagInfo Information + face global InfoDefault Information + face global InfoBlock Information + face global InfoBlockQuote Information + face global InfoBullet Information + face global InfoHeader Information + face global InfoLink Information + face global InfoLinkMono Information + face global InfoMono Information + face global InfoRule Information + face global InfoDiagnosticError Information + face global InfoDiagnosticHint Information + face global InfoDiagnosticInformation Information + face global InfoDiagnosticWarning Information + " } |
