Spell: Vim didn't search automatically for a spell file in my language

2,397 views
Skip to first unread message

pqs

unread,
Jul 12, 2008, 7:58:35 AM7/12/08
to vim_use
Hello,

I recently installed gvim on a fresh install of Ubuntu Hardy (v
7.1.138).

I opened a LaTeX file and wanted to spell check it.

:set spelllang=fr
:set spell

The output of the command was

Warning: Cannot find word list.

I was specting gvim to look for the file and install it. That's what
happened to me on other systems.

Is there a way to ask vim to look for this files or I should do this
automatically?

Thanks.

Michael Wagner

unread,
Jul 12, 2008, 8:40:23 AM7/12/08
to vim...@googlegroups.com
* pqs <pere.q...@gmail.com> 12.07.2008


> I recently installed gvim on a fresh install of Ubuntu Hardy (v
> 7.1.138).
>
> I opened a LaTeX file and wanted to spell check it.
>
> :set spelllang=fr
> :set spell
>
> The output of the command was
>
> Warning: Cannot find word list.
>
> I was specting gvim to look for the file and install it. That's what
> happened to me on other systems.

Hello pqs,

I had the same problem here on my Debian Sid, but with the german spell
files. You must download the files by your own from the net and put it
in ~/.vim/spell. Look at vim.org where the files are located, because I
don't remember where I got them.

Hth Michael

--
Sometimes it's better to light a
flamethrower than curse the darkness.
-- (Terry Pratchett, Men At Arms)

Tony Mechelynck

unread,
Jul 12, 2008, 8:53:07 AM7/12/08
to vim...@googlegroups.com

Have you got the French spell files, as follows?
$VIMRUNTIME/spell/fr.latin1.spl
$VIMRUNTIME/spell/fr.latin1.sug
$VIMRUNTIME/spell/fr.utf-8.spl
$VIMRUNTIME/spell/fr.utf-8.sug

Depending on how you installed Vim (which depends on which OS you are
on, and on whether you installed a pre-compiled version or compiled it
yourself, with which Makefile) you may have to find out how to get them.


Best regards,
Tony.
--
Optimization hinders evolution.

Ag. D. Hatzimanikas

unread,
Jul 12, 2008, 9:16:48 AM7/12/08
to vim...@googlegroups.com

:runtime plugin/spellfile.vim
:setlocal spell spelllang=fr
See,

:help spellfile.vim

