From 7f22411b1f4a541488268191127de4ce4803bc0f Mon Sep 17 00:00:00 2001 From: ray-x Date: Thu, 17 Mar 2022 03:03:49 +1100 Subject: [PATCH] issue #156 Can't disable virutal text --- lua/navigator.lua | 4 ++-- lua/navigator/diagnostics.lua | 13 +++++-------- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/lua/navigator.lua b/lua/navigator.lua index a9302d9..0ab2bdb 100755 --- a/lua/navigator.lua +++ b/lua/navigator.lua @@ -33,7 +33,7 @@ _NgConfigValues = { transparency = 50, -- 0 ~ 100 blur the main window, 100: fully transparent, 0: opaque, set to nil to disable it lsp_signature_help = true, -- if you would like to hook ray-x/lsp_signature plugin in navigator -- setup here. if it is nil, navigator will not init signature help - signature_help_cfg = {debug=false}, -- if you would like to init ray-x/lsp_signature plugin in navigator, pass in signature help + signature_help_cfg = { debug = false }, -- if you would like to init ray-x/lsp_signature plugin in navigator, pass in signature help lsp = { code_action = { enable = true, @@ -51,7 +51,7 @@ _NgConfigValues = { }, diagnostic = { underline = true, - virtual_text = { spacing = 3 }, -- show virtual for diagnostic message + virtual_text = { spacing = 3, source = true }, -- show virtual for diagnostic message update_in_insert = false, -- update diagnostic message in insert mode severity_sort = { reverse = true }, }, diff --git a/lua/navigator/diagnostics.lua b/lua/navigator/diagnostics.lua index e40c158..13c2e35 100644 --- a/lua/navigator/diagnostics.lua +++ b/lua/navigator/diagnostics.lua @@ -36,11 +36,7 @@ end local diagnostic_cfg = { -- Enable underline, use default values underline = _NgConfigValues.lsp.diagnostic.underline, - -- Enable virtual text, override spacing to 3 (prevent overlap) - virtual_text = { - spacing = _NgConfigValues.lsp.diagnostic.virtual_text.spacing, - prefix = _NgConfigValues.icons.diagnostic_virtual_text, - }, + -- Enable virtual -- Use a function to dynamically turn signs off -- and on, using buffer local variables signs = true, @@ -327,10 +323,11 @@ local diag_hdlr_async = function() end local M = {} -if _NgConfigValues.lsp.diagnostic.virtual_text == false then - diagnostic_cfg.virtual_text = false -end +diagnostic_cfg.virtual_text = _NgConfigValues.lsp.diagnostic.virtual_text +if type(_NgConfigValues.lsp.diagnostic.virtual_text) == 'table' then + diagnostic_cfg.virtual_text.prefix = _NgConfigValues.icons.diagnostic_virtual_text +end -- vim.lsp.handlers["textDocument/publishDiagnostics"] M.diagnostic_handler = vim.lsp.with(diag_hdlr, diagnostic_cfg)