Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] Support bacon lsp in pack-rust #1308

Open
chaozwn opened this issue Jan 5, 2025 · 4 comments
Open

[Feature] Support bacon lsp in pack-rust #1308

chaozwn opened this issue Jan 5, 2025 · 4 comments
Labels
enhancement New feature or request

Comments

@chaozwn
Copy link
Contributor

chaozwn commented Jan 5, 2025

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

@chaozwn chaozwn added the enhancement New feature or request label Jan 5, 2025
@Uzaaft
Copy link
Member

Uzaaft commented Jan 5, 2025

This shouldnt be added to the rust pack. It can be its own pack if needed

@Uzaaft
Copy link
Member

Uzaaft commented Jan 14, 2025

Tried to add this to a bacon pack, but didnt get it to work.

@chaozwn
Copy link
Contributor Author

chaozwn commented Jan 14, 2025

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,
  }
}

@chaozwn
Copy link
Contributor Author

chaozwn commented Jan 14, 2025

and after open rust project, run in terminal bacon -j bacon-ls.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants