1
0
Fork 0
dotfiles/home/config/nvim/plugins/lsp.fnl

98 lines
5.3 KiB
Text
Raw Normal View History

2022-04-05 19:57:44 +00:00
(let [lsp (require :lspconfig)
2023-08-09 11:05:42 +00:00
lsp-configs (require :lspconfig.configs)
coq (require :coq)
navic (require :nvim-navic)
diagnostic (require :nifoc.diagnostic)
2022-11-27 16:12:49 +00:00
formatting (require :nifoc.formatting)
augroup (vim.api.nvim_create_augroup :NifocLsp {:clear true})
aucmd vim.api.nvim_create_autocmd]
2023-06-26 11:07:19 +00:00
(fn setup-inlay-hint-toggle [bufnr]
2023-07-05 21:55:20 +00:00
(aucmd :InsertEnter {:callback #(vim.lsp.inlay_hint bufnr false)
2023-06-26 11:07:19 +00:00
:buffer bufnr
:group augroup})
2023-07-05 21:55:20 +00:00
(aucmd :InsertLeave {:callback #(vim.lsp.inlay_hint bufnr true)
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]
(when (client.supports_method :textDocument/documentSymbol)
(navic.attach client bufnr))
2023-06-22 18:57:21 +00:00
(when (client.supports_method :textDocument/inlayHint)
2023-07-05 21:55:20 +00:00
(vim.lsp.inlay_hint bufnr true)
2023-06-26 11:07:19 +00:00
(setup-inlay-hint-toggle bufnr))
2022-11-27 16:12:49 +00:00
(diagnostic.maybe-enable-lsp client bufnr)
2023-10-05 11:14:18 +00:00
(formatting.maybe-enable-lsp client bufnr)
((. (require :lsp-notify) :setup) {})))
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)
(let [flags {:allow_incremental_sync true :debounce_text_changes 700}
default-config (coq.lsp_ensure_capabilities {: flags})
2022-04-05 19:57:44 +00:00
default-servers [:bashls
:cssls
:dockerls
:erlangls
:eslint
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
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
2023-08-09 11:05:42 +00:00
(when (not lsp-configs.lexical)
(set lsp-configs.lexical
{:default_config {:filetypes [:elixir :eelixir]
:cmd [:lexical :start]
:root_dir (fn [fname]
(or ((lsp.util.root_pattern :mix.exs
:.git) fname)
(vim.loop.os_homedir)))
:settings {}}}))
(if (= (vim.fn.executable :elixir-ls) 1)
(lsp.elixirls.setup (->> {:cmd [:elixir-ls]}
(vim.tbl_extend :force default-config)))
(lsp.lexical.setup {}))
(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}]
(lsp.tsserver.setup (->> {:cmd [:typescript-language-server
:--stdio
:--tsserver-path
:tsserver]
: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-07-22 20:56:25 +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))))))