3 releases (breaking)

0.3.0 May 21, 2024
0.2.0 May 18, 2024
0.1.0 May 17, 2024

#112 in Text editors

Download history 44/week @ 2024-06-09 70/week @ 2024-06-16 48/week @ 2024-06-23 60/week @ 2024-06-30 49/week @ 2024-07-07 48/week @ 2024-07-14 46/week @ 2024-07-21 49/week @ 2024-07-28 48/week @ 2024-08-04 59/week @ 2024-08-11 59/week @ 2024-08-18 40/week @ 2024-08-25 63/week @ 2024-09-01 47/week @ 2024-09-08 51/week @ 2024-09-15

218 downloads per month

Custom license

3MB
517 lines

🐽 Bacon Language Server 🐽

Ci Release Crates.io License

LSP Server wrapper for the exceptional Bacon exposing textDocument/diagnostic and workspace/diagnostic capabilities.

See bacon-ls 🐽 blog post: https://lmno.lol/crisidev/bacon-language-server

Bacon screenshot

bacon-ls 🐽 is meant to be easy to include in your IDE configuration.

Features - ✅ done 🕖 in progress 🌍 future

Bacon gif

Installation

First, install Bacon and bacon-ls 🐽

❯❯❯ cargo install --locked bacon bacon-ls

Configure Bacon export-locations settings with bacon-ls 🐽 export format:

[export]
enabled = true
path = ".bacon-locations"
line_format = "{kind}:{path}:{line}:{column}:{message}"

Configuration

The language server can be configured using the appropriate LSP protocol and supports the following values:

  • locationsFile Bacon export filename, default .bacon-locations.
  • waitTimeSeconds Maximum time in seconds the LSP server waits for Bacon to update the export file before loading the new diagnostics, default 10.

Neovim - LazyVim

return {
    {
        "neovim/nvim-lspconfig",
        opts = {
            diagnostics = {
                update_in_insert = true,
            },
            servers = {
                rust_analyzer = { enable = false },
                bacon_ls = {
                    enable = true
                    settings = {
                        -- locationsFile = ".locations",
                        -- waitTimeSeconds = 5
                    },
                },
            },
        },
    },
    {
        "mrcjkb/rustaceanvim",
        opts = {
            default_settings = {
                ["rust-analyzer"] = {
                    diagnostics = { enable = false },
                    checkOnSave = { enable = false },
                },
            },
        },
    },
}

Neovim - Manual

NeoVim requires nvim-lspconfig to be configured and rust-analyzer diagnostics must be turned off for Bacon-Ls 🐽 to properly function.

bacon-ls is part of nvim-lspconfig from commit 6d2ae9f and it can be configured like any other LSP server works best when vim.diagnostics.Opts.update_in_insert is set to true.

require("lspconfig.configs").bacon_ls.setup({
    autostart=true,
    settings = {
        -- locationsFile = ".locations",
        -- waitTimeSeconds = 5
    },
})

For rust-analyzer, these 2 options must be turned off:

rust-analyzer.checkOnSave.enable = false
rust-analyzer.diagnostics.enable = false

How does it work?

bacon-ls 🐽 reads the diagnostics location list generated by Bacon's export-locations and exposes them on STDIO over the LSP protocol to be consumed by the client diagnostics.

It requires Bacon to be running alongside to ensure regular updates of the export locations.

The LSP client reads them as response to textDocument/diagnostic and workspace/diagnostic.

Thanks

bacon-ls 🐽 has been inspired by typos-lsp.

Dependencies

~10–19MB
~254K SLoC