summaryrefslogtreecommitdiff
path: root/fnl/config/lsp/lspconfig.fnl
blob: b7143abb22e3237385d3fffe377b6f1dad441429 (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
;; Setup of lsps.
(module config.lsp.lspconfig
        {autoload {nvim aniseed.nvim
                   util config.util
                   keymaps config.lsp.keymaps}})

(defn- on-attach []
       (nvim.create_autocmd :LspAttach
                            {:callback (fn [args]
                                         (let [bufnr (. args :buf)]
                                           (keymaps.on-attach bufnr)))}))

(defn- capabilities []
       (let [cmp-lsp (util.prequire :cmp_nvim_lsp)]
         (cmp-lsp.default_capabilities (vim.lsp.protocol.make_client_capabilities))))

(defn- mason-opts [servers]
       {:ensure_installed (vim.tbl_keys servers) :automatic_installation true})

(let [lspconfig (util.prequire :lspconfig)
      mason-lspconfig (util.prequire :mason-lspconfig)
      servers (require :config.lsp.servers)]
  (on-attach)
  (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)))]))