summaryrefslogtreecommitdiffstats
path: root/makefu/2configs/editor/vimrc
blob: d270effa2eaa45c737afeaf0e1e4d55893a7365a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
set nocompatible
syntax on
set list
set listchars=tab:▸\ 
"set list listchars=tab:>-,trail:.,extends:>

filetype off
filetype plugin indent on

colorscheme desert
set background=dark

set number
set relativenumber
set mouse=a
set ignorecase
set incsearch
set wildignore=*.o,*.obj,*.bak,*.exe,*.os
set textwidth=79
set shiftwidth=2
set expandtab
set softtabstop=2
set shiftround
set smarttab
set tabstop=2
set et
set autoindent
set backspace=indent,eol,start


inoremap <F1> <ESC>
nnoremap <F1> <ESC>
vnoremap <F1> <ESC>

nnoremap <F5> :UndotreeToggle<CR>
set undodir  =~/.vim/undo
set undofile
"maximum number of changes that can be undone
set undolevels=1000000
"maximum number lines to save for undo on a buffer reload
set undoreload=10000000

nnoremap <F2> :set invpaste paste?<CR>
set pastetoggle=<F2>
set showmode

set showmatch
set matchtime=3
set hlsearch

autocmd ColorScheme * highlight ExtraWhitespace ctermbg=red guibg=red

let g:better_whitespace_enabled=1
let g:strip_whitespace_on_save=1


" save on focus lost
au FocusLost * :wa

autocmd BufRead *.json set filetype=json
au  BufNewFile,BufRead *.mustache set syntax=mustache

cnoremap SudoWrite w !sudo tee > /dev/null %

" create Backup/tmp/undo dirs
set backupdir=~/.vim/backup
set directory=~/.vim/tmp

function! InitBackupDir()
  let l:parent = $HOME    . '/.vim/'
  let l:backup = l:parent . 'backup/'
  let l:tmpdir = l:parent . 'tmp/'
  let l:undodir= l:parent . 'undo/'


  if !isdirectory(l:parent)
    call mkdir(l:parent)
  endif
  if !isdirectory(l:backup)
    call mkdir(l:backup)
  endif
  if !isdirectory(l:tmpdir)
    call mkdir(l:tmpdir)
  endif
  if !isdirectory(l:undodir)
    call mkdir(l:undodir)
  endif
endfunction
call InitBackupDir()

augroup Binary
  " edit binaries in xxd-output, xxd is part of vim
  au!
  au BufReadPre  *.bin let &bin=1
  au BufReadPost *.bin if &bin | %!xxd
  au BufReadPost *.bin set ft=xxd | endif
  au BufWritePre *.bin if &bin | %!xxd -r
  au BufWritePre *.bin endif
  au BufWritePost *.bin if &bin | %!xxd
  au BufWritePost *.bin set nomod | endif
augroup END


" youcompleteme
let g:ycm_collect_identifiers_from_tags_files = 1 " Let YCM read tags from Ctags file
let g:ycm_use_ultisnips_completer = 1 " Default 1, just ensure
let g:ycm_seed_identifiers_with_syntax = 1 " Completion for programming language's keyword
let g:ycm_complete_in_comments = 1 " Completion in comments
let g:ycm_complete_in_strings = 1 " Completion in string

" utilsnips
let g:UltiSnipsExpandTrigger       = "<c-j>"
let g:UltiSnipsJumpForwardTrigger  = "<c-j>"
let g:UltiSnipsJumpBackwardTrigger = "<c-p>"
let g:UltiSnipsListSnippets        = "<c-k>" "List possible snippets based on current file

hi MatchParen cterm=none ctermbg=green ctermfg=blue