ayamir / nvimdots

A well configured and structured Neovim.
BSD 3-Clause "New" or "Revised" License
2.82k stars 450 forks source link

How to configure plugins for neovim to support Rust-DAP and smart tips for variable types in Rust #1223

Closed Kanna-jiahe closed 2 months ago

Kanna-jiahe commented 2 months ago

Version confirmation

Following prerequisites

Neovim version

NVIM v0.9.5

Branch info

main (Default/Latest)

Minimal (user) folder structure required to reproduce the issue

lua/user/plugins/rustaceanvim.lua

Minimal config with steps on how to reproduce the issue

Configuration files are not available at this time

Expected behavior

I would wish to change rustaceanvim or rust-tool.nvim to support Rust debugging and variable type display.

like this:

image image

Additional information

I am a new user of neovim and like the nvimdots configuration developed by the developers, and have read the tutorials in the wiki, but there are still some things that I do not understand, I hope that the respected developers can help me.

CharlesChiuGit commented 2 months ago

@ClSlaid might have some tips for u

Kanna-jiahe commented 2 months ago

I try configure rust-tools.nvim with this code

lang["mrcjkb/rustaceanvim"] = {
    lazy = false,
    ft = "rust",
    version = "^4",
    config = require("lang.rust"),
    dependencies = { "nvim-lua/plenary.nvim" },
}
lang["simrat39/rust-tools.nvim"] = {
    lazy = true,
    local rt = require("rust-tools")

        rt.setup({
            server = {
                rust = {
                    imports = {
                        granularity = {
                            group = "module",
                        },
                        prefix = "self",
                    },
                    cargo = {
                        buildScripts = {
                            enable = true,
                        },
                    },
                    procMacro = {
                        enable = true,
                    },
                    inlayHints = {
                        bindingModeHints = {
                            enable = true,
                        },
                        chainingHints = {
                            enable = true,
                        },
                        closingBraceHints = {
                            enable = true,
                        },
                    },
                },
            },
}

will be support inlayHints for Rust Types.

but i don't know how to configure dap-client for rust.

RivTian commented 2 months ago

The Rust variable type display might be viewed using K. move cursor to variable,now,push K. (capital letter)

image
ayamir commented 2 months ago

cargo build first and debug with the correct binary path.

image image

Kanna-jiahe commented 2 months ago

cargo build first and debug with the correct binary path.

image image

It turns out that I did not perform the debugging steps properly. Thanks, this helps me a lot