1

Refresh generated neovim config

This commit is contained in:
2024-07-14 21:12:36 +02:00
parent f215ce2ab5
commit 00464e0e65
731 changed files with 6780 additions and 31110 deletions

View File

@ -182,13 +182,13 @@ FloatWinConfig *FloatWinConfig*
executor_alias *executor_alias*
Type: ~
"termopen"|"quickfix"|"toggleterm"|"vimux"|"neotest"
"termopen"|"quickfix"|"toggleterm"|"vimux"
test_executor_alias *test_executor_alias*
Type: ~
executor_alias|"background"
executor_alias|"background"|"neotest"
RustaceanHoverActionsOpts *RustaceanHoverActionsOpts*
@ -242,6 +242,9 @@ RustaceanLspClientOpts *RustaceanLspClientOpts*
{logfile?} (string) The path to the rust-analyzer log file.
{load_vscode_settings?} (boolean) Whether to search (upward from the buffer) for rust-analyzer settings in .vscode/settings json. If found, loaded settings will override configured options. Default: false
See: ~
|vim.lsp.ClientConfig|
RustaceanDapOpts *RustaceanDapOpts*

View File

@ -59,6 +59,7 @@ function cargo.get_root_dir(file_name)
upward = true,
path = path,
})[1])
---@type string | nil
local cargo_workspace_dir = nil
if vim.fn.executable('cargo') == 1 then
local cmd = { 'cargo', 'metadata', '--no-deps', '--format-version', '1' }
@ -80,8 +81,10 @@ function cargo.get_root_dir(file_name)
cm = -1
end
if cm == 0 then
cargo_workspace_dir = vim.fn.json_decode(cargo_metadata)['workspace_root']
---@cast cargo_workspace_dir string
local ok, cargo_metadata_json = pcall(vim.fn.json_decode, cargo_metadata)
if ok and cargo_metadata_json then
cargo_workspace_dir = cargo_metadata_json['workspace_root']
end
end
end
return cargo_workspace_dir

View File

@ -332,17 +332,17 @@ function M.create_rust_lsp_command()
bang = true,
desc = 'Interacts with the rust-analyzer LSP client',
complete = function(arg_lead, cmdline, _)
local commands = cmdline:match('^' .. rust_lsp_cmd_name .. '!') ~= nil
local commands = cmdline:match("^['<,'>]*" .. rust_lsp_cmd_name .. '!') ~= nil
-- bang!
and tbl_keys_by_value_filter(function(command)
return command.bang == true
end, rustlsp_command_tbl)
or vim.tbl_keys(rustlsp_command_tbl)
local subcmd, subcmd_arg_lead = cmdline:match('^' .. rust_lsp_cmd_name .. '[!]*%s(%S+)%s(.*)$')
local subcmd, subcmd_arg_lead = cmdline:match("^['<,'>]*" .. rust_lsp_cmd_name .. '[!]*%s(%S+)%s(.*)$')
if subcmd and subcmd_arg_lead and rustlsp_command_tbl[subcmd] and rustlsp_command_tbl[subcmd].complete then
return rustlsp_command_tbl[subcmd].complete(subcmd_arg_lead)
end
if cmdline:match('^' .. rust_lsp_cmd_name .. '[!]*%s+%w*$') then
if cmdline:match("^['<,'>]*" .. rust_lsp_cmd_name .. '[!]*%s+%w*$') then
return vim.tbl_filter(function(command)
return command:find(arg_lead) ~= nil
end, commands)

View File

@ -82,9 +82,9 @@ vim.g.rustaceanvim = vim.g.rustaceanvim
---@see vim.lsp.util.open_floating_preview.Opts
---@see vim.api.nvim_open_win
---@alias executor_alias 'termopen' | 'quickfix' | 'toggleterm' | 'vimux' | 'neotest'
---@alias executor_alias 'termopen' | 'quickfix' | 'toggleterm' | 'vimux'
---@alias test_executor_alias executor_alias | 'background'
---@alias test_executor_alias executor_alias | 'background' | 'neotest'
---@class RustaceanHoverActionsOpts
---@field replace_builtin_hover? boolean Whether to replace Neovim's built-in `vim.lsp.buf.hover` with hover actions. Default: `true`
@ -115,6 +115,7 @@ vim.g.rustaceanvim = vim.g.rustaceanvim
---@field standalone? boolean Standalone file support (enabled by default). Disabling it may improve rust-analyzer's startup time.
---@field logfile? string The path to the rust-analyzer log file.
---@field load_vscode_settings? boolean Whether to search (upward from the buffer) for rust-analyzer settings in .vscode/settings json. If found, loaded settings will override configured options. Default: false
---@see vim.lsp.ClientConfig
---@class RustaceanDapOpts
--- @field autoload_configurations boolean Whether to autoload nvim-dap configurations when rust-analyzer has attached? Default: `true`.

View File

