You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. # Stolen from eraserhd
  2. declare-option -hidden regex curword
  3. declare-option -hidden regex curword_word_class
  4. set-face global CurWord +b
  5. add-highlighter global/current-word dynregex '%opt{curword}' 0:CurWord
  6. define-command -override -hidden highlight-curword %{
  7. eval -draft %{
  8. try %{
  9. execute-keys <space><a-i>w
  10. set-option buffer curword "(?<!%opt{curword_word_class})\Q%val{selection}\E(?!%opt{curword_word_class})"
  11. } catch %{
  12. set-option buffer curword ''
  13. }
  14. }
  15. }
  16. define-command -override -hidden make-curword-word-class %{
  17. evaluate-commands %sh{
  18. eval set -- "$kak_quoted_opt_extra_word_chars"
  19. word_class='['
  20. while [ $# -ne 0 ]; do
  21. case "$1" in
  22. -) word_class="$word_class-";;
  23. esac
  24. shift
  25. done
  26. word_class="$word_class"'\w'
  27. eval set -- "$kak_quoted_opt_extra_word_chars"
  28. while [ $# -ne 0 ]; do
  29. case "$1" in
  30. "-") ;;
  31. "]") word_class="$word_class"'\]';;
  32. "'") word_class="$word_class''";;
  33. *) word_class="$word_class$1";;
  34. esac
  35. shift
  36. done
  37. word_class="$word_class]"
  38. printf "set-option window curword_word_class '%s'\\n" "$word_class"
  39. }
  40. }
  41. hook -group highlight-curword global NormalIdle .* highlight-curword
  42. hook -group highlight-curword global WinSetOption extra_word_chars=.* make-curword-word-class