Skip to content
This repository was archived by the owner on Jan 3, 2024. It is now read-only.
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions lua/rust-tools/inlay_hints.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ local M = {}

function M.new()
M.namespace = vim.api.nvim_create_namespace("textDocument/inlayHints")
local self = setmetatable({ cache = {}, enabled = false }, { __index = M })
local self = setmetatable({ cache = {} }, { __index = M })

return self
end
Expand All @@ -17,6 +17,7 @@ end
-- Disable hints and clear all cached buffers
function M.disable(self)
self.disable = false
M.is_enabled = false
M.disable_cache_autocmd()

for k, _ in pairs(self.cache) do
Expand All @@ -34,11 +35,22 @@ end

-- Enable auto hints and set hints for the current buffer
function M.enable(self)
self.enabled = true
self.enable = false
M.is_enabled = true
M.enable_cache_autocmd()
set_all(self)
end

-- Toggles inlay hints state globally. Uses disable and enable internally
function M.toggle(self)
if self.is_enabled then
M.disabled(self)
else
M.enable(self)
end
M.is_enabled = not M.is_enabled
end

-- Set inlay hints only for the current buffer
function M.set(self)
M.cache_render(self, 0)
Expand Down