Skip to content

andrejlevkovitch/vim-hl-client

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

60 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

vim-hl-client: semantic highlighting for c/c++ in vim

NOTE: since YouCompleteMe started supporting highlighting, that project is abandoned and no longer supported.

Fast asynchronous vim client for hl-server. Provide semantic highlighting for c, cpp (based on clang) and go (based on go ast). Uses .color_coded file for specify compile flags for analizing.

use version protocol: v1.1

Requirements

  • vim 8.2 (can be used vim 8 with branch win-matching)

  • hl-server

  • go (optional)

Installation

  1. Install cmake, libclang-dev and llvm-dev packages

  2. Use vundle for install this plagin. Add to your .vimrc next line:

Plugin 'andrejlevkovitch/vim-hl-client'

and call :PluginUpdate in vim command line

  1. Compile hl-server by cmake. Just call:
make clean
make build

At the end this command will print path to server binary file that you should put in your .vimrc file (see bellow)

In case of some some problems with cmake configuration or compilation, please look into hl-server README

NOTE for not linux system you can try use boost branch of hl-server, or checkout to v1.0. Anyway the program doesn't tested on other systems

  1. Add to your .vimrc file next line:
let g:hl_server_binary  = "/path/to/hl-server/binary"

This command starts your hl-server automaticly after starting vim

Additional settings

  • set port for server manually
let g:hl_server_port    = 53827
  • debug mode for hl-server. All logs will write in debug file.
let g:hl_debug_file     = "/path/to/debug/file"
  • for check some errors you can call:
echo HLServerLastError()
  • for restarting hl-server you can run command:
call HLServerStop()
call HLServerStart()
  • for check status of hl-server you can call
call HLServerStatus()

NOTE that hl-server can be started only ones (with same port), so if you run other instance of vim this command return that hl-server is dead

Why should not use color-coded

color-coded is similar plugin for semantic highlighting for c/c++. I used it previously, but it has several serious problems, like:

  • need vim, compiled with lua support

  • impassible to integrate the plugin with other editors

  • hard for debug

  • low stability - color-coded crashes sometimes and crashes vim also!

  • speed and memory - color-coded can use above 2Gb of memory and can work very slowly with big files

Why vim-hl-client is better then color-coded

  • this plugin has client-server architecture: vim-hl-client as client and hl-server as server. So vim don't need some extra features like be compiled with lua support. It works with standard features only (jobs, channels, textproperties).

  • absolutly asynchronous. vim-hl-client uses standard vim asynchronous features like channels and callbacks for calling requests. All tasks handles on server side.

  • simple to debug. Server is a separate program, you can start it by gdb, or just see logs

  • high stability. Even if hl-server will crash, vim will work as expected, but without highlighting.

  • hl-server absolutly independent from vim, so you can integrate it with other editors - just create you own *-hl-client

Bugs

After updating plugin you can get notice that you should recompile hl-server. Highly recomended remove previous cmake configs and generate new.

cd build
rm * -r
cmake ..
cmake --build . -- -j4

Also note, that debug file truncate every time when new instance of vim raised. So, if you set g:hl_debug_file like a static file, then you may have a problem with save it, or even reading (you can't open it by new instance of vim, because it will be trancated before opening). So highly recomended set debug file as:

let g:hl_debug_file = "/path/to/file" . localtime()

In this case every instance of vim will has your own debug file

About

vim client for hl-server

Resources

Stars

Watchers

Forks

Packages

No packages published