RRethy / vim-illuminate

illuminate.vim - (Neo)Vim plugin for automatically highlighting other uses of the word under the cursor using either LSP, Tree-sitter, or regex matching.
2.14k stars 47 forks source link

highlight not working with lsp #61

Closed quantum-booty closed 3 years ago

quantum-booty commented 3 years ago

nvim version: NVIM v0.5.0-dev+1019-ge0a4399ad nvim completion-nvim, lspconfig version: latest

image

let g:python3_host_prog = '/home/henryw/virtualenvs/data_sci/bin/python'
au BufNewFile,BufRead *.py set filetype=python

call plug#begin('~/.config/nvim/plugged')
Plug 'nvim-lua/completion-nvim'
Plug 'neovim/nvim-lspconfig'
Plug 'RRethy/vim-illuminate'
call plug#end()

set updatetime=50
set completeopt+=menuone,noselect,noinsert
set completeopt-=preview
set shortmess+=c

:lua <<EOF
require'lspconfig'.pyls.setup {
on_attach = function(client)
  -- [[ other on_attach code ]]
  require 'completion'.on_attach(client)
  require 'illuminate'.on_attach(client)
end,
}
EOF

Checkhealth result:


health#completion_nvim#check
========================================================================
## general
  - OK: neovim version is supported

## completion source
  - OK: all completion sources are valid

## snippet source
  - INFO: You haven't set up any snippet source

health#lspconfig#check
========================================================================
## Checking language server protocol configuration
  - INFO: pyls: configuration checked.

health#nvim#check
========================================================================
## Configuration
  - OK: no issues found

## Performance
  - OK: Build type: Release

## Remote Plugins
  - OK: Up to date

## terminal
  - INFO: key_backspace (kbs) terminfo entry: key_backspace=\177
  - INFO: key_dc (kdch1) terminfo entry: key_dc=\E[3~
  - INFO: $COLORTERM='truecolor'

health#provider#check
========================================================================
## Clipboard (optional)
  - OK: Clipboard tool found: xclip

## Python 2 provider (optional)
  - WARNING: No Python executable found that can `import neovim`. Using the first available executable for diagnostics.
  - ERROR: Python provider error:
    - ADVICE:
      - provider/pythonx: Could not load Python 2:
          /usr/bin/python2 does not have the "neovim" module. :help |provider-python|
          /usr/bin/python2.7 does not have the "neovim" module. :help |provider-python|
          python2.6 not found in search path or not executable.
          /home/henryw/virtualenvs/data_sci/bin/python is Python 3.9 and cannot provide Python 2.
  - INFO: Executable: Not found

## Python 3 provider (optional)
  - INFO: Using: g:python3_host_prog = "/home/henryw/virtualenvs/data_sci/bin/python"
  - INFO: Executable: /home/henryw/virtualenvs/data_sci/bin/python
  - INFO: Python version: 3.9.1
  - INFO: pynvim version: 0.4.2
  - OK: Latest pynvim is installed.

## Python virtualenv
  - INFO: $VIRTUAL_ENV is set to: /home/henryw/virtualenvs/data_sci
  - INFO: Python version: 3.9.1
  - OK: $VIRTUAL_ENV provides :!python.

## Ruby provider (optional)
  - INFO: Ruby: ruby 2.7.2p137 (2020-10-01 revision 5445e04352) [x86_64-linux]
  - WARNING: `neovim-ruby-host` not found.
    - ADVICE:
      - Run `gem install neovim` to ensure the neovim RubyGem is installed.
      - Run `gem environment` to ensure the gem bin directory is in $PATH.
      - If you are using rvm/rbenv/chruby, try "rehashing".
      - See :help |g:ruby_host_prog| for non-standard gem installations.

## Node.js provider (optional)
  - INFO: Node.js: v15.5.1
  - INFO: Nvim node.js host: /usr/lib/node_modules/neovim/bin/cli.js
  - OK: Latest "neovim" npm/yarn package is installed: 4.9.0

## Perl provider (optional)
  - ERROR: perl provider error:
    - ADVICE:
      - "Neovim::Ext" cpan module is not installed
RRethy commented 3 years ago

For the language server integration, highlighting is done using the LspReferenceText, LspReferenceRead, and LspReferenceWrite highlight groups which can be defined as follows:

hi LspReferenceText gui=underline
hi LspReferenceWrite gui=underline
hi LspReferenceText gui=underline

Note: You can change these to whatever, they don't have to be underlines, I link it to CursorLine.

These highlight groups have no defaults as they as used by the LSP. Try defining them and let me know if it still doesn't work.

quantum-booty commented 3 years ago

Thank you, this worked for me:

autocmd VimEnter * hi LspReferenceText cterm=inverse gui=inverse
autocmd VimEnter * hi LspReferenceRead cterm=inverse gui=inverse
autocmd VimEnter * hi LspReferenceWrite cterm=inverse gui=inverse