From 0584a5cd064fbb4f1b4509c0c1716f75035044ab Mon Sep 17 00:00:00 2001 From: ray-x Date: Tue, 17 Aug 2021 08:32:17 +1000 Subject: [PATCH] feature: diagnostic sign in scroll bar area enable by default --- README.md | 3 ++- lua/navigator.lua | 2 +- lua/navigator/diagnostics.lua | 15 ++++++++------- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 070c02a..9f65602 100644 --- a/README.md +++ b/README.md @@ -216,7 +216,8 @@ require'navigator'.setup({ lsp = { format_on_save = true, -- set to false to disasble lsp code format on save (if you are using prettier/efm/formater etc) - diag_scroll_bar_sign = nil, -- experimental: set to {'╍', 'ﮆ'} to enable diagnostic status in scroll bar area + diag_scroll_bar_sign = {'▃', '█'}, -- experimental: diagnostic status in scroll bar area; set to nil to disable the diagnostic sign, + -- for other style, set to {'╍', 'ﮆ'} or {'-', '='} disply_diagnostic_qf = true, -- always show quickfix if there are diagnostic errors, set to false if you want to ignore it diff --git a/lua/navigator.lua b/lua/navigator.lua index 49cfeec..af96886 100644 --- a/lua/navigator.lua +++ b/lua/navigator.lua @@ -19,7 +19,7 @@ _NgConfigValues = { lsp = { format_on_save = true, -- set to false to disasble lsp code format on save (if you are using prettier/efm/formater etc) disply_diagnostic_qf = true, -- always show quickfix if there are diagnostic errors - diag_scroll_bar_sign = nil, -- set to {'╍', 'ﮆ'} to enable diagnostic status in scroll bar area + diag_scroll_bar_sign = {'▃', '█'}, -- set to nil to disable, set to {'╍', 'ﮆ'} to enable diagnostic status in scroll bar area tsserver = { -- filetypes = {'typescript'} -- disable javascript etc, -- set to {} to disable the lspclient for all filetype diff --git a/lua/navigator/diagnostics.lua b/lua/navigator/diagnostics.lua index 200ca2d..31e3e65 100644 --- a/lua/navigator/diagnostics.lua +++ b/lua/navigator/diagnostics.lua @@ -24,7 +24,7 @@ local function error_marker(result, client_id) return end - log(result, bufnr) + trace(result, bufnr) if result == nil or result.diagnostics == nil or #result.diagnostics == 0 then local diag_cnt = vim.lsp.diagnostic.get_count(bufnr, [[Error]]) @@ -35,19 +35,20 @@ local function error_marker(result, client_id) return end - if _NG_VT_NS == nil then - _NG_VT_NS = vim.api.nvim_create_namespace("navigator_lua") - end - - vim.api.nvim_buf_clear_namespace(0, _NG_VT_NS, 0, -1) - -- total line num of current buffer local winid = vim.fn.win_getid(vim.fn.winnr()) local total_num = vim.fn.getbufinfo(vim.fn.winbufnr(winid))[1].linecount -- window size of current buffer local wwidth = vim.fn.winwidth(winid) local wheight = vim.fn.winheight(winid) + if total_num <= wheight then + return + end + if _NG_VT_NS == nil then + _NG_VT_NS = vim.api.nvim_create_namespace("navigator_lua") + end + vim.api.nvim_buf_clear_namespace(0, _NG_VT_NS, 0, -1) if total_num <= wheight then first_line = 0 end