"
" MisoFov .vimrc verzia 1.1
"
" Note: ak vsetko funguje, mali by po otvoreni vo vimku byt jednotlive casti
" tohto .vimrc foldnute.
"
" Zakladna praca s foldmi:
" 'zo' na prislusnej ciare fold otvori, 'zc' zavrie, <Ins> otvori a zapne i mod
" 'zR', 'zM' otvori/zavrie uplne vsetko
" vid :help folding
" ======================================================================================================
" Pre istotu na uvod zopar nastaveni, ktore by mali byt standardne, ale jeden nikdy nevie: {{{
set nocompatible " prudko chceme nove ficurie oproti vi...
set bs=2 " backspace by mohol fungovat
set autoindent
set history=50 " pamata sa 50 poslednych prikazov
set ruler " pozicia kurzoru v spodnom riadku
map Q gq " Ex modu sa vyhneme, dobrym zvykom v sucasnosti je aby Q = gq
syntax on " zapneme syntax highlighting
" }}}
" ======================================================================================================
" Niekolko drobnych nastaveni -- indent, tw, farby, autowrite, atd.: {{{
" mne sa paci odsadzovanie o dve medzery
set shiftwidth=2
set expandtab
set softtabstop=2
" zalamovanie na sirku 100 znakov
set textwidth=100
" moj terminal ma tmave pozadie, chcem vidiet komentare
set background=dark
" takto sa da natvrdo povedat aby mal cierne pozadie:
" highlight Normal guibg=black guifg=white ctermbg=black ctermfg=white
" nech netreba save pred kazdym kompilovanim
set autowrite
" co s tabom v prikazovom riadku, ked je viac moznosti? nech nam ich pekne ukaze!
set wildmenu
" kopirovane (a mazane) veci idu do systemoveho clipboardu a von z vim
set clipboard=unnamed
" }}}
" ======================================================================================================
" Vyhladavanie zobrazuje priebezne prvy match, inteligentna case sensitivity: {{{
set incsearch
set ignorecase
set smartcase
set nohlsearch " irituje ma ked mi pol textu svieti
" }}}
" ======================================================================================================
" Timeout na mapovane prikazy -- 200 milisekund musi stacit: {{{
set timeout
set timeoutlen=200
" }}}
" ======================================================================================================
" Posledne riadky obrazovky -- lastline a statusline: {{{
" ukaz z posledneho riadku co sa ti vojde, nie len zavinace, divne znaky pis <13>, nie ^M
set display+=lastline
set display+=uhex
" statuslajna: chceme ju furt, biela na modrom pozadi, je tam navyse ascii kod akt. pismena
set statusline=%<%f%h%m%r%=char=%b=0x%B\ \ %l,%c%V\ %P
set laststatus=2
set highlight+=s:MyStatusLineHighlight
highlight MyStatusLineHighlight ctermbg=darkblue ctermfg=white
" }}}
" ======================================================================================================
" Konverzia prave editovaneho suboru do HTML: {{{
command ConvertToHTML so $VIMRUNTIME/syntax/2html.vim
" }}}
" ======================================================================================================
" <Tab> na konci slova funguje na automaticke doplnanie: {{{
function! My_Tab_Completion()
if col('.')>1 && strpart( getline('.'), col('.')-2, 3 ) =~ '^\w'
return "\<C-N>"
else
return "\<Tab>"
endfunction
inoremap <Tab> <C-R>=My_Tab_Completion()<CR>
" }}}
" ======================================================================================================
" Specificke nastavenia pre editovanie konkretnych typov suborov: {{{
" Specificke nastavenie pre TeX: {{{
function! TEXSET()
" make: ak mame Makefile, tak make, inak cslatex + dvips
set makeprg=if\ \[\ -f\ \"Makefile\"\ \];then\ make;else\ if\ \[\ -f\ \"makefile\"\ \];then\ make;else\ cslatex\ -c-style-error\ %;\ dvips\ `basename\ %\ .tex`;fi;fi
" set makeprg=if\ \[\ -f\ \"Makefile\"\ \];then\ make;else\ if\ \[\ -f\ \"makefile\"\ \];then\ make;else\ cslatex\ -file-line-error-style\ %;\ dvips\ `basename\ %\ .tex`;fi;fi " starsia verzia TeXu
set errorformat=%f:%l:\ %m
" aby nam zvyraznilo zle slova aj v zatvorkach, pridame si do syntaxu BADWORD
syn cluster texMatchGroup contains=@texMathZones,texAccent,texBadMath,texComment,texDefCmd,texDelimiter,texDocType,texInput,texLength,texLigature,texMatcher,texNewCmd,texNewEnv,texOnlyMath,texParen,texRefZone,texSection,texSpecialChar,texStatement,texString,texTypeSize,texTypeStyle,texZone,texInputFile,BADWORD
" najskor ide moj slovnik s najcastejsimi prikazmi
set complete=k,.,w,b,u,t,i
let &dictionary = "~/.vim/dict/tex.dict"
endfunction
" }}}
" Specificke nastavenie pre C/C++: {{{
function! CSET()
set makeprg=if\ \[\ -f\ \"Makefile\"\ \];then\ make;else\ if\ \[\ -f\ \"makefile\"\ \];then\ make;else\ gcc\ -g\ -Wall\ -W\ -lm\ -o%.bin\ %;fi;fi
set errorformat=%f:%l:\ %m
set cindent
" Krajsie viacriadkove /* komentare
set comments-=s1:/*,mb:*,ex:*/
set comments+=s:/*,mb:**,ex:*/
set comments+=fb:*
endfunction
function! CPPSET()
set makeprg=if\ \[\ -f\ \"Makefile\"\ \];then\ make;else\ if\ \[\ -f\ \"makefile\"\ \];then\ make;else\ g++\ -g\ -ansi\ -pedantic\ -Wall\ -W\ -o%.bin\ %;fi;fi
set errorformat=%f:%l:\ %m
set cindent
" Krajsie viacriadkove /* komentare
set comments-=s1:/*,mb:*,ex:*/
set comments+=s:/*,mb:**,ex:*/
set comments+=fb:*
endfunction
" }}}
" Specificke nastavenie pre Pascal: {{{
function! PPSET()
set makeprg=if\ \[\ -f\ \"Makefile\"\ \];then\ make;else\ if\ \[\ -f\ \"makefile\"\ \];then\ make;else\ ppc386\ -o\%bin\ %;fi;fi
set errorformat=%f:%l:\ %m
endfunction
" }}}
" Specificke nastavenie pre Vim skripty: {{{
function! VIMSET()
" v konfiguraku mame dlhe riadky
set nowrap
" aj riadky zacinajuce " su komentare
set comments+=b:\"
endfunction
" }}}
" Specificke nastavenie pre Makefile: {{{
function! MAKEFILESET()
" v konfiguraku mame dlhe riadky
set nowrap
" potrebujeme taby, nie medzery
set noet
set sts=8
iunmap <Tab>
endfunction
" }}}
" Autocommandy pre jednotlive jazyky: {{{
autocmd FileType vim call VIMSET()
autocmd FileType c call CSET()
autocmd FileType C call CPPSET()
autocmd FileType cc call CPPSET()
autocmd FileType cpp call CPPSET()
autocmd FileType tex call TEXSET()
autocmd FileType pascal call PPSET()
autocmd FileType make call MAKEFILESET()
" }}}
" }}}
" ======================================================================================================
" Podpora spell-checkingu: {{{
"
" na to, aby spell checking fungoval, potrebuje:
" - aspell so slovenskym a anglickym jazykom
" - vim s podporou ruby (`vim --version | grep ruby`)
" - asi aj nainstalovany ruby (taky objektovy skriptovaci jazyk)
"
" je to samozrejme vykradnute a upravene, predchadzajuce verzie
" maju na svedomi:
" - Author: Matthias Veit <matthias_veit@yahoo.de>
" - Improvements by: Patrik Sundberg <ps@radiac.mine.nu>
" - Czech version by: Petr Mach <gsl@seznam.cz>
" default jazyk je slovencina
let s:language_tag = "sk"
" ======================================================================================================
" Skontroluj pravopis, zvyrazni chyby: {{{
function SpellCheck()
ruby << RUBYBLOCK
#setup syntax highligting
lang = VIM::evaluate("s:language_tag")
VIM::command("syn match BADWORD \"BADWORD\"")
VIM::command("syn clear BADWORD")
VIM::command("highlight BADWORD term=bold ctermfg=Red guibg=Brown guifg=White")
buffer = VIM::Buffer.current
aspell = IO.popen("aspell --language-tag=#{lang} -t -l", "w+") #--language-tag=de_DE
1.upto(buffer.count) { |linenr|
aspell.puts(buffer[linenr])
}
aspell.close_write
aspell.each { |badword|
badword.chomp!
VIM::command("syn match BADWORD \"\\<#{badword}\\>\"")
}
RUBYBLOCK
endfunction
" }}}
" ======================================================================================================
" Ponukni moznosti pre slovo pod kurzorom: {{{
function Propose()
ruby << RUBYBLOCK
lang = VIM::evaluate("s:language_tag")
cword = VIM::evaluate("expand(\"<cword>\")")
aspell = IO.popen("aspell --language-tag=#{lang} -a","w+")
aspell.puts(cword)
aspell.close_write
aspell.readlines.each{ |line|
if (line=~/^#/)
print("Sorry, no proposals for #{cword}\n")
elsif (line=~/^\*/)
print("#{cword} is correct!\n")
elsif (line=~/^&.*:\s*(.+)/)
counter = 0
words = $1.split(/,\s*/)
print("Proposal(s) for #{cword}\n")
print("-------------------------------\n")
words.each { |word|
print("(#{counter+1}) #{word}\n")
counter += 1
}
print("Change '#{cword}' to alternative (return for no change): ")
alt = VIM::evaluate("input('[1-#{counter}] ')").chomp.to_i
if (alt < counter+1) and (alt > 0)
VIM::command("%s/#{cword}/#{words[alt-1]}/g")
end
end
}
RUBYBLOCK
endfunction
" }}}
" ======================================================================================================
" Pridaj slovo do userovho slovnika pre aktivny jazyk: {{{
function AddToDictionary()
ruby << RUBYBLOCK
langtag_to_dic = {
"de_DE" => "de",
"uk_UK" => "english",
"us_US" => "english",
"cs_CZ" => "cs",
"sk" => "sk"
}
dic = langtag_to_dic[VIM::evaluate("s:language_tag")]
raise "Which dictionary to use with language tag #{VIM::evaluate("s:language_tag")} ??" if
(dic.nil?)
privatedic = ENV["HOME"]+File::Separator+".aspell."+dic+".pws"
cword = VIM::evaluate("expand(\"<cword>\")")
content = nil
if (File.exists?(privatedic))
content = File.readlines(privatedic)
header = content[0]
header =~ /(\S+\s\S+\s)(\d+)/
content[0]="#{$1}#{$2.to_i+1}\n"
else
content = ["personal_ws-1.1 #{dic} 1\n"]
end
content.push(cword+"\n")
dictionary = File.open(privatedic,"w+")
dictionary.write(content)
dictionary.close
RUBYBLOCK
endfunction
" }}}
" ======================================================================================================
" Chod na dalsie zle slovo: {{{
function! SpchkNxt()
let badword = synIDtrans(hlID("BADWORD"))
let lastline= line("$")
let curcol = 0
norm w
while synIDtrans(synID(line("."),col("."),1)) != badword
norm w
if line(".") == lastline
let prvcol=curcol
let curcol=col(".")
if curcol == prvcol
break
endif
endif
endwhile
unlet curcol
unlet badword
unlet lastline
if exists("prvcol")
unlet prvcol
endif
endfunction
" }}}
" ======================================================================================================
" Chod na predchadzajuce zle slovo: {{{
function! SpchkPrv()
let badword = synIDtrans(hlID("BADWORD"))
let curcol= 0
norm b
while synIDtrans(synID(line("."),col("."),1)) != badword
norm b
if line(".") == 1
let prvcol=curcol
let curcol=col(".")
if curcol == prvcol
break
endif
endif
endwhile
unlet curcol
unlet badword
if exists("prvcol")
unlet prvcol
endif
endfunction
" }}}
" ======================================================================================================
" Automaticky sa obnovujuci spellcheck: {{{
function SpellAutoEnable()
augroup classbrowser
autocmd! CursorHold * call SpellCheck()
set updatetime=2000
augroup END
endfunction
" }}}
" ======================================================================================================
" Koniec autospellchecku: {{{
function SpellAutoDisable()
augroup classbrowser
syn clear BADWORD
autocmd! CursorHold *
set updatetime=4000
augroup END
endfunction
" }}}
" ======================================================================================================
" Nastavenie jazyka: {{{
function SetLanguageTag(tag)
let s:language_tag=a:tag
endfunction
" }}}
" ======================================================================================================
" A mame kooopec prikazov (este by sa ich dalo na nieco namapovat): {{{
command Spell call SpellCheck()
command NoSpell syn clear BADWORD
command AddDict call AddToDictionary()
command Propose call Propose()
command AutoSpell call SpellAutoEnable()
command NoAutoSpell call SpellAutoDisable()
command SpellLangSlovak call SetLanguageTag("sk")
command SpellLangEnglish call SetLanguageTag("en")
" }}}
" ======================================================================================================
" }}}
" ======================================================================================================
" a na zaver povieme vimku, nech posklada foldy do seba
" vim: fdm=marker:commentstring=\ \"\ %s