artemave / workspace-diagnostics.nvim

Populate diagnostics for all projects files, not just the opened ones.

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

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

workspace-diagnostics.nvim

Populates project-wide lsp diagnostcs, regardless of what files are opened.

This post goes into details of lsp diagnostics and how this plugin works.

Demo

Here you can see that even though a single file gets opened, the diagnostics are populated for other files as well.

workspace_diagnostics.mp4

📋 Installation

Package manager Snippet

wbthomason/packer.nvim

use {"artemave/workspace-diagnostics.nvim"}

junegunn/vim-plug

Plug "artemave/workspace-diagnostics.nvim"

folke/lazy.nvim

require("lazy").setup({"artemave/workspace-diagnostics.nvim"})

⚡️ Usage

Populate workspace diagnostcs when an lsp client is attached:

require('lspconfig').tsserver.setup({
  on_attach = function(client, bufnr)
                ...
                require("workspace-diagnostics").populate_workspace_diagnostics(client, bufnr)
                ...
              end
})

Despite its placement, populate_workspace_diagnostics will actually do the work only once per client.

⚙ Configuration

You can configure a different function that returns a list of project files (it defaults to the output of git ls-files).

require("workspace-diagnostics").setup({
  workspace_files = function()
    return { 'index.js', 'lib/banana.js' }
  end
})

⌨ Contributing

PRs and issues are always welcome. Make sure to provide as much context as possible when opening one.

To run make lint locally, you'd need to install stylua:

cargo install stylua --features lua52

About

Populate diagnostics for all projects files, not just the opened ones.

https://artem.rocks/posts/workspace_diagnostics_nvim

License:MIT License


Languages

Language:Lua 92.3%Language:Makefile 7.7%