From fa9a5c6b80b5b0ffdcddc4b1d1c6cfe887d0bb04 Mon Sep 17 00:00:00 2001 From: Gustaf Rydholm Date: Thu, 7 Apr 2022 22:32:36 +0200 Subject: feat(lsp handler): finish fnl config --- fnl/config/lsp/handlers.fnl | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) (limited to 'fnl/config') diff --git a/fnl/config/lsp/handlers.fnl b/fnl/config/lsp/handlers.fnl index fc0b006..c691d1a 100644 --- a/fnl/config/lsp/handlers.fnl +++ b/fnl/config/lsp/handlers.fnl @@ -1,4 +1,6 @@ -(module config.lsp.handlers) +(module config.lsp.handlers + {autoload {util util + nvim aniseed.nvim}}) (def- signs [{ :name "DiagnosticSignError" :text "" } @@ -33,3 +35,25 @@ (set vim.lsp.handlers.textDocument/hover (vim.lsp.with { :border "rounded"} )) (set vim.lsp.handlers.textDocument/signatureHelp (vim.lsp.with vim.lsp.handlers.signature_help { :border "rounded"} )))) +(defn- lsp-keymaps [bufnr] + (let [opts { :noremap true :silent true }] + (do + (nvim.buf_set_keymap bufnr :n :gD "lua vim.lsp.buf.declaration()" opts) + (nvim.buf_set_keymap bufnr :n :gd "lua vim.lsp.buf.definition()" opts) + (nvim.buf_set_keymap bufnr :n :K "lua vim.lsp.buf.hover()" opts) + (nvim.buf_set_keymap bufnr :n :gI "lua vim.lsp.buf.implementation()" opts) + (nvim.buf_set_keymap bufnr :n :gr "lua vim.lsp.buf.references()" opts) + (nvim.buf_set_keymap bufnr :n :gl "lua vim.diagnostic.open_float()" opts) + (nvim.buf_set_keymap bufnr :n :q "lua vim.diagnostic.setloclist()" opts)))) + +(defn on-attach [client bufnr] + (if (= client.name :html) + (set client.resolved_capabilities.document_formatting false)) + (lsp-keymaps bufnr)) + +(defn capabilities [] + (let [capabilities (vim.lsp.protocol.make_client_capabilities)] + (set capabilities.textDocument.completion.completionItem.snippetSupport true) + (let [cmp-nvim-lsp (util.load-plugin :cmp_nvim_lsp)] + (cmp-nvim-lsp.update_capabilities capabilities)) + (capabilities))) -- cgit v1.2.3-70-g09d2