{"id":15678122,"url":"https://github.com/crisidev/bacon-ls","last_synced_at":"2025-04-04T11:07:39.223Z","repository":{"id":240270556,"uuid":"802170677","full_name":"crisidev/bacon-ls","owner":"crisidev","description":"A Language Server for Rust using Bacon diagnostics","archived":false,"fork":false,"pushed_at":"2025-03-26T09:54:27.000Z","size":4172,"stargazers_count":81,"open_issues_count":3,"forks_count":5,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-28T10:01:44.537Z","etag":null,"topics":["diagnostics","ide","lsp","lsp-server","neovim","rust"],"latest_commit_sha":null,"homepage":"https://github.com/crisidev/bacon-ls","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/crisidev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-05-17T16:50:59.000Z","updated_at":"2025-03-28T06:24:21.000Z","dependencies_parsed_at":"2024-05-19T23:23:11.878Z","dependency_job_id":"ecc72771-2d5f-4f2c-9071-bf810018b6f5","html_url":"https://github.com/crisidev/bacon-ls","commit_stats":null,"previous_names":["crisidev/bacon-ls"],"tags_count":19,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/crisidev%2Fbacon-ls","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/crisidev%2Fbacon-ls/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/crisidev%2Fbacon-ls/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/crisidev%2Fbacon-ls/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/crisidev","download_url":"https://codeload.github.com/crisidev/bacon-ls/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247160149,"owners_count":20893774,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["diagnostics","ide","lsp","lsp-server","neovim","rust"],"created_at":"2024-10-03T16:17:08.120Z","updated_at":"2025-04-04T11:07:39.187Z","avatar_url":"https://github.com/crisidev.png","language":"Rust","funding_links":[],"categories":["Rust"],"sub_categories":[],"readme":"# 🐽 Bacon Language Server 🐽\n\n[![Ci](https://img.shields.io/github/actions/workflow/status/crisidev/bacon-ls/ci.yml?style=for-the-badge)](https://github.com/crisidev/bacon-ls/actions?query=workflow%3Aci)\n[![Release](https://img.shields.io/github/actions/workflow/status/crisidev/bacon-ls/release.yml?style=for-the-badge)](https://github.com/crisidev/bacon-ls/actions?query=workflow%3Arelease)\n[![Crates.io](https://img.shields.io/crates/v/bacon-ls?style=for-the-badge)](https://crates.io/crates/bacon-ls)\n[![Crates.io](https://img.shields.io/crates/d/bacon-ls?style=for-the-badge)](https://crates.io/crates/bacon-ls)\n[![License](https://img.shields.io/badge/license-MIT-blue?style=for-the-badge)](https://github.com/crisidev/bacon-ls/blob/main/LICENSE)\n[![Codecov](https://img.shields.io/codecov/c/github/crisidev/bacon-ls?style=for-the-badge\u0026token=42UR7SSSPB)](https://codecov.io/github/crisidev/bacon-ls)\n\n**Are you tired of [rust-analyzer](https://rust-analyzer.github.io/) diagnostics being slow?**\n\nLSP Server wrapper for the exceptional [Bacon](https://dystroy.org/bacon/) exposing [textDocument/diagnostic](https://microsoft.github.io/language-server-protocol/specification#textDocument_diagnostic) and [workspace/diagnostic](https://microsoft.github.io/language-server-protocol/specification#workspace_diagnostic) capabilities.\n\n`bacon-ls` 🐽 does not substitute `rust-analyzer`, it's a companion tool that can help with large \ncodebases where `rust-analyzer` can become slow dealing with diagnostics. \n\n**`bacon-ls` 🐽 does not help with completion, analysis, refactor, etc... For these, `rust-analyzer` must be running.**\n\n![Bacon screenshot](./img/screenshot.png)\n\n\u003c!-- vim-markdown-toc Marked --\u003e\n\n* [Features](#features)\n    * [Limitations](#limitations)\n* [Installation](#installation)\n    * [VSCode](#vscode)\n    * [Mason.nvim](#mason.nvim)\n    * [Manual](#manual)\n    * [Nix](#nix)\n* [Configuration](#configuration)\n    * [Neovim - LazyVim](#neovim---lazyvim)\n    * [Neovim - Manual](#neovim---manual)\n    * [VSCode](#vscode)\n    * [Coc.nvim](#coc.nvim)\n    * [Helix](#helix)\n* [Troubleshooting](#troubleshooting)\n    * [Bacon preferences](#bacon-preferences)\n    * [Vim - Neovim](#vim---neovim)\n    * [VSCode](#vscode)\n* [How does it work?](#how-does-it-work?)\n* [Thanks](#thanks)\n* [Roadmap to 1.0 - ✅ done 🕖 in progress 🌍 future](#roadmap-to-1.0---✅-done-🕖-in-progress-🌍-future)\n\n\u003c!-- vim-markdown-toc --\u003e\n\nSee `bacon-ls` 🐽 blog post: https://lmno.lol/crisidev/bacon-language-server\n\n`bacon-ls` 🐽 is meant to be easy to include in your IDE configuration.\n\n![Bacon gif](./img/bacon-ls.gif)\n\n## Features\n\n* Read diagnostics from produced by Bacon.\n* Push diagnostics to the LSP client on certain events like saving or files changes.\n* Precise diagnostics positions.\n* Ability to react to changes over document saves and changes that can be configured.\n* Replacement code actions as suggested by `clippy`.\n* Automatic validation of `bacon` preferences to ensure `bacon-ls` can work with them.\n* Start `bacon` in background based on user preferences (requires `bacon` 3.8.0).\n* Synchronize diagnostics for all open files. \n* Support [cargo workspaces](https://doc.rust-lang.org/book/ch14-03-cargo-workspaces.html).\n\n### Limitations\n\n* Windows support is not tested and probably broken - [#10](https://github.com/crisidev/bacon-ls/issues/10)\n\n## Installation\n\n### VSCode\n\nFirst, install [Bacon](https://dystroy.org/bacon/#installation).\n\nThe VSCode extension is available on both VSCE and OVSX:\n\n* `VSCE` [https://marketplace.visualstudio.com/items?itemName=MatteoBigoi.bacon-ls-vscode](https://marketplace.visualstudio.com/items?itemName=MatteoBigoi.bacon-ls-vscode)\n* `OVSX` [https://open-vsx.org/extension/MatteoBigoi/bacon-ls-vscode](https://open-vsx.org/extension/MatteoBigoi/bacon-ls-vscode)\n\n### Mason.nvim\n\nBoth Bacon and Bacon-ls are installable via [mason.nvim](https://github.com/williamboman/mason.nvim):\n\n```vim\n:MasonInstall bacon bacon-ls\n```\n\n### Manual\n\nFirst, install [Bacon](https://dystroy.org/bacon/#installation) and `bacon-ls` 🐽\n\n```bash\n❯❯❯ cargo install --locked bacon bacon-ls\n❯❯❯ bacon --version\nbacon 3.8.0  # make sure you have at least 3.8.0\n❯❯❯ bacon-ls --version\n0.14.0        # make sure you have at least 0.14.0\n```\n\n### Nix\n\nBoth [bacon](https://github.com/Canop/bacon/blob/main/flake.nix) and [bacon-ls](./flake.nix) can be consumed from their Nix flakes.\n\n## Configuration\n\nConfigure Bacon export settings with `bacon-ls` 🐽 export format and proper span support in the `bacon` preference file.\nTo find where the file should be saved, you can use the command `bacon --prefs`:\n\n```toml\n[jobs.bacon-ls]\ncommand = [ \"cargo\", \"clippy\", \"--workspace\", \"--tests\", \"--all-targets\", \"--all-features\", \"--message-format\", \"json-diagnostic-rendered-ansi\" ]\nanalyzer = \"cargo_json\"\nneed_stdout = true\n\n[exports.cargo-json-spans]\nauto = true\nexporter = \"analyzer\"\nline_format = \"{diagnostic.level}|:|{span.file_name}|:|{span.line_start}|:|{span.line_end}|:|{span.column_start}|:|{span.column_end}|:|{diagnostic.message}|:|{diagnostic.rendered}|:|{span.suggested_replacement}\"\npath = \".bacon-locations\"\n```\n\n**NOTE: `bacon` MUST be running to generate the export locations with the `bacon-ls` job: `bacon -j bacon-ls`.\nFrom `bacon-ls` 0.10.0, this is done automatically if the option `runBaconInBackground` is set to true.**\n\nThe language server can be configured using the appropriate LSP protocol and\nsupports the following values:\n\n- `locationsFile` Bacon export filename (default: `.bacon-locations`).\n- `updateOnSave` Try to update diagnostics every time the file is saved (default: true).\n- `updateOnSaveWaitMillis` How many milliseconds to wait before updating diagnostics after a save (default: 1000).\n- `validateBaconPreferences`: Try to validate that `bacon` preferences are setup correctly to work with `bacon-ls` (default: true).\n- `createBaconPreferencesFile`: If no `bacon` preferences file is found, create a new preferences file with the `bacon-ls` job definition (default: true).\n- `runBaconInBackground`: Run `bacon` in background for the `bacon-ls` job (default: true)\n- `runBaconInBackgroundCommandArguments`: Command line arguments to pass to `bacon` running in background (default \"--headless -j bacon-ls\")\n- `synchronizeAllOpenFilesWaitMillis`: How many milliseconds to wait between background diagnostics check to synchronize all open files (default: 2000).\n\n### Neovim - LazyVim\n\n```lua\nvim.g.lazyvim_rust_diagnostics = \"bacon-ls\"\n```\n\n### Neovim - Manual\n\nNeoVim requires [nvim-lspconfig](https://github.com/neovim/nvim-lspconfig/) to be configured\nand [rust-analyzer](https://rust-analyzer.github.io/) diagnostics must be turned off for `bacon-ls` 🐽\nto properly function.\n\n`bacon-ls` is part of `nvim-lspconfig` from commit\n[6d2ae9f](https://github.com/neovim/nvim-lspconfig/commit/6d2ae9fdc3111a6e8fd5db2467aca11737195a30)\nand it can be configured like any other LSP server works best when\n[vim.diagnostics.opts.update_in_insert](https://neovim.io/doc/user/diagnostic.html#vim.diagnostic.Opts)\nis set to `true`.\n\n```lua\nrequire(\"lspconfig\").bacon_ls.setup({\n    init_options = {\n        updateOnSave = true \n        updateOnSaveWaitMillis = 1000\n        ...\n    }\n})\n```\n\nFor `rust-analyzer`, these 2 options must be turned off:\n\n```lua\nrust-analyzer.checkOnSave.enable = false\nrust-analyzer.diagnostics.enable = false\n```\n\n### VSCode\n\nThe extension can be configured using the VSCode settings interface.\n\n**It is very important that rust-analyzer `Check On Save` and `Diagnostics` are turned off for `bacon-ls` to work properly:**\n\n* Untick `Rust-analyzer -\u003e general -\u003e Check On Save`\n* Untick `Rust-analyzer -\u003e diagnostics -\u003e Enable`\n\n### Coc.nvim\n\n```vim\ncall coc#config('languageserver', {\n      \\ 'bacon-ls': {\n      \\   'command': '~/.cargo/bin/bacon-ls',\n      \\   'filetypes': ['rust'],\n      \\   'rootPatterns': ['.git/', 'Cargo.lock', 'Cargo.toml'],\n      \\   'initializationOptions': {\n      \\     'updateOnSave': v:true, \n      \\     'updateOnSaveWaitMillis': 1000,\n      \\   },\n      \\   'settings': {}\n      \\ }\n\\ })\n```\n\n### Helix\n\nExtend your `languages.toml` with the following:\n\n```toml\n[[language]]\nname = \"rust\"\nlanguage-servers = [\"rust-analyzer\", \"bacon-ls\"]\n\n[language-server.rust-analyzer.config]\ncheckOnSave = { enable = false }\ndiagnostics = { enable = false }\n\n[language-server.bacon-ls]\ncommand = \"bacon-ls\"\n```\n\n\n## Troubleshooting\n\n`bacon-ls` 🐽 can produce a log file in the folder where its running by exporting the `RUST_LOG` variable in the shell:\n\n### Bacon preferences\n\nIf the `bacon` preference are not correct, an error message will be published to the LSP client, advising the user to\ncheck the README.\n\n### Vim - Neovim\n\n```bash\n❯❯❯ export RUST_LOG=debug\n❯❯❯ nvim src/some-file.rs                 # or vim src/some-file.rs\n# the variable can also be exported for the current command and not for the whole shell\n❯❯❯ RUST_LOG=debug nvim src/some-file.rs  # or RUST_LOG=debug vim src/some-file.rs\n❯❯❯ tail -F ./bacon-ls.log\n```\n\n### VSCode\n\nEnable debug logging in the extension options.\n\n```bash\n❯❯❯ tail -F ./bacon-ls.log\n```\n\n## How does it work?\n\n`bacon-ls` 🐽 reads the diagnostics location list generated\nby [Bacon's export-locations](https://dystroy.org/bacon/config/#export-locations)\nand exposes them on STDIO over the LSP protocol to be consumed\nby the client diagnostics.\n\nIt requires [Bacon](https://dystroy.org/bacon/) to be running alongside\nto ensure regular updates of the export locations.\n\nThe LSP client reads them as response to `textDocument/diagnostic` and `workspace/diagnostic`.\n\n## Thanks\n\n`bacon-ls` 🐽 has been inspired by [typos-lsp](https://github.com/tekumara/typos-lsp).\n\n## Roadmap to 1.0 - ✅ done 🕖 in progress 🌍 future\n\n- ✅ Implement LSP server interface for `textDocument/diagnostic` and `workspace/diagnostic`\n- ✅ Manual Neovim configuration\n- ✅ Manual [LazyVim](https://www.lazyvim.org) configuration\n- ✅ Automatic NeoVim configuration\n  - ✅ Add `bacon-ls` to [nvim-lspconfig](https://github.com/neovim/nvim-lspconfig/) - https://github.com/neovim/nvim-lspconfig/pull/3160\n  - ✅ Add `bacon` and `bacon-ls` to [mason.nvim](https://github.com/williamboman/mason.nvim) - https://github.com/mason-org/mason-registry/pull/5774\n  - ✅ Add `bacon-ls` to LazyVim [Rust extras](https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/plugins/extras/lang/rust.lua) - https://github.com/LazyVim/LazyVim/pull/3212\n- ✅ Add compiler hints to [Bacon](https://dystroy.org/bacon/) export locations - https://github.com/Canop/bacon/pull/187 https://github.com/Canop/bacon/pull/188\n- ✅ Support correct span in [Bacon](https://dystroy.org/bacon/) export locations - working from `bacon` 3.7 and `bacon-ls` 0.6.0\n- ✅ VSCode extension and configuration - available on the [release](https://github.com/crisidev/bacon-ls/releases) page from 0.6.0\n- ✅ VSCode extension published available on Marketplace\n- ✅ Add `bacon-ls` to `bacon` website - https://github.com/Canop/bacon/pull/289\n- ✅ Smarter handling of parsing the Bacon locations file\n- ✅ Faster response after a save event\n- ✅ Replacement code actions\n- ✅ Validate `bacon` preferences and return an error to the LSP client if they are not compatible with `bacon` - working from `bacon-ls` 0.9.0\n- ✅ Create `bacon` preferences file if not found on disk - working from `bacon-ls` 0.10.0\n- ✅ Start `bacon` in background based on user preferences - working from `bacon-ls` 0.10.0\n- ✅ Synchronize diagnostics for all open files - working from `bacon-ls` 0.10.0\n- ✅ Support Helix editor - working from `bacon-ls` 0.12.0\n- ✅ Nix flake support\n- ✅ Support [cargo workspaces](https://doc.rust-lang.org/book/ch14-03-cargo-workspaces.html) - working from `bacon-ls` 0.14.0\n- 🌍 Emacs configuration\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcrisidev%2Fbacon-ls","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcrisidev%2Fbacon-ls","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcrisidev%2Fbacon-ls/lists"}