Skip to content

Commit

Permalink
feat(rust): Remove rust-tools and use ferris.nvim instead
Browse files Browse the repository at this point in the history
  • Loading branch information
Uzaaft committed Nov 10, 2023
1 parent 5c6b189 commit e51bec8
Showing 1 changed file with 19 additions and 50 deletions.
69 changes: 19 additions & 50 deletions lua/astrocommunity/pack/rust/init.lua
Original file line number Diff line number Diff line change
@@ -1,64 +1,33 @@
local utils = require "astrocore"
return {
{ import = "astrocommunity.pack.toml" },
{
"AstroNvim/astrolsp",
opts = {
handlers = { rust_analyzer = false },
},
},
{
"nvim-treesitter/nvim-treesitter",
opts = function(_, opts)
if opts.ensure_installed ~= "all" then
opts.ensure_installed = utils.list_insert_unique(opts.ensure_installed, "rust")
end
end,
},
{
"simrat39/rust-tools.nvim",
ft = { "rust" },
opts = function()
local adapter
local success, package = pcall(function() return require("mason-registry").get_package "codelldb" end)
if success then
local package_path = package:get_install_path()
local codelldb_path = package_path .. "/codelldb"
local liblldb_path = package_path .. "/extension/lldb/lib/liblldb"
local this_os = vim.loop.os_uname().sysname

-- The path in windows is different
if this_os:find "Windows" then
codelldb_path = package_path .. "\\extension\\adapter\\codelldb.exe"
liblldb_path = package_path .. "\\extension\\lldb\\bin\\liblldb.dll"
else
-- The liblldb extension is .so for linux and .dylib for macOS
liblldb_path = liblldb_path .. (this_os == "Linux" and ".so" or ".dylib")
end
adapter = require("rust-tools.dap").get_codelldb_adapter(codelldb_path, liblldb_path)
else
adapter = require("rust-tools.dap").get_codelldb_adapter()
end

return { server = require("astrolsp").lsp_opts "rust_analyzer", dap = { adapter = adapter } }
"vxpm/ferris.nvim",
lazy = true,
init = function()
vim.api.nvim_create_autocmd("LspAttach", {
group = vim.api.nvim_create_augroup("lazy_ferris", { clear = true }),
desc = "Lazy load Ferris",
once = true,
callback = function(args)
if vim.lsp.get_client_by_id(args.data.client_id).name == "rust_analyzer" then
if require("ferris.private.config").opts.create_commands then
require("ferris").create_commands(args.buf)
end
end
end,
})
end,
dependencies = {
{
"jay-babu/mason-nvim-dap.nvim",
opts = function(_, opts) opts.ensure_installed = utils.list_insert_unique(opts.ensure_installed, "codelldb") end,
},
opts = {
url_handler = function(str) require("astrocore").system_open(str) end,
},
},
{
"williamboman/mason-lspconfig.nvim",
opts = function(_, opts) opts.ensure_installed = utils.list_insert_unique(opts.ensure_installed, "rust_analyzer") end,
},
{
"Saecki/crates.nvim",
event = { "BufRead Cargo.toml" },
lazy = true,
init = function()
vim.api.nvim_create_autocmd("BufRead", {
group = vim.api.nvim_create_augroup("CmpSourceCargo", { clear = true }),
desc = "Load crates.nvim into Cargo buffers",
pattern = "Cargo.toml",
callback = function()
require("cmp").setup.buffer { sources = { { name = "crates" } } }
Expand Down

0 comments on commit e51bec8

Please sign in to comment.