mrcjkb / rustaceanvim

🦀 Supercharge your Rust experience in Neovim! A heavily modified fork of rust-tools.nvim
GNU General Public License v2.0
1.66k stars 61 forks source link

Config for placement of diagnostics float #455

Closed GordianDziwis closed 1 week ago

GordianDziwis commented 2 months ago

Feature description

I have a function for lsp-diagnostics, whihc place the diagnostic float in the lower left corner:

            local _, winnr = vim.diagnostic.open_float({ source = true })
            if winnr then
                local width = vim.api.nvim_get_option("columns")
                local height = vim.api.nvim_get_option("lines")
                local config = {
                  anchor = 'SW',
                  relative = 'editor',
                  row = height - 2,
                  col = 1,
                }
                vim.api.nvim_win_set_config(winnr, config)
            end

Because rusteceanvim does not show hints and info diagnostic levels, I have a function to fall back to lsp diagnostics in `ftplugin/rust.lua:

local bufnr = vim.api.nvim_get_current_buf()
local opts = { silent = true, buffer = bufnr }
vim.keymap.set("n", "<localleader>e", function()
    local output = vim.fn.execute('RustLsp renderDiagnostic current')
    if output:match("No renderable diagnostics found.") then
        vim.cmd('lua _G.show_diagnostics()')
    end
end, opts)

But now the diagnostic float placement is inconsistent between native diagnostics and rustaceanvim.

Can I modify the window placement for RustLsp renderDiagnostic current dynamically?

mrcjkb commented 2 months ago

Hey 👋

You can configure rustaceanvim's floating windows with vim.g.rustaceanvim.tools.float_win_config.

See :h rustaceanvim.config.

If that doesn't provide what you're looking for, PRs are welcome 😀.

GordianDziwis commented 2 months ago

@mrcjkb Is this config lazily evaluated on creation of a float?

mrcjkb commented 2 months ago

@mrcjkb Is this config lazily evaluated on creation of a float?

No.