From 927f6bc4efaa6d2812e26b10fc6d3a23b237ef70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9ana=20=E6=B1=9F?= Date: Thu, 3 Jul 2025 19:56:18 +0200 Subject: [PATCH] nvim: disable inlay hint request for cabal --- .config/nvim/after/plugin/lsp.lua | 41 ++++++++++++++++++------------- 1 file changed, 24 insertions(+), 17 deletions(-) diff --git a/.config/nvim/after/plugin/lsp.lua b/.config/nvim/after/plugin/lsp.lua index d381e8c4..80b9b922 100644 --- a/.config/nvim/after/plugin/lsp.lua +++ b/.config/nvim/after/plugin/lsp.lua @@ -1,4 +1,5 @@ local map = vim.keymap.set +local methods = vim.lsp.protocol.Methods ---------------------- -- Language servers -- @@ -75,22 +76,31 @@ local servers = { ------------- -- Helpers -- ------------- -local on_attach = function(client, bufno) - vim.api.nvim_set_option_value("omnifunc", "v:lua.vim.lsp.omnifunc", { buf = bufno }) - local ts = require("telescope.builtin") - local opts = { buffer = bufno } +local on_attach = function(client, bufnr) + vim.api.nvim_set_option_value("omnifunc", "v:lua.vim.lsp.omnifunc", { buf = bufnr }) + local telescope = require("telescope.builtin") - map("n", "K", vim.lsp.buf.hover, opts) - map("n", "", vim.lsp.buf.signature_help, opts) - map("n", "gd", vim.lsp.buf.definition, opts) + map("n", "K", vim.lsp.buf.hover, { buffer = bufnr }) + map("n", "", vim.lsp.buf.signature_help, { buffer = bufnr }) + map("n", "gd", vim.lsp.buf.definition, { buffer = bufnr }) -- conflicts with tabs - -- map("n", "gtd", vim.lsp.buf.type_definition, opts) - map("n", "gi", vim.lsp.buf.implementation, opts) - map("n", "gu", ts.lsp_references, opts) - map("n", "ca", vim.lsp.buf.code_action, opts) - map("n", "cl", vim.lsp.codelens.run, opts) - map("n", "r", vim.lsp.buf.rename, opts) - map("n", "f", function() vim.lsp.buf.format { async = true } end, opts) + -- map("n", "gtd", vim.lsp.buf.type_definition, { buffer = bufnr }) + map("n", "gi", vim.lsp.buf.implementation, { buffer = bufnr }) + map("n", "gu", telescope.lsp_references, { buffer = bufnr }) + map("n", "ca", vim.lsp.buf.code_action, { buffer = bufnr }) + map("n", "cl", vim.lsp.codelens.run, { buffer = bufnr }) + map("n", "r", vim.lsp.buf.rename, { buffer = bufnr }) + map("n", "f", function() vim.lsp.buf.format { async = true } end, { buffer = bufnr }) + + 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" + then + vim.lsp.inlay_hint.enable(true, { bufnr = bufnr }) + end end -- Helix style border @@ -117,9 +127,6 @@ vim.diagnostic.config { virtual_text = false, severity_sort = true } -- Set log level vim.lsp.set_log_level("off") --- Enable inlay hints -vim.lsp.inlay_hint.enable() - -- Gutter symbols setup vim.fn.sign_define("DiagnosticSignError", { text = "E", texthl = "DiagnosticSignError", numhl = "DiagnosticSignError" }) vim.fn.sign_define("DiagnosticSignWarn", { text = "W", texthl = "DiagnosticSignWarn", numhl = "DiagnosticSignWarn" })