Skip to content

Commit

Permalink
feat(recipes): add recipe for toggling inlay hints when entering/leav…
Browse files Browse the repository at this point in the history
…ing insert mode
  • Loading branch information
mehalter committed May 3, 2024
1 parent 804a1af commit a9535b9
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# AstroLSP - Disable inlay hints in insert mode

**Website:** <https://docs.astronvim.com/recipes/advanced_lsp/#inlay-hints>

This plugin specification configures AstroLSP to disable inlay hints in a buffer when going into insert mode and re-enables them when leaving insert mode.
33 changes: 33 additions & 0 deletions lua/astrocommunity/recipes/astrolsp-no-insert-inlay-hints/init.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
return {
"AstroNvim/astrolsp",
---@type AstroLSPOpts
opts = {
autocmds = {
no_insert_inlay_hints = {
-- only create for language servers that support inlay hints
-- (and only if vim.lsp.inlay_hint is available)
cond = vim.lsp.inlay_hint and "textDocument/inlayHint" or false,
{
-- when going into insert mode
event = "InsertEnter",
desc = "disable inlay hints on insert",
callback = function(args)
local filter = { bufnr = args.buf }
-- if the inlay hints are currently enabled
if vim.lsp.inlay_hint.is_enabled(filter) then
-- disable the inlay hints
vim.lsp.inlay_hint.enable(false, filter)
-- create a single use autocommand to turn the inlay hints back on
-- when leaving insert mode
vim.api.nvim_create_autocmd("InsertLeave", {
buffer = args.buf,
once = true,
callback = function() vim.lsp.inlay_hint.enable(true, filter) end,
})
end
end,
},
},
},
},
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# heirline.nvim clock statusline

**Website:** <https://docs.astronvim.com/Recipes/status#default-statusline-with-clock>
**Website:** <https://docs.astronvim.com/recipes/status#default-statusline-with-clock>

This plugin specification configures the `statusline` in AstroNvim to show a clock in the right hand side mode indicator.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# heirline.nvim mode text statusline

**Website:** <https://docs.astronvim.com/Recipes/status#default-statusline-with-mode-text>
**Website:** <https://docs.astronvim.com/recipes/status#default-statusline-with-mode-text>

This plugin specification configures the `statusline` in AstroNvim to show the mode text

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# heirline.nvim NvChad statusline

**Website:** <https://docs.astronvim.com/Recipes/status#replicate-nvchad-statusline>
**Website:** <https://docs.astronvim.com/recipes/status#replicate-nvchad-statusline>

This plugin specification configures the `statusline` in AstroNvim to emulate the NvChad statusline
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# heirline.nvim vscode style winbar

**Website:** <https://docs.astronvim.com/Recipes/status#replicate-visual-studio-code-winbar>
**Website:** <https://docs.astronvim.com/recipes/status#replicate-visual-studio-code-winbar>

This plugin specification configures the `winbar` in AstroNvim to look more like VS Code's

Expand Down

0 comments on commit a9535b9

Please sign in to comment.