Skip to content

Instantly share code, notes, and snippets.

@emilcarr
Last active March 15, 2021 15:14
Show Gist options
  • Save emilcarr/1c07acfad9bfd14e6551ebb9cd961df8 to your computer and use it in GitHub Desktop.
Save emilcarr/1c07acfad9bfd14e6551ebb9cd961df8 to your computer and use it in GitHub Desktop.
C/C++ Development Workflow

C/C++ Development Workflow

Setup

Install nvim with coc.nvim and NERDTree

Add this to your .vimrc:

""" NERDTree
" Show NERDTree file manager
autocmd VimEnter * NERDTree | wincmd p
" Exit vim if NERDTree is last window
autocmd BufEnter * if tabpagenr('$') == 1 && winnr('$') == 1 && exists('b:NERDTree') &&b:NERDTree.isTabTree() | quit | endif
let g:NERDTreeWinSize=20

""" COC
so ~/.vim/coc.vim " (download from example on https://github.com/neoclide/coc.nvim/blob/release/Readme.md)

Install coc-clangd:

:CocInstall coc-clangd

Install scan-build

# pip install scan-build

Initialisation

Initialise, clone etc your project as usual. Then run (or whatever build system you are using):

$ intercept-build make all

You may wish to add this as a task in your Makefile:

intercept:
    intercept-build make all

Add the resulting compile_commands.json to your .gitignore:

$ echo compile_commands.json > .gitignore

Workflow

Edit code in nvim and build as normal

Run make intercept after adding any new files or includes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment