Skip to content

fix(rust): drop incompatible root_dir under native_lsp_config - #1754

Merged
Uzaaft merged 1 commit into
AstroNvim:mainfrom
rami3l:fix-rust-native-lsp-config
Apr 11, 2026
Merged

fix(rust): drop incompatible root_dir under native_lsp_config#1754
Uzaaft merged 1 commit into
AstroNvim:mainfrom
rami3l:fix-rust-native-lsp-config

Conversation

@rami3l

@rami3l rami3l commented Apr 11, 2026

Copy link
Copy Markdown
Contributor

📑 Description

With astrolsp native_lsp_config enabled, lsp_opts("rust_analyzer") returns the full vim.lsp.config table including nvim-lspconfig's root_dir(bufnr, on_dir) function. rustaceanvim calls its root_dir with (file_name, default_fn) instead, causing on every rust file open:

Error executing lua callback: .../lsp/rust_analyzer.lua:89: Invalid 'buffer': Expected Lua number
stack traceback:
        [C]: in function 'nvim_buf_get_name'
        .../nvim-lspconfig/lsp/rust_analyzer.lua:89: in function 'root_dir'
        .../rustaceanvim/lua/rustaceanvim/cargo.lua:127: in function 'get_config_root_dir'
        .../rustaceanvim/lua/rustaceanvim/lsp/init.lua:171: in function 'start'

This drops root_dir from the forwarded opts so rustaceanvim falls back to its own cargo-aware root detection.

📖 Additional Information

Replaces #1747 since some details have been changed after upgrading to AstroNvim v6.

Original commit from @Mic92.

cc @Uzaaft

@github-actions

github-actions Bot commented Apr 11, 2026

Copy link
Copy Markdown

Review Checklist

Does this PR follow the [Contribution Guidelines](development guidelines)? Following is a partial checklist:

Proper conventional commit scoping:

  • If you are adding a new plugin, the scope would be the name of the category it is being added into. ex. feat(utility): added noice.nvim plugin

  • If you are modifying a pre-existing plugin or pack, the scope would be the name of the plugin folder. ex. fix(noice-nvim): fix LSP handler error

  • Pull request title has the appropriate conventional commit type and scope where the scope is the name of the pre-existing directory in the project as described above

  • README is properly formatted and uses fenced in links with <url> unless they are inside a [title](url)

  • Entry returns a single plugin spec with the new plugin as the only top level spec (not applicable for recipes or packs).

  • Proper usage of opts table rather than setting things up with the config function.

  • Proper usage of specs table for all specs that are not dependencies of a given plugin (not applicable for recipes or packs).

With astrolsp native_lsp_config enabled, lsp_opts("rust_analyzer")
returns the full vim.lsp.config table including nvim-lspconfig's
root_dir(bufnr, on_dir) function. rustaceanvim calls its root_dir
with (file_name, default_fn) instead, causing:

  lsp/rust_analyzer.lua:89: Invalid 'buffer': Expected Lua number

Drop root_dir from the forwarded opts so rustaceanvim falls back to
its own cargo-aware root detection.

This becomes relevant once native_lsp_config is the default
(astrolsp v4).

Co-authored-by: rami3l <rami3l@outlook.com>
@rami3l
rami3l force-pushed the fix-rust-native-lsp-config branch from 18a9a51 to e2ca130 Compare April 11, 2026 07:21
@Uzaaft
Uzaaft merged commit 0f87ef8 into AstroNvim:main Apr 11, 2026
16 checks passed
@rami3l
rami3l deleted the fix-rust-native-lsp-config branch April 11, 2026 17:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants