summaryrefslogtreecommitdiff
path: root/fnl/plugins/lsp/mason-lspconfig.fnl
blob: 429e948d8d8ae7e358f221359edb2bda2438af64 (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
;; A bridge plugin between mason and lspconfig, handles installation of lsp and 
;; setup hooks for client configurations.

(local textDocument-handlers
       {:textDocument/hover (vim.lsp.with vim.lsp.handlers.hover {:border :single})
        :textDocument/signatureHelp (vim.lsp.with vim.lsp.handlers.signature_help
                                                  {:border :single})})

(λ capabilities []
  (let [blink-cmp (require :blink.cmp)]
    (blink-cmp.get_lsp_capabilities)))

(λ handlers [server]
  (let [servers (require :plugins.lsp.servers)
        lspconfigs (require :lspconfig)]
    (let [lspconfig (. lspconfigs server)
          server-config (or (. servers server) {})]
      (tset server-config :capabilities (capabilities))
      (tset server-config :handlers textDocument-handlers)
      (lspconfig.setup server-config))))

(λ setup []
  (let [mason-lspconfig (require :mason-lspconfig)
        servers (require :plugins.lsp.servers)]
    (mason-lspconfig.setup {:ensure_installed (vim.tbl_keys servers)
                            :automatic_installation true
                            :handlers [handlers]})))

{: setup}