-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrust-tools.vim
More file actions
80 lines (70 loc) · 2.62 KB
/
Copy pathrust-tools.vim
File metadata and controls
80 lines (70 loc) · 2.62 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
74
75
76
77
78
79
" Set completeopt to have a better completion experience
" :help completeopt
" menuone: popup even when there's only one match
" noinsert: Do not insert text until a selection is made
" noselect: Do not select, force user to select one from the menu
set completeopt=menuone,noinsert,noselect
" Avoid showing extra messages when using completion
set shortmess+=c
" rust-tools setup combined into lspconfig.=vim
" Configure LSP through rust-tools.nvim plugin.
" rust-tools will configure and enable certain LSP features for us.
" See https://github.com/simrat39/rust-tools.nvim#configuration
"lua <<EOF
"require('rust-tools').setup()
"EOF
" Setup Completion
" See https://github.com/hrsh7th/nvim-cmp#basic-configuration
"lua <<EOF
"local cmp = require'cmp'
"cmp.setup({
"-- Enable LSP snippets
"snippet = {
"expand = function(args)
"vim.fn["vsnip#anonymous"](args.body)
"end,
"},
"mapping = {
"['<C-p>'] = cmp.mapping.select_prev_item(),
"['<C-n>'] = cmp.mapping.select_next_item(),
"-- Add tab support
"['<S-Tab>'] = cmp.mapping.select_prev_item(),
"['<Tab>'] = cmp.mapping.select_next_item(),
"['<C-d>'] = cmp.mapping.scroll_docs(-4),
"['<C-f>'] = cmp.mapping.scroll_docs(4),
"['<C-Space>'] = cmp.mapping.complete(),
"['<C-e>'] = cmp.mapping.close(),
"['<CR>'] = cmp.mapping.confirm({
"behavior = cmp.ConfirmBehavior.Insert,
"select = true,
"})
"},
"-- Installed sources
"sources = {
"{ name = 'nvim_lsp' },
"{ name = 'vsnip' },
"{ name = 'path' },
"{ name = 'buffer' },
"},
"})
"EOF
" Code navigation shortcuts
"nnoremap <silent> <c-]> <cmd>lua vim.lsp.buf.definition()<CR>
"nnoremap <silent> K <cmd>lua vim.lsp.buf.hover()<CR>
"nnoremap <silent> gD <cmd>lua vim.lsp.buf.implementation()<CR>
"nnoremap <silent> <c-k> <cmd>lua vim.lsp.buf.signature_help()<CR>
"nnoremap <silent> 1gD <cmd>lua vim.lsp.buf.type_definition()<CR>
"nnoremap <silent> gr <cmd>lua vim.lsp.buf.references()<CR>
"nnoremap <silent> g0 <cmd>lua vim.lsp.buf.document_symbol()<CR>
"nnoremap <silent> gW <cmd>lua vim.lsp.buf.workspace_symbol()<CR>
"nnoremap <silent> gd <cmd>lua vim.lsp.buf.definition()<CR>
" Code action
"nnoremap <silent> ga <cmd>lua vim.lsp.buf.code_action()<CR>
" Set updatetime for CursorHold
" 300ms of no cursor movement to trigger CursorHold
"set updatetime=300
" Show diagnostic popup on cursor hold
"autocmd CursorHold * lua vim.lsp.diagnostic.show_line_diagnostics()
" Goto previous/next diagnostic warning/error
"nnoremap <silent> g[ <cmd>lua vim.lsp.diagnostic.goto_prev()<CR>
"nnoremap <silent> g] <cmd>lua vim.lsp.diagnostic.goto_next()<CR>