vim-ccls


Ⅰ. 插件描述

Vim plugin for the ccls language server

Ⅱ. 基本信息

创建日期:  2019-03-17
使用用户:  1
Github星:  24
插件作者:  Martino Pilia

Ⅲ. 安装方法

使用Vundle管理器安装

在你的.vimrc下添加:
Plugin 'm-pilia/vim-ccls'
… 然后在Vim中运行以下命令:
:source %
:PluginInstall

对于Vundle版本 < 0.10.2,请用上面的Bundle替换Plugin。

使用NeoBundle管理器安装

在你的.vimrc下添加:
NeoBundle 'm-pilia/vim-ccls'
… 然后在Vim中运行以下命令:
:source %
:NeoBundleInstall

使用VimPlug管理器安装

在你的.vimrc下添加:
Plug 'm-pilia/vim-ccls'
… 然后在Vim中运行以下命令:
:source %
:PlugInstall

使用Pathogen管理器安装

在终端中运行以下命令:
cd ~/.vim/bundle
git clone https://github.com/m-pilia/vim-ccls

Ⅳ. 文档说明

vim-ccls: vim plugin for the ccls Language Server

Travis CI Build Status
codecov
License

This plugin supports some additional methods provided by
ccls, which are not part of the standard
Language Server Protocol (LSP). It does not implement a LSP client, but it
relies on an existing LSP plugin, adding on top of it the ccls-specific

  1. Currently supported LSP clients are:

The plugin implements a tree viewer to display call, inheritance, and member

  1. Trees are built lazily, fetching children only when it is needed
  2. expand a sub-tree, allowing to handle large trees.

The call hierarchy allows to visualise a tree of functions calling the function
under the cursor (analogous to the Call Hierarchy View in Eclipse). Similarly,
the callee tree visualises a hierarchy in the opposite direction, showing
functions being called.

The base/derived hierarchy allows to visualise inheritance trees for the class
under the cursor.

The member hierarchy allows to visualise a tree of members inside a type under
the cursor.

demo

Installation

This plugin can be installed with any vim plugin manager. One of the supported
Language Server clients listed above needs to be installed and properly
configured with ccls as language server in order for it to work.

If you have not done it already,
build and
install ccls, and configure
your LSP client to use it (example instructions in the ccls wiki):

In order for ccls to work, make sure to correctly [set up your
project](https://github.com/MaskRay/ccls/wiki/Project-Setup), by either
providing a compilation database (compile_commands.json) or a .ccls
configuration file.

Commands

The plugin provides the following commands. Hierarchy commands will open a
tree-like buffer, while the other commands will populate the [quickfix
list](http://vimdoc.sourceforge.net/htmldoc/quickfix.html).

  • CclsBase:
    Get a list of base classes for the symbol under the cursor.
  • CclsBaseHierarchy:
    Get a tree of inheritance ancestors for the symbol under cursor.
  • CclsDerived:
    Get a list of derived classes for the symbol under the cursor.
  • CclsDerivedHierarchy:
    Get a tree of inheritance descendants for the symbol under cursor.
  • CclsCallers:
    Get a list of functions calling the function under the cursor.
  • CclsCallHierarchy:
    Get a hierarchy of functions calling the function under the cursor.
  • CclsCallees:
    Get a list of functions called by the function under the cursor.
  • CclsCalleeHierahy:
    Get a hierarchy of functions called by the function under the cursor.
  • CclsMembers:
    Get a lists of members for the symbol under cursor.
  • CclsMemberHierarchy:
    Get a tree of members for the symbol under cursor.
  • CclsVars:
    Get a list of document variables.

Settings

It is possible to automatically close a tree buffer when jumping to a location:

let g:ccls_close_on_jump = v:true

To control how many levels of depth in the sub-tree are fetched for each
request, when building a tree (a large value may make execution slow when
generating large trees):

let g:ccls_levels = 1

The size and position of the tree window can be set:

let g:ccls_size = 50
let g:ccls_position = 'botright'
let g:ccls_orientation = 'horizontal'

The following <Plug> mappings are available to interact with a tree buffer:

<Plug>(yggdrasil-toggle-node)
<Plug>(yggdrasil-open-node)
<Plug>(yggdrasil-close-node)
<Plug>(yggdrasil-execute-node)

The default key bindings are:

nmap <silent> <buffer> o    <Plug>(yggdrasil-toggle-node)
nmap <silent> <buffer> <cr> <Plug>(yggdrasil-execute-node)
nnoremap <silent> <buffer> q :q<cr>

They can be disabled and replaced with custom mappings:

let g:yggdrasil_no_default_maps = 1
au FileType yggdrasil nmap <silent> <buffer> o <Plug>(yggdrasil-toggle-node)

Debugging

If you encounter any problem, the first step for troubleshooting is to enable
logging, by setting the following variable:

let g:ccls_log_file = expand('~/my_log_file.txt')

License

This software is distributed under the MIT license. The full text of the license
is available in the [LICENSE
file](https://github.com/m-pilia/vim-ccls/blob/master/LICENSE) distributed
alongside the source code.

添加新评论