Note: If that doesn't work, then you may need to unlet the
"loaded_spellfile_plugin" variable.
Setting this var it's a convenient way to not let one plugin to load
at the startup time (because you may don't need it to run), I know I do,
maybe your distribution is doing the same as well.

Regards,

Ag.

Ben Schmidt

unread,
Jul 12, 2008, 9:23:38 AM7/12/08
to vim...@googlegroups.com

The spellfile.vim plugin (usually in $VIMRUNTIME/autoload/spellfile.vim)
handles automatic downloading of spell files, and it seems it is
disabled/not installed/not working on your system. You will need to
either install the plugin or download the spell files yourself.

:help spellfile.vim

Ben.


pqs

unread,
Jul 13, 2008, 10:04:06 AM7/13/08
to vim_use


On 12 Jul, 14:40, Michael Wagner <michaeldeb...@web.de> wrote:
> I had the same problem here on my Debian Sid, but with the german spell
> files. You must download the files by your own from the net and put it
> in ~/.vim/spell. Look at vim.org where the files are located, because I
> don't remember where I got them.

At the end this is the easiest solution I found. I just copied the
~/.vim/spell folder from another computer.

Thanks for all your comments.

Pere

Leandro Lucarella

unread,
Nov 19, 2008, 1:22:13 PM11/19/08
to pqs, vim...@googlegroups.com

Just in case anyone else find this message with the exact same problem
like me, I found here:
https://bugs.launchpad.net/ubuntu/+source/vim/+bug/183935/+viewstatus
that the problem is the spellfile.vim plugin needs a writeable spell
directory to work.

I did:
$ mkdir -p ~/.vim/spell

and all worked like a charm.

Enjoy!

Bram Moolenaar

unread,
Nov 19, 2008, 4:01:23 PM11/19/08
to Leandro Lucarella, pqs, vim...@googlegroups.com

Leandro Lucarella wrote:

Try the replacement for runtime/autoload/spellfile.vim below. For Unix
it will create ~/.vim/spell if it doesn't exist yet. Let me know if you
spot a problem.


-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
" Vim script to download a missing spell file
" Maintainer: Bram Moolenaar <Br...@vim.org>
" Last Change: 2008 Nov 19

if !exists('g:spellfile_URL')
" Prefer using http:// when netrw should be able to use it, since
" more firewalls let this through.
if executable("curl") || executable("wget") || executable("fetch")
let g:spellfile_URL = 'http://ftp.vim.org/pub/vim/runtime/spell'
else
let g:spellfile_URL = 'ftp://ftp.vim.org/pub/vim/runtime/spell'
endif
endif
let s:spellfile_URL = '' " Start with nothing so that s:donedict is reset.

" This function is used for the spellfile plugin.
function! spellfile#LoadFile(lang)
" If the netrw plugin isn't loaded we silently skip everything.
if !exists(":Nread")
if &verbose
echomsg 'spellfile#LoadFile(): Nread command is not available.'
endif
return
endif

" If the URL changes we try all files again.
if s:spellfile_URL != g:spellfile_URL
let s:donedict = {}
let s:spellfile_URL = g:spellfile_URL
endif

" I will say this only once!
if has_key(s:donedict, a:lang . &enc)
if &verbose
echomsg 'spellfile#LoadFile(): Tried this language/encoding before.'
endif
return
endif
let s:donedict[a:lang . &enc] = 1

" Find spell directories we can write in.
let [dirlist, dirchoices] = spellfile#GetDirChoices()
if len(dirlist) == 0
let try_create = (has("unix") && glob($HOME . "/.vim/spell") == "")
if &verbose || try_create
echomsg 'spellfile#LoadFile(): There is no writable spell directory.'
endif
if try_create
if confirm("Shall I create ~/.vim/spell/", "&Yes\n&No", 2) == 1
" After creating the directory it should show up in the list.
call mkdir($HOME . "/.vim/spell", "p")
let [dirlist, dirchoices] = spellfile#GetDirChoices()
endif
endif
if len(dirlist) == 0
return
endif
endif

let msg = 'Cannot find spell file for "' . a:lang . '" in ' . &enc
let msg .= "\nDo you want me to try downloading it?"
if confirm(msg, "&Yes\n&No", 2) == 1
let enc = &encoding
if enc == 'iso-8859-15'
let enc = 'latin1'
endif
let fname = a:lang . '.' . enc . '.spl'

" Split the window, read the file into a new buffer.
" Remember the buffer number, we check it below.
new
let newbufnr = winbufnr(0)
setlocal bin
echo 'Downloading ' . fname . '...'
call spellfile#Nread(fname)
if getline(2) !~ 'VIMspell'
" Didn't work, perhaps there is an ASCII one.
" Careful: Nread() may have opened a new window for the error message,
" we need to go back to our own buffer and window.
if newbufnr != winbufnr(0)
let winnr = bufwinnr(newbufnr)
if winnr == -1
" Our buffer has vanished!? Open a new window.
echomsg "download buffer disappeared, opening a new one"
new
setlocal bin
else
exe winnr . "wincmd w"
endif
endif
if newbufnr == winbufnr(0)
" We are back the old buffer, remove any (half-finished) download.
g/^/d
else
let newbufnr = winbufnr(0)
endif

let fname = a:lang . '.ascii.spl'
echo 'Could not find it, trying ' . fname . '...'
call spellfile#Nread(fname)
if getline(2) !~ 'VIMspell'
echo 'Sorry, downloading failed'
exe newbufnr . "bwipe!"
return
endif
endif

" Delete the empty first line and mark the file unmodified.
1d
set nomod

let msg = "In which directory do you want to write the file:"
for i in range(len(dirlist))
let msg .= "\n" . (i + 1) . '. ' . dirlist[i]
endfor
let dirchoice = confirm(msg, dirchoices) - 2
if dirchoice >= 0
if exists('*fnameescape')
let dirname = fnameescape(dirlist[dirchoice])
else
let dirname = escape(dirlist[dirchoice], ' ')
endif
exe "write " . dirname . '/' . fname

" Also download the .sug file, if the user wants to.
let msg = "Do you want me to try getting the .sug file?\n"
let msg .= "This will improve making suggestions for spelling mistakes,\n"
let msg .= "but it uses quite a bit of memory."
if confirm(msg, "&No\n&Yes") == 2
g/^/d
let fname = substitute(fname, '\.spl$', '.sug', '')
echo 'Downloading ' . fname . '...'
call spellfile#Nread(fname)
if getline(2) =~ 'VIMsug'
1d
exe "write " . dirname . '/' . fname
set nomod
else
echo 'Sorry, downloading failed'
" Go back to our own buffer/window, Nread() may have taken us to
" another window.
if newbufnr != winbufnr(0)
let winnr = bufwinnr(newbufnr)
if winnr != -1
exe winnr . "wincmd w"
endif
endif
if newbufnr == winbufnr(0)
set nomod
endif
endif
endif
endif

" Wipe out the buffer we used.
exe newbufnr . "bwipe"
endif
endfunc

" Read "fname" from the server.
function! spellfile#Nread(fname)
" We do our own error handling, don't want a window for it.
if exists("g:netrw_use_errorwindow")
let save_ew = g:netrw_use_errorwindow
endif
let g:netrw_use_errorwindow=0

if g:spellfile_URL =~ '^ftp://'
" for an ftp server use a default login and password to avoid a prompt
let machine = substitute(g:spellfile_URL, 'ftp://\([^/]*\).*', '\1', '')
let dir = substitute(g:spellfile_URL, 'ftp://[^/]*/\(.*\)', '\1', '')
exe 'Nread "' . machine . ' anonymous vim7user ' . dir . '/' . a:fname . '"'
else
exe 'Nread ' g:spellfile_URL . '/' . a:fname
endif

if exists("save_ew")
let g:netrw_use_errorwindow = save_ew
else
unlet g:netrw_use_errorwindow
endif
endfunc

" Get a list of writable spell directories and choices for confirm().
function! spellfile#GetDirChoices()
let dirlist = []
let dirchoices = '&Cancel'
for dir in split(globpath(&rtp, 'spell'), "\n")
if filewritable(dir) == 2
call add(dirlist, dir)
let dirchoices .= "\n&" . len(dirlist)
endif
endfor
return [dirlist, dirchoices]
endfunc
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-


--
ARTHUR: (as the MAN next to him is squashed by a sheep) Knights! Run away!
Midst echoing shouts of "run away" the KNIGHTS retreat to cover with the odd
cow or goose hitting them still. The KNIGHTS crouch down under cover.
"Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ download, build and distribute -- http://www.A-A-P.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///

Leandro Lucarella

unread,
Nov 19, 2008, 4:12:23 PM11/19/08
to Bram Moolenaar, pqs, vim...@googlegroups.com
Bram Moolenaar, el 19 de noviembre a las 22:01 me escribiste:

> > I did:
> > $ mkdir -p ~/.vim/spell
> >
> > and all worked like a charm.
>
> Try the replacement for runtime/autoload/spellfile.vim below. For Unix
> it will create ~/.vim/spell if it doesn't exist yet. Let me know if you
> spot a problem.

Works great for me. Thank you.

--
Leandro Lucarella (luca) | Blog colectivo: http://www.mazziblog.com.ar/blog/
----------------------------------------------------------------------------
GPG Key: 5F5A8D05 (F8CD F9A7 BF00 5431 4145 104C 949E BFB6 5F5A 8D05)
----------------------------------------------------------------------------
A veces quisiera ser un barco,
para flotar como floto siendo humano,
y no hundirme como me hundo

Reply all
Reply to author
Forward
0 new messages