autozimu / LanguageClient-neovim

Language Server Protocol (LSP) support for vim and neovim.
MIT License
3.55k stars 272 forks source link

Cannot disable highlighting #1187

Closed carbolymer closed 3 years ago

carbolymer commented 3 years ago

Describe the bug

Cannot disable document highlighting.

Environment

function LC_maps() if has_key(g:LanguageClient_serverCommands, &filetype) let g:LanguageClient_loggingFile = '/tmp/LanguageClient.log' let g:LanguageClient_serverStderr = '/tmp/LanguageClient_stderr.log' endif endfunction

if &filetype == 'haskell' let g:LanguageClient_documentHighlightDisplay = {} endif

autocmd FileType * call LC_maps()

- Language server link and version:

https://github.com/haskell/haskell-language-server

haskell-language-server version: 0.8.0.0 (GHC: 8.10.1) (PATH: /usr/bin/haskell-language-server-wrapper) (GIT hash: eb58f13f7b8e4f9bc771af30ff9fd82dc4309ff5)



## To Reproduce

Steps to reproduce the behavior:

1. Open haskell source code file
2. HLS takes significant time to load - after loading hints are visible

## Current behavior
Despite disabling `documentHighlightDisplay` current buffer still gets highlighted, which breaks syntax highlighting and it is not possible to disable highlighting.

![broken](https://user-images.githubusercontent.com/228866/106577841-256a4a80-653f-11eb-965c-c044113551c3.png)

## Expected behavior

Buffer does not get highilghted.
martskins commented 3 years ago

Can you provide a minimal, complete vimrc that reproduces this issue? I haven't been able to reproduce the issue myself.

carbolymer commented 3 years ago

@martskins sure, here you have python example with venv, requirements and minimal vimrc: https://gitlab.com/carbolymer/lc-nvim-broken-highlight

martskins commented 3 years ago

I'm still not able to reproduce. I had to move some stuff around in the vimrc you provided there (I didn't have the /vim82/defaults file, I found one though, that I think must be the one you are referring to in there) and the vimrc was missing the colorscheme plugin, which I also think I managed to find. But adding that and moving the plugins to the top of the file worked fine for me and it looked fine as well:

image

carbolymer commented 3 years ago

@martskins you don't have errors and hints on the margin so it looks like language server wasn't even started? I think something is still missing there, I'll try to reproduce it again tomorrow.

martskins commented 3 years ago

I'm not sure how pyls works in terms of diagnostics, but the server is definitely running, I tried calling textDocument/definition just to make sure and it works.

carbolymer commented 3 years ago

@martskins ok, I've added Dockerfile which reproduces the problem. If you don't have podman, you can replace podman with docker commands in test.sh

https://gitlab.com/carbolymer/lc-nvim-broken-highlight

martskins commented 3 years ago

Ok I see what's going on. What you are seeing is the text decoration for diagnostics. LanguageClient-neovim defines a few highlight groups to use in the code that has diagnostics to display. You can change those by overriding the g:LanguageClient_diagnosticsDisplay config variable. The default value is the following:

{
        1: {
            "name": "Error",
            "texthl": "LanguageClientError",
            "signText": "✖",
            "signTexthl": "LanguageClientErrorSign",
            "virtualTexthl": "Error",
        },
        2: {
            "name": "Warning",
            "texthl": "LanguageClientWarning",
            "signText": "⚠",
            "signTexthl": "LanguageClientWarningSign",
            "virtualTexthl": "Todo",
        },
        3: {
            "name": "Information",
            "texthl": "LanguageClientInfo",
            "signText": "ℹ",
            "signTexthl": "LanguageClientInfoSign",
            "virtualTexthl": "Todo",
        },
        4: {
            "name": "Hint",
            "texthl": "LanguageClientInfo",
            "signText": "➤",
            "signTexthl": "LanguageClientInfoSign",
            "virtualTexthl": "Todo",
        },
    }

The highlight group that's applied is the texthl bit in those. Note that the highlight groups are LanguageClientWarning, LanguageClientError, etc. Those are defined as such:

if !hlexists('LanguageClientWarning')
  hi link LanguageClientWarning SpellCap
endif

if !hlexists('LanguageClientInfo')
  hi link LanguageClientInfo LanguageClientWarning
endif

if !hlexists('LanguageClientError')
  hi link LanguageClientError SpellBad
endif

So in your case it's probably using LanguageClientWarning, which is a link to SpellCap, which surely is set by your colorscheme. So if you want to change how that is displayed you'll need to either re-define the LanguageClientWarning (and/or LanguageClientError and LanguageClientInfo) highlight groups, or re-define SpellCap and SpellBad. I would advise for the former.

For more info no this see :help g:LanguageClient_diagnosticsDisplay.

carbolymer commented 3 years ago

@martskins Thanks a lot for the explanation! I suspected that it was related with the highlight groups but I couldn't figure out which is the right option from the docs. I guess this is not a bug.