@ -29,7 +29,6 @@ function server.load_rust_analyzer_settings(project_root, opts)
then
---@diagnostic disable-next-line: inject-field
default_settings['rust-analyzer'].check = {
allFeatures = true,
command = 'clippy',
extraArgs = { '--no-deps' },
}
@ -148,7 +147,7 @@ function server.create_client_capabilities()
}
end)
return vim.tbl_deep_extend(
'keep',
'force',
rs_capabilities,
cmp_capabilities,
selection_range_capabilities,

View File

@ -188,7 +188,7 @@ local function add_dynamic_library_paths(adapter, workspace_root)
if not workspace_root or environments[workspace_root] then
return
end
compat.system({ 'rustc', '--print', 'target-libdir' }, nil, function(sc)
compat.system({ 'rustc', '--print', 'target-libdir' }, { cwd = workspace_root }, function(sc)
---@cast sc vim.SystemCompleted
local result = sc.stdout
if sc.code ~= 0 or result == nil then
@ -202,7 +202,7 @@ local function add_dynamic_library_paths(adapter, workspace_root)
elseif shell.is_macos() then
---@diagnostic disable-next-line: missing-parameter
environments[workspace_root] = environments[workspace_root]
or format_environment_variable(adapter, 'DKLD_LIBRARY_PATH', { rustc_target_path, target_path }, ':')
or format_environment_variable(adapter, 'DYLD_LIBRARY_PATH', { rustc_target_path, target_path }, ':')
else
---@diagnostic disable-next-line: missing-parameter
environments[workspace_root] = environments[workspace_root]

View File

@ -73,6 +73,27 @@ local function get_start_settings(bufname, root_dir, client_config)
return evaluated_settings
end
---HACK: Workaround for https://github.com/neovim/neovim/pull/28690
--- to solve #423.
--- Checks if Neovim's file watcher is enabled, and if it isn't,
--- configures rust-analyzer to enable server-side file watching (if not configured otherwise).
---
---@param server_cfg LspStartConfig LSP start settings
local function configure_file_watcher(server_cfg)
local is_client_file_watcher_enabled =
vim.tbl_get(server_cfg.capabilities, 'workspace', 'didChangeWatchedFiles', 'dynamicRegistration')
local file_watcher_setting = vim.tbl_get(server_cfg.settings, 'rust-analyzer', 'files', 'watcher')
if is_client_file_watcher_enabled and not file_watcher_setting then
server_cfg.settings = vim.tbl_deep_extend('force', server_cfg.settings, {
['rust-analyzer'] = {
files = {
watcher = 'server',
},
},
})
end
end
---@class LspStartConfig: RustaceanLspClientConfig
---@field root_dir string | nil
---@field init_options? table
@ -105,6 +126,7 @@ M.start = function(bufnr)
lsp_start_config.root_dir = root_dir
lsp_start_config.settings = get_start_settings(bufname, root_dir, client_config)
configure_file_watcher(lsp_start_config)
-- Check if a client is already running and add the workspace folder if necessary.
for _, client in pairs(rust_analyzer.get_active_rustaceanvim_clients()) do

View File

@ -1 +1 @@
/nix/store/mqbhz05llkddfb5wni0m48kw22ixxps4-lua-5.1.5
/nix/store/3czmrawji85vf8979kll2yx2f1kjkric-lua-5.1.5

View File

@ -1,7 +1,7 @@
rock_manifest = {
doc = {
["mason.txt"] = "858adffa88b1649b91187f49f191e376",
["rustaceanvim.txt"] = "a9fa5fd997f2e2c099d2bf715cf4d5e9"
["rustaceanvim.txt"] = "015b5fced4394fb911e73ba609c2b00c"
},
ftplugin = {
["rust.lua"] = "b225026e3590a6741373922fbae423e5",
@ -11,7 +11,7 @@ rock_manifest = {
lua = {
rustaceanvim = {
["cached_commands.lua"] = "6e23c8231f44a3edc76be54766fca334",
["cargo.lua"] = "43ba56ed4ba112dd22cac598e7b248df",
["cargo.lua"] = "f2a24f708ff861b7aa914407c67a5c0e",
commands = {
["code_action_group.lua"] = "55bf0c83a007e5d64924eafe2e2a96eb",
["crate_graph.lua"] = "30d01abc92dff63ace83a5d1697d2073",
@ -21,7 +21,7 @@ rock_manifest = {
["external_docs.lua"] = "1d2fa5d88ea197ad9976c23b0ff70763",
["fly_check.lua"] = "3f7b89700bd8f98fd5ab0ec02cce1cdd",
["hover_range.lua"] = "68828cfd0c465bbe0915996795ff7b92",
["init.lua"] = "6d7415da1c6e12b7b7914ab4e0339fae",
["init.lua"] = "0f99af7dabcd1ad961de545363e0f658",
["join_lines.lua"] = "f31a68f1ddac01b926d58ccd249bc03d",
["move_item.lua"] = "f05118ba148e66c1e92882141e68343f",
["open_cargo_toml.lua"] = "2368251db4ce52659693acc8eee15b74",
@ -37,12 +37,12 @@ rock_manifest = {
["compat.lua"] = "fedaef1aeaceaf086116ed62b423d0a3",
config = {
["check.lua"] = "55ddc99999546e6951cd2641cc997af2",
["init.lua"] = "a583a64ac0023a551c16a92f61ff063d",
["init.lua"] = "4f8a4eb148571862d1439263f18c7cee",
["internal.lua"] = "854115363fcfc13e65098150b873a8ff",
["json.lua"] = "a8c7caf443ad9ce1193726aec053cc8d",
["server.lua"] = "d642a65f31cb4f12b812840c1171821f"
["server.lua"] = "a58c53c1333c5d050d97cf3e2bf82d99"
},
["dap.lua"] = "757ecf822f6c30ebf9e462f7009ce99a",
["dap.lua"] = "e39cbe01d5d7c03d585e7448d24ceab7",
executors = {
["background.lua"] = "ae1c76a5c2f73e9c58456f580b7552b7",
["init.lua"] = "a443891fc3b974db6787502179d85c19",
@ -56,7 +56,7 @@ rock_manifest = {
["health.lua"] = "126952700269c9ab976f29f59604c5da",
["hover_actions.lua"] = "d0842822fa99c55b4cc5a65eae968ff2",
["init.lua"] = "a48de2e7e937208adc6781a5ea35ec88",
["lsp.lua"] = "c36e5b79bb7fb41a9781d70421f7a55c",
["lsp.lua"] = "5e8af804d16be73193df6067141bdf9f",
neotest = {
["init.lua"] = "ec54c5df5002742877ec6c925b273b2d",
["trans.lua"] = "1f79320bca0c81d91673543dd7ad4984"
@ -74,5 +74,5 @@ rock_manifest = {
["ui.lua"] = "185cbb4ef9b15b4feb6699fcbd5d4435"
}
},
["rustaceanvim-4.22.8-1.rockspec"] = "1d483e8dffa0275323da043a1e8c9cf3"
["rustaceanvim-4.25.1-1.rockspec"] = "fc780a2aa2e2df3fdb088697523f426f"
}

View File

@ -1,241 +0,0 @@
commands = {}
dependencies = {
rustaceanvim = {
["4.22.8-1"] = {
{
constraints = {
{
op = ">=",
version = {
5, 1, string = "5.1"
}
}
},
name = "lua"
}
}
}
}
modules = {
["rustaceanvim.cached_commands"] = {
"rustaceanvim/4.22.8-1"
},
["rustaceanvim.cargo"] = {
"rustaceanvim/4.22.8-1"
},
["rustaceanvim.commands.code_action_group"] = {
"rustaceanvim/4.22.8-1"
},
["rustaceanvim.commands.crate_graph"] = {
"rustaceanvim/4.22.8-1"
},
["rustaceanvim.commands.debuggables"] = {
"rustaceanvim/4.22.8-1"
},
["rustaceanvim.commands.diagnostic"] = {
"rustaceanvim/4.22.8-1"
},
["rustaceanvim.commands.expand_macro"] = {
"rustaceanvim/4.22.8-1"
},
["rustaceanvim.commands.external_docs"] = {
"rustaceanvim/4.22.8-1"
},
["rustaceanvim.commands.fly_check"] = {
"rustaceanvim/4.22.8-1"
},
["rustaceanvim.commands.hover_range"] = {
"rustaceanvim/4.22.8-1"
},
["rustaceanvim.commands.init"] = {
"rustaceanvim/4.22.8-1"
},
["rustaceanvim.commands.join_lines"] = {
"rustaceanvim/4.22.8-1"
},
["rustaceanvim.commands.move_item"] = {
"rustaceanvim/4.22.8-1"
},
["rustaceanvim.commands.open_cargo_toml"] = {
"rustaceanvim/4.22.8-1"
},
["rustaceanvim.commands.parent_module"] = {
"rustaceanvim/4.22.8-1"
},
["rustaceanvim.commands.rebuild_proc_macros"] = {
"rustaceanvim/4.22.8-1"
},
["rustaceanvim.commands.rustc_unpretty"] = {
"rustaceanvim/4.22.8-1"
},
["rustaceanvim.commands.ssr"] = {
"rustaceanvim/4.22.8-1"
},
["rustaceanvim.commands.syntax_tree"] = {
"rustaceanvim/4.22.8-1"
},
["rustaceanvim.commands.view_ir"] = {
"rustaceanvim/4.22.8-1"
},
["rustaceanvim.commands.workspace_refresh"] = {
"rustaceanvim/4.22.8-1"
},
["rustaceanvim.commands.workspace_symbol"] = {
"rustaceanvim/4.22.8-1"
},
["rustaceanvim.compat"] = {
"rustaceanvim/4.22.8-1"
},
["rustaceanvim.config.check"] = {
"rustaceanvim/4.22.8-1"
},
["rustaceanvim.config.init"] = {
"rustaceanvim/4.22.8-1"
},
["rustaceanvim.config.internal"] = {
"rustaceanvim/4.22.8-1"
},
["rustaceanvim.config.json"] = {
"rustaceanvim/4.22.8-1"
},
["rustaceanvim.config.server"] = {
"rustaceanvim/4.22.8-1"
},
["rustaceanvim.dap"] = {
"rustaceanvim/4.22.8-1"
},
["rustaceanvim.executors.background"] = {
"rustaceanvim/4.22.8-1"
},
["rustaceanvim.executors.init"] = {
"rustaceanvim/4.22.8-1"
},
["rustaceanvim.executors.meta"] = {
"rustaceanvim/4.22.8-1"
},
["rustaceanvim.executors.neotest"] = {
"rustaceanvim/4.22.8-1"
},
["rustaceanvim.executors.quickfix"] = {
"rustaceanvim/4.22.8-1"
},
["rustaceanvim.executors.termopen"] = {
"rustaceanvim/4.22.8-1"
},
["rustaceanvim.executors.toggleterm"] = {
"rustaceanvim/4.22.8-1"
},
["rustaceanvim.executors.vimux"] = {
"rustaceanvim/4.22.8-1"
},
["rustaceanvim.health"] = {
"rustaceanvim/4.22.8-1"
},
["rustaceanvim.hover_actions"] = {
"rustaceanvim/4.22.8-1"
},
["rustaceanvim.init"] = {
"rustaceanvim/4.22.8-1"
},
["rustaceanvim.lsp"] = {
"rustaceanvim/4.22.8-1"
},
["rustaceanvim.neotest.init"] = {
"rustaceanvim/4.22.8-1"
},
["rustaceanvim.neotest.trans"] = {
"rustaceanvim/4.22.8-1"
},
["rustaceanvim.os"] = {
"rustaceanvim/4.22.8-1"
},
["rustaceanvim.overrides"] = {
"rustaceanvim/4.22.8-1"
},
["rustaceanvim.runnables"] = {
"rustaceanvim/4.22.8-1"
},
["rustaceanvim.rust_analyzer"] = {
"rustaceanvim/4.22.8-1"
},
["rustaceanvim.server_status"] = {
"rustaceanvim/4.22.8-1"
},
["rustaceanvim.shell"] = {
"rustaceanvim/4.22.8-1"
},
["rustaceanvim.test"] = {
"rustaceanvim/4.22.8-1"
},
["rustaceanvim.types.internal"] = {
"rustaceanvim/4.22.8-1"
},
["rustaceanvim.ui"] = {
"rustaceanvim/4.22.8-1"
}
}
repository = {
rustaceanvim = {
["4.22.8-1"] = {
{
arch = "installed",
commands = {},
dependencies = {},
modules = {
["rustaceanvim.cached_commands"] = "rustaceanvim/cached_commands.lua",
["rustaceanvim.cargo"] = "rustaceanvim/cargo.lua",
["rustaceanvim.commands.code_action_group"] = "rustaceanvim/commands/code_action_group.lua",
["rustaceanvim.commands.crate_graph"] = "rustaceanvim/commands/crate_graph.lua",
["rustaceanvim.commands.debuggables"] = "rustaceanvim/commands/debuggables.lua",
["rustaceanvim.commands.diagnostic"] = "rustaceanvim/commands/diagnostic.lua",
["rustaceanvim.commands.expand_macro"] = "rustaceanvim/commands/expand_macro.lua",
["rustaceanvim.commands.external_docs"] = "rustaceanvim/commands/external_docs.lua",
["rustaceanvim.commands.fly_check"] = "rustaceanvim/commands/fly_check.lua",
["rustaceanvim.commands.hover_range"] = "rustaceanvim/commands/hover_range.lua",
["rustaceanvim.commands.init"] = "rustaceanvim/commands/init.lua",
["rustaceanvim.commands.join_lines"] = "rustaceanvim/commands/join_lines.lua",
["rustaceanvim.commands.move_item"] = "rustaceanvim/commands/move_item.lua",
["rustaceanvim.commands.open_cargo_toml"] = "rustaceanvim/commands/open_cargo_toml.lua",
["rustaceanvim.commands.parent_module"] = "rustaceanvim/commands/parent_module.lua",
["rustaceanvim.commands.rebuild_proc_macros"] = "rustaceanvim/commands/rebuild_proc_macros.lua",
["rustaceanvim.commands.rustc_unpretty"] = "rustaceanvim/commands/rustc_unpretty.lua",
["rustaceanvim.commands.ssr"] = "rustaceanvim/commands/ssr.lua",
["rustaceanvim.commands.syntax_tree"] = "rustaceanvim/commands/syntax_tree.lua",
["rustaceanvim.commands.view_ir"] = "rustaceanvim/commands/view_ir.lua",
["rustaceanvim.commands.workspace_refresh"] = "rustaceanvim/commands/workspace_refresh.lua",
["rustaceanvim.commands.workspace_symbol"] = "rustaceanvim/commands/workspace_symbol.lua",
["rustaceanvim.compat"] = "rustaceanvim/compat.lua",
["rustaceanvim.config.check"] = "rustaceanvim/config/check.lua",
["rustaceanvim.config.init"] = "rustaceanvim/config/init.lua",
["rustaceanvim.config.internal"] = "rustaceanvim/config/internal.lua",
["rustaceanvim.config.json"] = "rustaceanvim/config/json.lua",
["rustaceanvim.config.server"] = "rustaceanvim/config/server.lua",
["rustaceanvim.dap"] = "rustaceanvim/dap.lua",
["rustaceanvim.executors.background"] = "rustaceanvim/executors/background.lua",
["rustaceanvim.executors.init"] = "rustaceanvim/executors/init.lua",
["rustaceanvim.executors.meta"] = "rustaceanvim/executors/meta.lua",
["rustaceanvim.executors.neotest"] = "rustaceanvim/executors/neotest.lua",
["rustaceanvim.executors.quickfix"] = "rustaceanvim/executors/quickfix.lua",
["rustaceanvim.executors.termopen"] = "rustaceanvim/executors/termopen.lua",
["rustaceanvim.executors.toggleterm"] = "rustaceanvim/executors/toggleterm.lua",
["rustaceanvim.executors.vimux"] = "rustaceanvim/executors/vimux.lua",
["rustaceanvim.health"] = "rustaceanvim/health.lua",
["rustaceanvim.hover_actions"] = "rustaceanvim/hover_actions.lua",
["rustaceanvim.init"] = "rustaceanvim/init.lua",
["rustaceanvim.lsp"] = "rustaceanvim/lsp.lua",
["rustaceanvim.neotest.init"] = "rustaceanvim/neotest/init.lua",
["rustaceanvim.neotest.trans"] = "rustaceanvim/neotest/trans.lua",
["rustaceanvim.os"] = "rustaceanvim/os.lua",
["rustaceanvim.overrides"] = "rustaceanvim/overrides.lua",
["rustaceanvim.runnables"] = "rustaceanvim/runnables.lua",
["rustaceanvim.rust_analyzer"] = "rustaceanvim/rust_analyzer.lua",
["rustaceanvim.server_status"] = "rustaceanvim/server_status.lua",
["rustaceanvim.shell"] = "rustaceanvim/shell.lua",
["rustaceanvim.test"] = "rustaceanvim/test.lua",
["rustaceanvim.types.internal"] = "rustaceanvim/types/internal.lua",
["rustaceanvim.ui"] = "rustaceanvim/ui.lua"
}
}
}
}
}

View File

@ -1,54 +0,0 @@
==============================================================================
mason-lspconfig troubleshooting *rustaceanvim.mason*
This plugin supports automatically detecting mason.nvim codelldb installations,
but not rust-analyzer.
The main reason for this choice is that it mason.nvim installations of rust-analyzer
will most likely have been built with a different toolchain than your project,
leading to inconsistencies and possibly subtle bugs.
If you want to use a mason.nvim installation anyway, you can do so by specifying
the `server.cmd` setting (see |rustaceanvim.config| and |RustaceanLspClientOpts|):
>lua
vim.g.rustaceanvim = {
server = {
cmd = function()
local mason_registry = require('mason-registry')
local ra_binary = mason_registry.is_installed('rust-analyzer')
-- This may need to be tweaked, depending on the operating system.
and mason_registry.get_package('rust-analyzer'):get_install_path() .. "/rust-analyzer"
or "rust-analyzer"
return { ra_binary } -- You can add args to the list, such as '--log-file'
end,
},
}
<
Note that mason-lspconfig.nvim, when configured to ensure rust-analyzer is installed,
assumes you are using the `nvim-lspconfig.rust_analyzer` client.
Some Neovim distributions will automatically call the client's `setup`
function, resulting in a conflict with this plugin.
General approach to prevent mason-lspconfig from setting up
`lspconfig.rust_analyzer`:
>lua
require('mason-lspconfig').setup_handlers {
['rust_analyzer'] = function() end,
}
<
Using LazyVim:
>lua
{
'neovim/nvim-lspconfig',
opts = {
setup = {
rust_analyzer = function()
return true
end,
},
},
}
<
vim:tw=78:ts=8:noet:ft=help:norl:

View File

@ -1,410 +0,0 @@
==============================================================================
Table of Contents *rustaceanvim.contents*
Introduction ··························································· |intro|
································································ |rustaceanvim|
plugin configuration ····································· |rustaceanvim.config|
LSP configuration utility ························· |rustaceanvim.config.server|
························································ |rustaceanvim.neotest|
==============================================================================
Introduction *intro*
This plugin automatically configures the `rust-analyzer` builtin LSP client
and integrates with other rust tools.
==============================================================================
*rustaceanvim*
Commands:
':RustAnalyzer start' - Start the LSP client.
':RustAnalyzer stop' - Stop the LSP client.
':RustAnalyzer restart' - Restart the LSP client.
':RustAnalyzer reloadSettings' - Reload settings for the LSP client.
The ':RustLsp[!]' command is available after the LSP client has initialized.
It accepts the following subcommands:
'runnables {args[]}?' - Run tests, executables, etc.
':RustLsp!' means run the last runnable (ignores any args).
`args[]` allows you to override the executable's arguments.
'run {args[]}?' - Like 'runnables', but runs the target at the current cursor position.
'debuggables {args[]}?' - Debug tests, executables, etc. (requires |nvim-dap|).
':RustLsp!' means run the last debuggable (ignores any args).
`args[]` allows you to override the executable's arguments.
'debug {args[]}?' - Like 'debuggables', but debugs the target at the current cursor position.
'testables {args[]}?' - Run tests
':RustLsp!' means run the last testable (ignores any args).
`args[]` allows you to override the executable's arguments.
'expandMacro' - Expand macros recursively.
'moveItem {up|down}' - Move items up or down.
'hover {actions|range}' - Hover actions, or hover over visually selected range.
'explainError' - Display a hover window with explanations form the Rust error index.
Like |vim.diagnostic.goto_next|, |explainError| will cycle diagnostics,
starting at the cursor position, until it can find a diagnostic with
an error code.
'renderDiagnostic' - Display a hover window with the rendered diagnostic,
as displayed during `cargo build`.
Like |vim.diagnostic.goto_next|, |renderDiagnostic| will cycle diagnostics,
starting at the cursor position, until it can find a diagnostic with
rendered data.
'openCargo' - Open the Cargo.toml file for the current package.
'openDocs' - Open docs.rs documentation for the symbol under the cursor.
'parentModule' - Open the current module's parent module.
'workspaceSymbol {onlyTypes?|allSymbols?} {query?}'
Filtered workspace symbol search.
When run with a bang (`:RustLsp! workspaceSymbol ...`),
rust-analyzer will include dependencies in the search.
You can also configure rust-analyzer so that |vim.lsp.buf.workspace_symbol|
supports filtering (with a # suffix to the query) or searching dependencies.
'joinLines' - Join adjacent lines.
'ssr {query}' - Structural search and replace.
Searches the entire buffer in normal mode.
Searches the selected region in visual mode.
'crateGraph {backend}' - Create and view a crate graph with graphviz.
'syntaxTree' - View the syntax tree.
'view {mir|hir}' - View MIR or HIR.
'flyCheck' {run?|clear?|cancel?}
- Run `cargo check` or another compatible command (f.x. `clippy`)
in a background thread and provide LSP diagnostics based on
the output of the command.
Useful in large projects where running `cargo check` on each save
can be costly.
Defaults to `flyCheck run` if called without an argument.
'logFile' - Open the rust-analyzer log file.
The ':Rustc' command can be used to interact with rustc.
It accepts the following subcommands:
'unpretty {args[]}' - Opens a buffer with a textual representation of the MIR or others things,
of the function closest to the cursor.
Achieves an experience similar to Rust Playground.
NOTE: This currently requires a tree-sitter parser for Rust,
and a nightly compiler toolchain.
==============================================================================
plugin configuration *rustaceanvim.config*
rustaceanvim is a filetype plugin, and does not need
a `setup` function to work.
To configure rustaceanvim, set the variable `vim.g.rustaceanvim`,
which is a `RustaceanOpts` table, in your neovim configuration.
Example:
>lua
---@type RustaceanOpts
vim.g.rustaceanvim = {
---@type RustaceanToolsOpts
tools = {
-- ...
},
---@type RustaceanLspClientOpts
server = {
on_attach = function(client, bufnr)
-- Set keybindings, etc. here.
end,
default_settings = {
-- rust-analyzer language server configuration
['rust-analyzer'] = {
},
},
-- ...
},
---@type RustaceanDapOpts
dap = {
-- ...
},
}
<
Notes:
- `vim.g.rustaceanvim` can also be a function that returns a `RustaceanOpts` table.
- `server.settings`, by default, is a function that looks for a `rust-analyzer.json` file
in the project root, to load settings from it. It falls back to an empty table.
RustaceanOpts *RustaceanOpts*
Fields: ~
{tools?} (RustaceanToolsOpts) Plugin options
{server?} (RustaceanLspClientOpts) Language server client options
{dap?} (RustaceanDapOpts) Debug adapter options
RustaceanToolsOpts *RustaceanToolsOpts*
Fields: ~
{executor?} (RustaceanExecutor|executor_alias) The executor to use for runnables/debuggables
{test_executor?} (RustaceanExecutor|test_executor_alias) The executor to use for runnables that are tests / testables
{crate_test_executor?} (RustaceanExecutor|test_executor_alias) The executor to use for runnables that are crate test suites (--all-targets)
{cargo_override?} (string) Set this to override the 'cargo' command for runnables, debuggables (etc., e.g. to 'cross'). If set, this takes precedence over 'enable_nextest'.
{enable_nextest?} (boolean) Whether to enable nextest. If enabled, `cargo test` commands will be transformed to `cargo nextest run` commands. Defaults to `true` if cargo-nextest is detected. Ignored if `cargo_override` is set.
{enable_clippy?} (boolean) Whether to enable clippy checks on save if a clippy installation is detected. Default: `true`
{on_initialized?} (fun(health:RustAnalyzerInitializedStatus)) Function that is invoked when the LSP server has finished initializing
{reload_workspace_from_cargo_toml?} (boolean) Automatically call `RustReloadWorkspace` when writing to a Cargo.toml file
{hover_actions?} (RustaceanHoverActionsOpts) Options for hover actions
{code_actions?} (RustaceanCodeActionOpts) Options for code actions
{float_win_config?} (FloatWinConfig) Options applied to floating windows. See |api-win_config|.
{create_graph?} (RustaceanCrateGraphConfig) Options for showing the crate graph based on graphviz and the dot
{open_url?} (fun(url:string):nil) If set, overrides how to open URLs
{rustc?} (RustcOpts) Options for `rustc`
RustaceanExecutor *RustaceanExecutor*
Fields: ~
{execute_command} (fun(cmd:string,args:string[],cwd:string|nil,opts?:RustaceanExecutorOpts))
RustaceanExecutorOpts *RustaceanExecutorOpts*
Fields: ~
{bufnr?} (integer) The buffer from which the executor was invoked.
FloatWinConfig *FloatWinConfig*
Fields: ~
{auto_focus?} (boolean)
{open_split?} ("horizontal"|"vertical")
See: ~
|vim.lsp.util.open_floating_preview.Opts|
|vim.api.nvim_open_win|
executor_alias *executor_alias*
Type: ~
"termopen"|"quickfix"|"toggleterm"|"vimux"|"neotest"
test_executor_alias *test_executor_alias*
Type: ~
executor_alias|"background"
RustaceanHoverActionsOpts *RustaceanHoverActionsOpts*
Fields: ~
{replace_builtin_hover?} (boolean) Whether to replace Neovim's built-in `vim.lsp.buf.hover` with hover actions. Default: `true`
RustaceanCodeActionOpts *RustaceanCodeActionOpts*
Fields: ~
{group_icon?} (string) Text appended to a group action
{ui_select_fallback?} (boolean) Whether to fall back to `vim.ui.select` if there are no grouped code actions. Default: `false`
lsp_server_health_status *lsp_server_health_status*
Type: ~
"ok"|"warning"|"error"
RustAnalyzerInitializedStatus *RustAnalyzerInitializedStatus*
Fields: ~
{health} (lsp_server_health_status)
RustaceanCrateGraphConfig *RustaceanCrateGraphConfig*
Fields: ~
{backend?} (string) Backend used for displaying the graph. See: https://graphviz.org/docs/outputs/ Defaults to `"x11"` if unset.
{output?} (string) Where to store the output. No output if unset. Relative path from `cwd`.
{enabled_graphviz_backends?} (string[]) Override the enabled graphviz backends list, used for input validation and autocompletion.
{pipe?} (string) Overide the pipe symbol in the shell command. Useful if using a shell that is not supported by this plugin.
RustcOpts *RustcOpts*
Fields: ~
{edition} (string) The edition to use. See https://rustc-dev-guide.rust-lang.org/guides/editions.html. Default '2021'.
RustaceanLspClientOpts *RustaceanLspClientOpts*
Fields: ~
{auto_attach?} (boolean|fun(bufnr:integer):boolean) Whether to automatically attach the LSP client. Defaults to `true` if the `rust-analyzer` executable is found.
{cmd?} (string[]|fun():string[]) Command and arguments for starting rust-analyzer
{root_dir?} (string|fun(filename:string,default:fun(filename:string):string|nil):string|nil) The directory to use for the attached LSP. Can be a function, which may return nil if no server should attach. The second argument contains the default implementation, which can be used for fallback behavior.
{settings?} (table|fun(project_root:string|nil,default_settings:table):table) Setting passed to rust-analyzer. Defaults to a function that looks for a `rust-analyzer.json` file or returns an empty table. See https://rust-analyzer.github.io/manual.html#configuration.
{standalone?} (boolean) Standalone file support (enabled by default). Disabling it may improve rust-analyzer's startup time.
{logfile?} (string) The path to the rust-analyzer log file.
{load_vscode_settings?} (boolean) Whether to search (upward from the buffer) for rust-analyzer settings in .vscode/settings json. If found, loaded settings will override configured options. Default: false
RustaceanDapOpts *RustaceanDapOpts*
Fields: ~
{adapter?} (DapExecutableConfig|DapServerConfig|disable|fun():DapExecutableConfig|DapServerConfig|disable) @field autoload_configurations boolean Whether to autoload nvim-dap configurations when rust-analyzer has attached? Default: `true`.
disable *disable*
Type: ~
false
DapCommand *DapCommand*
Type: ~
string
DapExecutableConfig *DapExecutableConfig*
Fields: ~
{type} (dap_adapter_type_executable) The type of debug adapter.
{command} (string) Default: `"lldb-vscode"`.
{args?} (string) Default: unset.
{name?} (string) Default: `"lldb"`.
DapServerConfig *DapServerConfig*
Fields: ~
{type} (dap_adapter_type_server) The type of debug adapter.
{host?} (string) The host to connect to.
{port} (string) The port to connect to.
{executable} (DapExecutable) The executable to run
{name?} (string)
DapExecutable *DapExecutable*
Fields: ~
{command} (string) The executable.
{args} (string[]) Its arguments.
dap_adapter_type_executable *dap_adapter_type_executable*
Type: ~
dap_adapter_type_server *dap_adapter_type_server*
Type: ~
DapClientConfig : Configuration *DapClientConfig*
Fields: ~
{type} (string) The dap adapter to use
{name} (string)
{request} (dap_config_request_launch|dap_config_request_attach|dap_config_request_custom) The type of dap session
{cwd?} (string) Current working directory
{program?} (string) Path to executable for most DAP clients
{args?} (string[]) Optional args to DAP client, not valid for all client types
{env?} (EnvironmentMap) Environmental variables
{initCommands?} (string[]) Initial commands to run, `lldb` clients only
{coreConfigs?} (table) Essential config values for `probe-rs` client, see https://probe.rs/docs/tools/debugger/
EnvironmentMap *EnvironmentMap*
Type: ~
table<string,string[]>
dap_config_request_launch *dap_config_request_launch*
Type: ~
dap_config_request_attach *dap_config_request_attach*
Type: ~
dap_config_request_custom *dap_config_request_custom*
Type: ~
*M.get_codelldb_adapter*
M.get_codelldb_adapter({codelldb_path}, {liblldb_path})
For the heroes who want to use it.
Parameters: ~
{codelldb_path} (string) Path to the codelldb executable
{liblldb_path} (string) Path to the liblldb dynamic library
Returns: ~
(DapServerConfig)
==============================================================================
LSP configuration utility *rustaceanvim.config.server*
LoadRASettingsOpts *LoadRASettingsOpts*
Fields: ~
{settings_file_pattern} (string|nil) File name or pattern to search for. Defaults to 'rust-analyzer.json'
{default_settings} (table|nil) Default settings to merge the loaded settings into
*server.load_rust_analyzer_settings*
server.load_rust_analyzer_settings({project_root}, {opts})
Load rust-analyzer settings from a JSON file,
falling back to the default settings if none is found or if it cannot be decoded.
Parameters: ~
{project_root} (string|nil) The project root
{opts} (LoadRASettingsOpts|nil)
Returns: ~
(table) server_settings
See: ~
|https://rust-analyzer.github.io/manual.html#configuration|
server.create_client_capabilities() *server.create_client_capabilities*
Returns: ~
(lsp.ClientCapabilities)
==============================================================================
*rustaceanvim.neotest*
A |neotest| adapter for rust, powered by rustaceanvim.
If you add this to neotest:
>
require('neotest').setup {
-- ...,
adapters = {
-- ...,
require('rustaceanvim.neotest')
},
}
<
this plugin will configure itself to use |neotest|
as a test executor, and |neotest| will use rust-analyzer
for test discovery and command construction.
Note: If you use this adapter, do not add the neotest-rust adapter
(another plugin).
vim:tw=78:ts=8:noet:ft=help:norl:

View File

@ -1,57 +0,0 @@
---@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 auto_attach = config.server.auto_attach
if type(auto_attach) == 'function' then
local bufnr = vim.api.nvim_get_current_buf()
auto_attach = auto_attach(bufnr)
end
if auto_attach then
require('rustaceanvim.lsp').start()
end

View File

@ -1,26 +0,0 @@
" 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

@ -1,24 +0,0 @@
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

View File

@ -1,78 +0,0 @@
rock_manifest = {
doc = {
["mason.txt"] = "858adffa88b1649b91187f49f191e376",
["rustaceanvim.txt"] = "a9fa5fd997f2e2c099d2bf715cf4d5e9"
},
ftplugin = {
["rust.lua"] = "b225026e3590a6741373922fbae423e5",
["rust.vim"] = "3121ffa3b7f1aa9c3efbfe32e438dbeb",
["toml.lua"] = "a8807dcfb5f6687ac543f4f8da3a9554"
},
lua = {
rustaceanvim = {
["cached_commands.lua"] = "6e23c8231f44a3edc76be54766fca334",
["cargo.lua"] = "43ba56ed4ba112dd22cac598e7b248df",
commands = {
["code_action_group.lua"] = "55bf0c83a007e5d64924eafe2e2a96eb",
["crate_graph.lua"] = "30d01abc92dff63ace83a5d1697d2073",
["debuggables.lua"] = "6548c5c600f14c9dc3d10e87983f6fb4",
["diagnostic.lua"] = "55160b50ac49bcab96e15176fc5c7dde",
["expand_macro.lua"] = "0a5991437c93aa39ace91d31dfd5d041",
["external_docs.lua"] = "1d2fa5d88ea197ad9976c23b0ff70763",
["fly_check.lua"] = "3f7b89700bd8f98fd5ab0ec02cce1cdd",
["hover_range.lua"] = "68828cfd0c465bbe0915996795ff7b92",
["init.lua"] = "6d7415da1c6e12b7b7914ab4e0339fae",
["join_lines.lua"] = "f31a68f1ddac01b926d58ccd249bc03d",
["move_item.lua"] = "f05118ba148e66c1e92882141e68343f",
["open_cargo_toml.lua"] = "2368251db4ce52659693acc8eee15b74",
["parent_module.lua"] = "c274b7357e35825f75802dc96e609992",
["rebuild_proc_macros.lua"] = "6113336c3b82042f60c54446e6c5a887",
["rustc_unpretty.lua"] = "fafde14d3d482667cecce2981444cad2",
["ssr.lua"] = "1c936709630f09b2a81d22452d3e3fa2",
["syntax_tree.lua"] = "c28fd8b22608e3f7bd3bdbb2e10c1617",
["view_ir.lua"] = "12eadc00a2ca1005bcbeda4fa8fc80a0",
["workspace_refresh.lua"] = "083b2d70533d0f417b65d2b7866f531b",
["workspace_symbol.lua"] = "69bdc6d1255f7eb586ea8e350b840b85"
},
["compat.lua"] = "fedaef1aeaceaf086116ed62b423d0a3",
config = {
["check.lua"] = "55ddc99999546e6951cd2641cc997af2",
["init.lua"] = "a583a64ac0023a551c16a92f61ff063d",
["internal.lua"] = "854115363fcfc13e65098150b873a8ff",
["json.lua"] = "a8c7caf443ad9ce1193726aec053cc8d",
["server.lua"] = "d642a65f31cb4f12b812840c1171821f"
},
["dap.lua"] = "757ecf822f6c30ebf9e462f7009ce99a",
executors = {
["background.lua"] = "ae1c76a5c2f73e9c58456f580b7552b7",
["init.lua"] = "a443891fc3b974db6787502179d85c19",
["meta.lua"] = "99cae6c6b77725710ec2fc7d86bff665",
["neotest.lua"] = "64a17e71f15a1741f0e7f835472f26e3",
["quickfix.lua"] = "b1ea55a261b8623e73c2fd6aed278fd3",
["termopen.lua"] = "4a225919ab4e1ad67fc591a9947d86e9",
["toggleterm.lua"] = "221616f53cc50124694fcc1b0f1c92a2",
["vimux.lua"] = "24d3f692083ca86f0926e7aa4722c0fe"
},
["health.lua"] = "126952700269c9ab976f29f59604c5da",
["hover_actions.lua"] = "d0842822fa99c55b4cc5a65eae968ff2",
["init.lua"] = "a48de2e7e937208adc6781a5ea35ec88",
["lsp.lua"] = "c36e5b79bb7fb41a9781d70421f7a55c",
neotest = {
["init.lua"] = "ec54c5df5002742877ec6c925b273b2d",
["trans.lua"] = "1f79320bca0c81d91673543dd7ad4984"
},
["os.lua"] = "4c8caca1afb6a8e7862300b4dcc29f09",
["overrides.lua"] = "177b171bfb8c16c19326d6402b94a535",
["runnables.lua"] = "d458cb318b2cd900e178930d3b14f224",
["rust_analyzer.lua"] = "aa3bce32849886001dc2cb38a4ff951e",
["server_status.lua"] = "25017ef9b15fadd713574c897e242970",
["shell.lua"] = "561e4be6d5ba43f93a00ad5e6169e0eb",
["test.lua"] = "e436ae539217729f46a1d556974e1100",
types = {
["internal.lua"] = "95d9ff5763390a3efae83cc27dbef452"
},
["ui.lua"] = "185cbb4ef9b15b4feb6699fcbd5d4435"
}
},
["rustaceanvim-4.22.8-1.rockspec"] = "1d483e8dffa0275323da043a1e8c9cf3"
}

View File

@ -1,40 +0,0 @@
local git_ref = '4.22.8'
local modrev = '4.22.8'
local specrev = '1'
local repo_url = 'https://github.com/mrcjkb/rustaceanvim'
rockspec_format = '3.0'
package = 'rustaceanvim'
version = modrev ..'-'.. specrev
description = {
summary = 'Supercharge your Rust experience in Neovim! A heavily modified fork of rust-tools.nvim',
detailed = [[
This plugin automatically configures the rust-analyzer builtin LSP client
and integrates with other Rust tools. See the README's #features section
for more info.]],
labels = { 'dap', 'debug-adapter-protocol', 'language-server-protocol', 'lsp', 'neovim', 'nvim', 'plugin', 'rust', 'rust-analyzer', 'rust-lang', 'rust-tools' } ,
homepage = 'https://github.com/mrcjkb/rustaceanvim',
license = 'GPL-2.0'
}
dependencies = { 'lua >= 5.1' }
test_dependencies = { }
source = {
url = repo_url .. '/archive/' .. git_ref .. '.zip',
dir = 'rustaceanvim-' .. '4.22.8',
}
if modrev == 'scm' or modrev == 'dev' then
source = {
url = repo_url:gsub('https', 'git')
}
end
build = {
type = 'builtin',
copy_directories = { 'doc', 'ftplugin' } ,
}

View File

@ -1,40 +0,0 @@
local git_ref = '4.22.8'
local modrev = '4.22.8'
local specrev = '1'
local repo_url = 'https://github.com/mrcjkb/rustaceanvim'
rockspec_format = '3.0'
package = 'rustaceanvim'
version = modrev ..'-'.. specrev
description = {
summary = 'Supercharge your Rust experience in Neovim! A heavily modified fork of rust-tools.nvim',
detailed = [[
This plugin automatically configures the rust-analyzer builtin LSP client
and integrates with other Rust tools. See the README's #features section
for more info.]],
labels = { 'dap', 'debug-adapter-protocol', 'language-server-protocol', 'lsp', 'neovim', 'nvim', 'plugin', 'rust', 'rust-analyzer', 'rust-lang', 'rust-tools' } ,
homepage = 'https://github.com/mrcjkb/rustaceanvim',
license = 'GPL-2.0'
}
dependencies = { 'lua >= 5.1' }
test_dependencies = { }
source = {
url = repo_url .. '/archive/' .. git_ref .. '.zip',
dir = 'rustaceanvim-' .. '4.22.8',
}
if modrev == 'scm' or modrev == 'dev' then
source = {
url = repo_url:gsub('https', 'git')
}
end
build = {
type = 'builtin',
copy_directories = { 'doc', 'ftplugin' } ,
}