-
Notifications
You must be signed in to change notification settings - Fork 0
/
languages.kak
212 lines (183 loc) · 7.86 KB
/
languages.kak
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
evaluate-commands %sh{kak-lsp}
map global object 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 d '<a-semicolon>lsp-diagnostic-object --include-warnings<ret>' -docstring 'LSP diagnostic'
# set-option global lsp_cmd "kak-lsp -s %val{session} -vvv --log /tmp/kak-lsp.log"
hook global WinSetOption filetype=(c|cpp|css|go|html|javascript|latex|markdown|python|rust|typescript|zig) %{
map window user -docstring 'LSP mode' l ': enter-user-mode lsp<ret>'
set-option global lsp_snippet_support false
lsp-enable-window
lsp-auto-signature-help-enable
lsp-auto-hover-insert-mode-disable
set-option window lsp_auto_highlight_references true
set-option window lsp_hover_max_lines 20
}
# Semantic highlighting for supported languages
hook global WinSetOption filetype=(c|cpp|html|javascript|typescript|go|rust|zig) %{
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
}
}
hook global WinSetOption filetype=(c|cpp) %{
set-option window formatcmd 'clang-format'
}
hook -group lsp-filetype-c-family global BufSetOption filetype=(?:c|cpp|objc) %{
set-option buffer lsp_servers %{
[clangd]
root_globs = ["compile_commands.json", ".clangd", ".git", ".hg"]
args = ["-clang-tidy", "-compile-commands-dir=build", "-background-index", "-completion-style=detailed", "-header-insertion=never", "--malloc-trim"]
}
}
hook global WinSetOption filetype=python %{
set-option window formatcmd 'ruff format -'
set-option window lintcmd 'ruff'
}
hook -group lsp-filetype-python global BufSetOption filetype=python %{
set-option buffer lsp_servers %{
[jedi-language-server]
root_globs = ["requirements.txt", "setup.py", "pyproject.toml", ".git", ".hg"]
}
set-option -add buffer lsp_servers %{
[ruff]
args = ["server", "--quiet"]
root_globs = ["requirements.txt", "setup.py", "pyproject.toml", ".git", ".hg"]
settings_section = "_"
[ruff.settings._.globalSettings]
organizeImports = true
fixAll = true
}
}
hook global WinSetOption filetype=zig %{
# remove-highlighter window/zig
set-option window formatcmd 'zig fmt --stdin'
set-option window lintcmd 'zig fmt --color off --ast-check 2>&1'
set-option window makecmd 'zig build --summary all'
hook window -group format BufWritePre .* lsp-formatting-sync
map window normal '<a-#>' ':exec %{x_i// autofix<lt>ret>if(false){<lt>esc>a<lt>ret>}<lt>esc>:format<lt>ret>_}<ret>'
set-register pipe "fmt -w 99 -p '///'"
}
hook global WinSetOption filetype=rust %{
set-option window formatcmd 'rustfmt'
hook window -group format BufWritePre .* lsp-formatting-sync
}
hook global WinSetOption filetype=go %{
set-option window formatcmd 'gofmt'
set-option window tabstop 4
hook window -group format BufWritePre .* lsp-formatting-sync
set-option window lsp_auto_highlight_references true
set-option window lintcmd "run() { golint $1; go vet $1 2> | sed -e 's/: /: error /'; } && run"
lint
}
hook global BufSetOption filetype=go %{
set-option buffer lsp_servers %{
[gopls]
root_globs = ["Gopkg.toml" "go.mod" ".git" ".hg"]
[gopls.settings.gopls]
hints.assignVariableTypes = true
hints.compositeLiteralFields = true
hints.compositeLiteralTypes = true
hints.constantValues = true
hints.functionTypeParameters = true
hints.parameterNames = true
hints.rangeVariableTypes = true
usePlaceholders = true
semanticTokens = true
}
}
hook global WinSetOption filetype=html %{
set-option window formatcmd 'superhtml fmt --stdin'
# set-option window lintcmd "run() { superhtml check $1 } && run"
set-option window lintcmd 'superhtml check'
hook buffer -group format BufWritePre .* lsp-formatting-sync
}
hook -group lsp-filetype-html global BufSetOption filetype=html %{
set-option buffer lsp_servers %{
[vscode-html-language-server]
root_globs = ["package.json", ".git", ".hg"]
args = ["--stdio"]
settings_section = "_"
[vscode-html-language-server.settings._]
provideFormatter = true
[vscode-html-language-server.settings]
embeddedLanguages.css = true
embeddedLanguages.javascript = true
html.autoClosingTags = true
html.format.enable = true
html.mirrorCursorOnMatchingTag = true
html.validate.scripts = true
html.validate.styles = true
css.validate = true
css.format.enable = true
css.validProperties = []
javascript.format.enable = true
javascript.validate.enable = true
[superhtml]
root_globs = ["package.json", ".git", ".hg"]
args = ["lsp"]
}
}
hook global WinSetOption filetype=(javascript|typescript) %{
set-option window formatcmd "npx prettier --stdin-filepath=%val{buffile}"
hook buffer BufWritePre .* format
map global lsp -docstring 'format buffer' f ':format<ret>'
}
hook global WinSetOption filetype=makefile %{
add-highlighter window/ show-whitespaces
}
set-option global lsp_semantic_tokens %{
[
# values
{token = "number", face = "value"},
{token = "enumMember", face = "value"},
{token = "enumMember", modifiers = ["declaration"], face = "value_declaration"},
{token = "keywordLiteral", face = "value"},
# types
{token = "type", face = "type"},
{token = "class", face = "type"},
{token = "enum", face = "type"},
{token = "struct", face = "type"},
{token = "type", modifiers = ["declaration"], face = "type_declaration"},
{token = "class", modifiers = ["declaration"], face = "type_declaration"},
{token = "enum", modifiers = ["declaration"], face = "type_declaration"},
{token = "struct", modifiers = ["declaration"], face = "type_declaration"},
{token = "typeParameter", face = "type_declaration"},
# variables
{token = "variable", face = "variable"},
{token = "variable", modifiers = ["declaration"], face = "variable_declaration"},
{token = "parameter", modifiers = ["declaration"], face = "variable_declaration"},
{token = "property", face = "property"},
{token = "property", modifiers = ["declaration"], face = "property_declaration"},
# modules
{token = "namespace", face = "module"},
{token = "namespace", modifiers = ["declaration"], face = "module_declaration"},
# functions
{token = "function", face = "function"},
{token = "function", modifiers = ["declaration"], face = "function_declaration"},
{token = "method", face = "method"},
{token = "method", modifiers = ["declaration"], face = "method_declaration"},
# strings
# {token = "string", face = "string"},
# keywords
{token = "keyword", face = "keyword"},
# operator
{token = "operator", face = "operator"},
# attributes
{token = "attribute", face = "attribute"},
# comments
{token = "comment", face = "comment"},
{token = "comment", modifiers = ["documentation"], face = "documentation"},
# meta
{token = "macro", face = "meta"},
{token = "dependent", face = "meta_member"},
# builtins
{token = "builtin", face = "builtin"},
# other
{token = "concept", face = "concept"},
{token = "regexp", face = "regexp"},
{token = "label", face = "label"},
{token = "errorTag", face = "errortag"},
]
}