File tree Expand file tree Collapse file tree 4 files changed +20
-1
lines changed
Expand file tree Collapse file tree 4 files changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -73,6 +73,7 @@ rt.setup({
7373 -- Commands:
7474 -- RustEnableInlayHints
7575 -- RustDisableInlayHints
76+ -- RustToggleInlayHints
7677 -- RustSetInlayHints
7778 -- RustUnsetInlayHints
7879
@@ -85,6 +86,8 @@ rt.setup({
8586 require (' rust-tools' ).inlay_hints .enable ()
8687 -- Disable inlay hints auto update and unset them for all buffers
8788 require (' rust-tools' ).inlay_hints .disable ()
89+ -- Toggle between enabled and disabled inlay hints states for all buffer
90+ require (' rust-tools' ).inlay_hints .toggle ()
8891 ```
8992</details >
9093
Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ local M = {
1111 inlay_hints = {
1212 enable = nil ,
1313 disable = nil ,
14+ toggle = nil ,
1415 set = nil ,
1516 unset = nil ,
1617 cache = nil ,
@@ -85,6 +86,9 @@ function M.setup(opts)
8586 render = function ()
8687 inlay .render (hints )
8788 end ,
89+ toggle = function ()
90+ inlay .toggle (hints )
91+ end ,
8892 }
8993
9094 local join_lines = require (" rust-tools.join_lines" )
Original file line number Diff line number Diff line change 1616
1717-- Disable hints and clear all cached buffers
1818function M .disable (self )
19- self .disable = false
19+ self .enabled = false
2020 M .disable_cache_autocmd ()
2121
2222 for k , _ in pairs (self .cache ) do
@@ -44,6 +44,15 @@ function M.set(self)
4444 M .cache_render (self , 0 )
4545end
4646
47+ -- Toggles inlay hints state globally. Uses disable and enable internally
48+ function M .toggle (self )
49+ if self .enabled then
50+ M .disable (self )
51+ else
52+ M .enable (self )
53+ end
54+ end
55+
4756-- Clear hints only for the current buffer
4857function M .unset ()
4958 clear_ns (0 )
Original file line number Diff line number Diff line change @@ -55,6 +55,9 @@ local function setup_commands()
5555 RustDisableInlayHints = {
5656 rt .inlay_hints .disable ,
5757 },
58+ RustToggleInlayHints = {
59+ rt .inlay_hints .toggle ,
60+ },
5861 RustLastDebug = {
5962 rt .cached_commands .execute_last_debuggable ,
6063 },
You can’t perform that action at this time.
0 commit comments