This repository has been archived by the owner on Jun 2, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 8
/
lspconfig.fnl
122 lines (107 loc) · 5.14 KB
/
lspconfig.fnl
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
(module config.plugin.lspconfig
{autoload {nvim aniseed.nvim
lsp lspconfig
cmplsp cmp_nvim_lsp}})
;; gutter icons for lsp diagnostics
;; :help vim.lsp.diagnostic.set_signs
(defn define-signs
[prefix]
(let [error (.. prefix "SignError")
warn (.. prefix "SignWarn")
info (.. prefix "SignInfo")
hint (.. prefix "SignHint")]
(vim.fn.sign_define error {:text "" :texthl error})
(vim.fn.sign_define warn {:text "" :texthl warn})
(vim.fn.sign_define info {:text "" :texthl info})
(vim.fn.sign_define hint {:text "" :texthl hint})))
;; LSP naming changed between neovim 0.6 and 0.7 onward
(if (= (nvim.fn.has "nvim-0.6") 1)
(define-signs "Diagnostic")
(define-signs "LspDiagnostics"))
;; Configure server features
(let [handlers {"textDocument/publishDiagnostics"
(vim.lsp.with
vim.lsp.diagnostic.on_publish_diagnostics
{:severity_sort true
:update_in_insert false
:underline true
:virtual_text false})
"textDocument/hover"
(vim.lsp.with
vim.lsp.handlers.hover
{:border "single"})
"textDocument/signatureHelp"
(vim.lsp.with
vim.lsp.handlers.signature_help
{:border "single"})}
capabilities (cmplsp.default_capabilities)
on_attach (fn [client bufnr]
(do
(nvim.buf_set_keymap bufnr :n :gd "<Cmd>lua vim.lsp.buf.definition()<CR>" {:noremap true})
(nvim.buf_set_keymap bufnr :n :K "<Cmd>lua vim.lsp.buf.hover()<CR>" {:noremap true})
(nvim.buf_set_keymap bufnr :n :<leader>ld "<Cmd>lua vim.lsp.buf.declaration()<CR>" {:noremap true})
(nvim.buf_set_keymap bufnr :n :<leader>lt "<cmd>lua vim.lsp.buf.type_definition()<CR>" {:noremap true})
(nvim.buf_set_keymap bufnr :n :<leader>lh "<cmd>lua vim.lsp.buf.signature_help()<CR>" {:noremap true})
(nvim.buf_set_keymap bufnr :n :<leader>ln "<cmd>lua vim.lsp.buf.rename()<CR>" {:noremap true})
(nvim.buf_set_keymap bufnr :n :<leader>le "<cmd>lua vim.diagnostic.open_float()<CR>" {:noremap true})
(nvim.buf_set_keymap bufnr :n :<leader>lq "<cmd>lua vim.diagnostic.setloclist()<CR>" {:noremap true})
(nvim.buf_set_keymap bufnr :n :<leader>lf "<cmd>lua vim.lsp.buf.formatting()<CR>" {:noremap true})
(nvim.buf_set_keymap bufnr :n :<leader>lj "<cmd>lua vim.diagnostic.goto_next()<CR>" {:noremap true})
(nvim.buf_set_keymap bufnr :n :<leader>lk "<cmd>lua vim.diagnostic.goto_prev()<CR>" {:noremap true})
(nvim.buf_set_keymap bufnr :n :<leader>la "<cmd>lua vim.lsp.buf.code_action()<CR>" {:noremap true})
(nvim.buf_set_keymap bufnr :v :<leader>la "<cmd>lua vim.lsp.buf.range_code_action()<CR> " {:noremap true})
;telescope
(nvim.buf_set_keymap bufnr :n :<leader>lw ":lua require('telescope.builtin').lsp_workspace_diagnostics()<cr>" {:noremap true})
(nvim.buf_set_keymap bufnr :n :<leader>lr ":lua require('telescope.builtin').lsp_references()<cr>" {:noremap true})
(nvim.buf_set_keymap bufnr :n :<leader>li ":lua require('telescope.builtin').lsp_implementations()<cr>" {:noremap true})))]
;; Clojure LSP Server setup
(lsp.clojure_lsp.setup {:on_attach on_attach
:handlers handlers
:capabilities capabilities})
;; C/Cpp
(lsp.clangd.setup {:on_attach on_attach
:handlers handlers
:capabilities capabilities})
;; JavaScript and TypeScript
(lsp.tsserver.setup {:on_attach on_attach
:handlers handlers
:capabilities capabilities})
;; html / css / json
(lsp.cssls.setup {:on_attach on_attach
:handlers handlers
:capabilities capabilities
:cmd ["vscode-css-languageserver" "--stdio"]})
(lsp.html.setup {:on_attach on_attach
:handlers handlers
:capabilities capabilities
:cmd ["vscode-html-languageserver" "--stdio"]})
(lsp.jsonls.setup {:on_attach on_attach
:handlers handlers
:capabilities capabilities
:cmd ["vscode-json-languageserver" "--stdio"]}))
;; (vim.lsp.protocol.CompletionItemKind
;; {" (Text) ",
;; " (Method)",
;; " (Function)",
;; " (Constructor)",
;; " ﴲ (Field)",
;; "[] (Variable)",
;; " (Class)",
;; " ﰮ (Interface)",
;; " (Module)",
;; " 襁 (Property)",
;; " (Unit)",
;; " (Value)",
;; " 練 (Enum)",
;; " (Keyword)",
;; " (Snippet)",
;; " (Color)",
;; " (File)",
;; " (Reference)",
;; " (Folder)",
;; " (EnumMember)",
;; " ﲀ (Constant)",
;; " ﳤ (Struct)",
;; " (Event)",
;; " (Operator)",
;; " (TypeParameter)"})