diff options
Diffstat (limited to 'autoload')
| -rw-r--r-- | autoload/folding.kak | 23 | ||||
| -rw-r--r-- | autoload/lsp-config.kak | 68 | ||||
| -rw-r--r-- | autoload/marks.kak | 22 |
3 files changed, 106 insertions, 7 deletions
diff --git a/autoload/folding.kak b/autoload/folding.kak new file mode 100644 index 0000000..b19af5f --- /dev/null +++ b/autoload/folding.kak @@ -0,0 +1,23 @@ +# declare-option range-specs fold_ranges + +# define-command fold-range -params 1 %{ +# # TODO: Check if cursor is within range +# evaluate-commands %sh{ +# if (echo "$kak_opt_fold_ranges" | grep -F "${1}" >/dev/null 2>&1); then +# echo "set-option -remove buffer fold_ranges '${1}|Texthere'" +# else +# echo "set-option -add buffer fold_ranges '${1}|Texthere'" +# fi +# } +# } + +# define-command fold-enable %{ +# add-highlighter global/folding replace-ranges fold_ranges +# } + +# define-command fold-indent %{ +# execute-keys '<a-i>i' +# fold-range %val{selection_desc} +# } + +# fold-enable diff --git a/autoload/lsp-config.kak b/autoload/lsp-config.kak index cea1f3d..c1c6cb9 100644 --- a/autoload/lsp-config.kak +++ b/autoload/lsp-config.kak @@ -1,14 +1,76 @@ eval %sh{kak-lsp} - +set-option global lsp_file_watch_support true +set-option global lsp_snippet_support true +set-option global lsp_diagnostic_line_error_sign '' +set-option global lsp_diagnostic_line_warning_sign '' +set-option global lsp_diagnostic_line_info_sign '■' +set-option global lsp_diagnostic_line_hint_sign '■' lsp-enable map global user l ':enter-user-mode lsp<ret>' -docstring 'LSP mode' -map global insert <tab> '<a-;>:try lsp-snippets-select-next-placeholders catch %{ execute-keys -with-hooks <lt>tab> }<ret>' -docstring 'Select next snippet placeholder' - map global object a '<a-semicolon>lsp-object<ret>' -docstring 'LSP any symbol' map global object <a-a> '<a-semicolon>lsp-object<ret>' -docstring 'LSP any symbol' map global object f '<a-semicolon>lsp-object Function Method<ret>' -docstring 'LSP function or method' map global object t '<a-semicolon>lsp-object Class Interface Struct<ret>' -docstring 'LSP class interface or struct' map global object d '<a-semicolon>lsp-diagnostic-object --include-warnings<ret>' -docstring 'LSP errors and warnings' map global object D '<a-semicolon>lsp-diagnostic-object<ret>' -docstring 'LSP errors' + +map global insert <c-n> '<a-;>:lsp-snippets-select-next-placeholders<ret>' -docstring 'Select next snippet placeholder' +hook global InsertCompletionShow .* %{ + unmap global insert <c-n> '<a-;>:lsp-snippets-select-next-placeholders<ret>' +} +hook global InsertCompletionHide .* %{ + map global insert <c-n> '<a-;>:lsp-snippets-select-next-placeholders<ret>' -docstring 'Select next snippet placeholder' +} + +hook global BufSetOption filetype=(?:javascript|typescript) %{ + set-option buffer lsp_servers %{ + [typescript-language-server] + root_globs = ["package.json", "tsconfig.json", "jsconfig.json", ".git"] + args = ["--stdio"] + [tailwindcss-language-server] + root_globs = ["tailwind.*", "postcss.*"] + args = ["--stdio"] + [tailwindcss-language-server.settings.tailwindCSS] + editor = {} + [biome] + root_globs = ["biome.json", "package.json", "tsconfig.json", "jsconfig.json"] + args = ["lsp-proxy"] + } +} + +hook global BufSetOption filetype=ruby %{ + set-option buffer lsp_servers %{ + [ruby-lsp] + root_globs = ["Gemfile"] + args = ["stdio"] + } +} + +hook global WinSetOption filetype=(?:javascript|typescript|ruby) %{ + 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 + } + + set-option window lsp_semantic_tokens %{ + [ + {face="documentation", token="comment", modifiers=["documentation"]}, + {face="comment", token="comment"}, + {face="function", token="function"}, + {face="function", token="method"}, + {face="keyword", token="keyword"}, + {face="module", token="namespace"}, + {face="operator", token="operator"}, + {face="string", token="string"}, + {face="type", token="type"}, + {face="variable", token="variable"}, + {face="const_variable", token="variable", modifiers=["readonly"]}, + {face="const_variable", token="variable", modifiers=["constant"]}, + ] + } +} + diff --git a/autoload/marks.kak b/autoload/marks.kak index e99e3bf..adbf3a2 100644 --- a/autoload/marks.kak +++ b/autoload/marks.kak @@ -20,12 +20,16 @@ define-command marks-add -params 1..2 %{ [ -f "$path" ] || touch "$path" newfile="$1" pos="$2" - if [ -z "$pos" ] || [ "$pos" = "0" ]; then pos="99"; else pos=$(($pos-1)); fi + if [ -z "$pos" ] || [ "$pos" = "0" ]; then + pos="99"; + else + pos="$(echo "$pos" | awk '{printf "%.1f", $1 <= 1 ? 0 : $1 - 0.5}')"; + fi function append() { cat; echo -e "$pos\t$newfile"; } newfiles=$(grep -v "$newfile" "$path" \ | nl | sed 's/^\s*//' \ - | append | sort -k 2 | uniq -f1 | sort \ - | sed 's/^\s*[-0-9]\+\s\+//') + | append | LC_ALL=C sort -g -b -k 2 | uniq -f1 | LC_ALL=C sort -g -b \ + | sed 's/^\s*[-.0-9]\+\s\+//') echo -e "$newfiles" > "$path.tmp" mv "$path.tmp" "$path" || true rm -f "$path.tmp" || true @@ -42,11 +46,20 @@ define-command marks-delete -params 1 %{ marks-show } +define-command marks-clear %{ + nop %sh{ + path="$kak_opt_marks_path/$kak_opt_marks_name" + [ -f "$path" ] && rm -f "$path" || true + } +} + define-command marks-show %{ info -title 'marks' -markup %sh{ path="$kak_opt_marks_path/$kak_opt_marks_name" - [ -f "$path" ] || exit 0 echo -n "{Default}" + if ! [ -f "$path" ] || [ "$(wc -l "$path")" = "0" ]; then + echo "{comment}<empty>" && exit 0; + fi cat "$path" | while IFS= read file; do short_path=$(echo "$file" | awk -F/ '{if (NF >= 2) {print $(NF-1) "/" $NF} else {print $NF}}') hl=$([ "$file" = "$kak_buffile" ] && echo "{keyword}" || echo "{Default}") @@ -72,3 +85,4 @@ map global user a ':enter-user-mode-with-count marks<ret>' -docstring 'Marks mod map global user <space> ':marks-switch %val{count}<ret>' -docstring 'Switch marks' map global marks a ':marks-add %val{buffile} %opt{user_mode_count}<ret>' -docstring 'Create new mark from buffer' map global marks d ':marks-delete %val{buffile}<ret>' -docstring 'Delete mark' +map global marks C ':marks-clear<ret>' -docstring 'Clear mark' |
