summaryrefslogtreecommitdiff
path: root/.config/nvim/lua/plugins/rustaceanvim.lua
blob: 59f17173470ef7665bc28f3081399fefd154acc0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
return {
    'mrcjkb/rustaceanvim',
    version = '^5',
    lazy = false, -- already lazy
    init = function()
        ---@type RustaceanOpts
        vim.g.rustaceanvim = {
            ---@type RustaceanToolsOpts
            tools = {
                float_win_config = {
                    border = 'rounded',
                },
            },
            ---@type RustaceanLspClientOpts
            server = {
                on_attach = function(_, bufnr)
                    local keymaps = {
                        { { 'n', 'i' }, '<M-Enter>', '<cmd>RustLsp codeAction<cr>', { desc = 'Code Action' } },
                    }

                    for _, keymap in ipairs(keymaps) do
                        local modes = keymap[1]
                        local lhs = keymap[2]
                        local rhs = keymap[3]
                        local opts = keymap[4]
                        opts.buffer = bufnr

                        vim.keymap.set(modes, lhs, rhs, opts)
                    end
                end,
                default_settings = {
                    ['rust-analyzer'] = {
                        semanticHighlighting = {
                            operator = { specialization = { enable = true } },
                            punctuation = { enable = true, specialization = { enable = true } },
                        },
                    },
                },
            },
            ---@type RustaceanDapOpts
            dap = {},
        }
    end,
}