diff --git a/README.md b/README.md index 79dfadd..ec2e682 100644 --- a/README.md +++ b/README.md @@ -72,6 +72,8 @@ Use or `:q!` to kill the floating window, to move and 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 diff --git a/lua/navigator/diagnostics.lua b/lua/navigator/diagnostics.lua index 046fc73..a9685fc 100644 --- a/lua/navigator/diagnostics.lua +++ b/lua/navigator/diagnostics.lua @@ -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 diff --git a/lua/navigator/treesitter.lua b/lua/navigator/treesitter.lua index 8ee56a6..6d83149 100644 --- a/lua/navigator/treesitter.lua +++ b/lua/navigator/treesitter.lua @@ -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 diff --git a/lua/navigator/util.lua b/lua/navigator/util.lua index 5e6648b..79eaf7b 100644 --- a/lua/navigator/util.lua +++ b/lua/navigator/util.lua @@ -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