~gpanders/dotfiles

63d6e0545a4b0fe42b978a6d65f3c8276769a1bf — Greg Anders 2 years ago f367292
Enhance C/C++ environment

* Set formatprg to use Google style if .clang-format file not found
* Create an indent file for C++ to use two spaces for indent (per
  Google's style recommendations)
* For CMake projects, use projectionist to set makeprg to rebuild cmake
  files and :Dispatch to run 'make'
* Tell ALE to use compile_commands.json if they're available
M vim/.vim/after/ftplugin/c.vim => vim/.vim/after/ftplugin/c.vim +1 -1
@@ 34,7 34,7 @@ if exists(':Man') == 2
endif

if executable('clang-format')
  setlocal formatprg=clang-format
  setlocal formatprg=clang-format\ -style=file\ -fallback-style=Google
  let b:undo_ftplugin .= ' fp<'
endif


A vim/.vim/after/indent/cpp.vim => vim/.vim/after/indent/cpp.vim +14 -0
@@ 0,0 1,14 @@
" cpp indent configuration
" Author: Greg Anders <greg@gpanders.com>

if &filetype !=# 'cpp'
  finish
endif

let b:undo_indent = get(b:, 'undo_indent', '')

" Use two spaces for indenting per Google's C++ style guide
setlocal softtabstop=2
setlocal shiftwidth=2

let b:undo_indent .= '|setl sts< sw<'

M vim/.vim/after/indent/gitcommit.vim => vim/.vim/after/indent/gitcommit.vim +5 -1
@@ 1,9 1,13 @@
" Git commit indent configuration
" Author: Greg Anders <greg@gpanders.com>

if &filetype !=# 'gitcommit'
  finish
endif

let b:undo_indent = get(b:, 'undo_indent', '')

setlocal shiftwidth=2
setlocal softtabstop=2

let b:undo_indent = 'setl sw< sts<'
let b:undo_indent .= '|setl sw< sts<'

M vim/.vim/after/plugin/ale.vim => vim/.vim/after/plugin/ale.vim +1 -0
@@ 8,6 8,7 @@ if !get(g:, 'loaded_ale', 0)
endif

let g:ale_python_pylint_change_directory = 0
let g:ale_c_parse_compile_commands = 1

let g:ale_fixers = {
      \ 'python': ['isort'],

M vim/.vim/after/plugin/dispatch.vim => vim/.vim/after/plugin/dispatch.vim +0 -3
@@ 17,9 17,6 @@ let g:dispatch_compilers['pytest'] = 'pytest'
augroup plugin.dispatch
  autocmd!

  " C/C++
  autocmd FileType c,cpp let b:dispatch = 'clang-tidy -quiet %:S'

  " Python
  autocmd FileType python let b:dispatch = 'pytest --tb=short -q'


M vim/.vim/after/plugin/projectionist.vim => vim/.vim/after/plugin/projectionist.vim +34 -1
@@ 47,7 47,40 @@ let g:projectionist_heuristics = {
      \   }
      \ },
      \ 'CMakeLists.txt&build/': {
      \   '*': { 'dispatch': '-dir=build -- make -f build/Makefile' },
      \   '*': {
      \     'make': 'cmake -B build -DCMAKE_EXPORT_COMPILE_COMMANDS=1 .',
      \     'dispatch': '-dir=build make',
      \   },
      \   'CMakeLists.txt': { 'type': 'list' },
      \   'src/*.cc': {
      \     'type': 'src',
      \     'alternate': ['include/{}.h', 'src/{}.h'],
      \   },
      \   'src/*.cpp': {
      \     'type': 'src',
      \     'alternate': ['include/{}.h', 'src/{}.h'],
      \   },
      \   'src/*.h': {
      \     'type': 'header',
      \     'alternate': ['src/{}.cc', 'src/{}.cpp'],
      \     'template': [
      \       '#ifndef _{project|basename|snakecase|uppercase}_{snakecase|uppercase}_H_',
      \       '#define _{project|basename|snakecase|uppercase}_{snakecase|uppercase}_H_',
      \       '',
      \       '#endif //_{project|basename|snakecase|uppercase}_{snakecase|uppercase}_H_',
      \     ],
      \   },
      \   'include/*.h': {
      \     'type': 'header',
      \     'alternate': ['src/{}.cc', 'src/{}.cpp'],
      \     'template': [
      \       '#ifndef _{project|basename|snakecase|uppercase}_{uppercase}_H_',
      \       '#define _{project|basename|snakecase|uppercase}_{uppercase}_H_',
      \       '',
      \       '#endif //_{project|basename|snakecase|uppercase}_{uppercase}_H_',
      \     ],
      \   },
      \   'README.md': { 'type': 'doc' },
      \ },
      \ 'include/': {
      \   '*.h':   { 'path': 'include' },

M vim/.vim/plugin/ale.vim => vim/.vim/plugin/ale.vim +1 -1
@@ 7,7 7,7 @@ if !has('nvim') && v:version < 801
  finish
endif

" silent! packadd ale
silent! packadd ale

" This variable must be set before ALE is loaded so that it can create the
" proper autocmds

M vim/.vim/plugin/coc.vim => vim/.vim/plugin/coc.vim +2 -2
@@ 4,8 4,8 @@
" Date: 2019-02-25

" Only load coc when using nvim
if !has('nvim') && v:version < 801
if !has('nvim')
  finish
endif

" silent! packadd coc.nvim
silent! packadd coc.nvim