add lsp.workspace_diag_only_cwd option to filter out diagnostics entries from files outside of the current working directory (#36)

* add lsp.workspace_diag_only_cwd option to filter

out diagnostics entries from files outside of the current
working directory;

* switch to cwd_only option;

* restore original filtering in buffer_diag loop;
main
Denys Zadorozhnyi 3 years ago committed by GitHub
parent ef673b20ea
commit d7b4696985
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -360,6 +360,7 @@ require'fzf-lua'.setup {
lsp = {
prompt = ' ',
-- cwd = vim.loop.cwd(),
cwd_only = false, -- show workspace diagnostics only for the files in cwd
file_icons = true,
git_icons = false,
lsp_icons = true,

@ -302,6 +302,7 @@ M.globals.lsp = {
["Information"] = { icon = "", color = "blue" }, -- info
["Hint"] = { icon = "", color = "magenta" }, -- hint
},
cwd_only = false,
}
M.globals.builtin = {
prompt = 'Builtin> ',

@ -384,12 +384,14 @@ M.diagnostics = function(opts)
end
end
for bufnr, diags in pairs(buffer_diags) do
for _, diag in ipairs(diags) do
-- workspace diagnostics may include empty tables for unused bufnr
if not vim.tbl_isempty(diag) then
if filter_diag_severity(opts, diag.severity) then
diagnostics_handler(opts, cb, co,
preprocess_diag(diag, bufnr))
if not opts.cwd_only or (opts.cwd_only and string.find(vim.api.nvim_buf_get_name(bufnr), vim.loop.cwd(), 1, true) ) then
for _, diag in ipairs(diags) do
-- workspace diagnostics may include empty tables for unused bufnr
if not vim.tbl_isempty(diag) then
if filter_diag_severity(opts, diag.severity) then
diagnostics_handler(opts, cb, co,
preprocess_diag(diag, bufnr))
end
end
end
end

Loading…
Cancel
Save