Crates.io | bacon-ls |
lib.rs | bacon-ls |
version | |
source | src |
created_at | 2024-05-17 22:49:59.955751 |
updated_at | 2025-01-02 17:58:22.955312 |
description | Bacon Language Server |
homepage | https://github.com/crisidev/bacon-ls |
repository | https://github.com/crisidev/bacon-ls |
max_upload_size | |
id | 1243779 |
Cargo.toml error: | TOML parse error at line 18, column 1 | 18 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include` |
size | 0 |
NOTE: bacon-ls 0.5 has breaking changes and will work only with bacon 3.7+. The README for bacon-ls 0.4 can be found here.
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-ls
🐽 is meant to be easy to include in your IDE configuration.
textDocument/diagnostic
and workspace/diagnostic
bacon-ls
to nvim-lspconfig - https://github.com/neovim/nvim-lspconfig/pull/3160bacon
and bacon-ls
to mason.nvim - https://github.com/mason-org/mason-registry/pull/5774bacon-ls
to LazyVim Rust extras - https://github.com/LazyVim/LazyVim/pull/3212Both Bacon and Bacon-ls are installable via mason.nvim:
:MasonInstall bacon bacon-ls
First, install Bacon and bacon-ls
🐽
❯❯❯ cargo install --locked bacon bacon-ls
❯❯❯ bacon --version
bacon 3.7.0 # make sure you have at least 3.7.0
❯❯❯ bacon-ls --version
0.5.0 # make sure you have at least 0.5.0
Configure Bacon export settings with bacon-ls
🐽 export format and proper span support in ~/.config/bacon/prefs.toml
:
[jobs.bacon-ls]
command = [ "cargo", "clippy", "--tests", "--all-targets", "--all-features", "--message-format", "json-diagnostic-rendered-ansi" ]
analyzer = "cargo_json"
need_stdout = true
[exports.cargo-json-spans]
auto = true
exporter = "analyzer"
line_format = "{diagnostic.level}:{span.file_name}:{span.line_start}:{span.line_end}:{span.column_start}:{span.column_end}:{diagnostic.message}"
path = ".bacon-locations"
NOTE: bacon
MUST be running to generate the export locations with the bacon-ls
job: bacon -j bacon-ls
.
The language server can be configured using the appropriate LSP protocol and supports the following values:
locationsFile
Bacon export filename (default: .bacon-locations
).updateOnSave
Try to update diagnostics every time the file is saved (default: true).updateOnSaveWaitMillis
How many milliseconds to wait before updating diagnostics after a save (default: 1000).updateOnChange
Try to update diagnostics every time the file changes (default: false).vim.g.lazyvim_rust_diagnostics = "bacon-ls"
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").bacon_ls.setup({
init_options = {
updateOnSave = true
updateOnSaveWaitMillis = 1000
updateOnChange = true
}
})
For rust-analyzer
, these 2 options must be turned off:
rust-analyzer.checkOnSave.enable = false
rust-analyzer.diagnostics.enable = false
The Vscode extension is not ready yet but should be part of Bacon-ls 0.6.0.
bacon-ls
🐽 can produce a log file in the folder where its running by exporting the RUST_LOG
variable in the shell:
❯❯❯ export RUST_LOG=debug
❯❯❯ nvim src/some-file.rs
# or
❯❯❯ RUST_LOG=debug nvim src/some-file.rs
❯❯❯ tail -F ./bacon-ls.log
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
.
bacon-ls
🐽 has been inspired by typos-lsp.