astrocommunity
astrocommunity copied to clipboard
[Feature] Support bacon lsp in pack-rust
Is your feature related to a problem?
Refer to Bacon:
https://github.com/crisidev/bacon-ls?tab=readme-ov-file#manual
Refer to Lazyvim:
https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/plugins/extras/lang/rust.lua
Describe the new feature
Baconls is faster than rust-analyzer in analysis. I hope it can be supported.
Additional context
No response
This shouldnt be added to the rust pack. It can be its own pack if needed
Tried to add this to a bacon pack, but didnt get it to work.
Tried to add this to a bacon pack, but didnt get it to work.
vim.g.astronvim_rust_diagnostics = "bacon-ls"
local diagnostics = vim.g.astronvim_rust_diagnostics or "rust-analyzer"
return {
{
"AstroNvim/astrolsp",
---@type AstroLSPOpts
opts = function(_, opts)
-- add this
if diagnostics ~= "rust-analyzer" then require("astrocore").list_insert_unique(opts.servers, { "bacon_ls" }) end
return vim.tbl_deep_extend("force", opts, {
handlers = {
rust_analyzer = false,
},
---@diagnostic disable: missing-fields
config = {
bacon_ls = {
init_options = {
updateOnSave = true,
updateOnSaveWaitMillis = 1000,
updateOnChange = false,
},
},
rust_analyzer = {
settings = {
["rust-analyzer"] = {
cargo = {
allFeatures = true,
loadOutDirsFromCheck = true,
buildScripts = {
enable = true,
},
},
-- Add clippy lints for Rust if using rust-analyzer
checkOnSave = diagnostics == "rust-analyzer",
-- Enable diagnostics if using rust-analyzer
diagnostics = {
enable = diagnostics == "rust-analyzer",
},
procMacro = {
enable = true,
ignored = {
["async-trait"] = { "async_trait" },
["napi-derive"] = { "napi" },
["async-recursion"] = { "async_recursion" },
},
},
files = {
excludeDirs = {
".direnv",
".git",
".github",
".gitlab",
"bin",
"node_modules",
"target",
"venv",
".venv",
},
},
},
},
},
},
})
end,
},
{
"WhoIsSethDaniel/mason-tool-installer.nvim",
optional = true,
opts = function(_, opts)
opts.ensure_installed = require("astrocore").list_insert_unique(opts.ensure_installed, { "codelldb" })
if diagnostics ~= "rust-analyzer" then
require("astrocore").list_insert_unique(opts.ensure_installed, { "bacon" })
end
end,
}
}
and after open rust project, run in terminal bacon -j bacon-ls.