diff options
| author | Lorenzo Bellina <59364991+TheRealLorenz@users.noreply.github.com> | 2025-04-13 00:15:43 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-04-12 15:15:43 -0700 |
| commit | 81a570f58b2113cc2d538efae743ad38d6ab564f (patch) | |
| tree | 74f9691bbb1b303cd7cfaab7b543f82cb0dc6b46 /lsp/bacon_ls.lua | |
| parent | refactor: replace vim.loop with vim.uv #3703 (diff) | |
| download | nvim-lspconfig-81a570f58b2113cc2d538efae743ad38d6ab564f.tar nvim-lspconfig-81a570f58b2113cc2d538efae743ad38d6ab564f.tar.gz nvim-lspconfig-81a570f58b2113cc2d538efae743ad38d6ab564f.tar.bz2 nvim-lspconfig-81a570f58b2113cc2d538efae743ad38d6ab564f.tar.lz nvim-lspconfig-81a570f58b2113cc2d538efae743ad38d6ab564f.tar.xz nvim-lspconfig-81a570f58b2113cc2d538efae743ad38d6ab564f.tar.zst nvim-lspconfig-81a570f58b2113cc2d538efae743ad38d6ab564f.zip | |
feat: migrate to vim.lsp.config #3659
Problem:
Nvim 0.11 has vim.lsp.config, which mostly replaces the legacy
nvim-lspconfig "framework".
Solution:
Migrate all configs to `lsp/*` variants. The old configs in
`lua/lspconfig/` are "frozen".
The new configs include these changes:
- `commands` field became raw calls to
`vim.api.nvim_buf_create_user_command` inside `on_attach`.
- `root_dir` became:
- `root_markers` whenever the file list was simple didn't need to mach `*`
- if the logic was complicated, or needed to match something like
'\*.c', it was defined as a vim.lsp.Config `root_dir` callback.
- `on_config_change` became `before_init`. I don't actually know if this
is the correct approach, but looking around the documentation of
`nvim-lspconfig` a saw that it was defined as the function that gets
called as soon as the config have `root_dir`, and so I thought
`before_init` might be the closest alternative.
- `docs.description` became a luadoc `@brief` docstring.
- `single_file_support = false`?
Co-authored-by: Aliou Diallo <aliou@users.noreply.github.com>
Co-authored-by: Justin M. Keyes <justinkz@gmail.com>
Diffstat (limited to 'lsp/bacon_ls.lua')
| -rw-r--r-- | lsp/bacon_ls.lua | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/lsp/bacon_ls.lua b/lsp/bacon_ls.lua new file mode 100644 index 00000000..caa1867d --- /dev/null +++ b/lsp/bacon_ls.lua @@ -0,0 +1,45 @@ +---@brief +--- +---https://github.com/crisidev/bacon-ls +-- +-- A Language Server Protocol wrapper for [bacon](https://dystroy.org/bacon/). +-- It offers textDocument/diagnostic and workspace/diagnostic capabilities for Rust +-- workspaces using the Bacon export locations file. +-- +-- It requires `bacon` and `bacon-ls` to be installed on the system using +-- [mason.nvim](https://github.com/williamboman/mason.nvim) or manually +-- +-- ```sh +-- $ cargo install --locked bacon bacon-ls +-- ``` +-- +-- Settings can be changed using the `init_options` dictionary:util +-- +-- ```lua +-- init_options = { +-- -- Bacon export filename (default: .bacon-locations). +-- locationsFile = ".bacon-locations", +-- -- Try to update diagnostics every time the file is saved (default: true). +-- updateOnSave = true, +-- -- How many milliseconds to wait before updating diagnostics after a save (default: 1000). +-- updateOnSaveWaitMillis = 1000, +-- -- Try to update diagnostics every time the file changes (default: true). +-- updateOnChange = true, +-- -- Try to validate that bacon preferences are setup correctly to work with bacon-ls (default: true). +-- validateBaconPreferences = true, +-- -- f no bacon preferences file is found, create a new preferences file with the bacon-ls job definition (default: true). +-- createBaconPreferencesFile = true, +-- -- Run bacon in background for the bacon-ls job (default: true) +-- runBaconInBackground = true, +-- -- Command line arguments to pass to bacon running in background (default "--headless -j bacon-ls") +-- runBaconInBackgroundCommandArguments = "--headless -j bacon-ls", +-- -- How many milliseconds to wait between background diagnostics check to synchronize all open files (default: 2000). +-- synchronizeAllOpenFilesWaitMillis = 2000, +-- } +-- ``` +return { + cmd = { 'bacon-ls' }, + filetypes = { 'rust' }, + root_markers = { '.bacon-locations', 'Cargo.toml' }, + init_options = {}, +} |
