mirror of
https://github.com/ray-x/navigator.lua
synced 2024-11-05 12:00:21 +00:00
get diagnostic for all buffers
This commit is contained in:
parent
e97f80d038
commit
5d16212099
@ -72,6 +72,8 @@ Use <c-e> or `:q!` to kill the floating window, <up/down> to move and <c-o> to o
|
||||
### Diagnostic
|
||||
|
||||
![diagnostic](https://github.com/ray-x/files/blob/master/img/navigator/diag.jpg?raw=true)
|
||||
Show diagnostic in files
|
||||
![diagnostic multi files](https://github.com/ray-x/files/blob/master/img/navigator/diagnostic_multiplefiles.jpg?raw=true)
|
||||
|
||||
### Implementation
|
||||
|
||||
|
@ -1,12 +1,17 @@
|
||||
local gui = require "navigator.gui"
|
||||
local diagnostic_list = {}
|
||||
local log = require "navigator.util".log
|
||||
|
||||
local util = require "navigator.util"
|
||||
local log = util.log
|
||||
|
||||
diagnostic_list[vim.bo.filetype] = {}
|
||||
|
||||
local diag_hdlr = function(err, method, result, client_id, br, config)
|
||||
-- log(result)
|
||||
vim.lsp.diagnostic.on_publish_diagnostics(err, method, result, client_id, br, config)
|
||||
if err ~= nil then log(err, config) end
|
||||
if err ~= nil then
|
||||
log(err, config)
|
||||
end
|
||||
local cwd = vim.fn.getcwd(0)
|
||||
local ft = vim.bo.filetype
|
||||
if diagnostic_list[ft] == nil then
|
||||
@ -53,7 +58,7 @@ M.diagnostic_handler =
|
||||
-- Enable virtual text, override spacing to 0
|
||||
virtual_text = {
|
||||
spacing = 0,
|
||||
prefix = "👨" --' ,
|
||||
prefix = "🦊" --' ,
|
||||
},
|
||||
-- Use a function to dynamically turn signs off
|
||||
-- and on, using buffer local variables
|
||||
@ -63,6 +68,17 @@ M.diagnostic_handler =
|
||||
}
|
||||
)
|
||||
M.show_diagnostic = function()
|
||||
vim.lsp.diagnostic.get_all()
|
||||
|
||||
local bufs = vim.api.nvim_list_bufs()
|
||||
for _, buf in ipairs(bufs) do
|
||||
local bname = vim.fn.bufname(buf)
|
||||
if #bname > 0 and not util.exclude(bname) then
|
||||
if vim.api.nvim_buf_is_loaded(buf) then
|
||||
vim.lsp.diagnostic.get(buf, nil)
|
||||
end
|
||||
end
|
||||
end
|
||||
if diagnostic_list[vim.bo.filetype] ~= nil then
|
||||
log(diagnostic_list[vim.bo.filetype])
|
||||
-- vim.fn.setqflist({}, " ", {title = "LSP", items = diagnostic_list[vim.bo.filetype]})
|
||||
@ -73,11 +89,12 @@ M.show_diagnostic = function()
|
||||
table.insert(display_items, it)
|
||||
end
|
||||
end
|
||||
log(display_items)
|
||||
-- log(display_items)
|
||||
if #display_items > 0 then
|
||||
gui.new_list_view({items = display_items, api = '🚑 Diagnostic'})
|
||||
gui.new_list_view({items = display_items, api = "🚑 Diagnostic"})
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
return M
|
||||
|
@ -3,6 +3,7 @@ local ts_locals = require "nvim-treesitter.locals"
|
||||
local parsers = require "nvim-treesitter.parsers"
|
||||
local ts_utils = require "nvim-treesitter.ts_utils"
|
||||
local api = vim.api
|
||||
local util = require'navigator.util'
|
||||
local M = {}
|
||||
|
||||
local cwd = vim.fn.getcwd(0)
|
||||
@ -99,15 +100,6 @@ function M.buf_ts()
|
||||
local all_nodes = get_all_nodes()
|
||||
gui.new_list_view({items = all_nodes, prompt = true, rawdata = true, api = "🎄"})
|
||||
end
|
||||
local exclude_ft = {"scroll", "help", "NvimTree"}
|
||||
local function exclude(fname)
|
||||
for i = 1, #exclude_ft do
|
||||
if string.find(fname, exclude_ft[i]) then
|
||||
return true
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
function M.bufs_ts()
|
||||
if ts_locals == nil then
|
||||
@ -118,7 +110,7 @@ function M.bufs_ts()
|
||||
local ts_opened = {}
|
||||
for _, buf in ipairs(bufs) do
|
||||
local bname = vim.fn.bufname(buf)
|
||||
if #bname > 0 and not exclude(bname) then
|
||||
if #bname > 0 and not util.exclude(bname) then
|
||||
if vim.api.nvim_buf_is_loaded(buf) then
|
||||
local all_nodes = get_all_nodes(buf)
|
||||
if all_nodes ~= nil then
|
||||
|
@ -230,4 +230,15 @@ function M.partial(func, arg)
|
||||
end)
|
||||
end
|
||||
|
||||
local exclude_ft = {"scrollbar", "help", "NvimTree"}
|
||||
function M.exclude(fname)
|
||||
for i = 1, #exclude_ft do
|
||||
if string.find(fname, exclude_ft[i]) then
|
||||
return true
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
|
||||
return M
|
||||
|
Loading…
Reference in New Issue
Block a user