Skip to content

Commit

Permalink
feat(keymap.helpers): add helpers to toggle inlay hints and virtual text
Browse files Browse the repository at this point in the history
Signed-off-by: Jint-lzxy <[email protected]>
  • Loading branch information
Jint-lzxy committed Feb 15, 2025
1 parent 9fe5fb1 commit cb17c3e
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/lint_code.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ jobs:
- uses: actions/checkout@v4
- uses: lunarmodules/luacheck@v1
with:
args: . --std luajit --globals vim _debugging _buf_vtext _command_panel _flash_esc_or_noh _toggle_lazygit --max-line-length 150 --no-config
args: . --std luajit --globals vim _debugging _command_panel _flash_esc_or_noh _toggle_inlayhint _toggle_virtualtext _toggle_lazygit --max-line-length 150 --no-config
24 changes: 24 additions & 0 deletions lua/keymap/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,30 @@ _G._flash_esc_or_noh = function()
end
end

_G._toggle_inlayhint = function()
local is_enabled = vim.lsp.inlay_hint.is_enabled()

vim.lsp.inlay_hint.enable(not is_enabled)
vim.notify(
(is_enabled and "Inlay hint disabled successfully" or "Inlay hint enabled successfully"),
vim.log.levels.INFO,
{ title = "LSP Inlay Hint" }
)
end

local _vt_enabled = require("core.settings").diagnostics_virtual_text
_G._toggle_virtualtext = function()
if vim.diagnostic.is_enabled() then
_vt_enabled = not _vt_enabled
vim.diagnostic[_vt_enabled and "show" or "hide"]()
vim.notify(
(_vt_enabled and "Virtual text is now displayed" or "Virtual text is now hidden"),
vim.log.levels.INFO,
{ title = "LSP Diagnostic" }
)
end
end

local lazygit = nil
_G._toggle_lazygit = function()
if not lazygit then
Expand Down

0 comments on commit cb17c3e

Please sign in to comment.