" Enable syntax highlighting syntax enable " Put tabspace to 4 positions set sts=4 " backspace and cursor keys wrap to previous/next line set backspace=indent,eol,start whichwrap+=<,>,[,] " backspace in Visual mode deletes selection vnoremap d "For VIM 7.x, always show tabs set stal=2 set nobackup " Enable line numbering set nu " Do not wrap lines set nowrap " Set fileformat to Unix set fileformat=unix set fileencodings=latin1 " Set horizontal bar set guioptions+=b " Set splitoptions set nosplitbelow set splitright " Some WIN options source $VIMRUNTIME/mswin.vim behave mswin " Set contextmenu, layout if has("gui_gtk2") set tb=icons,text set tbis=large endif " Set statusline options set laststatus=2 set statusline=% 0 call writefile([bacon], $HOME . "/.vim/bacon.cfg") let choice = confirm("\nBaCon now is defined as:\n\n" . bacon) endif endfunction " Define options to BaCon function! BaConOpt() " Check directory if (!isdirectory($HOME . "/.vim")) call mkdir($HOME . "/.vim") endif " Get arguments if !filereadable($HOME . "/.vim/args.cfg") let args = "" else let args = get(readfile($HOME . "/.vim/args.cfg"), 0) endif " Show dialog let args = inputdialog("\nAdditional BaCon options:", args, -1) " Empty string means 'cancel' or some error if args != -1 call writefile([args], $HOME . "/.vim/args.cfg") endif endfunction " Compile current BaCon file function! BaConCompile() " Get the converter name if !filereadable($HOME . "/.vim/bacon.cfg") let bacon = "bacon" else let bacon = get(readfile($HOME . "/.vim/bacon.cfg"), 0) endif " Get arguments if !filereadable($HOME . "/.vim/args.cfg") let args = "" else let args = get(readfile($HOME . "/.vim/args.cfg"), 0) endif " Check if it can be executed if !filereadable(bacon) let choice = confirm("\nMake sure '" . bacon . "' exists and has executable rights!") " Execute compilation else execute "!" . bacon . " " . args . " %" endif endfunction " Run current BaCon file function! BaConRun() let args = inputdialog("\nArguments to program:", "", -1) let prog = fnamemodify(bufname(""), ":r") if filereadable(prog) && args != -1 execute "!" . prog . " " . args elseif args != -1 let choice = confirm("\nThe program '" . prog . "' does not exist, compile first!") endif endfunction " Set current file to BaCon syntax function! BaConSyntax() set syntax=bacon endfunction " For GUI function! BaConHelp(txt) let result = "" let doc = getcwd() . "/documentation.html" " Get the documentation file if !filereadable(doc) let result = system("wget http://www.basic-converter.org/documentation.html; touch documentation.html") else " File exists, not an old one? Otherwise download again if localtime() - getftime(doc) > 24*3600 let result = rename(doc, doc . ".old") let result = system("wget http://www.basic-converter.org/documentation.html; touch documentation.html") if result =~ "wget" "If download fails use old documentation let result = rename(doc . ".old", doc) else let result = delete(doc . ".old") endif endif endif " Download fails if result =~ "wget" let info = "Cannot download the BaCon documentation!\n\nPlease get the file 'documentation.html' from the BaCon website and put it in the current directory." else " Now parse the file let info = "" if len(a:txt) > 0 let show = 0 for line in readfile(doc) " Find start of keyword definitions if line =~ "" . a:txt . "" && show == 0 let show += 1 endif " End of info if line =~ "", "\n\n", "g") let info = substitute(info, "
", "\n", "g") " Delete the other HTML tags while info =~ "<" let info = strpart(info, 0, match(info, "<")) . strpart(info, match(info, ">") + 1) endwhile " Bigger/smaller signs let info = substitute(info, "<", "<", "g") let info = substitute(info, ">", ">", "g") endif endif return info endfunction " Print on console function! ConsoleBaConHelp(func) if len(a:func) > 0 let info = BaConHelp(toupper(a:func)) if len(info) > 0 echo info else echo "Keyword not found!" endif endif endfunction " Define command for help command! -complete=function -nargs=1 Help :call ConsoleBaConHelp() " For GUI function! GuiBaConHelp() let txt = toupper(inputdialog("\nEnter the statement or function to lookup:", "")) if len(txt) > 0 let info = BaConHelp(txt) if len(info) > 0 let choice = confirm(info) else let choice = confirm("\nKeyword not found!") endif endif endfunction " Toggle insert mode function! ToggleInsertmode() set im! endfunction " Setup menus amenu 90.10 B&aCon.&Define\ location\ of\ BaCon :call BaConLoc() amenu 90.15 B&aCon.Define\ &options\ to\ BaCon :call BaConOpt() amenu 90.20 B&aCon.-Sep1- : amenu 90.30 B&aCon.&Compile\ current\ program :call BaConCompile() amenu 90.40 B&aCon.&Run\ current\ program :call BaConRun() amenu 90.50 B&aCon.-Sep2- : amenu 90.60 B&aCon.&Set\ syntax\ to\ BaCon :call BaConSyntax() amenu 90.70 B&aCon.-Sep3- : amenu 90.80 B&aCon.&Help\ on\ statement :call GuiBaConHelp() " Setup Toolbar amenu ToolBar.-Sep1- : tmenu ToolBar.Convert Convert current BaCon file amenu ToolBar.Convert :call BaConCompile() tmenu ToolBar.Run Run compiled BaCon file amenu ToolBar.Run :call BaConRun() " Setup Insert Mode option amenu ToolBar.-Sep2- : tmenu ToolBar.NoVIM Toggle insert mode amenu ToolBar.NoVIM :call ToggleInsertmode() " Delete some never used icons if has("gui_running") aunmenu ToolBar.-sep3- aunmenu ToolBar.-sep7- aunmenu ToolBar.-sep5- aunmenu ToolBar.-sep6- aunmenu ToolBar.FindHelp aunmenu ToolBar.FindPrev aunmenu ToolBar.FindNext aunmenu ToolBar.Replace aunmenu ToolBar.LoadSesn aunmenu ToolBar.SaveSesn aunmenu ToolBar.RunScript aunmenu ToolBar.Make aunmenu ToolBar.RunCtags aunmenu ToolBar.TagJump aunmenu ToolBar.Help endif