summaryrefslogtreecommitdiffstats
path: root/root/.vimrc
blob: d8bc435dc7d1d85629330353ef462bc12254ac93 (plain) (blame)
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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
" An example for a vimrc file.
"
" Maintainer:	Bram Moolenaar <Bram@vim.org>
" Last change:	2017 Sep 20
"
" To use it, copy it to
"     for Unix and OS/2:  ~/.vimrc
"	      for Amiga:  s:.vimrc
"  for MS-DOS and Win32:  $VIM\_vimrc
"	    for OpenVMS:  sys$login:.vimrc

set nocompatible              " be iMproved, required
filetype off                  " required

" When started as "evim", evim.vim will already have done these settings.
if v:progname =~? "evim"
  finish
endif

" Get the defaults that most users want.
source $VIMRUNTIME/defaults.vim

if has("vms")
  set nobackup		" do not keep a backup file, use versions instead
else
  set backup		" keep a backup file (restore to previous version)
  if has('persistent_undo')
    set undofile	" keep an undo file (undo changes after closing)
  endif
endif

if &t_Co > 2 || has("gui_running")
  " Switch on highlighting the last used search pattern.
  set hlsearch
endif

" Only do this part when compiled with support for autocommands.
if has("autocmd")

  " Put these in an autocmd group, so that we can delete them easily.
  augroup vimrcEx
  au!

  " For all text files set 'textwidth' to 78 characters.
  autocmd FileType text setlocal textwidth=0

  augroup END

else

  set autoindent		" always set autoindenting on

endif " has("autocmd")

" Add optional packages.
"
" The matchit plugin makes the % command work better, but it is not backwards
" compatible.
" The ! means the package won't be loaded right away but when plugins are
" loaded during initialization.
if has('syntax') && has('eval')
  packadd! matchit
endif

set tabstop=8
set shiftwidth=8

set backupdir=.backup//,~/.vim/backup//,/tmp//
set directory=.swp//,~/.vim/swp//,/tmp//
set undodir=.undo//,~/.vim/undo//,/tmp//

function! TextEnableCodeSnip(filetype,start,end,textSnipHl) abort
  let ft=toupper(a:filetype)
  let group='textGroup'.ft
  if exists('b:current_syntax')
    let s:current_syntax=b:current_syntax
    " Remove current syntax definition, as some syntax files (e.g. cpp.vim)
    " do nothing if b:current_syntax is defined.
    unlet b:current_syntax
  endif
  execute 'syntax include @'.group.' syntax/'.a:filetype.'.vim'
  try
    execute 'syntax include @'.group.' after/syntax/'.a:filetype.'.vim'
  catch
  endtry
  if exists('s:current_syntax')
    let b:current_syntax=s:current_syntax
  else
    unlet b:current_syntax
  endif
  execute 'syntax region textSnip'.ft.'
  \ matchgroup='.a:textSnipHl.'
  \ keepend
  \ start="'.a:start.'" end="'.a:end.'"
  \ contains=@'.group
endfunction

call TextEnableCodeSnip('javascript', '@begin=js@', '@end=js@', 'comment')
call TextEnableCodeSnip('html', '@begin=html@', '@end=html@', 'comment')
call TextEnableCodeSnip('html', '<!DOCTYPE html>', '</html>', 'comment')
syn sync fromstart

function OnWrite()
	" echom fnamemodify(expand("%:p"), ":r")
	if (&ft == 'tex' && match(readfile(expand("%:p")), "do-vimlatex-onwrite")!=-1)
		" :silent !~/projects/doc/f5ff.sh %:p:r > stdout.log 2> stderr.log &
		:silent !pdflatex -shell-escape %:p:r > stdout.log 2> stderr.log &
		" preveč dela, če bi zaganjali f5ff.sh - med urejanjem itak ne
		" rabimo časa generiranja ampak predvsem hitrost
	endif
endfunction

function OnRead()
	if (&ft == 'tex' || &ft == 'php')
		setl nocin nosi inde=
		" :silent !firefox %:p:r.pdf &
	endif
endfunction

function OnMekiC()
	:silent !firefox %:p:r.pdf > /dev/null 2>&1 &
	:redraw!
endfunction

