Skip to content

Commit

Permalink
feat: add rebuildProcMacros command
Browse files Browse the repository at this point in the history
  • Loading branch information
mrcjkb committed Oct 28, 2023
1 parent d3a6e90 commit 37cd559
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ 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]
### Added
- `:RustLsp rebuildProcMacros` command.

## [3.0.4] - 2023-10-25
### Fixed
- Allow `:RustLsp hover range` to accept a range.
Expand Down
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,20 @@ for more configuration options.
![](https://github.com/mrcjkb/rustaceanvim/assets/12857160/477d9e58-74b0-42ff-87ca-2fef34d06db3)
</details>

<details>
<summary>
<b>Rebuild proc macros</b>
</summary>

```vimscript
:RustLsp rebuildProcMacros
```
```lua
vim.cmd.RustLsp('rebuildProcMacros')
```

</details>

<details>
<summary>
<b>Move Item Up/Down</b>
Expand Down
3 changes: 3 additions & 0 deletions lua/rustaceanvim/commands/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ local command_tbl = {
expandMacro = function(_)
require('rustaceanvim.commands.expand_macro')()
end,
rebuildProcMacros = function()
require('rustaceanvim.commands.rebuild_proc_macros')()
end,
externalDocs = function(_)
require('rustaceanvim.commands.external_docs')()
end,
Expand Down
18 changes: 18 additions & 0 deletions lua/rustaceanvim/commands/rebuild_proc_macros.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
local M = {}

---@param err string | nil
local function handler(err, _, _)
if err then
vim.notify('Error rebuilding proc macros: ' .. err)
return
end
end

local rl = require('rustaceanvim.rust_analyzer')

--- Sends the request to rust-analyzer rebuild proc macros
function M.rebuild_macros()
rl.buf_request(0, 'rust-analyzer/rebuildProcMacros', nil, handler)
end

return M.rebuild_macros

0 comments on commit 37cd559

Please sign in to comment.