From 5eff7fed68ea497a205a19f16e56d341e652066e Mon Sep 17 00:00:00 2001 From: buffet Date: Sat, 15 May 2021 00:20:12 +0000 Subject: [PATCH] Setup lsp --- install.py | 1 + nvim/.config/nvim/fnl/modules/keybinds.fnl | 8 +++- nvim/.config/nvim/fnl/modules/lsp.fnl | 37 +++++++++++++++++++ .../nvim/fnl/modules/plugins/lspsaga.fnl | 10 +++++ 4 files changed, 54 insertions(+), 2 deletions(-) create mode 100644 nvim/.config/nvim/fnl/modules/lsp.fnl create mode 100644 nvim/.config/nvim/fnl/modules/plugins/lspsaga.fnl diff --git a/install.py b/install.py index 08b8e2d..6cc6649 100644 --- a/install.py +++ b/install.py @@ -26,6 +26,7 @@ DOTS = ['alacritty', 'bash', 'direnv', 'git', 'nvim', 'profile', 'xinit'] dependencies = [ 'acpi', 'alacritty', + 'clang', 'curl', 'firefox', 'git', diff --git a/nvim/.config/nvim/fnl/modules/keybinds.fnl b/nvim/.config/nvim/fnl/modules/keybinds.fnl index dd6407f..29fb829 100644 --- a/nvim/.config/nvim/fnl/modules/keybinds.fnl +++ b/nvim/.config/nvim/fnl/modules/keybinds.fnl @@ -36,7 +36,11 @@ :g (cmd "Goyo" "goyo") :l (cmd "Limelight!!" "limelight")} - ;; TODO: lsp binds - :l {:name "+lsp"}} + :l {:name "+lsp" + :a (cmd "Lspsaga code_action" "code actions") + :d (cmd "Lspsaga hover_doc" "show docs") + :f (cmd "Lspsaga lsp_finder" "finder") + :r (cmd "Lspsaga rename" "rename") + :g [vim.lsp.buf.definition "go to definition"]}} {:prefix ""}) diff --git a/nvim/.config/nvim/fnl/modules/lsp.fnl b/nvim/.config/nvim/fnl/modules/lsp.fnl new file mode 100644 index 0000000..c1a551d --- /dev/null +++ b/nvim/.config/nvim/fnl/modules/lsp.fnl @@ -0,0 +1,37 @@ +(module modules.lsp + {require {a aniseed.core + lsp lspconfig + lsp_signature lsp_signature + rust-tools rust-tools + utils utils}}) + +(fn on_attach [client bufnr] + (lsp_signature.on_attach) + (if client.resolved_capabilities.document_highlight + (do + (utils.highlight "LspReferenceRead" {:gui "underline"}) + (utils.highlight "LspReferenceText" {:gui "underline"}) + (utils.highlight "LspReferenceWrite" {:gui "underline"})))) + +(fn init-lsp [lsp-name ?opts] + "Initialize a language server" + (let [merged-opts (a.merge {:on_attach on_attach} (or ?opts {}))] + ((. lsp lsp-name :setup) merged-opts))) + +;; Rust extra caps +(let [caps (vim.lsp.protocol.make_client_capabilities)] + ;; TODO: fix + (set caps.textDocument.completion.completionItem.snippetSupport true) + (set caps.textDocument.completion.completionItem.resolveSupport + {:properties ["documentation" "detail" "additionalTextEdits"]}) + (lsp.rust_analyzer.setup + {:capabilities caps + :on_attach (fn [...] + (on_attach ...))})) + ;; TODO: fix + ;(rust-tools.setup + ; {:tools {:inlay_hints {:show_parameter_hints false}}}))})) + +(init-lsp :bashls) +(init-lsp :clangd) +(init-lsp :vimls) diff --git a/nvim/.config/nvim/fnl/modules/plugins/lspsaga.fnl b/nvim/.config/nvim/fnl/modules/plugins/lspsaga.fnl new file mode 100644 index 0000000..42f3494 --- /dev/null +++ b/nvim/.config/nvim/fnl/modules/plugins/lspsaga.fnl @@ -0,0 +1,10 @@ +(module modules.plugins.lspsaga + {require {saga lspsaga}}) + +(saga.init_lsp_saga + {:border_style "round" + :finder_action_keys + {:open "" + :vsplit :v + :split :s + :quit :q}})