Regenerate nvim config
This commit is contained in:
@ -0,0 +1,64 @@
|
||||
---@type RustaceanConfig
|
||||
local config = require('rustaceanvim.config.internal')
|
||||
|
||||
if not vim.g.loaded_rustaceanvim then
|
||||
require('rustaceanvim.config.check').check_for_lspconfig_conflict(vim.schedule_wrap(function(warn)
|
||||
vim.notify_once(warn, vim.log.levels.WARN)
|
||||
end))
|
||||
vim.lsp.commands['rust-analyzer.runSingle'] = function(command)
|
||||
local runnables = require('rustaceanvim.runnables')
|
||||
local cached_commands = require('rustaceanvim.cached_commands')
|
||||
---@type RARunnable[]
|
||||
local ra_runnables = command.arguments
|
||||
local runnable = ra_runnables[1]
|
||||
local cargo_args = runnable.args.cargoArgs
|
||||
if #cargo_args > 0 and vim.startswith(cargo_args[1], 'test') then
|
||||
cached_commands.set_last_testable(1, ra_runnables)
|
||||
end
|
||||
cached_commands.set_last_runnable(1, ra_runnables)
|
||||
runnables.run_command(1, ra_runnables)
|
||||
end
|
||||
|
||||
vim.lsp.commands['rust-analyzer.gotoLocation'] = function(command, ctx)
|
||||
local client = vim.lsp.get_client_by_id(ctx.client_id)
|
||||
if client then
|
||||
vim.lsp.util.jump_to_location(command.arguments[1], client.offset_encoding)
|
||||
end
|
||||
end
|
||||
|
||||
vim.lsp.commands['rust-analyzer.showReferences'] = function(_)
|
||||
vim.lsp.buf.implementation()
|
||||
end
|
||||
|
||||
vim.lsp.commands['rust-analyzer.debugSingle'] = function(command)
|
||||
local overrides = require('rustaceanvim.overrides')
|
||||
local args = command.arguments[1].args
|
||||
overrides.sanitize_command_for_debugging(args.cargoArgs)
|
||||
local cached_commands = require('rustaceanvim.cached_commands')
|
||||
cached_commands.set_last_debuggable(args)
|
||||
local rt_dap = require('rustaceanvim.dap')
|
||||
rt_dap.start(args)
|
||||
end
|
||||
|
||||
local commands = require('rustaceanvim.commands')
|
||||
commands.create_rustc_command()
|
||||
end
|
||||
|
||||
vim.g.loaded_rustaceanvim = true
|
||||
|
||||
local bufnr = vim.api.nvim_get_current_buf()
|
||||
local auto_attach = config.server.auto_attach
|
||||
if type(auto_attach) == 'function' then
|
||||
auto_attach = auto_attach(bufnr)
|
||||
end
|
||||
|
||||
if auto_attach then
|
||||
-- Defer for a smoother experience on low-end devices
|
||||
vim.api.nvim_create_autocmd('BufEnter', {
|
||||
buffer = bufnr,
|
||||
group = vim.api.nvim_create_augroup('RustaceanvimAttach', { clear = true }),
|
||||
callback = function()
|
||||
require('rustaceanvim.lsp').start()
|
||||
end,
|
||||
})
|
||||
end
|
||||
Reference in New Issue
Block a user