jackguo380 / vim-lsp-cxx-highlight

Vim plugin for C/C++/ObjC semantic highlighting using cquery, ccls, or clangd
MIT License
337 stars 26 forks source link

can not make it work with nvim-lsp #47

Open jdhao opened 3 years ago

jdhao commented 3 years ago

Describe the bug

I have install ccls successfully and make this plugin work with vim-lsp. But I can not make it work with nvim-lspconfig.

Note that nvim-lsp has been renamed to nvim-lspconfig several month ago.

To Reproduce

Use the below config and open a test.cc file.

#include <iostream>                                
#include <vector>

int add(int a, int b);

int main() {
    /* std::vector<int> v = {1, 2, 3, 4, 5}; */    
    std::vector<int> v(10, 5);                     
    int sum = 0;                                   

    for (int i = 0; i < v.size(); i++){
        sum += v[i];
    }
    std::cout << "sum is " << sum << std::endl;
    std::cout << add(2, 3) << std::endl;
    return 0;
}

int add(int a, int b){
    return a+b;
}

Expected behavior

The extra highlight for std::cout will work.

Configuration (Fill this out):

The config I use:

let g:PLUGIN_HOME=expand(stdpath('data') . '/plugged')
call plug#begin(g:PLUGIN_HOME)
" Plug 'prabirshrestha/vim-lsp'                                   
Plug 'neovim/nvim-lspconfig'                                      
Plug 'jackguo380/vim-lsp-cxx-highlight'                           
call plug#end()                                                   

let g:lsp_cxx_hl_log_file = '/tmp/lsp-cxx-hl.log'                 
let g:lsp_cxx_hl_verbose_log = 1                                  

lua <<EOF                                                         
require'nvim_lsp'.ccls.setup{                                     
  init_options = {                                                
    highlight = {                                                 
      lsRanges = true;                                            
    }                                                             
  }                                                               
}                                                                 
EOF                                                                                                                  

Log File: Enable logging by adding these lines:

let g:lsp_cxx_hl_log_file = '/tmp/lsp-cxx-hl.log'
let g:lsp_cxx_hl_verbose_log = 1

Then post the contents of the log file:

Mon 02 Nov 2020 11:10:14 PM CST: lsp_cxx_hl beginning initialization...   
Mon 02 Nov 2020 11:10:14 PM CST: vim-lsp not detected
Mon 02 Nov 2020 11:10:14 PM CST: LanguageClient-neovim not detected
Mon 02 Nov 2020 11:10:14 PM CST: coc.nvim not detected
Mon 02 Nov 2020 11:10:14 PM CST: nvim-lsp successfully registered         

Note that config here for vim-lsp works as expected. So it may be an config issue for nvim-lspconfig. But I am not sure how to debug where it has gone wrong.

Badhi commented 3 years ago

Hi, By any chance did you try enabling the log of lsp? vim.lsp.set_log_level("debug")

Better to make sure that ccls is publishing $ccls/publishSemanticHighlight

mathsten commented 3 years ago

Any update on this?

I am having the same issue as OP. Additionally, I get an error message Error: ls ranges is not enabled in ccls, when opening an .c/.c++ file. My setup is identical to OP.