2022-04-05 19:57:44 +00:00
|
|
|
(let [lsp (require :lspconfig)
|
2023-10-31 20:24:26 +00:00
|
|
|
cmp (require :cmp_nvim_lsp)
|
2023-11-28 16:09:38 +00:00
|
|
|
schemastore (require :schemastore)
|
2022-09-22 20:34:18 +00:00
|
|
|
navic (require :nvim-navic)
|
2022-04-19 12:56:22 +00:00
|
|
|
diagnostic (require :nifoc.diagnostic)
|
2022-11-27 16:12:49 +00:00
|
|
|
augroup (vim.api.nvim_create_augroup :NifocLsp {:clear true})
|
2023-11-29 19:46:11 +00:00
|
|
|
aucmd vim.api.nvim_create_autocmd
|
|
|
|
ns (vim.api.nvim_create_namespace :nifoc_lsp_float)]
|
2023-06-26 11:07:19 +00:00
|
|
|
(fn setup-inlay-hint-toggle [bufnr]
|
2024-04-20 17:13:41 +00:00
|
|
|
(aucmd :InsertEnter {:callback #(vim.lsp.inlay_hint.enable false {: bufnr})
|
2023-06-26 11:07:19 +00:00
|
|
|
:buffer bufnr
|
|
|
|
:group augroup})
|
2024-04-20 17:13:41 +00:00
|
|
|
(aucmd :InsertLeave {:callback #(vim.lsp.inlay_hint.enable true {: bufnr})
|
2023-06-26 11:07:19 +00:00
|
|
|
:buffer bufnr
|
|
|
|
:group augroup}))
|
|
|
|
|
2022-11-27 16:12:49 +00:00
|
|
|
;; Attach
|
|
|
|
(aucmd :LspAttach {:callback (fn [args]
|
|
|
|
(let [client (vim.lsp.get_client_by_id args.data.client_id)
|
|
|
|
bufnr args.buf]
|
2024-04-10 13:44:20 +00:00
|
|
|
(when (client.supports_method :textDocument/documentSymbol
|
|
|
|
{: bufnr})
|
2022-11-27 16:12:49 +00:00
|
|
|
(navic.attach client bufnr))
|
2024-04-10 13:44:20 +00:00
|
|
|
(when (client.supports_method :textDocument/inlayHint
|
|
|
|
{: bufnr})
|
2024-04-20 17:13:41 +00:00
|
|
|
(vim.lsp.inlay_hint.enable true {: bufnr})
|
2023-06-26 11:07:19 +00:00
|
|
|
(setup-inlay-hint-toggle bufnr))
|
2023-10-14 17:55:02 +00:00
|
|
|
(diagnostic.maybe-enable-lsp client bufnr)))
|
2022-11-27 16:12:49 +00:00
|
|
|
:group augroup
|
|
|
|
:desc "Automatic LSP setup"})
|
2022-04-05 19:57:44 +00:00
|
|
|
;; Servers
|
2023-09-11 22:05:25 +00:00
|
|
|
(vim.lsp.set_log_level :OFF)
|
2023-11-21 21:02:44 +00:00
|
|
|
(let [capabilities (vim.tbl_deep_extend :force
|
|
|
|
(vim.lsp.protocol.make_client_capabilities)
|
|
|
|
(cmp.default_capabilities))
|
2023-11-20 20:59:54 +00:00
|
|
|
handlers {:textDocument/hover (vim.lsp.with vim.lsp.handlers.hover
|
|
|
|
{:border :rounded})
|
|
|
|
:textDocument/signatureHelp (vim.lsp.with vim.lsp.handlers.signature_help
|
|
|
|
{:border :rounded})}
|
2023-10-25 13:58:46 +00:00
|
|
|
flags {:allow_incremental_sync true :debounce_text_changes 700}
|
2023-11-20 20:59:54 +00:00
|
|
|
default-config {: capabilities : handlers : flags}
|
2022-04-05 19:57:44 +00:00
|
|
|
default-servers [:bashls
|
|
|
|
:cssls
|
|
|
|
:dockerls
|
|
|
|
:erlangls
|
2023-02-12 21:13:10 +00:00
|
|
|
:fennel_ls
|
2022-04-05 19:57:44 +00:00
|
|
|
:html
|
2022-11-27 16:12:49 +00:00
|
|
|
:jsonls
|
2024-06-25 14:57:10 +00:00
|
|
|
:marksman
|
2022-05-04 13:03:51 +00:00
|
|
|
:svelte
|
2023-11-28 16:09:38 +00:00
|
|
|
:taplo]]
|
2022-04-05 19:57:44 +00:00
|
|
|
;; Default
|
|
|
|
(each [_ name (pairs default-servers)]
|
|
|
|
((. lsp name :setup) default-config))
|
|
|
|
;; Custom
|
2023-11-18 12:45:55 +00:00
|
|
|
(when (= (vim.fn.executable :elixir-ls) 1)
|
|
|
|
(lsp.elixirls.setup (->> {:cmd [:elixir-ls]}
|
|
|
|
(vim.tbl_extend :force default-config))))
|
2023-11-28 16:09:38 +00:00
|
|
|
(lsp.jsonls.setup (->> {:settings {:json {:schemas (schemastore.json.schemas)
|
|
|
|
:validate {:enable true}}}}
|
|
|
|
(vim.tbl_extend :force default-config)))
|
2023-11-18 12:45:55 +00:00
|
|
|
(when (= (vim.fn.executable :lexical) 1)
|
|
|
|
(lsp.lexical.setup (->> {:cmd [:lexical :start]}
|
|
|
|
(vim.tbl_extend :force default-config))))
|
2024-07-08 21:44:34 +00:00
|
|
|
(when (= (vim.fn.executable :nextls) 1)
|
|
|
|
(lsp.nextls.setup (->> {:cmd [:nextls]}
|
|
|
|
(vim.tbl_extend :force default-config))))
|
2023-11-28 16:09:38 +00:00
|
|
|
(when (= (vim.fn.executable :lua-language-server) 1)
|
|
|
|
(lsp.lua_ls.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))))
|
2023-07-14 23:07:28 +00:00
|
|
|
(when (= (vim.fn.executable :nil) 1)
|
|
|
|
(lsp.nil_ls.setup (->> {:settings {:nil {:formatting {:command [:nixpkgs-fmt]}}}}
|
|
|
|
(vim.tbl_extend :force default-config))))
|
|
|
|
(when (= (vim.fn.executable :nixd) 1)
|
|
|
|
(lsp.nixd.setup (->> {:settings {:formatting {:command [:nixpkgs-fmt]}}}
|
|
|
|
(vim.tbl_extend :force default-config))))
|
2023-06-26 11:07:19 +00:00
|
|
|
(let [inlay-hints {:includeInlayParameterNameHints :all
|
|
|
|
:includeInlayParameterNameHintsWhenArgumentMatchesName false
|
|
|
|
:includeInlayFunctionParameterTypeHints true
|
|
|
|
:includeInlayVariableTypeHints true
|
|
|
|
:includeInlayVariableTypeHintsWhenTypeMatchesName false
|
|
|
|
:includeInlayPropertyDeclarationTypeHints true
|
|
|
|
:includeInlayFunctionLikeReturnTypeHints true
|
|
|
|
:includeInlayEnumMemberValueHints true}]
|
2024-10-02 11:48:58 +00:00
|
|
|
(lsp.ts_ls.setup (->> {:cmd [:typescript-language-server :--stdio]
|
|
|
|
:settings {:typescript {:inlayHints inlay-hints}
|
|
|
|
:javascript {:inlayHints inlay-hints}}}
|
|
|
|
(vim.tbl_extend :force default-config))))
|
2022-04-05 19:57:44 +00:00
|
|
|
(lsp.solargraph.setup (->> {:settings {:solargraph {:diagnostics true}}}
|
|
|
|
(vim.tbl_extend :force default-config)))
|
2023-11-28 16:09:38 +00:00
|
|
|
(lsp.yamlls.setup (->> {:settings {:yaml {:schemaStore {:enable false
|
|
|
|
:url ""}
|
|
|
|
:schemas (schemastore.yaml.schemas)}}}
|
2024-07-09 22:45:24 +00:00
|
|
|
(vim.tbl_extend :force default-config)))))
|