set breakindent showbreak=\ +
set shiftround
set formatoptions+=j
-set wrap
+set tabstop=4
+set softtabstop=0
+set shiftwidth=4
+set expandtab
" searching
set incsearch
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
set lazyredraw
set number
set relativenumber
-set titlestring=vim:\ %f
+
+set title
+set titlestring=%F
" folding
set foldmethod=syntax
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
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(<f-args>)
-
-function! s:Doxygen()
- set errorformat+=%f:%l:\ %m
- set makeprg=doxygen
-endfunction
-command! -bang -nargs=0 -complete=file Doxygen call s:Doxygen(<f-args>)
-
-function! s:Iar()
- set errorformat=%f(%l)\ :\ %m
- set makeprg=vim-iarbuild.cmd
-endfunction
-command! -bang -nargs=0 -complete=file Iar call s:Iar(<f-args>)
-
" grep
" file:line:coloumn:message
set grepformat^=%f:%l:%c:%m
packadd mesonic
" UltiSnips
-packadd ultisnips
packadd vim-snippets
-
-
-" Normal mode Mappings
-nnoremap ; :
-nnoremap : ;
-nnoremap <c-h> <c-w><c-h>
-nnoremap <c-j> <c-w><c-j>
-nnoremap <c-k> <c-w><c-k>
-nnoremap <c-l> <c-w><c-l>
-nnoremap <silent> <c-n> :bnext<cr>
-nnoremap <silent> <c-p> :bprev<cr>
-nnoremap <silent> <leader>+ :exe "resize " . (winheight(0) * 3/2)<cr>
-nnoremap <silent> <leader>- :exe "resize " . (winheight(0) * 2/3)<cr>
-nnoremap <silent> <cr> :nohlsearch<bar>:echo<cr>
-nnoremap <leader>ev :vsplit $MYVIMRC<cr>
-"nnoremap <leader>sv :source $MYVIMRC<cr>
-
-" Insert mode Mappings
+packadd ultisnips
+let g:UltiSnipsExpandTrigger="<tab>"
+let g:UltiSnipsJumpForwardTrigger="<tab>"
+let g:UltiSnipsJumpBackwardTrigger="<c-b>"
+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 <c-h> <c-w><c-h>
+noremap <c-j> <c-w><c-j>
+noremap <c-k> <c-w><c-k>
+noremap <c-l> <c-w><c-l>
+noremap <silent> <c-n> :bn<cr>
+noremap <silent> <c-p> :bp<cr>
+"noremap <leader>z :bp<CR>
+"noremap <leader>q :bp<CR>
+"noremap <leader>x :bn<CR>
+"noremap <leader>w :bn<CR>
+"noremap <leader>c :bd<CR>
+
+" Normal Mode Mappings
+nnoremap ; :
+nnoremap : ;
+nnoremap n nzzzv
+nnoremap N Nzzzv
+nnoremap <silent><leader>+ :exe "resize " . (winheight(0) * 3/2)<cr>
+nnoremap <silent><leader>- :exe "resize " . (winheight(0) * 2/3)<cr>
+nnoremap <silent><leader><space> :noh<cr>
+nnoremap <silent><leader>ev :vsplit $MYVIMRC<cr>
+"nnoremap <silent><leader>sv :source $MYVIMRC<cr>
+nnoremap <silent><leader>sh :terminal<CR>
+"nnoremap <silent><leader>html :-1read ~/.vim/template/html<CR>3jwf>a
+"nnoremap <silent><leader>php :-1read ~/.vim/template/php<CR>2ja
+
+
+
+
+"" Visual Mode Mappings
+vmap < <gv
+vmap > >gv
+
+" Insert Mode Mappings
inoremap <C-U> <C-G>u<C-U>
-" Command mode Mappings
+" Command Mode Mappings
" Command aliases
cnoreabbrev w!! w !sudo tee "%"
tnoremap <silent> <c-n> <C-\><C-n>:bnext<cr>
tnoremap <silent> <c-p> <C-\><C-n>:bprev<cr>
+" 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(<f-args>)
+
+function! s:Doxygen()
+ set errorformat+=%f:%l:\ %m
+ set makeprg=doxygen
+endfunction
+command! -bang -nargs=0 -complete=file Doxygen call s:Doxygen(<f-args>)
+
+function! s:Iar()
+ set errorformat=%f(%l)\ :\ %m
+ set makeprg=vim-iarbuild.cmd
+endfunction
+command! -bang -nargs=0 -complete=file Iar call s:Iar(<f-args>)
+
+
" 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
autocmd bufnewfile,buffilepre,bufread *.json set filetype=json
autocmd bufnewfile,buffilepre,bufread *.yml set filetype=yaml
augroup END
-
+
augroup saveall
autocmd!
autocmd focuslost * wall
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
-