-
Notifications
You must be signed in to change notification settings - Fork 64
/
Copy pathrust_tools.lua
104 lines (97 loc) · 2.85 KB
/
rust_tools.lua
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
local M = {}
M.config = function()
local opts = {
tools = {
executor = require "rustaceanvim.executors.termopen", -- can be quickfix or termopen
reload_workspace_from_cargo_toml = true,
inlay_hints = {
auto = true,
only_current_line = false,
show_parameter_hints = true,
parameter_hints_prefix = "<-",
other_hints_prefix = "=>",
max_len_align = false,
max_len_align_padding = 1,
right_align = false,
right_align_padding = 7,
highlight = "Comment",
},
hover_actions = {
border = {
{ "╭", "FloatBorder" },
{ "─", "FloatBorder" },
{ "╮", "FloatBorder" },
{ "│", "FloatBorder" },
{ "╯", "FloatBorder" },
{ "─", "FloatBorder" },
{ "╰", "FloatBorder" },
{ "│", "FloatBorder" },
},
auto_focus = true,
},
},
server = {
on_attach = function(client, bufnr)
require("lvim.lsp").common_on_attach(client, bufnr)
end,
on_init = require("lvim.lsp").common_on_init,
capabilities = require("lvim.lsp").common_capabilities(),
default_settings = {
["rust-analyzer"] = {
inlayHints = { locationLinks = false },
lens = {
enable = true,
},
checkOnSave = {
enable = true,
command = "clippy",
},
diagnostics = {
experimental = true,
},
},
},
},
}
local mason_path = vim.fn.glob(vim.fn.stdpath "data" .. "/mason/packages/codelldb/extension/")
local vscode_path = vim.fn.expand "~/" .. ".vscode/extensions/vadimcn.vscode-lldb-1.10.0/"
local path = ""
local debugger_found = true
if M.dir_exists(mason_path) then
path = mason_path
elseif M.dir_exists(vscode_path) then
path = vscode_path
else
debugger_found = false
vim.notify("please install codelldb using :Mason or via vscode", vim.log.levels.WARN)
end
if debugger_found then
local codelldb_path = path .. "adapter/codelldb"
local liblldb_path = path .. "lldb/lib/liblldb.so"
if vim.fn.has "mac" == 1 then
liblldb_path = path .. "lldb/lib/liblldb.dylib"
end
if vim.fn.filereadable(codelldb_path) and vim.fn.filereadable(liblldb_path) then
local cfg = require "rustaceanvim.config"
opts.dap = {
adapter = cfg.get_codelldb_adapter(codelldb_path, liblldb_path),
}
else
vim.notify("please reinstall codellb, i cannot find liblldb or codelldb itself", vim.log.levels.WARN)
end
end
vim.g.rustaceanvim = function()
return opts
end
end
M.dir_exists = function(file)
local ok, _, code = os.rename(file, file)
if not ok then
if code == 13 then
-- Permission denied, but it exists
return true
end
end
return ok
end
return M