summaryrefslogtreecommitdiff
path: root/fnl/plugins/lsp
diff options
context:
space:
mode:
authorGustaf Rydholm <gustaf.rydholm@gmail.com>2024-01-07 01:28:22 +0100
committerGustaf Rydholm <gustaf.rydholm@gmail.com>2024-01-07 01:28:22 +0100
commit81b0fdd14fab1dfdd5b43fd5dc520709800d78a0 (patch)
treef4a7b8b050c4ed359133ac183053194c0773d96d /fnl/plugins/lsp
parentf005ce541335fb936a85e9997513e94067ef07ae (diff)
Refactor lspconfig
Diffstat (limited to 'fnl/plugins/lsp')
-rw-r--r--fnl/plugins/lsp/lspconfig.fnl32
-rw-r--r--fnl/plugins/lsp/servers.fnl7
2 files changed, 22 insertions, 17 deletions
diff --git a/fnl/plugins/lsp/lspconfig.fnl b/fnl/plugins/lsp/lspconfig.fnl
index cca52a4..84c460f 100644
--- a/fnl/plugins/lsp/lspconfig.fnl
+++ b/fnl/plugins/lsp/lspconfig.fnl
@@ -11,32 +11,34 @@
(let [cmp-lsp (require :cmp_nvim_lsp)]
(cmp-lsp.default_capabilities (vim.lsp.protocol.make_client_capabilities))))
+(fn handlers [server]
+ (let [servers (require :plugins.lsp.servers)
+ lspconfig (require :lspconfig)]
+ (let [config (. lspconfig server)
+ opts (or (. servers server) {})]
+ (tset opts :capabilities (capabilities))
+ (config.setup opts))))
+
(fn mason-opts [servers]
- {:ensure_installed (vim.tbl_keys servers) :automatic_installation true})
+ (let [servers (require :plugins.lsp.servers)]
+ {:ensure_installed (vim.tbl_keys servers)
+ :automatic_installation true
+ :handlers [handlers]}))
(fn config []
+ (on-attach)
(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)]
+ mason-lspconfig (require :mason-lspconfig)]
(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)))])))
+ (mason-lspconfig.setup (mason-opts))
+ (mason-lspconfig.setup_handlers [setup-handler])))
{1 :neovim/nvim-lspconfig
:event :BufReadPost
:dependencies [:mason.nvim
:williamboman/mason-lspconfig.nvim
- :b0o/SchemaStore.nvim
+ :b0o/schemastore.nvim
:hrsh7th/cmp-nvim-lsp]
: config}
diff --git a/fnl/plugins/lsp/servers.fnl b/fnl/plugins/lsp/servers.fnl
index d5a47fb..ab8cad6 100644
--- a/fnl/plugins/lsp/servers.fnl
+++ b/fnl/plugins/lsp/servers.fnl
@@ -8,7 +8,8 @@
:html {}
:jsonls {:init_options {:providerFormatter false}
:settings {:json {:schemas (let [schemastore (require :schemastore)]
- (schemastore.json.schemas))}}
+ (schemastore.json.schemas))
+ :validate {:enable true}}}
:setup {:commands {:Format [(fn []
(vim.lsp.buf.range_formatting [] [0 0]
[(vim.fn.line "$"
@@ -24,4 +25,6 @@
:taplo {}
:texlab {}
:vale_ls {:filetypes [:markdown :text :org]}
- :yamlls {}}
+ :yamlls {:settings {:yaml {:schemastore {:enable false :url ""}
+ :schemas (let [schemastore (require :schemastore)]
+ (schemastore.yaml.schemas))}}}}