-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrust.lua
More file actions
73 lines (63 loc) · 2.6 KB
/
rust.lua
File metadata and controls
73 lines (63 loc) · 2.6 KB
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
local bufnr = vim.api.nvim_get_current_buf()
local on_attach = function (_, _bufnr)
-- require 'lsp_signature'.on_attach(signature_setup, _bufnr)
local nmap = function (keys, func, desc)
if desc then
desc = 'LSP: ' .. desc
end
vim.keymap.set('n', keys, func, { buffer = _bufnr, desc = desc })
end
local imap = function (keys, func, desc)
if desc then
desc = 'LSP: ' .. desc
end
vim.keymap.set('i', keys, func, { buffer = _bufnr, desc = desc })
end
nmap('<leader>rn', vim.lsp.buf.rename, '[R]e[n]ame')
nmap('<leader>la', vim.cmd.RustLsp('codeAction'), '[C]ode [A]ction')
nmap('gd', require('telescope.builtin').lsp_definitions, '[G]oto [D]efinition')
nmap('gr', require('telescope.builtin').lsp_references, '[G]oto [R]eferences')
nmap('gI', require('telescope.builtin').lsp_implementations, '[G]oto [I]mplementation')
nmap('<leader>D', vim.lsp.buf.type_definition, 'Type [D]efinition')
nmap('<leader>ds', require('telescope.builtin').lsp_document_symbols, '[D]ocument [S]ymbols')
nmap('<leader>ws', require('telescope.builtin').lsp_dynamic_workspace_symbols, '[W]orkspace [S]ymbols')
-- See `:help K` for why this keymap
nmap('K', vim.lsp.buf.hover, 'Hover Documentation')
nmap('<C-k>', vim.lsp.buf.signature_help, 'Signature Documentation')
imap('<C-k>', vim.lsp.buf.signature_help, 'Signature Documentation')
-- Format code
nmap('<space>lf', function () vim.lsp.buf.format { async = true } end, 'Format')
-- Lesser used LSP functionality
nmap('gD', vim.lsp.buf.declaration, '[G]oto [D]eclaration')
nmap('<leader>wa', vim.lsp.buf.add_workspace_folder, '[W]orkspace [A]dd Folder')
nmap('<leader>wr', vim.lsp.buf.remove_workspace_folder, '[W]orkspace [R]emove Folder')
nmap('<leader>wl', function ()
print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
end, '[W]orkspace [L]ist Folders')
-- Create a command `:Format` local to the LSP buffer
vim.api.nvim_buf_create_user_command(bufnr, 'Format', function (_)
vim.lsp.buf.format()
end, { desc = 'Format current buffer with LSP' })
end
vim.g.rustaceanvim = {
-- Plugin configuration
tools = {
},
-- LSP configuration
server = {
on_attach = on_attach,
default_settings = {
['rust-analyzer'] = {
cargo = {
allFeatures = true,
},
-- diagnostics = {
-- enable = true;
-- }
},
},
},
-- DAP configuration
dap = {
},
}