2022-04-05 19:57:44 +00:00
|
|
|
(let [lsp (require :lspconfig)
|
|
|
|
lsp-status (require :lsp-status)
|
|
|
|
illuminate (require :illuminate)
|
|
|
|
virtual-types (require :virtualtypes)
|
|
|
|
cmp (require :cmp_nvim_lsp)
|
|
|
|
diagnostic (require :nifoc.diagnostic)]
|
|
|
|
(fn custom-attach [client bufnr]
|
2022-04-17 20:26:10 +00:00
|
|
|
(when client.server_capabilities.documentSymbolProvider
|
2022-04-05 19:57:44 +00:00
|
|
|
(lsp_status.on_attach client bufnr))
|
2022-04-17 20:26:10 +00:00
|
|
|
(when client.server_capabilities.documentHighlightProvider
|
2022-04-05 19:57:44 +00:00
|
|
|
(illuminate.on_attach client bufnr))
|
2022-04-17 20:26:10 +00:00
|
|
|
(when client.server_capabilities.codeLensProvider
|
2022-04-05 19:57:44 +00:00
|
|
|
(virtual-types.on_attach client bufnr))
|
|
|
|
(diagnostic.maybe-enable-lsp client bufnr)
|
|
|
|
(diagnostic.maybe-enable-fixer client bufnr))
|
|
|
|
|
|
|
|
(fn custom-attach-no-format [client bufnr]
|
2022-04-17 20:26:10 +00:00
|
|
|
(set client.server_capabilities.documentFormattingProvider false)
|
2022-04-05 19:57:44 +00:00
|
|
|
(custom-attach client bufnr))
|
|
|
|
|
|
|
|
;; Setup
|
|
|
|
(lsp-status.config {:current_function true
|
|
|
|
:show_filename false
|
|
|
|
:diagnostics false})
|
|
|
|
(lsp-status.register_progress)
|
2022-04-09 15:39:52 +00:00
|
|
|
;; Custom handler
|
|
|
|
(tset vim.lsp.handlers "textDocument/hover" (vim.lsp.with vim.lsp.handlers.hover {:border "rounded"}))
|
|
|
|
(tset vim.lsp.handlers "textDocument/signatureHelp" (vim.lsp.with vim.lsp.handlers.signature_help {:border "rounded"}))
|
2022-04-05 19:57:44 +00:00
|
|
|
;; Servers
|
|
|
|
(let [default-capabilities (vim.lsp.protocol.make_client_capabilities)
|
|
|
|
capabilities (vim.tbl_extend :keep
|
|
|
|
(cmp.update_capabilities default-capabilities)
|
|
|
|
lsp-status.capabilities)
|
|
|
|
flags {:allow_incremental_sync true :debounce_text_changes 700}
|
|
|
|
default-config {:on_attach custom-attach : capabilities : flags}
|
2022-04-09 15:39:52 +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
|
|
|
|
:rnix
|
|
|
|
:sqls
|
|
|
|
:taplo
|
|
|
|
:yamlls]]
|
|
|
|
;; Default
|
|
|
|
(each [_ name (pairs default-servers)]
|
|
|
|
((. lsp name :setup) default-config))
|
|
|
|
;; Custom
|
|
|
|
(lsp.elixirls.setup (->> {:cmd [:elixir-ls]}
|
2022-04-09 15:39:52 +00:00
|
|
|
(vim.tbl_extend :force default-config-no-format)))
|
2022-04-05 19:57:44 +00:00
|
|
|
(lsp.tsserver.setup (->> {:cmd [:typescript-language-server
|
|
|
|
:--stdio
|
|
|
|
:--tsserver-path
|
|
|
|
:tsserver]
|
|
|
|
:on_attach custom-attach-no-format}
|
|
|
|
(vim.tbl_extend :force default-config)))
|
|
|
|
(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]}
|
|
|
|
:workspace {:library {(vim.fn.expand "\$VIMRUNTIME/lua") true
|
|
|
|
(vim.fn.expand "\$VIMRUNTIME/lua/vim/lsp") true}}
|
|
|
|
:telemetry {:enable false}}}}
|
|
|
|
(vim.tbl_extend :force default-config)))))
|