Skip to content

Instantly share code, notes, and snippets.

@kmhofmann
Created February 29, 2020 13:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kmhofmann/3ddca1c7ee4276f399ca17d951aee2dc to your computer and use it in GitHub Desktop.
Save kmhofmann/3ddca1c7ee4276f399ca17d951aee2dc to your computer and use it in GitHub Desktop.
vim-lsp-cxx-highlight issue demonstration
" Bootstrap vim-plug automatically, if not already present
let s:vim_plug_autoload_file = '~/.config/nvim/autoload/plug.vim'
if empty(glob(s:vim_plug_autoload_file))
execute "!curl -fLo " . s:vim_plug_autoload_file . " --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim"
endif
set encoding=utf8
set ffs=unix,dos,mac
syntax enable
set background=dark
set termguicolors
set backspace=eol,start,indent
set hidden
set number
call plug#begin()
" SCENARIO 1: No semantic highlighing when only LanguageClient_neovim installed
Plug 'autozimu/LanguageClient-neovim', { 'branch': 'next', 'do': 'bash install.sh' }
Plug 'jackguo380/vim-lsp-cxx-highlight', { 'tag': '20f0f7c' } " Version with nvim-lsp support
" SCENARIO 2: Semantic highlighting works; only nvim-lsp installed
"Plug 'neovim/nvim-lsp'
"let s:have_nvim_lsp = 1
"Plug 'jackguo380/vim-lsp-cxx-highlight', { 'tag': '20f0f7c' } " Version with nvim-lsp support
" SCENARIO 3: Semantic highlighting works; both nvim-lsp and LanguageClient-neovim installed
"Plug 'neovim/nvim-lsp'
"let s:have_nvim_lsp = 1
"Plug 'autozimu/LanguageClient-neovim', { 'branch': 'next', 'do': 'bash install.sh' }
"Plug 'jackguo380/vim-lsp-cxx-highlight', { 'tag': '20f0f7c' } " Version with nvim-lsp support
" SCENARIO 4: Semantic highlighting WORKS; only LanguageClient-neovim installed
"Plug 'autozimu/LanguageClient-neovim', { 'branch': 'next', 'do': 'bash install.sh' }
"Plug 'jackguo380/vim-lsp-cxx-highlight', { 'tag': '71490fd' } " Version BEFORE nvim-lsp support
call plug#end()
" --- nvim-lsp options
if exists('s:have_nvim_lsp')
lua <<EOF
require'nvim_lsp'.ccls.setup{ init_options = { highlight = { lsRanges = true; } } }
EOF
autocmd Filetype cpp setlocal omnifunc=v:lua.vim.lsp.omnifunc
endif
" --- LanguageClient-neovim options
let s:ccls_settings = { 'highlight': { 'lsRanges' : v:true }, }
let g:LanguageClient_serverCommands = {}
let g:LanguageClient_serverCommands.cpp = ['ccls', '-init=' . json_encode(s:ccls_settings)]
let g:LanguageClient_serverCommands.c = ['ccls', '-init=' . json_encode(s:ccls_settings)]
setlocal completefunc=LanguageClient#complete
let g:lsp_cxx_hl_log_file = '/tmp/vim-lsp-cxx-hl.log'
let g:lsp_cxx_hl_verbose_log = 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment