summaryrefslogtreecommitdiff
path: root/fnl/plugins/lsp/lspconfig.fnl
diff options
context:
space:
mode:
authorGustaf Rydholm <gustaf.rydholm@gmail.com>2023-01-11 00:41:17 +0100
committerGustaf Rydholm <gustaf.rydholm@gmail.com>2023-01-11 00:41:17 +0100
commitf318452070d42e51231f7880a5d0eaa93d978a1e (patch)
treec76f35889ebc7a4e52bbd06e07c8f33f9bf68f5d /fnl/plugins/lsp/lspconfig.fnl
parent433952cf3efa8e2b5e23ff0e76a4afe6f95d44b5 (diff)
Rip aniseed, hail hotpot
Diffstat (limited to 'fnl/plugins/lsp/lspconfig.fnl')
-rw-r--r--fnl/plugins/lsp/lspconfig.fnl42
1 files changed, 42 insertions, 0 deletions
diff --git a/fnl/plugins/lsp/lspconfig.fnl b/fnl/plugins/lsp/lspconfig.fnl
new file mode 100644
index 0000000..b2ee792
--- /dev/null
+++ b/fnl/plugins/lsp/lspconfig.fnl
@@ -0,0 +1,42 @@
+;; Setup of lsps.
+
+(fn on-attach []
+ (vim.api.nvim_create_autocmd :LspAttach
+ {:callback (fn [args]
+ (let [keymaps (require :plugins.lsp.keymaps)
+ bufnr (. args :buf)]
+ (keymaps.on-attach bufnr)))}))
+
+(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)
+ mason-lspconfig (require :mason-lspconfig)
+ servers (require :plugins.lsp.servers)]
+ (diagnostics.setup)
+ (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)))])))
+
+{1 :neovim/nvim-lspconfig
+ :event :BufReadPre
+ :dependencies [:mason.nvim
+ :williamboman/mason-lspconfig.nvim
+ :b0o/SchemaStore.nvim
+ :hrsh7th/cmp-nvim-lsp]
+ :config (fn []
+ (setup))}