""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " Name: gramadoir.vim " Description: Vim interface to An Gramadóir Irish grammar checker " Author: Kevin Patrick Scannell " Url: http://borel.slu.edu/gramadoir/ " " Licence: This program is free software; you can redistribute it " and/or modify it under the terms of the GNU General Public " License. See http://www.gnu.org/copyleft/gpl.txt " Version: 0.5, 2004-07-28 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" if exists("loaded_gramadoir") || &compatible finish endif let loaded_gramadoir = 1 let s:active_file = 0 let s:cpo_save = &cpo let s:ignore="${HOME}/.neamhshuim" let s:errorwords = "" set cpo&vim function s:Check() echo "An Gramadóir: fan go fóill..." let l:filename=expand("%") if !strlen(l:filename) let l:filename=tempname() silent execute "w!".l:filename endif let errorfile = tempname() let l:dummy=system('cat '. escape(l:filename,' \')." | gram-ga.pl --html --ionchod=utf-8 | sed 's/
//g; s/ class=gramadoir//g' > ".escape(errorfile,' \')) silent exe 'split ' . errorfile execute "normal \b" execute "normal \K" execute "normal \b" execute "normal 7\_" execute "normal 1G" execute "normal \t" execute "normal 1G" let s:active_file = 1 endfunction function s:NextError() if s:active_file == 0 call s:Check() endif syntax clear execute "normal \b" syntax clear call search("[^<]*<.b>") let l:currline=getline(".") let l:position=col(".") let l:linenumber=matchstr(l:currline, "^[1-9][0-9]*") let l:boldplustail=strpart(l:currline, l:position-1, strlen(l:currline)-l:position) let l:bolderror=matchstr(l:boldplustail, "[^<]*<.b>") let s:errorwords=strpart(l:bolderror, 3, strlen(l:bolderror)-7) let s:errorpattern=substitute(s:errorwords," ",'[ \\t\\n]\\+',"g") execute "normal jk0".l:position."l" execute "normal ll" execute "syntax match grError /".s:errorwords."/" execute "normal \t" execute "normal ".l:linenumber."G" if l:linenumber == "1" execute "normal G$" else execute "normal jkk$" endif call search(s:errorpattern) execute "syntax match grError /".s:errorpattern."/" highlight grError cterm=bold ctermfg=Red guifg=Red endfunction function s:QuitGr() let s:active_file = 0 execute "normal \b" q! execute "syntax enable" endfunction function s:Neamhshuim() if s:errorwords !~ ".* .*" let l:dummy2=system("touch ". s:ignore) let l:dummy3=system("(cat ". s:ignore . "; echo \"". s:errorwords ."\") | LC_COLLATE=C sort -u -o ". s:ignore) execute "normal \b" execute "normal ma" silent execute "%s/".s:errorwords."<.b>/".s:errorwords."/g" execute "normal `a" execute "normal \t" echo "Cuireadh \"". s:errorwords ."\" isteach i ~/.neamhshuim." endif call s:NextError() endfunction if !hasmapto('Gr') map g Gr endif if !hasmapto('Amach') map a Amach endif if !hasmapto('Neamh') map n Neamh endif noremap