add diagnostic_virtual_text, #42

pull/47/head
ray-x 3 years ago
parent aef51cc696
commit f5a1fc747b

@ -0,0 +1,36 @@
name: Tests
on: [push, pull_request]
jobs:
appimage-ubuntu:
name: Appimage-ubuntu
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- run: date +%F > todays-date
- name: Restore cache for today's nightly.
uses: actions/cache@v2
with:
path: |
build
key: ${{ runner.os }}-appimage-${{ hashFiles('todays-date') }}
- name: Prepare
run: |
sudo apt install fd-find
test -d build || {
mkdir -p build
wget https://github.com/neovim/neovim/releases/download/nightly/nvim.appimage
chmod +x nvim.appimage
mv nvim.appimage ./build/nvim
}
mkdir -p ~/.local/share/nvim/site/pack/vendor/start
git clone --depth 1 https://github.com/nvim-lua/plenary.nvim ~/.local/share/nvim/site/pack/vendor/start/plenary.nvim
git clone --depth 1 https://github.com/ray-x/guihua.lua ~/.local/share/nvim/site/pack/vendor/start/guihua.lua
git clone --depth 1 https://github.com/kyazdani42/nvim-web-devicons ~/.local/share/nvim/site/pack/vendor/start/nvim-web-devicons
ln -s $(pwd) ~/.local/share/nvim/site/pack/vendor/start
- name: Run tests
run: |
export PATH="${PWD}/build/:${PATH}"
make test

@ -0,0 +1,2 @@
test:
nvim --headless --noplugin -u tests/minimal.vim -c "PlenaryBustedDirectory tests/ {minimal_init = 'tests/minimal.vim'}"