function OnF8()
	:silent !xdotool search --class Chrome windowactivate --sync %1 key F5 windowactivate $(xdotool getactivewindow)

endfunction

autocmd BufWritePost * call OnWrite()
autocmd BufReadPost,FileReadPost * call OnRead()
" nnoremap ć :call OnMekiC()<CR><LF>
nnoremap <F8> :call OnF8()<CR><LF>
nnoremap ;s :set spell spelllang=sl<CR><LF> 
nnoremap ;a :set spell spelllang=en<CR><LF>
nnoremap ;n :set spell spelllang=de<CR><LF>
nnoremap ;i :set spell nospell<CR><LF>
map <C-j> <200b>
function SpellSet(language)
	set spell spelllang=en_us
endfunction
set breakindent
function TurnWrapOn()
	setlocal wrap linebreak nolist
	set virtualedit=
	setlocal display+=lastline
	nnoremap  <buffer> <Up>   gk
	nnoremap  <buffer> <Down> gj
	nnoremap  <buffer> <Home> g<Home>
	nnoremap  <buffer> <End>  g<End>
	inoremap <buffer> <Up>   <C-o>gk
	inoremap <buffer> <Down> <C-o>gj
	inoremap <buffer> <Home> <C-o>g<Home>
	inoremap <buffer> <End>  <C-o>g<End>
endfunction
call TurnWrapOn()
noremap <silent> <Leader>w :call ToggleWrap()<CR>
function ToggleWrap()
  if &wrap
    echo "Wrap OFF"
    setlocal nowrap
    set virtualedit=all
    silent! nunmap <buffer> <Up>
    silent! nunmap <buffer> <Down>
    silent! nunmap <buffer> <Home>
    silent! nunmap <buffer> <End>
    silent! iunmap <buffer> <Up>
    silent! iunmap <buffer> <Down>
    silent! iunmap <buffer> <Home>
    silent! iunmap <buffer> <End>
  else
		echo "Wrap ON"
		call TurnWrapOn()
	endif
endfunction

"""""" vim-tex
let g:Imap_UsePlaceHolders = 0
let g:Tex_SmartKeyBS = 0
let g:Tex_SmartKeyQuote = 0
let g:Tex_SmartKeyDot = 0
let g:Tex_Leader = '`tex'
let g:Tex_Leader2 = ',tex'
let g:Imap_FreezeImap=1
" cross terminal copy
set clipboard+=unnamed
set ignorecase
set smartcase
hi Search cterm=NONE ctermfg=grey ctermbg=blue
hi Comment cterm=NONE ctermfg=cyan ctermbg=NONE
hi SpellBad cterm=NONE ctermfg=black ctermbg=magenta
hi SpellCap cterm=NONE ctermfg=black ctermbg=cyan
hi Visual cterm=NONE ctermfg=black ctermbg=white gui=none
map  <C-Left>
map  <C-Right>
map OA <C-Up>
map  <C-Down>
hi MatchParen cterm=none ctermbg=green ctermfg=blue
au FileType tex setlocal nonumber
au FileType tex setlocal norelativenumber
nnoremap đ <C-w>w
inoremap đ <C-o><C-w>w
set breakindentopt=shift:8,min:40,sbr
" colorscheme peachpuff " <<< za belo x11 okno
colorscheme koehler
" autocmd ModeChanged * {
" 	if mode() == 'v'
" 		set number
" 		set rnu
" 	else
" 		set nornu
" 		set nonumber
" 	endif
" }
set number
set rnu
" disable hard wrap
set textwidth=0

au BufNewFile,BufRead *.frag,*.vert,*.fp,*.vp,*.glsl setf glsl
if has("gui_running")
	set guioptions -=m " menubar
	set guioptions -=T " toolbar
	set guioptions -=r " no scrollbar
endif

let g:python_recommended_style = 0
let g:markdown_recommended_style = 0
syntax on

autocmd FileType python set tabstop=2
autocmd FileType python set shiftwidth=2

set guifont=terminus\ 12

let g:rust_recommended_style = 0

set modeline
set modelines=5
set modelineexpr
au FileType xml setlocal equalprg=xmllint\ --format\ --recover\ -\ 2>/dev/null