## 事象 以下のコードを書く。 ```rust fn main() { let numbers = [1..10].map(|x| x * 2).collect::<Vec<_>>(); } ``` [[nvim-lspconfig]]の表示は以下のようになる。 ![[Pasted image 20240303134546.png]] この行には3つのdiagnosticsがあるが、アイコンやメッセージでErrorのそれが表示されない。Errorの方が重要なのでそちらを優先表示してほしい。 ![[Pasted image 20240303140404.png|frame]] *期待値* ## 原因 `vim.diagnostic.config`の`severity_sort`がデフォルトだと`false`だから。 > severity_sort: (default false) Sort diagnostics by severity. This affects the order in which signs and virtual text are displayed. When true, higher severities are displayed before lower severities (e.g. ERROR is displayed before WARN). Options: > *`:h vim.diagnostic.config()`より引用* ## 解決方法 `vim.diagnostic.config`の`severity_sort`を`true`に設定する。 ```lua vim.diagnostic.config({ severity_sort = true }) ``` ## 参考 - [severity\_sort ](https://www.reddit.com/r/neovim/comments/wjr4oi/lsp_diagnostics_virtual_text_priority/)