1

Regenerate nvim config

This commit is contained in:
2024-06-02 03:29:20 +02:00
parent 75eea0c030
commit ef2e28883d
5576 changed files with 604886 additions and 503 deletions

View File

@ -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

View File

@ -0,0 +1,26 @@
" Copied from built-in compiler/{rustc,cargo}.vim
setlocal errorformat=
\%f:%l:%c:\ %t%*[^:]:\ %m,
\%f:%l:%c:\ %*\\d:%*\\d\ %t%*[^:]:\ %m,
\%-G%f:%l\ %s,
\%-G%*[\ ]^,
\%-G%*[\ ]^%*[~],
\%-G%*[\ ]...
" New errorformat (after nightly 2016/08/10)
setlocal errorformat+=
\%-G,
\%-Gerror:\ aborting\ %.%#,
\%-Gerror:\ Could\ not\ compile\ %.%#,
\%Eerror:\ %m,
\%Eerror[E%n]:\ %m,
\%Wwarning:\ %m,
\%Inote:\ %m,
\%C\ %#-->\ %f:%l:%c
setlocal errorformat+=
\%-G%\\s%#Downloading%.%#,
\%-G%\\s%#Compiling%.%#,
\%-G%\\s%#Finished%.%#,
\%-G%\\s%#error:\ Could\ not\ compile\ %.%#,
\%-G%\\s%#To\ learn\ more\\,%.%#

View File

@ -0,0 +1,24 @@
local fname = vim.fn.fnamemodify(vim.api.nvim_buf_get_name(0), ':t')
if fname ~= 'Cargo.toml' then
return
end
local config = require('rustaceanvim.config.internal')
local ra = require('rustaceanvim.rust_analyzer')
if config.tools.reload_workspace_from_cargo_toml then
local group = vim.api.nvim_create_augroup('RustaceanCargoReloadWorkspace', { clear = false })
local bufnr = vim.api.nvim_get_current_buf()
vim.api.nvim_clear_autocmds {
buffer = bufnr,
group = group,
}
vim.api.nvim_create_autocmd('BufWritePost', {
buffer = vim.api.nvim_get_current_buf(),
group = group,
callback = function()
if #ra.get_active_rustaceanvim_clients(nil) > 0 then
vim.cmd.RustLsp { 'reloadWorkspace', mods = { silent = true } }
end
end,
})
end