DEVenv/Installer/_vimrc

261 lines
9.8 KiB
VimL
Raw Normal View History

" ==============================================================================
" Plugins
" ==============================================================================
2019-02-05 05:43:53 +00:00
let s:running_windows = has("win16") || has("win32") || has("win64")
if s:running_windows
let g:myvimdir ="~/vimfiles"
2020-07-20 13:27:23 +00:00
silent! call plug#begin('~/vimfiles/plugged')
else
let g:myvimdir ="~/.vim"
silent! call plug#begin('~/.vim/plugged')
2019-02-05 05:43:53 +00:00
endif
Plug 'https://github.com/ervandew/supertab'
Plug 'https://github.com/scrooloose/nerdtree', { 'on': 'NERDTreeToggle' }
Plug 'https://github.com/tpope/vim-fugitive'
Plug 'https://github.com/bfrg/vim-cpp-modern'
Plug 'https://github.com/skywind3000/asyncrun.vim'
Plug 'https://github.com/Yggdroot/LeaderF'
2020-11-03 03:23:01 +00:00
Plug 'https://github.com/rhysd/vim-clang-format'
2019-02-05 05:43:53 +00:00
" Themes
Plug 'https://github.com/tomasr/molokai'
Plug 'https://github.com/roosta/vim-srcery'
Plug 'https://github.com/morhetz/gruvbox'
call plug#end()
" ==============================================================================
" Settings
" ==============================================================================
set nocompatible
2019-02-05 05:43:53 +00:00
set autowrite " Automatically save before commands like :next and :make
set autoread " Auto reload changed files
set backspace=2 " Backspace like most programs in insert mode
set hidden " Allow more than one modified buffer to be left without saving
set incsearch " Do incremental searching
set ignorecase " Search isn't case sensitive
set lazyredraw " Redraw the screen less often
set nowrap " No softwrapping by default
set splitright " Open new v-splits to the right
set showcmd " Display incomplete commands
set vb " Turn on screen flash which is quieter than audio bell
set wildmenu " Allow vim command-line autocompletion
set wildmode=full " Specifies option for wildmenu
set expandtab " Turn tabs into spaces
set noswapfile " Disable swapfile
set cscopetag " Search both cscopes db and tags file"
" Ignore files in commandline autocomplete
set wildignore+=*.class,*.o
set wildignore+=*\\tmp\\*,*.swp,*.zip,*.exe,*.obj,*.vcxproj,*.pdb,*.idb
" Undo Settings
silent! set undofile " Save undo history to file
set undolevels=1000 " Maximum number of undos that can be done
let &undodir=expand(g:myvimdir."/undodir") " Set location to save undo files
" Create the undo history folder if it doesn't exist
if !isdirectory(expand(&undodir))
call mkdir(expand(&undodir), "p")
endif
" ==============================================================================
" Appearance
" ==============================================================================
syntax on " syntax highlighting
set autoindent " Always use autoindent
set background=dark " Some themes use this indicator to theme themselves
set colorcolumn=80,100 " Set a 80, 100 char column marker
set cpoptions+=$ " $ as end marker for the change operator
set cursorline " Highlight current line
set encoding=utf-8 " Consistent character encoding
set fileformats=unix,dos
set foldlevelstart=99 " Initially all folds open
set foldmethod=indent " Allow folding of
set foldnestmax=1 " Maximum number of nested folds
set guioptions= " remove extra gui elements
set laststatus=2 " always show status bar
set linebreak " When wrapping lines, don't break words
set list " Show 'listchar' characters
set number " Show line numbers
set relativenumber " Show relative line numbers
set ruler " show the cursor position all the time
set shiftwidth=4 " Number of space chars for indentation
set showmatch " automatically show matching brackets. works like it does in bbedit.
set smartindent
set smarttab " Make 'tab' insert indents at the beginning of a line
set tabstop=4 " Number of space chars for pressing tab
set textwidth=80 " Always format to 80 chars
set listchars=tab:>-
2019-02-05 05:43:53 +00:00
" Show EOL type and last modified timestamp, right after the filename
set statusline=%<%F%h%m%r\ [%{&ff}]\ (%{strftime(\"%H:%M\ %d/%m/%Y\",getftime(expand(\"%:p\")))})%=%l,%c%V\ %P
" Resize splits when the window is resized
au VimResized * :wincmd =
" ==============================================================================
" Theme
" ==============================================================================
2019-02-05 05:43:53 +00:00
let g:gruvbox_contrast_dark='hard'
let g:gruvbox_italic=0
let g:gruvbox_bold=0
colorscheme gruvbox
if has("gui_running")
" NOTE(doyle): Some list chars in gui don't show correctly in terminal so separate logic
" old listchars=tab:>-,eol:¬,trail:■,extends:»,precedes:«
set listchars+=trail:■,extends,precedes
if s:running_windows
set guifont=Consolas:h11
else
set guifont=InputMonoCondensed:h10
endif
" Don't show trailing spaces in insert mode
augroup trailing
au!
au InsertEnter * :set listchars-=trail:■
au InsertLeave * :set listchars+=trail:■
augroup END
" Increase font size using (Ctrl+Up Arrow) or (Ctrl+Down Arrow) if we are using
" gvim Otherwise font size is determined in terminal
nnoremap <C-Up> :silent! let &guifont = substitute(
\ &guifont,
\ ':h\zs\d\+',
\ '\=eval(submatch(0)+1)',
\ 'g')<CR>
nnoremap <C-Down> :silent! let &guifont = substitute(
\ &guifont,
\ ':h\zs\d\+',
\ '\=eval(submatch(0)-1)',
\ 'g')<CR>
2019-02-05 05:43:53 +00:00
else
set t_Co=256 " 256 colors
let &t_AB="\e[48;5;%dm" " vodoo magic for CONEMU
let &t_AF="\e[38;5;%dm" " vodoo magic for CONEMU
2019-02-05 05:43:53 +00:00
set listchars+=trail:$,extends:>,precedes:<
2019-02-05 05:43:53 +00:00
" Fix Cmder backspace bug
inoremap <Char-0x07F> <BS>
nnoremap <Char-0x07F> <BS>
2019-02-05 05:43:53 +00:00
endif
" Formatting options (see :h fo-table)
2019-02-05 05:43:53 +00:00
augroup persistent_settings
au!
au BufEnter * :set formatoptions=q1j
augroup END
" ==============================================================================
" Key Bindings
" ==============================================================================
2019-02-05 05:43:53 +00:00
" Enable mouse support
if has('mouse')
set mouse=a
endif
" Map Ctrl+HJKL to navigate buffer window
nmap <silent> <C-h> :wincmd h<CR>
nmap <silent> <C-j> :wincmd j<CR>
nmap <silent> <C-k> :wincmd k<CR>
nmap <silent> <C-l> :wincmd l<CR>
" Move by wrapped lines instead of line numbers
nnoremap j gj
nnoremap k gk
nnoremap gj j
nnoremap gk k
" Map NERDTree to Ctrl-N
map <C-n> :NERDTreeToggle<CR>
" Change to current buffer's directory
nmap cd :cd <C-R>=expand("%:p:h")<CR><CR>
" Buffer Splitting
2019-02-05 05:43:53 +00:00
nnoremap <leader>s :vs<CR>
" Go to next error
" Go to previous error
nnoremap <A-n> :cn<CR>
nnoremap <A-p> :cp<CR>
" Fullscreen
2019-02-05 05:43:53 +00:00
if s:running_windows
2020-11-03 02:52:22 +00:00
noremap <f11> <esc>:call libcallnr('gvim_fullscreen.dll', 'ToggleFullScreen', 0)<cr>
2019-02-05 05:43:53 +00:00
endif
" ==============================================================================
" Leaderf
" ==============================================================================
" Config
let g:Lf_MruFileExclude = ['*.so', '*.tmp', '*.bak', '*.exe', '*.dll']
" Bindings
nnoremap <leader>b :<C-U><C-R>=printf("Leaderf buffer %s", "")<CR><CR>
nnoremap <leader>f :<C-U><C-R>=printf("Leaderf file %s", "")<CR><CR>
nnoremap <leader>l :<C-U><C-R>=printf("Leaderf line %s", "")<CR><CR>
nnoremap <leader>m :<C-U><C-R>=printf("Leaderf mru %s", "")<CR><CR>
nnoremap <leader>p :<C-U><C-R>=printf("Leaderf function %s", "")<CR><CR>
nnoremap <leader>t :<C-U><C-R>=printf("Leaderf tag %s", "")<CR><CR>
nnoremap <leader>h :<C-U><C-R>=printf("Leaderf self %s", "")<CR><CR>
noremap <C-P> :<C-U><C-R>=printf("Leaderf bufTag %s", "")<CR><CR>
noremap <C-F> :<C-U><C-R>=printf("Leaderf! rg -e %s ", expand("<cword>"))<CR>
" ==============================================================================
" Clang Format
" ==============================================================================
2020-11-03 03:23:01 +00:00
map <C-I> :ClangFormat<CR>
imap <C-I> <ESC>:ClangFormat<CR>i
2019-02-05 05:43:53 +00:00
" ==============================================================================
" Compiling / AsyncRun
" ==============================================================================
" Asyncrun open quickfix window up to 10 lines
let g:asyncrun_open = 10
2019-02-05 05:43:53 +00:00
" Error message formats thanks to
" https://forums.handmadehero.org/index.php/forum?view=topic&catid=4&id=704#3982
set errorformat+=\\\ %#%f(%l\\\,%c):\ %m " MSVC: MSBuild
set errorformat+=\\\ %#%f(%l)\ :\ %#%t%[A-z]%#\ %m " MSVC: cl.exe
set errorformat+=\\\ %#%t%nxx:\ %m " MSVC: cl.exe, fatal errors is crudely implemented
set errorformat+=\\\ %#LINK\ :\ %m " MSVC: link.exe, can't find link library badly implemented
set errorformat+=\\\ %#%s\ :\ error\ %m " MSVC: link.exe, errors is badly implemented
set errorformat+=\\\ %#%s\ :\ fatal\ error\ %m " MSVC: link.exe, fatal errors is badly implemented
set errorformat+=\\\ %#%f(%l\\\,%c-%*[0-9]):\ %#%t%[A-z]%#\ %m " MSVC: HLSL fxc.exe
set errorformat+=%\\%%(CTIME%\\)%\\@=%m " ctime.exe -stats
if s:running_windows
set makeprg=build
2020-10-20 02:10:40 +00:00
nnoremap <f5> :AsyncRun ./build.bat<cr>
2019-02-05 05:43:53 +00:00
else
2020-07-22 01:02:05 +00:00
" Set vim terminal to enter normal mode using escape like normal vim behaviour
tnoremap <Esc> <C-\><C-n>
2020-10-20 02:10:40 +00:00
nnoremap <f5> :AsyncRun ./build.sh<cr>
2019-02-05 05:43:53 +00:00
set makeprg=./build.sh
endif
" ==============================================================================
" Other
" ==============================================================================
" Reload vimrc when it's edited
augroup myvimrc
au!
au BufWritePost $MYVIMRC so $MYVIMRC
augroup end
2020-10-20 02:13:25 +00:00
" Return to the same line when a file is reopened
augroup line_return
au!
au BufReadPost *
\ if line("'\"") > 0 && line("'\"") <= line("$") |
\ execute 'normal! g`"zvzz' |
\ endif
augroup end