├── README.md ├── LICENSE └── crosshairs.kak /README.md: -------------------------------------------------------------------------------- 1 | # Kak Crosshairs 2 | 3 | 4 | Highlight Current Line/Column in Kakoune 5 | 6 | ### Commands added by this plugin: 7 | - `crosshairs` - Toggle the highlighting of the current line and column 8 | - `cursorline` - Toggle the highlighting of only the current line 9 | - `cursorcolumn` - Toggle the highlighting of only the current column 10 | 11 | Thank You to @alexherbo2 for creating the column highlighter 12 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | This is free and unencumbered software released into the public domain. 2 | 3 | Anyone is free to copy, modify, publish, use, compile, sell, or 4 | distribute this software, either in source code form or as a compiled 5 | binary, for any purpose, commercial or non-commercial, and by any 6 | means. 7 | 8 | In jurisdictions that recognize copyright laws, the author or authors 9 | of this software dedicate any and all copyright interest in the 10 | software to the public domain. We make this dedication for the benefit 11 | of the public at large and to the detriment of our heirs and 12 | successors. We intend this dedication to be an overt act of 13 | relinquishment in perpetuity of all present and future rights to this 14 | software under copyright law. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 20 | OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 21 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 | OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | For more information, please refer to 25 | -------------------------------------------------------------------------------- /crosshairs.kak: -------------------------------------------------------------------------------- 1 | set-face global crosshairs_line default,rgb:383838+bd 2 | set-face global crosshairs_column default,rgb:383838+bd 3 | 4 | declare-option -hidden bool highlight_current_line false 5 | declare-option -hidden str highlight_current_line_hook_cmd "nop" 6 | declare-option -hidden bool highlight_current_column false 7 | declare-option -hidden str highlight_current_column_hook_cmd "nop" 8 | 9 | define-command -hidden crosshairs-highlight-column -docstring "Highlight current column" %{ 10 | try %{ remove-highlighter window/crosshairs-column } 11 | try %{ add-highlighter window/crosshairs-column column %val{cursor_display_column} crosshairs_column } 12 | } 13 | 14 | define-command -hidden crosshairs-highlight-line -docstring "Highlight current line" %{ 15 | try %{ remove-highlighter window/crosshairs-line } 16 | try %{ add-highlighter window/crosshairs-line line %val{cursor_line} crosshairs_line } 17 | } 18 | 19 | define-command -hidden crosshairs-update %{ 20 | evaluate-commands %{ 21 | %opt(highlight_current_line_hook_cmd) 22 | %opt(highlight_current_column_hook_cmd) 23 | }} 24 | 25 | define-command -hidden -docstring "update hooks for highlighters" \ 26 | crosshairs-change-hooks %{ 27 | evaluate-commands %sh{ 28 | # set actions 29 | if [ "$kak_opt_highlight_current_line" = true ]; then 30 | printf "%s\n" "set-option global highlight_current_line_hook_cmd crosshairs-highlight-line" 31 | else 32 | printf "%s\n" "try %(remove-highlighter window/crosshairs-line)" 33 | printf "%s\n" "set-option global highlight_current_line_hook_cmd nop" 34 | fi 35 | if [ "$kak_opt_highlight_current_column" = true ]; then 36 | printf "%s\n" "set-option global highlight_current_column_hook_cmd crosshairs-highlight-column" 37 | else 38 | printf "%s\n" "try %(remove-highlighter window/crosshairs-column)" 39 | printf "%s\n" "set-option global highlight_current_column_hook_cmd nop" 40 | fi 41 | # set hook 42 | if [ "$kak_opt_highlight_current_column" = true ] || [ "$kak_opt_highlight_current_line" = true ]; then 43 | printf "%s\n" "hook global -group crosshairs RawKey .+ crosshairs-update" 44 | else 45 | printf "%s\n" "remove-hooks global crosshairs" 46 | fi 47 | } 48 | } 49 | 50 | define-command crosshairs -docstring "Toggle Crosshairs or line/col highlighting" %{ 51 | evaluate-commands %sh{ 52 | if [ "$kak_opt_highlight_current_column" = true ] && [ "$kak_opt_highlight_current_line" = true ]; then 53 | printf "%s\n" "set-option global highlight_current_line false" 54 | printf "%s\n" "set-option global highlight_current_column false" 55 | else 56 | printf "%s\n" "set-option global highlight_current_line true" 57 | printf "%s\n" "set-option global highlight_current_column true" 58 | fi 59 | } 60 | crosshairs-change-hooks 61 | crosshairs-update 62 | } 63 | 64 | define-command cursorline -docstring "Toggle Highlighting for current line" %{ 65 | evaluate-commands %sh{ 66 | if [ "$kak_opt_highlight_current_line" = true ] ; then 67 | printf "%s\n" "set-option global highlight_current_line false" 68 | else 69 | printf "%s\n" "set-option global highlight_current_line true" 70 | fi 71 | } 72 | crosshairs-change-hooks 73 | crosshairs-update 74 | } 75 | 76 | define-command cursorcolumn -docstring "Toggle highlighting for current column" %{ 77 | evaluate-commands %sh{ 78 | if [ "$kak_opt_highlight_current_column" = true ] ; then 79 | printf "%s\n" "set-option global highlight_current_column false" 80 | else 81 | printf "%s\n" "set-option global highlight_current_column true" 82 | fi 83 | } 84 | crosshairs-change-hooks 85 | crosshairs-update 86 | } 87 | 88 | 89 | --------------------------------------------------------------------------------