Skip to content

JBakamovic/cxxd-vim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Contents

Introduction

This is a Vim frontend for cxxd server.

Installation

Any of your preferred way of installing Vim plugins should be fine. Please note the necessity for recursive clone. For example:

Dependencies

Here.

Plugin managers

Pathogen

  • $ git clone --recursive https://github.com/JBakamovic/cxxd-vim.git ~/.vim/bundle/cxxd-vim
  • $ git clone https://github.com/JBakamovic/yaflandia.git ~/.vim/bundle/yaflandia (accompanying colorscheme)
  • $ git clone https://github.com/Shirk/vim-gas.git ~/.vim/bundle/vim-gas (optional but for better experience with disassembling)

Vundle

After cloning the repository with:

  • $ git clone --recursive https://github.com/JBakamovic/cxxd-vim.git
  • $ git clone https://github.com/JBakamovic/yaflandia.git (accompanying colorscheme)
  • $ git clone https://github.com/Shirk/vim-gas.git

Add the following to your .vimrc

  • Plugin 'JBakamovic/cxxd-vim'
  • Plugin 'JBakamovic/yaflandia' (accompanying colorscheme)
  • Plugin 'Shirk/vim-gas' (optional but for better experience with disassembling)

Manual

If you're not using any of the plugin managers, you can simply clone the repository into your ~/.vim/ directory:

  • $ git clone --recursive https://github.com/JBakamovic/cxxd-vim.git ~/.vim/cxxd-vim
  • $ git clone https://github.com/JBakamovic/yaflandia.git ~/.vim/yaflandia (accompanying colorscheme)
  • $ git clone https://github.com/Shirk/vim-gas.git ~/.vim/vim-gas (optional but for better experience with disassembling)

Features

Here

Supported platforms

Here

Getting started

You need to provide .cxxd_config.json file at the root of your source code repository. You will also need to generate a compilation database.

You can use .cxxd_config.json example configuration and tweak it to your needs.

Colorschemes

Compared to the vanilla Vim syntax highlighting mechanism, cxxd brings semantic syntax highlighting which not only that it attributes to the visual appeal but it also provides an immediate feedback on the correctness of your code (by not coloring the code in case of errors). In order to take advantage of that feature one has to use a colorscheme that knows how to make use of additional higlighting groups.

Vanilla Vim colorschemes do not handle these groups by default so one will have to either tweak those existing colorschemes to include those groups or simply use yaflandia for the start.

If you want to to tweak your favorite colorscheme, you can try using the make_color.py <path_to_your_colorscheme> utility so that it becomes compatible. It only links existing highlighting groups to the ones generated by cxxd so it shouldn't be destructive by any means.

Usage

Command Default Key-Mapping Purpose
CxxdStart <path-to-your-project-dir> None Starts cxxd server for given project directory in auto-discovery mode. Builds symbol index database. Most other commands will not have effect until symbol index database is built (which may take some time depending on the project size).
CxxdStart <path-to-your-project-dir> <build-target-name> None Starts cxxd server for given project directory and given build-target. Build-target must exist in .cxxd_config.json file. Builds symbol index database. Most other commands will not have effect until symbol index database is built (which may take some time depending on the project size).
CxxdStop None Stops cxxd server.
CxxdRebuildIndex <Ctrl-\>r Rebuilds the symbol index database.
CxxdGoToInclude <F3> and <Shift-F3> Jumps to the file included via #include directive.
CxxdGoToIncludeInPreview <Alt-F3> Peeks into the file included via #include directive and shows it in a small preview window.
CxxdGoToDefintion <F12> and <Shift-F12> Jumps to the symbol definition under the cursor.
CxxdGoToDefintionInPreview <Alt-F12> Peeks into the definition and shows it in a small preview window.
CxxdFindAllReferences <Ctrl-\>s Finds all references of symbol under the cursor. Results are stored into a QuickFix list once the operation is completed.
CxxdFetchAllDiagnostics <Ctrl-\>d Fetches all diagnostics of all source files indexed. Results are stored into a QuickFix list once the operation is completed.
CxxdAnalyzerClangTidyBuf <F5> Runs clang-tidy on current file. Results are stored into a QuickFix list once clang-tidy is completed.
CxxdAnalyzerClangTidyApplyFixesBuf <Shift-F5> Runs clang-tidy on current file and applies the fixes. Results are stored into a QuickFix list once clang-tidy is completed.
CxxdBuildRun <F9> Runs a build with <build_cmd> which is provided in .cxxd_config.json. Build command that will be run will correspond to the way how CxxdServer was started, e.g. <build-target-name>.
CxxdBuildRunWithParams <build_cmd> None Manual way of doing the CxxdBuildRun. Runs a build with <build_cmd> provided. <build_cmd> can be of any arbitrary form which fits the build system your project is using (e.g. make, make clean, make debug, make test, etc.). Results are stored into a QuickFix list once the <build_cmd> is completed.
CxxdDisassemblyPickTarget None Opens a list of available targets (executables) and allows you to select one of the them you're interested in into disassemblying. This target will be used when CxxdDisassemblyPickSymbol will be run.
CxxdDisassemblyPickSymbol None Position a cursor at some symbol of interest, e.g. some function, and run this command. It will open a list of potential symbols (this list will ideally be of size 1). After confirming your choice from the list, a disassembled binary will be opened and cursor will be positioned at the symbol which you just selected.
lopen None Opens location list containing clang-fix-it hints for current buffer.
w None Re-formats the source code in current buffer with clang-format.
mouse hover over the symbol None If hovered over the C or C++ sourc-code, it will show a symbol type in a tooltip. If hovered over the assembly (e.g. in disassembled binary after CxxdDisassemblyPickSymbol), it will show the documentation of the underlying ASM instruction in a tooltip.
colorscheme yaflandia None Activates a colorscheme which has support for semantic syntax highlighting. Any other compatible colorscheme can be used of course.

Screenshots

Semantic syntax highlighting

Semantic syntax hl

Go-to-definition

Go to definition

Go-to-include

Go to include

Find-all-references

Find all references

Fetch-all-diagnostics

TBD

Type-deduction

Type deduction

Clang-fix-it hints

Clang-fix-it hints

Clang-format

Clang-format

Clang-tidy

Clang-tidy

Project build

Project build

Disassembly

Use https://github.com/Shirk/vim-gas.git for better ASM syntax highlighting experience. See Dependencies section for more details.

Disassembly

FAQ

I can't seem to see the effect of semantic syntax highlighting?

Make sure you're using a compatible colorscheme. You can either use (e.g. yaflandia) or use make_color.py utility to convert the colorscheme you're using.

Not getting the behavior you expected?

Due to incorrect configuration, or lack of it, source code indexer might have stumbled upon the problems. Please use CxxdFetchAllDiagnostics command to debug the issues.

About

Vim frontend implementation for cxxd server.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published