-
-
Notifications
You must be signed in to change notification settings - Fork 253
/
Copy pathinit.lua
165 lines (162 loc) · 5.29 KB
/
init.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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
return {
{ import = "astrocommunity.pack.toml" },
{
"nvim-treesitter/nvim-treesitter",
optional = true,
opts = function(_, opts)
if opts.ensure_installed ~= "all" then
opts.ensure_installed = require("astrocore").list_insert_unique(opts.ensure_installed, { "rust" })
end
end,
},
{
"AstroNvim/astrolsp",
optional = true,
---@param opts AstroLSPOpts
opts = {
handlers = { rust_analyzer = false }, -- disable setup of `rust_analyzer`
---@diagnostic disable: missing-fields
config = {
rust_analyzer = {
settings = {
["rust-analyzer"] = {
check = {
command = "clippy",
extraArgs = {
"--no-deps",
},
},
assist = {
importEnforceGranularity = true,
importPrefix = "crate",
},
completion = {
postfix = {
enable = false,
},
},
inlayHints = {
lifetimeElisionHints = {
enable = true,
useParameterNames = true,
},
},
},
},
},
},
},
},
{
"jay-babu/mason-nvim-dap.nvim",
optional = true,
opts = function(_, opts)
opts.ensure_installed = require("astrocore").list_insert_unique(opts.ensure_installed, { "codelldb" })
end,
},
{
"WhoIsSethDaniel/mason-tool-installer.nvim",
optional = true,
opts = function(_, opts)
opts.ensure_installed = require("astrocore").list_insert_unique(opts.ensure_installed, { "codelldb" })
end,
},
{
"mrcjkb/rustaceanvim",
version = "^4",
ft = "rust",
specs = {
{
"AstroNvim/astrolsp",
optional = true,
---@param opts AstroLSPOpts
opts = {
handlers = { rust_analyzer = false }, -- disable setup of `rust_analyzer`
},
},
},
opts = function()
local adapter
local success, package = pcall(function() return require("mason-registry").get_package "codelldb" end)
local cfg = require "rustaceanvim.config"
if success then
local package_path = package:get_install_path()
local codelldb_path = package_path .. "/codelldb"
local liblldb_path = package_path .. "/extension/lldb/lib/liblldb"
local this_os = vim.loop.os_uname().sysname
-- The path in windows is different
if this_os:find "Windows" then
codelldb_path = package_path .. "\\extension\\adapter\\codelldb.exe"
liblldb_path = package_path .. "\\extension\\lldb\\bin\\liblldb.dll"
else
-- The liblldb extension is .so for linux and .dylib for macOS
liblldb_path = liblldb_path .. (this_os == "Linux" and ".so" or ".dylib")
end
adapter = cfg.get_codelldb_adapter(codelldb_path, liblldb_path)
else
adapter = cfg.get_codelldb_adapter()
end
local astrolsp_avail, astrolsp = pcall(require, "astrolsp")
local astrolsp_opts = (astrolsp_avail and astrolsp.lsp_opts "rust_analyzer") or {}
local server = {
---@type table | (fun(project_root:string|nil, default_settings: table|nil):table) -- The rust-analyzer settings or a function that creates them.
settings = function(project_root, default_settings)
local astrolsp_settings = astrolsp_opts.settings or {}
local merge_table = require("astrocore").extend_tbl(default_settings or {}, astrolsp_settings)
local ra = require "rustaceanvim.config.server"
-- load_rust_analyzer_settings merges any found settings with the passed in default settings table and then returns that table
return ra.load_rust_analyzer_settings(project_root, {
settings_file_pattern = "rust-analyzer.json",
default_settings = merge_table,
})
end,
}
local final_server = require("astrocore").extend_tbl(astrolsp_opts, server)
return { server = final_server, dap = { adapter = adapter }, tools = { enable_clippy = false } }
end,
config = function(_, opts) vim.g.rustaceanvim = require("astrocore").extend_tbl(opts, vim.g.rustaceanvim) end,
},
{
"Saecki/crates.nvim",
lazy = true,
dependencies = {
"AstroNvim/astrocore",
opts = {
autocmds = {
CmpSourceCargo = {
{
event = "BufRead",
desc = "Load crates.nvim into Cargo buffers",
pattern = "Cargo.toml",
callback = function()
require("cmp").setup.buffer { sources = { { name = "crates" } } }
require "crates"
end,
},
},
},
},
},
opts = {
completion = {
cmp = { enabled = true },
crates = {
enabled = true,
},
},
null_ls = {
enabled = true,
name = "crates.nvim",
},
},
},
{
"nvim-neotest/neotest",
optional = true,
opts = function(_, opts)
if not opts.adapters then opts.adapters = {} end
local rustaceanvim_avail, rustaceanvim = pcall(require, "rustaceanvim.neotest")
if rustaceanvim_avail then table.insert(opts.adapters, rustaceanvim) end
end,
},
}