From 1d16b8d86653e9e59be53a0cd5a0bf85414ba756 Mon Sep 17 00:00:00 2001 From: Jannik ZANDER Date: Wed, 18 Jul 2018 22:14:40 +0200 Subject: [PATCH] Add c-support to vim --- .gitmodules | 3 + .vim/gvimrc | 8 +- .vim/pack/github/opt/c-support | 1 + .vim/vimrc | 183 +++++++++++++++++++++++---------- 4 files changed, 140 insertions(+), 55 deletions(-) create mode 160000 .vim/pack/github/opt/c-support diff --git a/.gitmodules b/.gitmodules index 3187df6..5fe132a 100644 --- a/.gitmodules +++ b/.gitmodules @@ -52,3 +52,6 @@ [submodule ".vim/pack/github/opt/vim-snippets"] path = .vim/pack/github/opt/vim-snippets url = https://github.com/honza/vim-snippets.git +[submodule ".vim/pack/github/opt/c-support"] + path = .vim/pack/github/opt/c-support + url = https://github.com/WolfgangMehner/c-support.git diff --git a/.vim/gvimrc b/.vim/gvimrc index 66b16b3..efb1338 100644 --- a/.vim/gvimrc +++ b/.vim/gvimrc @@ -1,17 +1,18 @@ " Use :help 'option' to see the documentation for the given option. -" gui set guioptions+=a +set guioptions=egmrti set guioptions-=m "no menu bar set guioptions-=T "no toolbar set guioptions-=r "no scroolbar set noguipty " mouse +set mousemodel=popup set mousehide set mouse=a -set mousemodel=popup + " mapping map @@ -20,9 +21,12 @@ map! " colors highlight normal guibg=black guifg=white highlight linenr guifg=grey +set gcr=a:blinkon0 " fonts +set guifont=Monospace\ 10 if has("mac") +" set guifont=Menlo:h12 set guifont=monaco:h11 elseif has("unix") " set guifont=-misc-fixed-medium-r-normal--14-130-75-75-c-70-iso8859-1 diff --git a/.vim/pack/github/opt/c-support b/.vim/pack/github/opt/c-support new file mode 160000 index 0000000..1ef8728 --- /dev/null +++ b/.vim/pack/github/opt/c-support @@ -0,0 +1 @@ +Subproject commit 1ef872854c877997eade712a6b7b254c74e79ccf diff --git a/.vim/vimrc b/.vim/vimrc index 7351ce8..04c1a58 100644 --- a/.vim/vimrc +++ b/.vim/vimrc @@ -13,7 +13,10 @@ set breakindent set breakindent showbreak=\ + set shiftround set formatoptions+=j -set wrap +set tabstop=4 +set softtabstop=0 +set shiftwidth=4 +set expandtab " searching set incsearch @@ -21,10 +24,11 @@ set hlsearch set ignorecase set smartcase set showmatch -set wrapscan set complete-=i set virtualedit=block -set clipboard=unnamed +if has('unnamedplus') + set clipboard=unnamed,unnamedplus +endif " display set scrolloff=1 @@ -33,7 +37,9 @@ set display+=lastline set lazyredraw set number set relativenumber -set titlestring=vim:\ %f + +set title +set titlestring=%F " folding set foldmethod=syntax @@ -76,25 +82,41 @@ set noswapfile set undofile set undodir=~/.vim/undo set viminfo+=n~/.vim/viminfo -set sessionoptions-=options set history=1000 setglobal tags-=./tags tags-=./tags; tags^=./tags; +" sessions +set sessionoptions-=options +let g:session_directory = "~/.vim/session" +let g:session_autoload = "no" +let g:session_autosave = "no" +let g:session_command_aliases = 1 + " system set path=.,,** -set shell=/bin/bash +if exists('$SHELL') + set shell=$SHELL +else + set shell=/bin/sh +endif if has("win32") set shell=cmd set shellcmdflag=/c endif set fileformats=unix,dos,mac set fileignorecase -"set encoding=utf-8 + +"" Encoding +set encoding=utf-8 +set fileencoding=utf-8 +set fileencodings=utf-8 +set bomb +set binary +set ttyfast " colors set t_Co=256 set background=dark -highlight normal ctermbg=black ctermfg=white highlight linenr ctermfg=grey " fonts and chars @@ -110,25 +132,6 @@ let &t_SI.="\e[5 q" let &t_EI.="\e[1 q" let &t_te.="\e[0 q" -" make -function! s:CmakeInit() - let &errorformat="%f(%l) : %t%*\\D%n: %m,%*[^\"]\"%f\"%*\\D%l: %m,%f(%l) : %m,%*[^ ] %f %l: %m,%f:%l:%c:%m,%f(%l):%m,%f|%l| %m" - set makeprg=cmake -endfunction -command! -bang -nargs=0 -complete=file CmakeInit call s:CmakeInit() - -function! s:Doxygen() - set errorformat+=%f:%l:\ %m - set makeprg=doxygen -endfunction -command! -bang -nargs=0 -complete=file Doxygen call s:Doxygen() - -function! s:Iar() - set errorformat=%f(%l)\ :\ %m - set makeprg=vim-iarbuild.cmd -endfunction -command! -bang -nargs=0 -complete=file Iar call s:Iar() - " grep " file:line:coloumn:message set grepformat^=%f:%l:%c:%m @@ -220,29 +223,59 @@ packadd errormarker.vim packadd mesonic " UltiSnips -packadd ultisnips packadd vim-snippets - - -" Normal mode Mappings -nnoremap ; : -nnoremap : ; -nnoremap -nnoremap -nnoremap -nnoremap -nnoremap :bnext -nnoremap :bprev -nnoremap + :exe "resize " . (winheight(0) * 3/2) -nnoremap - :exe "resize " . (winheight(0) * 2/3) -nnoremap :nohlsearch:echo -nnoremap ev :vsplit $MYVIMRC -"nnoremap sv :source $MYVIMRC - -" Insert mode Mappings +packadd ultisnips +let g:UltiSnipsExpandTrigger="" +let g:UltiSnipsJumpForwardTrigger="" +let g:UltiSnipsJumpBackwardTrigger="" +let g:UltiSnipsEditSplit="vertical" + +" C/C++ IDE +packadd c-support + +" Jedi (python) +"packadd jedi-vim +"let g:polyglot_disabled = ['python'] +"let python_highlight_all = 1 + +" General Mappings +noremap +noremap +noremap +noremap +noremap :bn +noremap :bp +"noremap z :bp +"noremap q :bp +"noremap x :bn +"noremap w :bn +"noremap c :bd + +" Normal Mode Mappings +nnoremap ; : +nnoremap : ; +nnoremap n nzzzv +nnoremap N Nzzzv +nnoremap + :exe "resize " . (winheight(0) * 3/2) +nnoremap - :exe "resize " . (winheight(0) * 2/3) +nnoremap :noh +nnoremap ev :vsplit $MYVIMRC +"nnoremap sv :source $MYVIMRC +nnoremap sh :terminal +"nnoremap html :-1read ~/.vim/template/html3jwf>a +"nnoremap php :-1read ~/.vim/template/php2ja + + + + +"" Visual Mode Mappings +vmap < >gv + +" Insert Mode Mappings inoremap u -" Command mode Mappings +" Command Mode Mappings " Command aliases cnoreabbrev w!! w !sudo tee "%" @@ -255,8 +288,57 @@ tnoremap l tnoremap :bnext tnoremap :bprev +" Functions + +function! s:setupWrapping() + set wrapscan + set wrap + set wrapmargin=2 + set textwidth=79 +endfunction + +function! s:CmakeInit() + let &errorformat="%f(%l) : %t%*\\D%n: %m,%*[^\"]\"%f\"%*\\D%l: %m,%f(%l) : %m,%*[^ ] %f %l: %m,%f:%l:%c:%m,%f(%l):%m,%f|%l| %m" + set makeprg=cmake +endfunction +command! -bang -nargs=0 -complete=file CmakeInit call s:CmakeInit() + +function! s:Doxygen() + set errorformat+=%f:%l:\ %m + set makeprg=doxygen +endfunction +command! -bang -nargs=0 -complete=file Doxygen call s:Doxygen() + +function! s:Iar() + set errorformat=%f(%l)\ :\ %m + set makeprg=vim-iarbuild.cmd +endfunction +command! -bang -nargs=0 -complete=file Iar call s:Iar() + + " Autocommands if has('autocmd') + " c + augroup vimrc-c + autocmd! + autocmd FileType c setlocal tabstop=2 shiftwidth=2 expandtab + autocmd FileType cpp setlocal tabstop=2 shiftwidth=2 expandtab + augroup END + + " python + augroup vimrc-python + autocmd! + autocmd FileType python setlocal expandtab shiftwidth=4 tabstop=8 colorcolumn=79 + \ formatoptions+=croq softtabstop=4 + \ cinwords=if,elif,else,for,while,try,except,finally,def,class,with + augroup END + + " txt + augroup vimrc-txt + autocmd! + autocmd BufRead,BufNewFile *.txt call s:setupWrapping() + augroup END + augroup filetypes autocmd! autocmd bufnewfile,buffilepre,bufread *.md set filetype=markdown @@ -264,7 +346,7 @@ if has('autocmd') autocmd bufnewfile,buffilepre,bufread *.json set filetype=json autocmd bufnewfile,buffilepre,bufread *.yml set filetype=yaml augroup END - + augroup saveall autocmd! autocmd focuslost * wall @@ -295,11 +377,6 @@ if filereadable(expand('~/.vim/vimrc.local')) source ~/.vim/vimrc.local endif - " Load all plugins now. -" Plugins need to be added to runtimepath before helptags can be generated. packloadall -" Load all of the helptags now, after plugins have been loaded. -" All messages and errors will be ignored. silent! helptags ALL - -- 2.43.0