diff --git a/README.md b/README.md index 920cfd7..76612c9 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ ## Install vim-ide ```bash -git clone --recurse-submodules https://github.com/nuccleon/vim-ide.git +git clone --recurse-submodules https://github.com/beckenc/vim-ide.git ``` ### .. for current user @@ -37,4 +37,5 @@ git clone --recurse-submodules https://github.com/nuccleon/vim-ide.git * https://devhints.io/vimscript * https://learnvimscriptthehardway.stevelosh.com +* https://docs.microsoft.com/de-de/windows/terminal/tutorials/powerline-setup diff --git a/install.sh b/install.sh index 16687ec..4f659f4 100755 --- a/install.sh +++ b/install.sh @@ -1,5 +1,5 @@ #!/bin/bash -set -ue +set -u DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)" @@ -29,6 +29,7 @@ let \$MYVIMRCPATH = "$DIR/vimrc" let vimrc_misc = 1 let vimrc_keymap = 1 +let vimrc_hard_ass = 1 let vimrc_functions = 1 let vimrc_commands = 1 let vimrc_filetypes = 1 @@ -46,6 +47,10 @@ if 1 == vimrc_keymap so $DIR/vimrc/keymap.vim endif +if 1 == vimrc_hard_ass + so $DIR/vimrc/hard_ass.vim +endif + if 1 == vimrc_functions so $DIR/vimrc/functions.vim endif @@ -84,8 +89,12 @@ done echo "Update plugins .." vim -N -u "$DIR"/vimrc/plugins.vim -c "set packpath^=$DIR" -c "PackInstall" +if [ $? -ne 0 ]; then + echo "PackInstall failed. Minpack installed? (see README.md)" + exit 1 +fi echo "Update helptags .." -vim -N -u "$DIR"/vimrc/plugins.vim -c "silent! helptags ALL" -c "quit!" +vim -N -u "$DIR"/vimrc/plugins.vim -c "silent! helptags ALL" -c "quitall!" exit 0 diff --git a/pack/minpac/opt/minpac b/pack/minpac/opt/minpac index 544f2e6..093f008 160000 --- a/pack/minpac/opt/minpac +++ b/pack/minpac/opt/minpac @@ -1 +1 @@ -Subproject commit 544f2e642e55a764d144e97e8fb040cebef14948 +Subproject commit 093f00891aeb04e98ceb5a541885d025c9fae169 diff --git a/vimrc/commands.vim b/vimrc/commands.vim index cf022ea..c96e688 100644 --- a/vimrc/commands.vim +++ b/vimrc/commands.vim @@ -10,4 +10,4 @@ command QuickFixToggle call QuickFixToggle() " :W sudo saves the file " (useful for handling the permission-denied error) " command! W execute 'w !sudo tee % > /dev/null' edit! -"command! W w !sudo tee "%" > /dev/null +command! W w !sudo tee "%" > /dev/null diff --git a/vimrc/filetypes.vim b/vimrc/filetypes.vim index 367ea36..e2e6cd7 100644 --- a/vimrc/filetypes.vim +++ b/vimrc/filetypes.vim @@ -7,8 +7,8 @@ augroup filetype_generic autocmd! " Automatically remove all trailing spaces for all file types - autocmd BufWritePre * :call TrimWhiteSpace() - "autocmd BufWritePre *.txt,*.js,*.py,*.wiki,*.sh,*.md,*.cpp,*.h,*.hpp,*.c,*.mk,*.vim :call TrimWhiteSpace() + " autocmd BufWritePre * :call TrimWhiteSpace() + autocmd BufWritePre *.txt,*.js,*.py,*.wiki,*.sh,*.md,*.cpp,*.h,*.hpp,*.c,*.mk,*.vim :call TrimWhiteSpace() " When editing a file, always jump to the last known cursor position. " Don't do it when the position is invalid or when inside an event handler @@ -17,6 +17,9 @@ augroup filetype_generic \ if line("'\"") > 0 && line("'\"") <= line("$") | \ exe "normal g`\"" | \ endif + + " Re-source .vimrc on saving + autocmd! BufWritePost $MYVIMRCPATH/*.vim source ~/.vimrc augroup END augroup filetype_vim @@ -33,7 +36,7 @@ augroup END augroup filetype_cpp autocmd! autocmd FileType cpp setlocal shiftwidth=2 tabstop=2 softtabstop=2 - autocmd FileType cpp setlocal filetype=cpp.doxygen + autocmd FileType cpp setlocal filetype=cpp autocmd FileType cpp setlocal spelllang=en augroup END diff --git a/vimrc/hard_ass.vim b/vimrc/hard_ass.vim new file mode 100644 index 0000000..0d5f26c --- /dev/null +++ b/vimrc/hard_ass.vim @@ -0,0 +1,13 @@ + +" File: hard_ass.vim +" Descritpion: source this, to use vim the hard way +" ============================================================================= + +" ============================================================================= +" Section: Disable arrow keys for navigation +" ============================================================================= +for key in ['', '', '', ''] + exec 'noremap' key '' +" exec 'inoremap' key '' + exec 'cnoremap' key '' +endfor diff --git a/vimrc/keymap.vim b/vimrc/keymap.vim index 09ad6f5..d115029 100644 --- a/vimrc/keymap.vim +++ b/vimrc/keymap.vim @@ -1,4 +1,4 @@ -" ============================================================================= + " File: keymap.vim " Descritpion: Keymap configuration " ============================================================================= @@ -73,21 +73,42 @@ nnoremap tm :tabm nnoremap tt :tabnew nnoremap to :tabonly! -nnoremap :tabnew -nnoremap :confirm bdelete +"nnoremap :tabnew +nnoremap :confirm bdelete:tabclosegT " Open tag under cursor in new tab "noremap :tab split:exec("tag ".expand("")) +nmap 1 AirlineSelectTab1 +nmap 2 AirlineSelectTab2 +nmap 3 AirlineSelectTab3 +nmap 4 AirlineSelectTab4 +nmap 5 AirlineSelectTab5 +nmap 6 AirlineSelectTab6 +nmap 7 AirlineSelectTab7 +nmap 8 AirlineSelectTab8 +nmap 9 AirlineSelectTab9 + +" ============================================================================= +" Section: Buffer navigation +" ============================================================================= +nnoremap n :bnext +nnoremap p :bprevious +nnoremap c :confirm bdelete:tabclosegT + " ============================================================================= " Section: Window navigation " ============================================================================= -" Select window with Alt- Up/Down/Let/Right -nnoremap :wincmd k -nnoremap :wincmd j -nnoremap :wincmd h -nnoremap :wincmd l +" Select window with Alt- Up/Down/Left/Right +nnoremap k :wincmd k +inoremap k :wincmd ki +nnoremap j :wincmd j +inoremap j :wincmd ji +nnoremap h :wincmd h +inoremap h :wincmd hi +nnoremap l :wincmd l +inoremap l :wincmd li " Split window with Leader - and | noremap - :split @@ -104,9 +125,13 @@ inoremap nnoremap :YcmCompleter GoTo nnoremap :YcmCompleter GoToReferences nnoremap :YcmForceCompileAndDiagnostics +nnoremap gt :YcmCompleter GetType +nnoremap gd :YcmCompleter GetDoc " Look for files under current directory -nnoremap :FZF +nnoremap :FZF +" prevent opening FZF search result in NERD Tree +nnoremap (expand('%') =~ 'NERD_tree' ? "\\" : "").":FZF\" " ============================================================================= " Section: Formatting diff --git a/vimrc/misc.vim b/vimrc/misc.vim index 912f9d4..e0d9e24 100644 --- a/vimrc/misc.vim +++ b/vimrc/misc.vim @@ -74,21 +74,21 @@ set hlsearch " ============================================================================= " Set swap directory -if !isdirectory("~/.vim/swap") - silent !mkdir -p ~/.vim/swap +if !isdirectory($HOME."/.vim/swap") + call mkdir($HOME."/.vim/swap", "p", 0700) endif set directory=~/.vim/swap " Set backup directory -if !isdirectory("~/.vim/backup") - silent !mkdir -p ~/.vim/backup +if !isdirectory($HOME."/.vim/backup") + call mkdir($HOME."/.vim/backup", "p", 0700) endif set backupdir=~/.vim/backup set backup " Set undo directory -if !isdirectory("~/.vim/undo") - silent !mkdir -p ~/.vim/undo +if !isdirectory($HOME."/.vim/undo") + call mkdir($HOME."/.vim/undo", "p", 0700) endif set undodir=~/.vim/undo set undofile @@ -134,6 +134,9 @@ set noshowmode " Always show tabline set showtabline=2 +" Always show signcolumn +set signcolumn=yes + " Set utf8 as standard encoding set encoding=utf8 @@ -150,6 +153,8 @@ else colorscheme wombat endif set background=dark +" WSL workaround, google: VIM backround colors render incorrectly +set t_ut= if has('gui_running') set t_Co=256 diff --git a/vimrc/plugins.vim b/vimrc/plugins.vim index 35266b0..6decdaa 100644 --- a/vimrc/plugins.vim +++ b/vimrc/plugins.vim @@ -7,12 +7,17 @@ " Section: Minimal package manager " ============================================================================= -function! PackInit() abort +function! PackInit(verbose_level) abort packadd minpac - if exists('*minpac#init') + if !exists('g:loaded_minpac') + " minpac is not available. + " Settings for plugin-less environment + echoerr "minpac is not available" + cq 1 + else " Initialize minpac - call minpac#init({'verbose': '3'}) + call minpac#init({'verbose': a:verbose_level, 'status_auto': 'TRUE', 'progress_open': 'vertical', 'status_open': 'vertical'}) " Minimal package manager call minpac#add('k-takata/minpac', {'type': 'opt'}) @@ -20,8 +25,9 @@ function! PackInit() abort call minpac#add('scrooloose/nerdtree') " Syntax checking hacks for vim. call minpac#add('scrooloose/syntastic') - " A command-line fuzzy finder - call minpac#add('junegunn/fzf',{'do': 'call fzf#install()'}) + " A command-line fuzzy finder (pickup fzf binary available on the system. If it is not found in $PATH, + " it will ask if it should download the latest binary + call minpac#add('junegunn/fzf') " lean & mean status/tabline for vim that's light as air call minpac#add('vim-airline/vim-airline') call minpac#add('vim-airline/vim-airline-themes') @@ -36,26 +42,38 @@ function! PackInit() abort " A class outline viewer for Vim call minpac#add('majutsushi/tagbar') " A code-completion engine for Vim - call minpac#add('ycm-core/YouCompleteMe',{'do': {-> system('./install.py --clangd-completer')}}) + if has('python3') + call minpac#add('ycm-core/YouCompleteMe',{'do': {-> system('./install.py --clangd-completer')}}) + else + echomsg "YouCompleteMe needs vim compiled with python support" + endif + " Vim plugin for clang-format, a formatter for C, C++, Obj-C, Java, JavaScript, TypeScript and ProtoBuf. + call minpac#add('rhysd/vim-clang-format') " Cosmetics call minpac#add('vim-scripts/Wombat') call minpac#add('vim-scripts/wombat256.vim') - else - echoerr "minpac is not available" - cq + " Template + call minpac#add('gentoo/gentoo-syntax') + call minpac#add('kergoth/vim-bitbake') + call minpac#add('edkolev/tmuxline.vim') endif endfunction +" ============================================================================= +" Section: edkolev/tmuxline.vim +" ============================================================================= +let g:airline#extensions#tmuxline#enabled = 0 + " ============================================================================= " Section: k-takata/minpac " ============================================================================= " Define minpac user commands -command! PackUpdate call PackInit() | call minpac#update('', {'do': 'call minpac#status()'}) -command! PackClean call PackInit() | call minpac#clean() -command! PackStatus call PackInit() | call minpac#status() -command! PackInstall call PackInit() | call minpac#update('', {'do': 'quit'}) +command! PackUpdate call PackInit(4) | call minpac#update() +command! PackClean call PackInit(3) | call minpac#clean() +command! PackStatus call PackInit(3) | call minpac#status() +command! PackInstall call PackInit(4) | call minpac#update('', {'do': 'quitall!'}) " ============================================================================= " Section: scrooloose/nerdtree @@ -80,6 +98,7 @@ let g:syntastic_check_on_wq = 0 " ============================================================================= " Section: junegunn/fzf " ============================================================================= +let g:fzf_layout = { 'down': '30%' } " ============================================================================= " Section: majutsushi/tagbar @@ -91,17 +110,58 @@ let g:syntastic_check_on_wq = 0 " ============================================================================= " Section: ycm-core/YouCompleteMe " ============================================================================= -let g:ycm_complete_in_comments = 0 -let g:ycm_complete_in_strings = 0 +let g:ycm_complete_in_comments = 1 +let g:ycm_complete_in_strings = 1 +let g:ycm_max_num_candidates = 10 +let g:ycm_max_num_identifiers_candidates = 10 let g:ycm_autoclose_preview_window_after_completion = 1 let g:ycm_autoclose_preview_window_after_insertion = 1 +" want to just turn off the identifier completer but keep the semantic trigger (. or ->) active +let g:ycm_min_num_of_chars_for_completion = 99 +let g:ycm_key_list_stop_completion = ['', ''] + +" ============================================================================= +" Section: rhysd/vim-clang-format +" ============================================================================= +" automatically detect .clang-format / _clang-format in project's root +let g:clang_format#detect_style_file = 1 +" automatically format buffer on save +let g:clang_format#auto_format = 1 +" If autodetect of .clang-format / _clang-romat failes, use that settings +let g:clang_format#code_style = "microsoft" +let g:clang_format#style_options = { + \ "AllowShortBlocksOnASingleLine" : "true", + \ "AllowShortCaseLabelsOnASingleLine" : "true", + \ "AllowShortFunctionsOnASingleLine" : "true", + \ "BraceWrapping" : { + \ "AfterCaseLabel" : "true", + \ "SplitEmptyFunction" : "false", + \ "SplitEmptyRecord" : "false", + \ "SplitEmptyNamespace" : "false", + \ "AfterUnion" : "true" }, + \ "PointerAlignment" : "Left", + \ "BreakInheritanceList" : "BeforeComma", + \ "BreakConstructorInitializers" : "BeforeComma", + \ "CompactNamespaces" : "true", + \ "IndentCaseLabels" : "true", + \ "NamespaceIndentation" : "All", + \ "ConstructorInitializerIndentWidth" : 2, + \ "ContinuationIndentWidth" : 2, + \ "IndentWidth" : 2, + \ "TabWidth" : 2 } " ============================================================================= " Section: vim-airline " ============================================================================= let g:airline_powerline_fonts = 1 -let g:airline_theme = 'wombat' + +if !exists('g:airline_symbols') + let g:airline_symbols = {} +endif + let g:airline#extensions#tabline#enabled = 1 +let g:airline#extensions#tabline#buffer_idx_mode = 1 +let g:airline_theme='wombat' let g:airline#extensions#tabline#formatter = 'unique_tail'