mirror of
https://github.com/jdhao/nvim-config.git
synced 2025-06-08 14:14:33 +02:00
Initial support for C++
This commit is contained in:
parent
9a7ac4c9d1
commit
283356ee52
@ -1 +1,30 @@
|
|||||||
nnoremap <F9> :<C-U>w <CR> :!g++ -Wall -std=c++11 % -o %<&&./%<<CR>
|
nnoremap <silent> <buffer> <F9> :call <SID>compile_run_cpp()<CR>
|
||||||
|
|
||||||
|
function! s:compile_run_cpp() abort
|
||||||
|
let src_path = expand('%:p:~')
|
||||||
|
let src_noext = expand('%:p:~:r')
|
||||||
|
" The building flags
|
||||||
|
let _flag = '-Wall -Wextra -std=c++11 -O2'
|
||||||
|
|
||||||
|
if executable('clang++')
|
||||||
|
let prog = 'clang++'
|
||||||
|
elseif executable('g++')
|
||||||
|
let prog = 'g++'
|
||||||
|
else
|
||||||
|
echoerr 'No C++ compiler found on the system!'
|
||||||
|
endif
|
||||||
|
call s:create_term_buf('h', 20)
|
||||||
|
execute printf('term %s %s %s -o %s && %s', prog, _flag, src_path, src_noext, src_noext)
|
||||||
|
startinsert
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function s:create_term_buf(_type, size) abort
|
||||||
|
set splitbelow
|
||||||
|
set splitright
|
||||||
|
if a:_type ==# 'v'
|
||||||
|
vnew
|
||||||
|
else
|
||||||
|
new
|
||||||
|
endif
|
||||||
|
execute 'resize ' . a:size
|
||||||
|
endfunction
|
||||||
|
|||||||
@ -44,6 +44,9 @@ Plug 'machakann/vim-swap'
|
|||||||
" IDE for Lisp
|
" IDE for Lisp
|
||||||
" Plug 'kovisoft/slimv'
|
" Plug 'kovisoft/slimv'
|
||||||
Plug 'vlime/vlime', {'rtp': 'vim/', 'for': 'lisp'}
|
Plug 'vlime/vlime', {'rtp': 'vim/', 'for': 'lisp'}
|
||||||
|
|
||||||
|
" C++ semantic highlighting
|
||||||
|
Plug 'jackguo380/vim-lsp-cxx-highlight'
|
||||||
"}}
|
"}}
|
||||||
|
|
||||||
"{{ Search related plugins
|
"{{ Search related plugins
|
||||||
@ -390,6 +393,24 @@ if executable('pyls')
|
|||||||
augroup END
|
augroup END
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
if executable('ccls')
|
||||||
|
augroup ccls_setup
|
||||||
|
autocmd!
|
||||||
|
au User lsp_setup call lsp#register_server({
|
||||||
|
\ 'name': 'ccls',
|
||||||
|
\ 'cmd': {server_info->['ccls']},
|
||||||
|
\ 'root_uri': {server_info->lsp#utils#path_to_uri(
|
||||||
|
\ lsp#utils#find_nearest_parent_file_directory(
|
||||||
|
\ lsp#utils#get_buffer_path(), ['.ccls', 'compile_commands.json', '.git/']))},
|
||||||
|
\ 'initialization_options': {
|
||||||
|
\ 'highlight': { 'lsRanges' : v:true },
|
||||||
|
\ 'cache': {'directory': stdpath('cache') . '/ccls' },
|
||||||
|
\ },
|
||||||
|
\ 'whitelist': ['c', 'cpp', 'objc', 'objcpp', 'cc'],
|
||||||
|
\ })
|
||||||
|
augroup END
|
||||||
|
endif
|
||||||
|
|
||||||
if executable('vim-language-server')
|
if executable('vim-language-server')
|
||||||
augroup LspVim
|
augroup LspVim
|
||||||
autocmd!
|
autocmd!
|
||||||
@ -546,9 +567,12 @@ endif
|
|||||||
|
|
||||||
"{{ Navigation and tags
|
"{{ Navigation and tags
|
||||||
""""""""""""""""""""""""""" gutentags settings """"""""""""""""""""""""""""""
|
""""""""""""""""""""""""""" gutentags settings """"""""""""""""""""""""""""""
|
||||||
let g:gutentags_ctags_exclude = ['*.md', '*.html', '*.json', '*.toml', '*.css', '*.js',]
|
|
||||||
" The path to store tags files, instead of in the project root.
|
" The path to store tags files, instead of in the project root.
|
||||||
let g:gutentags_cache_dir = stdpath('cache') . '/ctags'
|
let g:gutentags_cache_dir = stdpath('cache') . '/ctags'
|
||||||
|
let g:gutentags_ctags_extra_args = ['--fields=+niazS', '--extra=+q']
|
||||||
|
let g:gutentags_ctags_extra_args += ['--c++-kinds=+px']
|
||||||
|
let g:gutentags_ctags_extra_args += ['--c-kinds=+px']
|
||||||
|
let g:gutentags_ctags_exclude = ['*.md', '*.html', '*.json', '*.toml', '*.css', '*.js',]
|
||||||
|
|
||||||
""""""""""""""""""""""""""" vista settings """"""""""""""""""""""""""""""""""
|
""""""""""""""""""""""""""" vista settings """"""""""""""""""""""""""""""""""
|
||||||
let g:vista#renderer#icons = {
|
let g:vista#renderer#icons = {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user