summaryrefslogtreecommitdiff
path: root/fnl/config/lsp/handlers.fnl
diff options
context:
space:
mode:
authorGustaf Rydholm <gustaf.rydholm@gmail.com>2022-04-12 21:15:44 +0200
committerGustaf Rydholm <gustaf.rydholm@gmail.com>2022-04-12 21:15:44 +0200
commit82779fc7fbb42f5f97bf5840d3248ad84a63c095 (patch)
tree7d8327aa0f7eeea7fed99b69c554eb19c671ef29 /fnl/config/lsp/handlers.fnl
parent4ec6fb5118f95f00dbacdcf0470e0f9fffd86abc (diff)
parentc561be2e3e71c226985640320559e3bf5e1c7034 (diff)
feat(fennel): migration
Diffstat (limited to 'fnl/config/lsp/handlers.fnl')
-rw-r--r--fnl/config/lsp/handlers.fnl61
1 files changed, 61 insertions, 0 deletions
diff --git a/fnl/config/lsp/handlers.fnl b/fnl/config/lsp/handlers.fnl
new file mode 100644
index 0000000..1e3785b
--- /dev/null
+++ b/fnl/config/lsp/handlers.fnl
@@ -0,0 +1,61 @@
+(module config.lsp.handlers {autoload {util util nvim aniseed.nvim}})
+
+(def- signs [{:name :DiagnosticSignError :text ""}
+ {:name :DiagnosticSignWarn :text ""}
+ {:name :DiagnosticSignHint :text ""}
+ {:name :DiagnosticSignInfo :text ""}])
+
+(defn- apply-signs [] (each [_ sign (ipairs signs)]
+ (vim.fn.sign_define sign.name
+ {:texthl sign.name
+ :text sign.text
+ :numhl ""})))
+
+(def- config {:virtual_text false
+ :signs {:active signs}
+ :update_in_insert true
+ :underline true
+ :severity_sort true
+ :float {:focusable false
+ :style :minimal
+ :border :rounded
+ :source :always
+ :header ""
+ :prefix ""}})
+
+(defn setup [] (apply-signs) (vim.diagnostic.config config)
+ (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}]
+ (nvim.buf_set_keymap bufnr :n :gD
+ "<cmd>lua vim.lsp.buf.declaration()<CR>" opts)
+ (nvim.buf_set_keymap bufnr :n :gd
+ "<cmd>lua vim.lsp.buf.definition()<CR>" opts)
+ (nvim.buf_set_keymap bufnr :n :K "<cmd>lua vim.lsp.buf.hover()<CR>"
+ opts)
+ (nvim.buf_set_keymap bufnr :n :gI
+ "<cmd>lua vim.lsp.buf.implementation()<CR>" opts)
+ (nvim.buf_set_keymap bufnr :n :gr
+ "<cmd>lua vim.lsp.buf.references()<CR>" opts)
+ (nvim.buf_set_keymap bufnr :n :gl
+ "<cmd>lua vim.diagnostic.open_float()<CR>" opts)
+ (nvim.buf_set_keymap bufnr :n :<leader>q
+ "<cmd>lua vim.diagnostic.setloclist()<CR>" 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))
+
+(setup)