Skip to content

Commit

Permalink
fix(lsp): support completions for RustLsp with selection ranges
Browse files Browse the repository at this point in the history
  • Loading branch information
mrcjkb committed Jun 16, 2024
1 parent 1e7600b commit a1d32cd
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

### Fixed

- LSP: Support completions for `RustLsp` with selection ranges.

## [4.25.0] - 2024-06-16

### Added
Expand Down
6 changes: 3 additions & 3 deletions lua/rustaceanvim/commands/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit a1d32cd

Please sign in to comment.