blob: d4f8790a9176d3af0941b394da26acf13a8c73c8 (
plain)
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
|
;; Setup of lsps.
(fn get-client-by-id [args]
(let [client-id (. (. args :data) :client_id)]
(vim.lsp.get_client_by_id client-id)))
(fn format-modifications [client buffer]
(let [lsp-format-modifications (require :lsp-format-modifications)]
(vim.api.nvim_buf_create_user_command buffer :FormatModifications
(fn []
(lsp-format-modifications.format_modifications client
buffer))
{})))
(fn on-attach []
(vim.api.nvim_create_autocmd :LspAttach
{:callback (fn [args]
(let [keymaps (require :plugins.lsp.keymaps)
buffer (. args :buf)
client (get-client-by-id args)]
(keymaps.on-attach buffer)
(format-modifications client
buffer)))}))
(fn capabilities []
(let [cmp-lsp (require :cmp_nvim_lsp)]
(cmp-lsp.default_capabilities (vim.lsp.protocol.make_client_capabilities))))
(fn mason-opts [servers]
{:ensure_installed (vim.tbl_keys servers) :automatic_installation true})
(fn setup []
(let [diagnostics (require :plugins.lsp.diagnostics)
lspconfig (require :lspconfig)
lspconfig-win (require :lspconfig.ui.windows)
mason-lspconfig (require :mason-lspconfig)
servers (require :plugins.lsp.servers)]
(diagnostics.setup)
(on-attach)
(set lspconfig-win.default_options.border :single)
(mason-lspconfig.setup (mason-opts servers))
(mason-lspconfig.setup_handlers [(fn [server-name]
(let [server-config (. lspconfig
server-name)
opts (or (. servers server-name)
{})]
(tset opts :capabilities
(capabilities))
(server-config.setup opts)))])))
{1 :neovim/nvim-lspconfig
:event :BufReadPost
:dependencies [:mason.nvim
:williamboman/mason-lspconfig.nvim
:b0o/SchemaStore.nvim
:joechrisellis/lsp-format-modifications.nvim
:hrsh7th/cmp-nvim-lsp]
:config (fn []
(setup))}
|