56 lines
1.9 KiB
Lua
56 lines
1.9 KiB
Lua
local rt = {
|
|
server = {
|
|
settings = {
|
|
on_attach = function(_, bufnr)
|
|
-- Hover actions
|
|
vim.keymap.set("n", "<C-a>", rt.hover_actions.hover_actions, { buffer = bufnr })
|
|
-- Code action groups
|
|
vim.keymap.set("n", "<Leader>a", rt.code_action_group.code_action_group, { buffer = bufnr })
|
|
require 'illuminate'.on_attach(client)
|
|
end,
|
|
["rust-analyzer"] = {
|
|
checkOnSave = {
|
|
command = "clippy"
|
|
},
|
|
},
|
|
}
|
|
},
|
|
}
|
|
require('rust-tools').setup(rt)
|
|
require('rust-tools').inlay_hints.enable()
|
|
|
|
local sign = function(opts)
|
|
vim.fn.sign_define(opts.name, {
|
|
texthl = opts.name,
|
|
text = opts.text,
|
|
numhl = ''
|
|
})
|
|
end
|
|
|
|
sign({name = 'DiagnosticSignError', text = ''})
|
|
sign({name = 'DiagnosticSignWarn', text = ''})
|
|
sign({name = 'DiagnosticSignHint', text = ''})
|
|
sign({name = 'DiagnosticSignInfo', text = ''})
|
|
|
|
local opts = { noremap=true, silent=true }
|
|
vim.keymap.set('n', '<space>e', vim.diagnostic.open_float, opts)
|
|
vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, opts)
|
|
vim.keymap.set('n', ']d', vim.diagnostic.goto_next, opts)
|
|
vim.keymap.set('n', '<space>q', vim.diagnostic.setloclist, opts)
|
|
|
|
-- Use an on_attach function to only map the following keys
|
|
-- after the language server attaches to the current buffer
|
|
local on_attach = function(client, bufnr)
|
|
local bufopts = { noremap=true, silent=true, buffer=bufnr }
|
|
vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, bufopts)
|
|
vim.keymap.set('n', 'gd', vim.lsp.buf.definition, bufopts)
|
|
vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, bufopts)
|
|
vim.keymap.set('n', '<leader>rn', vim.lsp.buf.rename, bufopts)
|
|
vim.keymap.set('n', '<leader><space>', vim.lsp.buf.code_action, bufopts)
|
|
vim.keymap.set('n', 'gr', vim.lsp.buf.references, bufopts)
|
|
end
|
|
|
|
require('lspconfig')['rust_analyzer'].setup{
|
|
on_attach = on_attach,
|
|
}
|