## 事象
[[workspace-diagnostics.nvim]] の `populate_workspace_diagnostics` を実行しても、サポートしているはずのファイルが診断結果取得対象にならないことがある。
設定。
`lua/plugins/workspace-diagnostics.lua`
```lua
return {
"artemave/workspace-diagnostics.nvim",
event = { "BufReadPre", "BufNewFile" },
config = function()
vim.api.nvim_set_keymap("n", "<space>x", "", {
noremap = true,
callback = function()
for _, client in ipairs(vim.lsp.get_clients()) do
require("workspace-diagnostics").populate_workspace_diagnostics(client, 0)
end
end,
})
end,
}
```
ソースコードを開いて `<Space>x` でコマンドを実行。
### 環境
| 対象 | バージョン |
| ------------------------------ | --------- |
| [[Neovim]] | 0.11.4 |
| [[trouble.nvim]] | `bd67efe` |
| [[workspace-diagnostics.nvim]] | `60f9175` |
## 原因
診断対象として期待するファイルが[[Git]]管理下になっていなかったから。
[[workspace-diagnostics.nvim]]では、デフォルトだと対象ファイルは[[Git]]管理下 (`git ls-files`) のファイルのみなので。
> You can configure a different function that returns a list of project files (it defaults to the output of `git ls-files`).
>
> *[GitHub - artemave/workspace-diagnostics.nvim: Populate diagnostics for _all_ projects files, not just opened ones.](https://github.com/artemave/workspace-diagnostics.nvim?tab=readme-ov-file#-configuration)*
## 解決方法
対象ファイルを `git add` する。