From 10c8aa854d9e7a4c30430bdb36213d3a5fde08e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9ana=20=E6=B1=9F?= Date: Sat, 12 Jul 2025 18:38:29 +0200 Subject: [PATCH] nvim/lsp: add an usercommand to toggle inlay hints --- .config/nvim/lua/lsp.lua | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.config/nvim/lua/lsp.lua b/.config/nvim/lua/lsp.lua index d720c41c..749fac1e 100644 --- a/.config/nvim/lua/lsp.lua +++ b/.config/nvim/lua/lsp.lua @@ -28,12 +28,20 @@ M.on_attach = function(client, bufnr) nnoremap("r", vim.lsp.buf.rename, "rename symbol") pcall(nnoremap, "f", function() vim.lsp.buf.format { async = true } end, "format buffer", { unique = true }) + vim.api.nvim_buf_create_user_command( + bufnr, + "LspToggleInlayHints", + function() vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled()) end, + {} + ) local filetype = vim.api.nvim_get_option_value("filetype", { buf = bufnr }) if client:supports_method(methods.textDocument_inlayHint) -- Never start cabal with inlay hint request -- Related: https://github.com/mrcjkb/haskell-tools.nvim/discussions/485 and filetype ~= "cabal" + -- I find it annoying especially with qmk + and filetype ~= "c" then vim.lsp.inlay_hint.enable(true, { bufnr = bufnr }) end