Lines 445-455
endfunction
Link Here
|
445 |
" Function: s:SpellVerifyLanguage(a:language) {{{2 |
445 |
" Function: s:SpellVerifyLanguage(a:language) {{{2 |
446 |
" Verify the availability of the language for the previously selected |
446 |
" Verify the availability of the language for the previously selected |
447 |
" spell checker. |
447 |
" spell checker. |
448 |
function! s:SpellVerifyLanguage(language) |
448 |
function! s:SpellVerifyLanguage(language) |
449 |
if b:spell_executable == "ispell" || b:spell_executable == "aspell" |
449 |
if b:spell_executable == "ispell" || b:spell_executable == "aspell" |
450 |
let l:dirs = system("echo word |". b:spell_executable ." -l -d". a:language ) |
450 |
if b:spell_executable == "ispell" |
|
|
451 |
let l:dirs = system("echo word |". b:spell_executable ." -l -d". a:language ) |
452 |
else |
453 |
let l:dirs = system("echo word |". b:spell_executable ." -d". a:language . " list ") |
454 |
endif |
451 |
if v:shell_error != 0 |
455 |
if v:shell_error != 0 |
452 |
echo "Language '". a:language ."' not known from ". b:spell_executable ."." |
456 |
echo "Language '". a:language ."' not known from ". b:spell_executable ."." |
453 |
return 1 |
457 |
return 1 |
454 |
endif |
458 |
endif |
455 |
else |
459 |
else |
Lines 470-481
function! s:SpellGuessLanguage()
Link Here
|
470 |
|
474 |
|
471 |
let l:mlang=substitute(b:spell_internal_language_list,",.*","","") |
475 |
let l:mlang=substitute(b:spell_internal_language_list,",.*","","") |
472 |
|
476 |
|
473 |
while matchstr(l:mlang,",") == "" |
477 |
while matchstr(l:mlang,",") == "" |
474 |
\ && l:langnum <= s:SpellGetOption("spell_guess_max_languages",3) |
478 |
\ && l:langnum <= s:SpellGetOption("spell_guess_max_languages",3) |
475 |
let l:errors=system(b:spell_executable . b:spell_options . " -l -d " . |
479 |
if b:spell_executable == "ispell" |
476 |
\ l:mlang . " < " . escape(expand("%"),' \')) |
480 |
let l:errors=system(b:spell_executable . b:spell_options . " -l -d " . |
|
|
481 |
\ l:mlang . " < " . escape(expand("%"),' \')) |
482 |
else |
483 |
let l:errors=system(b:spell_executable . b:spell_options . " -d " . |
484 |
\ l:mlang . " list " . " < " . escape(expand("%"),' \')) |
485 |
endif |
477 |
let l:errors=escape(l:errors,'"') |
486 |
let l:errors=escape(l:errors,'"') |
478 |
let l:index=stridx(l:errors, "\n") |
487 |
let l:index=stridx(l:errors, "\n") |
479 |
let l:spellcount=0 |
488 |
let l:spellcount=0 |
480 |
let l:errorcount=0 |
489 |
let l:errorcount=0 |
481 |
|
490 |
|
Lines 527-538
function! s:SpellGetDicoList()
Link Here
|
527 |
let l:dirfiles = substitute(l:dirfiles,"\.hash","","g") |
536 |
let l:dirfiles = substitute(l:dirfiles,"\.hash","","g") |
528 |
let l:dirfiles = substitute(l:dirfiles,"\n",",","g") |
537 |
let l:dirfiles = substitute(l:dirfiles,"\n",",","g") |
529 |
elseif b:spell_executable == "aspell" |
538 |
elseif b:spell_executable == "aspell" |
530 |
" Thanks to Alexandre Beneteau <alexandre.beneteau@wanadoo.fr> for showing |
539 |
" Thanks to Alexandre Beneteau <alexandre.beneteau@wanadoo.fr> for showing |
531 |
" me a way to get aspell directory for dictionaries. |
540 |
" me a way to get aspell directory for dictionaries. |
532 |
let l:dirs = system('aspell config | '. s:grep . ' "dict-dir current"') |
541 |
" let l:dirs = system('aspell config | '. s:grep . ' "dict-dir current"') |
533 |
let l:dirs = substitute(l:dirs,'^.*dict-dir current: \(\/.*\)','\1',"") |
542 |
" let l:dirs = substitute(l:dirs,'^.*dict-dir current: \(\/.*\)','\1',"") |
|
|
543 |
let l:dirs = system('aspell config dict-dir') |
534 |
"don't know, why there is a <NUL> char at the end of line ? Get rid of it. |
544 |
"don't know, why there is a <NUL> char at the end of line ? Get rid of it. |
535 |
let l:dirs = substitute(l:dirs,".$","","") |
545 |
let l:dirs = substitute(l:dirs,".$","","") |
536 |
|
546 |
|
537 |
let l:dirfiles = glob("`".s:find . l:dirs . s:findname . '"*.multi"' . s:findopt ."`") |
547 |
let l:dirfiles = glob("`".s:find . l:dirs . s:findname . '"*.multi"' . s:findopt ."`") |
538 |
let l:dirfiles = substitute(l:dirfiles,"\/[^\n]*\/","","g") |
548 |
let l:dirfiles = substitute(l:dirfiles,"\/[^\n]*\/","","g") |
Lines 650-660
function! s:SpellSetupBuffer()
Link Here
|
650 |
|
660 |
|
651 |
" This flag indicate that spell buffer is being, or has been setup. |
661 |
" This flag indicate that spell buffer is being, or has been setup. |
652 |
" It's put here to avoid possible reentering problem. |
662 |
" It's put here to avoid possible reentering problem. |
653 |
let b:spell_buffer_setup=1 |
663 |
let b:spell_buffer_setup=1 |
654 |
|
664 |
|
655 |
call s:SpellSetSpellchecker(s:SpellGetOption("spell_executable","ispell")) |
665 |
call s:SpellSetSpellchecker(s:SpellGetOption("spell_executable","aspell")) |
656 |
|
666 |
|
657 |
let b:spell_filter=s:SpellGetOption("spell_filter","") |
667 |
let b:spell_filter=s:SpellGetOption("spell_filter","") |
658 |
if exists("b:spell_filter") && b:spell_filter != "" |
668 |
if exists("b:spell_filter") && b:spell_filter != "" |
659 |
let b:spell_filter_pipe=b:spell_filter . "|" |
669 |
let b:spell_filter_pipe=b:spell_filter . "|" |
660 |
else |
670 |
else |
Lines 711-721
function! s:SpellSetupBuffer()
Link Here
|
711 |
endif |
721 |
endif |
712 |
endif |
722 |
endif |
713 |
|
723 |
|
714 |
call s:SpellCheckLanguage() |
724 |
call s:SpellCheckLanguage() |
715 |
|
725 |
|
716 |
call s:SpellTuneCommentSyntax(&l:ft) |
726 |
" We don't want to make any changes to syntax highlighting if we're editing |
|
|
727 |
" a directory rather than a file, because this upsets the builtin |
728 |
" explorer.vim plugin. |
729 |
if ! isdirectory(expand("%")) |
730 |
call s:SpellTuneCommentSyntax(&l:ft) |
731 |
endif |
717 |
|
732 |
|
718 |
call s:SpellSaveIskeyword() |
733 |
call s:SpellSaveIskeyword() |
719 |
|
734 |
|
720 |
" user need to be able to backspace before the start of insertion if |
735 |
" user need to be able to backspace before the start of insertion if |
721 |
" spell_insert_mode is set... (else backspace won't work for the user...) |
736 |
" spell_insert_mode is set... (else backspace won't work for the user...) |
Lines 743-752
endfunction
Link Here
|
743 |
" 1 if new document installed, 0 otherwise. |
758 |
" 1 if new document installed, 0 otherwise. |
744 |
" Note: Cleaned and generalized by guo-peng Wen |
759 |
" Note: Cleaned and generalized by guo-peng Wen |
745 |
"''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' |
760 |
"''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' |
746 |
|
761 |
|
747 |
function! s:SpellInstallDocumentation(full_name, revision) |
762 |
function! s:SpellInstallDocumentation(full_name, revision) |
|
|
763 |
return 0 |
748 |
" Name of the document path based on the system we use: |
764 |
" Name of the document path based on the system we use: |
749 |
if (has("unix")) |
765 |
if (has("unix")) |
750 |
" On UNIX like system, using forward slash: |
766 |
" On UNIX like system, using forward slash: |
751 |
let l:slash_char = '/' |
767 |
let l:slash_char = '/' |
752 |
let l:mkdir_cmd = ':silent !mkdir -p ' |
768 |
let l:mkdir_cmd = ':silent !mkdir -p ' |
Lines 895-909
function! s:SpellCheck()
Link Here
|
895 |
let b:spellerrors="nonexisitingwordinthisdociumnt\\" |
911 |
let b:spellerrors="nonexisitingwordinthisdociumnt\\" |
896 |
let b:spellcorrected="nonexisitingwordinthisdociumnt" |
912 |
let b:spellcorrected="nonexisitingwordinthisdociumnt" |
897 |
let b:spellicorrected="nonexisitingwordinthisdociumnt" |
913 |
let b:spellicorrected="nonexisitingwordinthisdociumnt" |
898 |
|
914 |
|
899 |
if exists("b:spell_filter") && b:spell_filter != "" |
915 |
if exists("b:spell_filter") && b:spell_filter != "" |
900 |
let l:errors=system('cat '. escape(l:filename,' \')."|".b:spell_filter_pipe |
916 |
if b:spell_executable == "ispell" |
901 |
\. b:spell_executable . b:spell_options . " -l -d ".b:spell_language) |
917 |
let l:errors=system('cat '. escape(l:filename,' \')."|".b:spell_filter_pipe |
|
|
918 |
\. b:spell_executable . b:spell_options . " -l -d ".b:spell_language) |
919 |
else |
920 |
let l:errors=system('cat '. escape(l:filename,' \')."|".b:spell_filter_pipe |
921 |
\. b:spell_executable . b:spell_options . " -d ".b:spell_language |
922 |
\. " list ") |
923 |
endif |
902 |
else |
924 |
else |
903 |
let l:errors=system(b:spell_executable . b:spell_options |
925 |
if b:spell_executable == "ispell" |
904 |
\. " -l -d ".b:spell_language." < ".escape(l:filename,' \')) |
926 |
let l:errors=system(b:spell_executable . b:spell_options |
|
|
927 |
\. " -l -d ".b:spell_language." < ".escape(l:filename,' \') ) |
928 |
else |
929 |
let l:errors=system(b:spell_executable . b:spell_options |
930 |
\. " -d ".b:spell_language." list "." < ".escape(l:filename,' \') ) |
931 |
endif |
905 |
endif |
932 |
endif |
906 |
|
933 |
|
907 |
let l:errors=escape(l:errors,'"') |
934 |
let l:errors=escape(l:errors,'"') |
908 |
let l:index=stridx(l:errors, "\n") |
935 |
let l:index=stridx(l:errors, "\n") |
909 |
let l:spellcount=0 |
936 |
let l:spellcount=0 |
Lines 1015-1026
function! s:SpellCheckWindow()
Link Here
|
1015 |
let b:spellerrors="nonexisitingwordinthisdociumnt\\" |
1042 |
let b:spellerrors="nonexisitingwordinthisdociumnt\\" |
1016 |
let b:spellcorrected="nonexisitingwordinthisdociumnt" |
1043 |
let b:spellcorrected="nonexisitingwordinthisdociumnt" |
1017 |
let b:spellicorrected="nonexisitingwordinthisdociumnt" |
1044 |
let b:spellicorrected="nonexisitingwordinthisdociumnt" |
1018 |
endif |
1045 |
endif |
1019 |
|
1046 |
|
1020 |
let l:errors=system(b:spell_executable . b:spell_options |
1047 |
if b:spell_executable == "ispell" |
1021 |
\ . " -l -d ".b:spell_language." < ".w:tempname) |
1048 |
let l:errors=system(b:spell_executable . b:spell_options |
|
|
1049 |
\ . " -l -d ".b:spell_language." < ".w:tempname) |
1050 |
else |
1051 |
let l:errors=system(b:spell_executable . b:spell_options |
1052 |
\ . " -d ".b:spell_language. " list " ." < ".w:tempname) |
1053 |
endif |
1022 |
let l:errors=escape(l:errors,'"') |
1054 |
let l:errors=escape(l:errors,'"') |
1023 |
let l:index=stridx(l:errors, "\n") |
1055 |
let l:index=stridx(l:errors, "\n") |
1024 |
|
1056 |
|
1025 |
while (l:index > 0) |
1057 |
while (l:index > 0) |
1026 |
" use stridx/strpart instead of sustitude, because it is faster |
1058 |
" use stridx/strpart instead of sustitude, because it is faster |
Lines 1087-1098
function! s:SpellCheckLine()
Link Here
|
1087 |
let b:spellerrors="nonexisitingwordinthisdociumnt\\" |
1119 |
let b:spellerrors="nonexisitingwordinthisdociumnt\\" |
1088 |
let b:spellcorrected="nonexisitingwordinthisdociumnt" |
1120 |
let b:spellcorrected="nonexisitingwordinthisdociumnt" |
1089 |
let b:spellicorrected="nonexisitingwordinthisdociumnt" |
1121 |
let b:spellicorrected="nonexisitingwordinthisdociumnt" |
1090 |
endif |
1122 |
endif |
1091 |
|
1123 |
|
1092 |
let l:ispexpr = "echo \"".escape(getline('.'),'\"<>')."\"|".b:spell_filter_pipe |
1124 |
if b:spell_executable == "ispell" |
1093 |
\ . b:spell_executable . b:spell_options . ' -l -d '.b:spell_language |
1125 |
let l:ispexpr = "echo \"".escape(getline('.'),'\"<>')."\"|".b:spell_filter_pipe |
|
|
1126 |
\ . b:spell_executable . b:spell_options . ' -l -d '.b:spell_language |
1127 |
else |
1128 |
let l:ispexpr = "echo \"".escape(getline('.'),'\"<>')."\"|".b:spell_filter_pipe |
1129 |
\ . b:spell_executable . b:spell_options . ' -d '.b:spell_language . " list " |
1130 |
endif |
1094 |
let l:errors=system(l:ispexpr) |
1131 |
let l:errors=system(l:ispexpr) |
1095 |
let l:errors=escape(l:errors,'"') |
1132 |
let l:errors=escape(l:errors,'"') |
1096 |
let l:index=stridx(l:errors, "\n") |
1133 |
let l:index=stridx(l:errors, "\n") |
1097 |
|
1134 |
|
1098 |
while (l:index > 0) |
1135 |
while (l:index > 0) |