Move inlay_hint toggle in Util.toggle

This commit is contained in:
Gary Murray 2023-11-16 11:32:56 -07:00
parent fe28ebb855
commit 26c09bbb39
3 changed files with 12 additions and 12 deletions

View file

@ -120,7 +120,7 @@ map("n", "<leader>ud", function() Util.toggle.diagnostics() end, { desc = "Toggl
local conceallevel = vim.o.conceallevel > 0 and vim.o.conceallevel or 3
map("n", "<leader>uc", function() Util.toggle("conceallevel", false, {0, conceallevel}) end, { desc = "Toggle Conceal" })
if vim.lsp.buf.inlay_hint or vim.lsp.inlay_hint then
map( "n", "<leader>uh", function() Util.lsp.toggle_inline_hint() end, { desc = "Toggle Inlay Hints" })
map( "n", "<leader>uh", function() Util.toggle.inlay_hints() end, { desc = "Toggle Inlay Hints" })
end
map("n", "<leader>uT", function() if vim.b.ts_highlight then vim.treesitter.stop() else vim.treesitter.start() end end, { desc = "Toggle Treesitter Highlight" })

View file

@ -122,15 +122,4 @@ function M.format(opts)
end
end
---@param bufnr? number
function M.toggle_inline_hint(bufnr)
bufnr = bufnr or 0
local inlay_hint = vim.lsp.buf.inlay_hint or vim.lsp.inlay_hint
if inlay_hint.enable then
vim.lsp.inlay_hint.enable(bufnr, not inlay_hint.is_enabled())
else
vim.lsp.inlay_hint(bufnr, nil)
end
end
return M

View file

@ -53,6 +53,17 @@ function M.diagnostics()
end
end
---@param bufnr? number
function M.inlay_hints(bufnr)
bufnr = bufnr or 0
local inlay_hint = vim.lsp.buf.inlay_hint or vim.lsp.inlay_hint
if inlay_hint.enable then
vim.lsp.inlay_hint.enable(bufnr, not inlay_hint.is_enabled())
else
vim.lsp.inlay_hint(bufnr, nil)
end
end
setmetatable(M, {
__call = function(m, ...)
return m.option(...)