aboutsummaryrefslogtreecommitdiff
path: root/autoload/lsp-config.kak
blob: c9af393eb856c7a59d91c10f2236d262b71d2516 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
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

lsp-inlay-diagnostics-enable global

map global user l ': enter-user-mode lsp<ret>' -docstring 'LSP mode'
# map global user t ':enter-user-mode tree-sitter<ret>' -docstring 'Treesitter mode'
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 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"]
  }
}

remove-hooks global lsp-filetype-c-family
hook global BufSetOption filetype=(?:c|cpp|objc) %{
  set-option buffer lsp_servers %{
    [clangd]
    args = ["--log=error"]
    root_globs = ["compile_commands.json", ".clangd", ".git"]
  }
}

hook global BufSetOption filetype=ruby %{
  set-option buffer lsp_servers %{
    [ruby-lsp]
    root_globs = ["Gemfile"]
    args = ["stdio"]
  }
}

hook global WinSetOption filetype=.* %{
  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"]},
    ]
  }
}