Skip to content

Commit f745207

Browse files
author
Marc Jakobi
committed
feat: completions for :RustLsp subcommands' arguments
1 parent 07dd5d9 commit f745207

File tree

2 files changed

+22
-6
lines changed

2 files changed

+22
-6
lines changed

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,19 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [Unreleased]
9+
10+
### Added
11+
- Completions for `:RustLsp` subcommands' arguments.
12+
813
## [3.1.1] - 2023-10-28
14+
915
### Fixed
1016
- Remove accidental use of Neovim nightly API (`dap`, `crateGraph`, `explainError`) [[#26](https://github.com/mrcjkb/rustaceanvim/issues/26)].
1117
- Add static type checking for Neovim stable API.
1218

1319
## [3.1.0] - 2023-10-28
20+
1421
### Added
1522
- `:RustLsp explainError` command, uses `rustc --explain` on error diagnostics with
1623
an error code.
@@ -20,11 +27,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2027
- Health check got stuck if `lldb-vscode` was installed.
2128

2229
## [3.0.4] - 2023-10-25
30+
2331
### Fixed
2432
- Allow `:RustLsp hover range` to accept a range.
2533
- Fix `:RustLsp crateGraph` passing arguments as list.
2634

2735
## [3.0.3] - 2023-10-25
36+
2837
### Fixed
2938
- Potential attempt to index `nil` upvalue when sending `workspace/didChangeWorkspaceFolders`
3039
to LSP server [[#22](https://github.com/mrcjkb/rustaceanvim/issues/22)].

lua/rustaceanvim/commands/init.lua

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -125,14 +125,21 @@ function M.create_rust_lsp_command()
125125
desc = 'Interacts with the rust-analyzer LSP client',
126126
complete = function(arg_lead, cmdline, _)
127127
local commands = vim.tbl_keys(command_tbl)
128+
local match_start = '^' .. rust_lsp_cmd_name
128129
-- special case: crateGraph comes with graphviz backend completions
129-
if cmdline:match('^' .. rust_lsp_cmd_name .. ' cr%s+%w*$') then
130-
local backends = config.tools.crate_graph.enabled_graphviz_backends or {}
131-
return vim.tbl_map(function(backend)
132-
return 'crateGraph ' .. backend
133-
end, backends)
130+
if cmdline:match(match_start .. ' debuggables%s+%w*$') or cmdline:match(match_start .. ' runnables%s+%w*$') then
131+
return { 'last' }
134132
end
135-
if cmdline:match('^' .. rust_lsp_cmd_name .. '%s+%w*$') then
133+
if cmdline:match(match_start .. ' hover%s+%w*$') then
134+
return { 'action', 'range' }
135+
end
136+
if cmdline:match(match_start .. ' moveItem%s+%w*$') then
137+
return { 'up', 'down' }
138+
end
139+
if cmdline:match(match_start .. ' crateGraph%s+%w*$') then
140+
return config.tools.crate_graph.enabled_graphviz_backends or {}
141+
end
142+
if cmdline:match(match_start .. '%s+%w*$') then
136143
return vim
137144
.iter(commands)
138145
:filter(function(command)

0 commit comments

Comments
 (0)