## 事象 [[lazy.nvim]]の設定は以下。 ```lua { 'RRethy/vim-illuminate', config = function() require('illuminate').configure {} end }, ``` [[Node.js]]のプロジェクトを作成し、`index.ts`を作成。 ```ts function sum(x: number, y: number): number { return x + y; } function main() { var a = 1; var b = 10; console.log(`sum(a, b): ${sum(a, b)}`); } main(); ``` `a`がハイライトされない。(`x`や`sum`も同様) ![[Pasted image 20240125144317.png]] ## 原因 はっきりとして原因は不明。 ## 解決方法 今のところなし。 ## 詳細調査 ### syntaxの設定を確認 ``` :set syntax? ``` `syntax=`と表示されたが、[[nvim-treesitter]]の挙動としてはこれで問題なさそう。 <div class="link-card-v2"> <div class="link-card-v2-site"> <img class="link-card-v2-site-icon" src="https://github.githubassets.com/favicons/favicon.svg" /> <span class="link-card-v2-site-name">GitHub</span> </div> <div class="link-card-v2-title"> nvim-treesitter/nvim-treesitter </div> <div class="link-card-v2-content"> Nvim Treesitter configurations and abstraction layer - nvim-treesitter/nvim-treesitter </div> <img class="link-card-v2-image" src="https://opengraph.githubassets.com/30d586226d89da902e36dbb7f882f4894d2ee1e6864bbb3bbdbf0d2e605b35ac/nvim-treesitter/nvim-treesitter" /> <a href="https://github.com/nvim-treesitter/nvim-treesitter/issues/1327"></a> </div> [[nvim-treesitter]]を無効化すると `syntax=typescript` のようになる。 ### プラグインのトリアージ - [[Neovim]]で読み込むプラグインを[[illuminate.vim]]以外すべて無効にすると **強調表示はされる** - ただし、パターンで見てそう ([[nvim-treesitter]]インストールしてないからそれはそう) - `vim.cmd('colorscheme gruvbox-material')` をコメントアウトしても変わらない - テーマの問題ではなさそう - コメントアウトしても変わらなかったもの - [[nvim-treesitter]] - [[coc.nvim]] - [[mini.nvim]] - [[gitsigns.nvim]] - [[nvim-tree.lua]] - [[nvim-hlslens]] - [[Rainbow CSV (Vim)|Rainbow CSV]] - [[gruvbox.nvim]] - [[gruvbox-material]] 結論から言うと [[nvim-treesitter]]の読み込み (依存に含むプラグインも) が行われると、見た目がハイライトされなくなる。一方、[[nvim-treesitter]]の読み込みができなかった場合はハイライトされる。 恐らく、[[regex]]の方をつかってる気がする。 ```lua { 'RRethy/vim-illuminate', config = function() require('illuminate').configure { providers = { 'lsp', -- 'treesitter', 'regex' }, } end }, ``` ではハイライトされたので `treesitter` 特有の問題である可能性が高い。 ### ハイライトグループの設定確認 [[ハイライトグループ (Vim)|ハイライトグループ]]に対して装飾が正しく設定されているかが怪しい。 ``` highlight IlluminatedWordRead highlight IlluminatedWordText highlight illuminatedWord highlight IlluminatedWordWrite ``` 上記の結果はすべて `CurrentWord` へのリンク。そこにはちゃんと設定されてそう。 ``` 16:31:36 msg_show IlluminatedWordReadxxx links to CurrentWord 16:31:48 msg_show highlight CurrentWord CurrentWord xxx ctermbg=237 guibg=#3c3836 ``` ちなみに、後から上書き設定しても変わらなかった。 ``` hi IlluminatedWordRead gui=underline hi IlluminatedWordText gui=underline hi illuminatedWord gui=underline hi IlluminatedWordWrite gui=underline ``` 色の設定方法でもなさそう。 ``` hi IlluminatedWordRead cterm=nocombine ctermfg=0 ctermbg=13 gui=nocombine guifg=Black guibg=Magenta hi IlluminatedWordText cterm=nocombine ctermfg=0 ctermbg=13 gui=nocombine guifg=Black guibg=Blue hi illuminatedWord cterm=nocombine ctermfg=0 ctermbg=13 gui=nocombine guifg=Black guibg=Red hi IlluminatedWordWrite cterm=nocombine ctermfg=0 ctermbg=13 gui=nocombine guifg=Black guibg=Cyan ``` なお、`IlluminatedWordText`は[[nvim-treesitter]]対応していない場合に適当されるっぽい。 ### ハイライトグループが割り当てられていない? とすると、残るは[[ハイライトグループ (Vim)|ハイライトグループ]]がそもそも適切に割り当てられていない可能性。 `:TSToggle illuminate`を実行したら`IlluminatedWordText`の[[ハイライトグループ (Vim)|ハイライトグループ]]ですべてハイライトされた。単に[[nvim-treesitter]]との連携がOFFになって、[[regex]]に変わっただけ。 いずれにせよ、`IlluminatedWordText`だけであれば[[illuminate.vim]]を使うメリットはあまりなさそう。[[coc.nvim]]から[[LSP]]ベースに今後移行することがあれば検討するくらいで。