dotfiles/home/config/nvim/plugins/lsp.fnl

61 lines
3 KiB
Text
Raw Normal View History

2022-04-05 19:57:44 +00:00
(let [lsp (require :lspconfig)
cmp (require :cmp_nvim_lsp)
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]
;; 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))
(diagnostic.maybe-enable-lsp client bufnr)
(formatting.maybe-enable-lsp client bufnr)))
:group augroup
:desc "Automatic LSP setup"})
2022-04-05 19:57:44 +00:00
;; 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}
2022-11-27 16:12:49 +00:00
default-config {: capabilities : flags}
2022-04-05 19:57:44 +00:00
default-servers [:bashls
:cssls
:dockerls
:erlangls
:eslint
2022-11-27 16:12:49 +00:00
:fennel-ls
2022-04-05 19:57:44 +00:00
:html
2022-11-27 16:12:49 +00:00
:jsonls
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]}
(vim.tbl_extend :force default-config)))
2022-04-05 19:57:44 +00:00
(lsp.tsserver.setup (->> {:cmd [:typescript-language-server
:--stdio
:--tsserver-path
:tsserver]}
2022-11-27 16:12:49 +00:00
(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)))
(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