Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

config validation fails on valid nvim-dap config #294

Closed
xusd320 opened this issue Mar 16, 2024 · 2 comments · Fixed by #298
Closed

config validation fails on valid nvim-dap config #294

xusd320 opened this issue Mar 16, 2024 · 2 comments · Fixed by #298
Labels
bug Something isn't working

Comments

@xusd320
Copy link

xusd320 commented Mar 16, 2024

Neovim version (nvim -v)

v0.9.5 with LazyVim latest

Operating system/version

macOS 13.6.4

Output of :checkhealth rustaceanvim

==============================================================================
rustaceanvim: require("rustaceanvim.health").check()

Checking for Lua dependencies ~
- OK [mfussenegger/nvim-dap](https://github.com/mfussenegger/nvim-dap) installed.

Checking external dependencies ~
- OK rust-analyzer: found rust-analyzer 0.3.1877-standalone (574e23ec5 2024-03-09)
- OK Cargo: found cargo 1.75.0-nightly (d2f6a0485 2023-10-20)
- OK rustc: found rustc 1.75.0-nightly (cd674d617 2023-10-24)
- OK debug adapter: found codelldb 

Checking config ~
- OK No errors found in config.

Checking for conflicting plugins ~
- OK No conflicting plugins detected.

Checking for tree-sitter parser ~
- OK tree-sitter parser for Rust detected.

How to reproduce the issue

The problem is really wield, some steps to produce.
 1. In terminal, cd to a certain rust project directory.
 2. Open vim, then open telescope recent files picker, chose a file which not in the chosed directory at the first step, 
    and then open the file.
 4. Rustacean plugin ant treesitter plugin will not attach to the opened file buf, 
    that is rust-analyzer will not be launched automatically, and treesitter highlight not work.

Sorry for I can't provide a minimal config, because the problem happened only when at the first step, 
I cd to my company private project. And after step 3, if I open another rust files from the file tree, 
the rustacean will launch rust-analyzer and treesitter highlight will both work normally.

When use the old rust-tools before, there is no problem like this. After some debugging, I found that this is 
related to mason codelldb adapter. If I uninstall the codelldb adapter, rustacean will launch rust-analyzer 
and treesitter highlight will be ok too. 

I checked the rustaceanvim codes, found the auto_attach config, if setup it to be true, rustacean will always 
launch rust-analyzer normally, but the treesitter is still bad.

I don't want wasting other people's time, just need some help about how to debug this problem, thanks.

Expected behaviour

When open a rust file rust othen repo, rustacean will always launch rust-analyzer,and treessitter highlight will be ok

Actual behaviour

rustacean will not launch rust-analyzer, treesitter highlight will not work.

Bad when start from this directory .

At the and, if I run ":e" in vim, it will be ok again.
iShot_2024-03-16_19 33 12

When setup rustacean with auto_attach: true, rust-analyzer works ok, but tree sitter highlight not good.
iShot_2024-03-16_19 40 46

Afer uninstall codelldb adapter, every thing will be ok.
iShot_2024-03-16_19 43 44

Good when start from another directory .

iShot_2024-03-16_19 38 10

The minimal config used to reproduce this issue.

rust-analyzer ant treesitter highlight will be ok.
@xusd320 xusd320 added the bug Something isn't working label Mar 16, 2024
@mrcjkb
Copy link
Owner

mrcjkb commented Mar 16, 2024

Hey 👋

Thanks for reporting.
Based on what you describe, it looks like an error is getting thrown were rustaceanvim looks for the mason codelldb installation, somewhere here:

local mason_codelldb_path = compat.joinpath(codelldb_package:get_install_path(), 'extension')

I am away from my laptop, but might have time to look into it tomorrow.
In the meantime, could you please try to reproduce this using plain Neovim (not LazyVim) and the minimal config I provide with this repo (see the readme's troubleshooting section). You can add mason.nvim to the minimal config, since it seems to be related.

LazyVim comes bundled with a lot of plugins, which makes it difficult for me to reproduce issues.
Also, a minimal config helps rule out or identify another plugin causing the issue.

@xusd320
Copy link
Author

xusd320 commented Mar 16, 2024

Hey 👋

Thanks for reporting. Based on what you describe, it looks like an error is getting thrown were rustaceanvim looks for the mason codelldb installation, somewhere here:

local mason_codelldb_path = compat.joinpath(codelldb_package:get_install_path(), 'extension')

I am away from my laptop, but might have time to look into it tomorrow. In the meantime, could you please try to reproduce this using plain Neovim (not LazyVim) and the minimal config I provide with this repo (see the readme's troubleshooting section). You can add mason.nvim to the minimal config, since it seems to be related.

LazyVim comes bundled with a lot of plugins, which makes it difficult for me to reproduce issues. Also, a minimal config helps rule out or identify another plugin causing the issue.

Thanks. I found the problem is that

program = { configuration.program, 'string', true },

Actually, dap.configuration.program can also be a function type according to this.
https://github.com/mfussenegger/nvim-dap/blob/c43c2473ecb482a9d91f32c1d4c0098fffad3c7d/doc/dap.txt#L287

Lazyvim use mason-nvim-dap.nvim to setup dap, for codelldb, the program field type is "function", see
https://github.com/jay-babu/mason-nvim-dap.nvim/blob/67210c0e775adec55de9826b038e8b62de554afc/lua/mason-nvim-dap/mappings/configurations.lua#L78

Just change the checker to { 'string', 'function' }, then everything works well.

I made a PR #296 to fix.

@mrcjkb mrcjkb changed the title rustacean and treesitter not working when jump to file in another repo, really weird config validation fails on valid nvim-dap config Mar 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
2 participants