. . .
1
2
3
4local function fix_menu()
5 local choices = {"spaces", "quotes", "both"}
6 vim.ui.select(choices, {prompt = "fix"}, function(choice)
7 if not choice then return end
8 if choice == "spaces" or choice == "both" then
9 vim.cmd("call CleanupWhitespace()")
10 end
11 if choice == "quotes" or choice == "both" then
12 vim.cmd([[:%s/'\([^']*\)'/"\1"/g]])
13 end
14 end)
15end
16
17vim.keymap.set("n", "fix", fix_menu)
18
19--[[
20
21TODO keybindings for
22
23vim.lsp.buf
24.definition()
25.declaration()
26.implementation()
27.type_definition()
28.references()
29.signature_help()
30.rename()
31.code_action()
32
33vim.diagnostic
34.open_float()
35.goto_prev(), _next()
36
37<C-x><C-o> for completion
38
39]]--
40
41vim.api.nvim_create_autocmd({"BufEnter"},
42 {
43 pattern = {"*.rs"},
44 callback = function(ev)
45 print(vim.fs.dirname(vim.fs.find({'Cargo.toml'}, {upward = true})[1]))
46 vim.lsp.start({
47 name = 'rust-analyzer',
48 cmd = {'rust-analyzer'},
49 root_dir = vim.fs.dirname(vim.fs.find({'Cargo.toml'}, {upward = true})[1]),
50 })
51
52 vim.keymap.set('n', '<leader><leader>', '<cmd>lua vim.lsp.buf.hover()<return>')
53 end
54 })
55
56require('lsp_lines').setup()
57
58vim.diagnostic.config({
59 virtual_text = false,
60})
61