dots-of-war/files/.config/nvim/fnl/plugins/lsp.fnl

71 lines
2.5 KiB
Text
Raw Normal View History

2021-04-03 18:34:15 +00:00
(module plugins.lsp
{require {a aniseed.core
lsp lspconfig
2021-04-22 14:00:33 +00:00
lsp-configs lspconfig.configs
2021-05-08 18:51:05 +00:00
utils utils}
2021-04-30 08:23:30 +00:00
2021-05-08 18:51:05 +00:00
require-macros [macros]})
2021-04-30 11:30:39 +00:00
2021-04-03 18:34:15 +00:00
(fn on_attach [client bufnr]
2021-05-08 20:24:53 +00:00
(pkg lsp_signature.nvim [lsp_signature (require "lsp_signature")]
(lsp_signature.on_attach))
2021-04-03 18:34:15 +00:00
(if client.resolved_capabilities.document_highlight
2021-04-04 13:04:29 +00:00
(do
(utils.highlight "LspReferenceRead" {:gui "underline"})
(utils.highlight "LspReferenceText" {:gui "underline"})
(utils.highlight "LspReferenceWrite" {:gui "underline"})
(vim.api.nvim_exec
"augroup lsp_document_highlight
autocmd! * <buffer>
autocmd CursorHold <buffer> lua vim.lsp.buf.document_highlight()
autocmd CursorMoved <buffer> lua vim.lsp.buf.clear_references()
augroup END"
false))))
2021-04-03 18:34:15 +00:00
2021-04-22 14:00:33 +00:00
(fn better_root_pattern [patterns except-patterns]
"match path if one of the given patterns is matched, EXCEPT if one of the except-patterns is matched"
(fn [path]
(when (not ((lsp.util.root_pattern except-patterns) path))
((lsp.util.root_pattern patterns) path))))
2021-04-22 17:54:37 +00:00
(fn init-lsp [lsp-name ?opts]
"initialize a language server with defaults"
2021-04-23 14:46:45 +00:00
(let [merged-opts (a.merge {:on_attach on_attach} (or ?opts {}))]
2021-04-22 17:54:37 +00:00
((. lsp lsp-name :setup) merged-opts)))
2021-04-23 14:46:45 +00:00
2021-04-22 17:54:37 +00:00
2021-04-30 14:26:31 +00:00
(let [capabilities (vim.lsp.protocol.make_client_capabilities)]
(set capabilities.textDocument.completion.completionItem.snippetSupport true)
(set capabilities.textDocument.completion.completionItem.resolveSupport
2021-05-06 18:54:55 +00:00
{:properties ["documentation" "detail" "additionalTextEdits"]})
(lsp.rust_analyzer.setup
{:capabilities capabilities
:on_attach (fn [...]
(on_attach ...)
(pkg rust-tools.nvim [rust-tools (require "rust-tools")]
(rust-tools.setup { :tools { :inlay_hints { :show_parameter_hints false}}})))}))
(init-lsp :tsserver {:root_dir (lsp.util.root_pattern "package.json")})
(init-lsp :jsonls {:commands {:Format [ #(vim.lsp.buf.range_formatting [] [0 0] [(vim.fn.line "$") 0])]}})
(init-lsp :denols {:root_dir (better_root_pattern [".git"] ["package.json"])})
(init-lsp :hls {:settings {:languageServerHaskell {:formattingProvider "stylish-haskell"}}})
2021-05-01 10:01:13 +00:00
(init-lsp :ocamllsp)
2021-04-22 17:54:37 +00:00
(init-lsp :vimls)
(init-lsp :bashls)
(init-lsp :erlangls)
(init-lsp :yamlls)
(init-lsp :html)
(init-lsp :cssls)
;(lsp.vimls.setup { :on_attach on_attach})
2021-04-30 14:26:31 +00:00
2021-04-30 11:30:39 +00:00
(set vim.o.signcolumn "yes")
2021-04-30 10:53:30 +00:00
2021-04-30 14:26:31 +00:00
; vim:foldmarker=<<<<<,>>>>>