From b285c4e258d5f0e6d24bb0d5f18c27d015552de0 Mon Sep 17 00:00:00 2001 From: Stefan Boca Date: Fri, 1 Nov 2024 10:47:20 -0700 Subject: [PATCH] feat: enable crates.nvim in-process lsp server --- lua/lazyvim/plugins/extras/lang/rust.lua | 53 ++++++------------------ 1 file changed, 13 insertions(+), 40 deletions(-) diff --git a/lua/lazyvim/plugins/extras/lang/rust.lua b/lua/lazyvim/plugins/extras/lang/rust.lua index 145940ca..450aee93 100644 --- a/lua/lazyvim/plugins/extras/lang/rust.lua +++ b/lua/lazyvim/plugins/extras/lang/rust.lua @@ -6,26 +6,23 @@ return { }) end, - -- Extend auto completion + -- LSP for Cargo.toml { - "hrsh7th/nvim-cmp", - optional = true, - dependencies = { - { - "Saecki/crates.nvim", - event = { "BufRead Cargo.toml" }, - opts = { - completion = { - cmp = { enabled = true }, - }, + "Saecki/crates.nvim", + event = { "BufRead Cargo.toml" }, + opts = { + completion = { + crates = { + enabled = true, }, }, + lsp = { + enabled = true, + actions = true, + completion = true, + hover = true, + }, }, - ---@param opts cmp.ConfigSchema - opts = function(_, opts) - opts.sources = opts.sources or {} - table.insert(opts.sources, { name = "crates" }) - end, }, -- Add Rust & related to treesitter @@ -90,30 +87,6 @@ return { end, }, - -- Correctly setup lspconfig for Rust 🚀 - { - "neovim/nvim-lspconfig", - opts = { - servers = { - taplo = { - keys = { - { - "K", - function() - if vim.fn.expand("%:t") == "Cargo.toml" and require("crates").popup_available() then - require("crates").show_popup() - else - vim.lsp.buf.hover() - end - end, - desc = "Show Crate Documentation", - }, - }, - }, - }, - }, - }, - { "nvim-neotest/neotest", optional = true,