@ -226,9 +226,10 @@ require'navigator'.setup({
disable_format_ft = {"sqls", "sumneko_lua", "gopls"}, -- a list of lsp not enable auto-format (e.g. if you using efm or vim-codeformat etc), empty by default
disable_lsp = {'pylsd', 'sqlls'}, -- a list of lsp server disabled for your project, e.g. denols and tsserver you may
-- only want to enable one lsp server
diag_scroll_bar_sign = {'▃', '█'}, -- experimental: diagnostic status in scroll bar area; set to nil to disable the diagnostic sign,
diagnostic_scroll_bar_sign = {'▃', '█'}, -- experimental: diagnostic status in scroll bar area; set to nil to disable the diagnostic sign,
-- for other style, set to {'╍', 'ﮆ'} or {'-', '='}
diagnostic_virtual_text = true, -- show virtual for diagnostic message
diagnostic_update_in_insert = false, -- update diagnostic message in insert mode
disply_diagnostic_qf = true, -- always show quickfix if there are diagnostic errors, set to false if you want to
ignore it
tsserver = {
@ -421,7 +422,7 @@ Jump between symbols with treesitter (with `]r` and `[r`)
### Diagnostic
Visual studio code style show errors minimap in scroll bar area
(Check setup for `diag_scroll_bar_sign`)
(Check setup for `diagnostic_scrollbar_sign`)
![diagnostic_scroll_bar](https://user-images.githubusercontent.com/1681295/128736430-e365523d-810c-4c16-a3b4-c74969f45f0b.jpg)

@ -25,7 +25,10 @@ _NgConfigValues = {
code_lens = false,
-- only want to enable one lsp server
disply_diagnostic_qf = true, -- always show quickfix if there are diagnostic errors
diag_scroll_bar_sign = {'', ''}, -- set to nil to disable, set to {'╍', 'ﮆ'} to enable diagnostic status in scroll bar area
diagnostic_virtual_text = true, -- show virtual for diagnostic message
diagnostic_update_in_insert = false, -- update diagnostic message in insert mode
diagnostic_scrollbar_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

@ -4,6 +4,7 @@
local codelens = require('vim.lsp.codelens')
local log = require"navigator.util".log
local trace = require"navigator.util".trace
local lsphelper = require "navigator.lspwrapper"
local api = vim.api
@ -42,11 +43,11 @@ local function _update_sign(line)
end
local function codelens_hdlr(err, _, result, client_id, bufnr)
if err then
warn("lsp code lens", vim.inspect(err))
if err or result == nil then
log("lsp code lens", vim.inspect(err))
return
end
log("codelenes result", result)
trace("codelenes result", result)
for _, v in pairs(result) do
_update_sign(v.range.start.line)
end

@ -5,6 +5,7 @@ _NG_VT_NS = vim.api.nvim_create_namespace("navigator_lua")
local util = require "navigator.util"
local log = util.log
local trace = require"guihua.log".trace
-- trace = log
local error = util.error
local path_sep = require"navigator.util".path_sep()
@ -12,7 +13,7 @@ local path_cur = require"navigator.util".path_cur()
diagnostic_list[vim.bo.filetype] = {}
local function error_marker(result, client_id)
if _NgConfigValues.lsp.diag_scroll_bar_sign == nil then -- not enabled or already shown
if _NgConfigValues.lsp.diagnostic_scrollbar_sign == nil then -- not enabled or already shown
return
end
local first_line = vim.fn.line('w0')
@ -61,13 +62,13 @@ local function error_marker(result, client_id)
if pos[#pos] and pos[#pos].line == p then
pos[#pos] = {
line = p,
sign = _NgConfigValues.lsp.diag_scroll_bar_sign[2],
sign = _NgConfigValues.lsp.diagnostic_scrollbar_sign[2],
severity = diag.severity
}
else
table.insert(pos, {
line = p,
sign = _NgConfigValues.lsp.diag_scroll_bar_sign[1],
sign = _NgConfigValues.lsp.diagnostic_scrollbar_sign[1],
severity = diag.severity
})
end
@ -90,7 +91,7 @@ local function error_marker(result, client_id)
end
local diag_hdlr = function(err, method, result, client_id, bufnr, config)
-- log(result)
trace(result)
if err ~= nil then
log(err, config)
return
@ -151,8 +152,7 @@ local diag_hdlr = function(err, method, result, client_id, bufnr, config)
end
local M = {}
-- vim.lsp.handlers["textDocument/publishDiagnostics"] =
M.diagnostic_handler = vim.lsp.with(diag_hdlr, {
local diagnostic_cfg = {
-- Enable underline, use default values
underline = true,
-- Enable virtual text, override spacing to 0
@ -161,8 +161,14 @@ M.diagnostic_handler = vim.lsp.with(diag_hdlr, {
-- and on, using buffer local variables
signs = true,
-- Disable a feature
update_in_insert = false
})
update_in_insert = _NgConfigValues.lsp.diagnostic_update_in_insert or false
}
if _NgConfigValues.lsp.diagnostic_virtual_text == false then
diagnostic_cfg.virtual_text = false
end
-- vim.lsp.handlers["textDocument/publishDiagnostics"] =
M.diagnostic_handler = vim.lsp.with(diag_hdlr, diagnostic_cfg)
M.show_diagnostic = function()
vim.lsp.diagnostic.get_all()
@ -209,7 +215,7 @@ M.set_diag_loclist = function()
end
end
function M.clear_blame_VT() -- important for clearing out when no more errors
local function clear_diag_VT() -- important for clearing out when no more errors
vim.api.nvim_buf_clear_namespace(0, _NG_VT_NS, 0, -1)
_NG_VT_NS = nil
end
@ -240,11 +246,11 @@ function M.update_err_marker()
end
-- TODO: update the marker
if _NgConfigValues.diag_scroll_bar_sign then
print("config deprecated, set lsp.diag_scroll_bar_sign instead")
if _NgConfigValues.diagnostic_scrollbar_sign then
print("config deprecated, set lsp.diagnostic_scrollbar_sign instead")
end
if _NgConfigValues.lsp.diag_scroll_bar_sign then
if _NgConfigValues.lsp.diagnostic_scrollbar_sign then
vim.cmd [[autocmd WinScrolled * lua require'navigator.diagnostics'.update_err_marker()]]
end

@ -38,7 +38,7 @@ local function ref_hdlr(err, api, locations, num, bufnr)
local wwidth = vim.api.nvim_get_option("columns")
local mwidth = _NgConfigValues.width
width = math.min(width + 30, 120, math.floor(wwidth * mwidth))
gui.new_list_view({
return gui.new_list_view({
items = items,
ft = ft,
width = width,

@ -0,0 +1,24 @@
set rtp +=.
set rtp +=../plenary.nvim/
runtime! plugin/plenary.vim
set noswapfile
set nobackup
filetype indent off
set nowritebackup
set noautoindent
set nocindent
set nosmartindent
set indentexpr=
lua << EOF
_G.test_rename = true
_G.test_close = true
require("plenary/busted")
require("navigator").setup()
EOF
Loading…
Cancel
Save