2022-04-05 19:57:44 +00:00
|
|
|
(let [lsp (require :lspconfig)
|
|
|
|
cmp (require :cmp_nvim_lsp)
|
2022-09-22 20:34:18 +00:00
|
|
|
navic (require :nvim-navic)
|
2022-04-19 12:56:22 +00:00
|
|
|
diagnostic (require :nifoc.diagnostic)
|
|
|
|
formatting (require :nifoc.formatting)]
|
2022-04-05 19:57:44 +00:00
|
|
|
(fn custom-attach [client bufnr]
|
2022-09-26 20:03:29 +00:00
|
|
|
(when (client.supports_method :textDocument/documentSymbol)
|
|
|
|
(navic.attach client bufnr))
|
2022-04-05 19:57:44 +00:00
|
|
|
(diagnostic.maybe-enable-lsp client bufnr)
|
2022-04-19 12:56:22 +00:00
|
|
|
(formatting.maybe-enable-lsp client bufnr))
|
2022-04-05 19:57:44 +00:00
|
|
|
|
|
|
|
(fn custom-attach-no-format [client bufnr]
|
2022-04-17 20:26:10 +00:00
|
|
|
(set client.server_capabilities.documentFormattingProvider false)
|
2022-04-18 21:08:19 +00:00
|
|
|
(set client.server_capabilities.documentRangeFormattingProvider false)
|
2022-04-05 19:57:44 +00:00
|
|
|
(custom-attach client bufnr))
|
|
|
|
|
|
|
|
;; Servers
|
2022-10-16 18:56:38 +00:00
|
|
|
(let [capabilities (cmp.default_capabilities)
|
2022-04-05 19:57:44 +00:00
|
|
|
flags {:allow_incremental_sync true :debounce_text_changes 700}
|
|
|
|
default-config {:on_attach custom-attach : capabilities : flags}
|
2022-04-19 12:56:22 +00:00
|
|
|
default-config-no-format {:on_attach custom-attach-no-format
|
|
|
|
: capabilities
|
|
|
|
: flags}
|
2022-04-05 19:57:44 +00:00
|
|
|
default-servers [:bashls
|
|
|
|
:cssls
|
|
|
|
:dockerls
|
|
|
|
:erlangls
|
|
|
|
:eslint
|
|
|
|
:html
|
2022-11-10 10:03:20 +00:00
|
|
|
:jdtls
|
2022-09-26 20:03:29 +00:00
|
|
|
:nil_ls
|
2022-04-05 19:57:44 +00:00
|
|
|
:rnix
|
|
|
|
:sqls
|
2022-05-04 13:03:51 +00:00
|
|
|
:svelte
|
2022-04-05 19:57:44 +00:00
|
|
|
:taplo
|
|
|
|
:yamlls]]
|
|
|
|
;; Default
|
|
|
|
(each [_ name (pairs default-servers)]
|
|
|
|
((. lsp name :setup) default-config))
|
|
|
|
;; Custom
|
|
|
|
(lsp.elixirls.setup (->> {:cmd [:elixir-ls]}
|
2022-04-19 12:56:22 +00:00
|
|
|
(vim.tbl_extend :force default-config)))
|
2022-04-05 19:57:44 +00:00
|
|
|
(lsp.tsserver.setup (->> {:cmd [:typescript-language-server
|
|
|
|
:--stdio
|
|
|
|
:--tsserver-path
|
2022-04-19 12:56:22 +00:00
|
|
|
:tsserver]}
|
|
|
|
(vim.tbl_extend :force default-config-no-format)))
|
2022-04-05 19:57:44 +00:00
|
|
|
(lsp.jsonls.setup (->> {:cmd [:vscode-json-language-server :--stdio]}
|
|
|
|
(vim.tbl_extend :force default-config)))
|
|
|
|
(lsp.solargraph.setup (->> {:settings {:solargraph {:diagnostics true}}}
|
|
|
|
(vim.tbl_extend :force default-config)))
|
|
|
|
(lsp.sumneko_lua.setup (->> {:cmd [:lua-language-server]
|
|
|
|
:root_dir (or (lsp.util.root_pattern :init.vim
|
|
|
|
:init.lua
|
|
|
|
:.git)
|
|
|
|
(vim.loop.os_homedir))
|
|
|
|
:settings {:Lua {:runtime {:version :LuaJIT
|
|
|
|
:path (vim.split package.path
|
|
|
|
";")}
|
|
|
|
:diagnostics {:globals [:vim]}
|
|
|
|
:telemetry {:enable false}}}}
|
|
|
|
(vim.tbl_extend :force default-config)))))
|
2022-04-22 12:19:36 +00:00
|
|
|
|