Skip to content

Commit

Permalink
Merge pull request #15 from crisidev/validate-bacon-config
Browse files Browse the repository at this point in the history
Validate bacon configuration and improve location format for code actions
  • Loading branch information
crisidev authored Jan 7, 2025
2 parents 6f56182 + 7490af4 commit 47963ea
Show file tree
Hide file tree
Showing 6 changed files with 346 additions and 41 deletions.
140 changes: 127 additions & 13 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 5 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,17 @@ categories = [
[dependencies]
argh = "0.1.13"
tokio = { version = "1.42.0", features = [
"macros",
"rt-multi-thread",
"fs",
"io-std",
"io-util",
"fs",
"macros",
"process",
"rt-multi-thread",
"time",
] }
serde = { version = "1.0.217", features = ["derive"] }
serde_json = "1.0.134"
toml = "0.8"
tower-lsp = "0.20.0"
tracing = "0.1.41"
tracing-subscriber = { version = "0.3.19", default-features = false, features = [
Expand Down
19 changes: 15 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ codebases where `rust-analyzer` can become slow dealing with diagnostics.
* [VSCode](#vscode)
* [Coc.nvim](#coc.nvim)
* [Troubleshooting](#troubleshooting)
* [Bacon preferences](#bacon-preferences)
* [Vim - Neovim](#vim---neovim)
* [VSCode](#vscode)
* [How does it work?](#how-does-it-work?)
Expand All @@ -56,6 +57,7 @@ See `bacon-ls` 🐽 blog post: https://lmno.lol/crisidev/bacon-language-server
* Precise diagnostics positions.
* Ability to react to changes over document saves and changes that can be configured.
* Replacement code actions as suggested by `clippy`.
* Automatic validation of `bacon` preferences to ensure `bacon-ls` can work with them.

### Limitations

Expand Down Expand Up @@ -91,12 +93,13 @@ First, install [Bacon](https://dystroy.org/bacon/#installation) and `bacon-ls`
❯❯❯ bacon --version
bacon 3.7.0 # make sure you have at least 3.7.0
❯❯❯ bacon-ls --version
0.8.0 # make sure you have at least 0.5.0
0.9.0 # make sure you have at least 0.9.0
```

## Configuration

Configure Bacon export settings with `bacon-ls` 🐽 export format and proper span support in `~/.config/bacon/prefs.toml`:
Configure Bacon export settings with `bacon-ls` 🐽 export format and proper span support in the `bacon` preference file.
To find where the file should be saved, you can use the command `bacon --prefs`:

```toml
[jobs.bacon-ls]
Expand All @@ -107,7 +110,7 @@ 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}:{span.suggested_replacement}"
line_format = "{diagnostic.level}|:|{span.file_name}|:|{span.line_start}|:|{span.line_end}|:|{span.column_start}|:|{span.column_end}|:|{diagnostic.message}|:|{span.suggested_replacement}"
path = ".bacon-locations"
```

Expand All @@ -120,6 +123,7 @@ supports the following values:
- `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).
- `validateBaconPreferences`: Try to validate that `bacon` preferences are setup correctly to work with `bacon-ls` (default: true).

### Neovim - LazyVim

Expand All @@ -145,6 +149,7 @@ require("lspconfig").bacon_ls.setup({
updateOnSave = true
updateOnSaveWaitMillis = 1000
updateOnChange = false
...
}
})
```
Expand Down Expand Up @@ -187,6 +192,11 @@ call coc#config('languageserver', {

`bacon-ls` 🐽 can produce a log file in the folder where its running by exporting the `RUST_LOG` variable in the shell:

### Bacon preferences

If the `bacon` preference are not correct, an error message will be published to the LSP client, advising the user to
check the README.

### Vim - Neovim

```bash
Expand Down Expand Up @@ -234,8 +244,9 @@ The LSP client reads them as response to `textDocument/diagnostic` and `workspac
- ✅ Support correct span in [Bacon](https://dystroy.org/bacon/) export locations - working from `bacon` 3.7 and `bacon-ls` 0.6.0
- ✅ VSCode extension and configuration - available on the [release](https://github.com/crisidev/bacon-ls/releases) page from 0.6.0
- ✅ VSCode extension published available on Marketplace
- 🕖 Add `bacon-ls` to `bacon` website - https://github.com/Canop/bacon/pull/289
- Add `bacon-ls` to `bacon` website - https://github.com/Canop/bacon/pull/289
- ✅ Smarter handling of parsing the Bacon locations file
- ✅ Faster response after a save event
- ✅ Replacement code actions
- ✅ 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
- 🌍 Emacs configuration
Loading

0 comments on commit 47963ea

Please sign in to comment.