artemave / workspace-diagnostics.nvim

Populate diagnostics for _all_ projects files, not just opened ones.

Home Page:https://artem.rocks/posts/workspace_diagnostics_nvim

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

No errors for unopened files

timsofteng opened this issue · comments

commented

Description

On my private ts-react project this plugin doesn't work. To be honest I have no ideat how to provide reproducable env but I would be happy to debug it somehow.

Here is my config related to lsp

local lspconfig = require("lspconfig")
local keymap = vim.keymap.set

local outerOpts = { noremap = true, silent = true }

keymap("n", "<leader>ls", "<cmd>LspStart <cr>", { desc = "Start lsp", unpack(opts) })
keymap("n", "<leader>lS", "<cmd>LspStop <cr>", { desc = "Stop lsp", unpack(opts) })

local on_attach = function(client, bufnr)
	local opts = { buffer = bufnr }
	keymap("n", "gD", vim.lsp.buf.declaration, opts)
	keymap("n", "gd", vim.lsp.buf.definition, opts)
	keymap("n", "K", vim.lsp.buf.hover, opts)
	keymap("n", "<leader>lW", vim.diagnostic.setqflist)
	keymap("n", "<C-k>", vim.lsp.buf.signature_help, opts)
	keymap("n", "gr", vim.lsp.buf.references, opts)
	keymap("n", "<leader>la", vim.lsp.buf.code_action, opts)
	keymap("n", "<leader>lr", vim.lsp.buf.rename, opts)

	require("workspace-diagnostics").trigger_workspace_diagnostics(client, bufnr)
end

-- LSP settings (for overriding per client)
local handlers = {
	["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, { border = "single" }),
	["textDocument/signatureHelp"] = vim.lsp.with(vim.lsp.handlers.signature_help, { border = "single" }),
}

-- Enable the following language servers
local servers = {
	"gopls",
	"vuels",
	"tsserver",
	"pylsp",
	"cssls",
	"lua_ls",
	"bashls",
	"eslint",
	"marksman",
	"clangd",
	"templ",
}

local capabilities = vim.lsp.protocol.make_client_capabilities()
capabilities.textDocument.completion.completionItem.snippetSupport = true

for _, lsp in ipairs(servers) do
	lspconfig[lsp].setup({
		autostart = false,
		on_attach = on_attach,
		capabilities = capabilities,
		handlers = handlers,
	})
end

-- require("typescript-tools").setup({
-- 	autostart = false,
-- 	on_attach = on_attach,
-- 	capabilities = capabilities,
-- 	handlers = handlers,
-- 	root_dir = lspconfig.util.root_pattern("turbo.json", "tsconfig.json", "package.json", ".git"),
-- })

Steps to reproduce

  1. Open ts-react repo
  2. Attach lsp
  3. No error in Trouble until I open specific file with error.

Expected behavior

Errors should be visible for unopened files in trouble.nvim.

Environment

  • Neovim version: 0.9.5
  • workspace-diagnostics version: latest
  • Plugin clash: Trouble

autostart = false looks suspicious. From the docs:

- {autostart}

    `bool` (default: true)

    Controls if the `FileType` autocommand that launches a language server is
    created. If `false`, allows for deferring language servers until manually
    launched with `:LspStart` (|lspconfig-commands|).

Although in that case I wouldn't expect any diagnostics at all, even when you open a file with errors.

commented

autostart = false looks suspicious. From the docs:

- {autostart}

    `bool` (default: true)

    Controls if the `FileType` autocommand that launches a language server is
    created. If `false`, allows for deferring language servers until manually
    launched with `:LspStart` (|lspconfig-commands|).

Although in that case I wouldn't expect any diagnostics at all, even when you open a file with errors.

I usually start lsp mannualy with :LspStart. I tried to comment this string but this plugin still doesn't work.

What's the output of git ls-files?