From 838f1fb2623a3e6ad33575ee8da5ddbc7bd309f1 Mon Sep 17 00:00:00 2001 From: u2515h Date: Sat, 6 Jan 2024 22:04:48 +0100 Subject: [PATCH] feat(nvim): switch rust-tools to rustaceanvim --- completion.lua | 12 ++++++++++++ default.nix | 2 +- rust.lua | 30 ++++++++++++++++++++++-------- 3 files changed, 35 insertions(+), 9 deletions(-) diff --git a/completion.lua b/completion.lua index 2d2d642..f94b568 100644 --- a/completion.lua +++ b/completion.lua @@ -20,6 +20,13 @@ autocmd CursorHold * lua vim.diagnostic.open_float(nil, { focusable = false }) vim.opt.spell = true vim.opt.spelllang = {'en_us'} +vim.lsp.handlers["textDocument/publishDiagnostics"] = + vim.lsp.with( + vim.lsp.diagnostic.on_publish_diagnostics, + { + virtual_text = true, + } +) -- Completion Plugin Setup local cmp = require 'cmp' cmp.setup({ @@ -82,3 +89,8 @@ cmp.setup({ end } }) +cmp.setup.cmdline('/', { + sources = { + { name = 'buffer' }, + } +}) diff --git a/default.nix b/default.nix index b3e27b2..b304e5d 100644 --- a/default.nix +++ b/default.nix @@ -55,7 +55,7 @@ in cmp-spell cmp-conventionalcommits cmp-calc - rust-tools-nvim + rustaceanvim plenary-nvim crates-nvim nvim-lspconfig diff --git a/rust.lua b/rust.lua index 1f994f0..04167c5 100644 --- a/rust.lua +++ b/rust.lua @@ -1,9 +1,8 @@ -local rt = require("rust-tools") local nvim_lsp = require 'lspconfig' local c = vim.lsp.protocol.make_client_capabilities() local deps = require("nvim-deps") -rt.setup({ +vim.g.rustaceanvim = { tools = { -- rust-tools options -- how to execute terminal commands -- options right now: termopen / quickfix / toggleterm / vimux @@ -122,13 +121,28 @@ rt.setup({ local keymap_opts = {buffer = bufnr} -- Hover actions -- call twice to focus - vim.keymap.set("n", "h", rt.hover_actions.hover_actions, - keymap_opts) + vim.keymap.set("n", "K", + function() + vim.cmd.RustLsp { 'hover', 'actions' } + end, keymap_opts) -- Code action groups vim.keymap.set("n", "as", - rt.code_action_group.code_action_group, keymap_opts) - vim.keymap.set('n', 'c', rt.open_cargo_toml.open_cargo_toml) - vim.keymap.set("n", "g0", vim.lsp.buf.document_symbol, keymap_opts) + function() + vim.cmd.RustLsp { 'hover', 'actions' } + end, keymap_opts) + vim.keymap.set('n', 'cc', + function() + vim.cmd.RustLsp('openCargo') + end, keymap_opts) + vim.keymap.set('n', 'cr', + function() + vim.cmd.RustLsp {'runnables', 'last' --[[ optional ]] } + end, keymap_opts) + vim.keymap.set('n', 'cd', + function() + vim.cmd.RustLsp {'debuggables', 'last' --[[ optional ]] } + end, keymap_opts) +-- vim.keymap.set("n", "g0", vim.lsp.buf.document_symbol, keymap_opts) local diag_float_grp = vim.api.nvim_create_augroup( "DiagnosticFloat", {clear = true}) vim.api.nvim_create_autocmd("CursorHold", { @@ -152,4 +166,4 @@ rt.setup({ name = "rt_lldb" } } -}) +}