simrat39 / rust-tools.nvim

Tools for better development in rust using neovim's builtin lsp
MIT License
2.17k stars 158 forks source link

Rust tools breaks support for nvim-navic #246

Closed tfachmann closed 2 years ago

tfachmann commented 2 years ago

nvim-navic is a simple statusline/winbar component that uses LSP to show the current node context. It uses lsp's document_symbol which is provided by rust-analyzer.

Without rust-tools, nvim-navic works as expected.

When using rust-tools in combination with nvim-navic, it is unavailable where the following reports false:

:lua print(require("nvim-navic").get_location())

Is there a mechanism of rust-tools that could explain this behavior?

tfachmann commented 2 years ago

I answered this myself. As rust-tools spawns the LSP for you, make sure to add modifications of on_attach to the setup of rust-tools.

E.g.


local function on_attach(client, bufnr)
    require("nvim-navic").attach(client, bufnr)
end

require("rust-tools").setup({
    server = {
        on_attach = on_attach,
    }
})