annotate runtime/autoload/spellfile.vim @ 14372:2a4a2dc35c55

Update runtime files. commit https://github.com/vim/vim/commit/a9604e61451707b38fdcb088fbfaeea2b922fef6 Author: Bram Moolenaar <Bram@vim.org> Date: Sat Jul 21 05:56:22 2018 +0200 Update runtime files.
author Christian Brabandt <cb@256bit.org>
date Sat, 21 Jul 2018 06:00:09 +0200
parents ba708ee8d69d
children 21fb2a3ad3ca
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
651
bc95c6c4bac1 updated for version 7.0191
vimboss
parents:
diff changeset
1 " Vim script to download a missing spell file
bc95c6c4bac1 updated for version 7.0191
vimboss
parents:
diff changeset
2 " Maintainer: Bram Moolenaar <Bram@vim.org>
3256
ba708ee8d69d Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
3 " Last Change: 2012 Jan 08
651
bc95c6c4bac1 updated for version 7.0191
vimboss
parents:
diff changeset
4
bc95c6c4bac1 updated for version 7.0191
vimboss
parents:
diff changeset
5 if !exists('g:spellfile_URL')
1652
e97a97d6a0eb updated for version 7.2a-004
vimboss
parents: 1624
diff changeset
6 " Prefer using http:// when netrw should be able to use it, since
e97a97d6a0eb updated for version 7.2a-004
vimboss
parents: 1624
diff changeset
7 " more firewalls let this through.
e97a97d6a0eb updated for version 7.2a-004
vimboss
parents: 1624
diff changeset
8 if executable("curl") || executable("wget") || executable("fetch")
e97a97d6a0eb updated for version 7.2a-004
vimboss
parents: 1624
diff changeset
9 let g:spellfile_URL = 'http://ftp.vim.org/pub/vim/runtime/spell'
e97a97d6a0eb updated for version 7.2a-004
vimboss
parents: 1624
diff changeset
10 else
e97a97d6a0eb updated for version 7.2a-004
vimboss
parents: 1624
diff changeset
11 let g:spellfile_URL = 'ftp://ftp.vim.org/pub/vim/runtime/spell'
e97a97d6a0eb updated for version 7.2a-004
vimboss
parents: 1624
diff changeset
12 endif
651
bc95c6c4bac1 updated for version 7.0191
vimboss
parents:
diff changeset
13 endif
bc95c6c4bac1 updated for version 7.0191
vimboss
parents:
diff changeset
14 let s:spellfile_URL = '' " Start with nothing so that s:donedict is reset.
bc95c6c4bac1 updated for version 7.0191
vimboss
parents:
diff changeset
15
bc95c6c4bac1 updated for version 7.0191
vimboss
parents:
diff changeset
16 " This function is used for the spellfile plugin.
bc95c6c4bac1 updated for version 7.0191
vimboss
parents:
diff changeset
17 function! spellfile#LoadFile(lang)
bc95c6c4bac1 updated for version 7.0191
vimboss
parents:
diff changeset
18 " If the netrw plugin isn't loaded we silently skip everything.
bc95c6c4bac1 updated for version 7.0191
vimboss
parents:
diff changeset
19 if !exists(":Nread")
bc95c6c4bac1 updated for version 7.0191
vimboss
parents:
diff changeset
20 if &verbose
bc95c6c4bac1 updated for version 7.0191
vimboss
parents:
diff changeset
21 echomsg 'spellfile#LoadFile(): Nread command is not available.'
bc95c6c4bac1 updated for version 7.0191
vimboss
parents:
diff changeset
22 endif
bc95c6c4bac1 updated for version 7.0191
vimboss
parents:
diff changeset
23 return
bc95c6c4bac1 updated for version 7.0191
vimboss
parents:
diff changeset
24 endif
14372
2a4a2dc35c55 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 3256
diff changeset
25 let lang = tolower(a:lang)
651
bc95c6c4bac1 updated for version 7.0191
vimboss
parents:
diff changeset
26
bc95c6c4bac1 updated for version 7.0191
vimboss
parents:
diff changeset
27 " If the URL changes we try all files again.
bc95c6c4bac1 updated for version 7.0191
vimboss
parents:
diff changeset
28 if s:spellfile_URL != g:spellfile_URL
bc95c6c4bac1 updated for version 7.0191
vimboss
parents:
diff changeset
29 let s:donedict = {}
bc95c6c4bac1 updated for version 7.0191
vimboss
parents:
diff changeset
30 let s:spellfile_URL = g:spellfile_URL
bc95c6c4bac1 updated for version 7.0191
vimboss
parents:
diff changeset
31 endif
bc95c6c4bac1 updated for version 7.0191
vimboss
parents:
diff changeset
32
bc95c6c4bac1 updated for version 7.0191
vimboss
parents:
diff changeset
33 " I will say this only once!
14372
2a4a2dc35c55 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 3256
diff changeset
34 if has_key(s:donedict, lang . &enc)
651
bc95c6c4bac1 updated for version 7.0191
vimboss
parents:
diff changeset
35 if &verbose
bc95c6c4bac1 updated for version 7.0191
vimboss
parents:
diff changeset
36 echomsg 'spellfile#LoadFile(): Tried this language/encoding before.'
bc95c6c4bac1 updated for version 7.0191
vimboss
parents:
diff changeset
37 endif
bc95c6c4bac1 updated for version 7.0191
vimboss
parents:
diff changeset
38 return
bc95c6c4bac1 updated for version 7.0191
vimboss
parents:
diff changeset
39 endif
14372
2a4a2dc35c55 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 3256
diff changeset
40 let s:donedict[lang . &enc] = 1
651
bc95c6c4bac1 updated for version 7.0191
vimboss
parents:
diff changeset
41
bc95c6c4bac1 updated for version 7.0191
vimboss
parents:
diff changeset
42 " Find spell directories we can write in.
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1652
diff changeset
43 let [dirlist, dirchoices] = spellfile#GetDirChoices()
651
bc95c6c4bac1 updated for version 7.0191
vimboss
parents:
diff changeset
44 if len(dirlist) == 0
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1652
diff changeset
45 let dir_to_create = spellfile#WritableSpellDir()
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1652
diff changeset
46 if &verbose || dir_to_create != ''
651
bc95c6c4bac1 updated for version 7.0191
vimboss
parents:
diff changeset
47 echomsg 'spellfile#LoadFile(): There is no writable spell directory.'
bc95c6c4bac1 updated for version 7.0191
vimboss
parents:
diff changeset
48 endif
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1652
diff changeset
49 if dir_to_create != ''
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1652
diff changeset
50 if confirm("Shall I create " . dir_to_create, "&Yes\n&No", 2) == 1
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1652
diff changeset
51 " After creating the directory it should show up in the list.
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1652
diff changeset
52 call mkdir(dir_to_create, "p")
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1652
diff changeset
53 let [dirlist, dirchoices] = spellfile#GetDirChoices()
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1652
diff changeset
54 endif
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1652
diff changeset
55 endif
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1652
diff changeset
56 if len(dirlist) == 0
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1652
diff changeset
57 return
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1652
diff changeset
58 endif
651
bc95c6c4bac1 updated for version 7.0191
vimboss
parents:
diff changeset
59 endif
bc95c6c4bac1 updated for version 7.0191
vimboss
parents:
diff changeset
60
14372
2a4a2dc35c55 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 3256
diff changeset
61 let msg = 'Cannot find spell file for "' . lang . '" in ' . &enc
651
bc95c6c4bac1 updated for version 7.0191
vimboss
parents:
diff changeset
62 let msg .= "\nDo you want me to try downloading it?"
bc95c6c4bac1 updated for version 7.0191
vimboss
parents:
diff changeset
63 if confirm(msg, "&Yes\n&No", 2) == 1
bc95c6c4bac1 updated for version 7.0191
vimboss
parents:
diff changeset
64 let enc = &encoding
bc95c6c4bac1 updated for version 7.0191
vimboss
parents:
diff changeset
65 if enc == 'iso-8859-15'
bc95c6c4bac1 updated for version 7.0191
vimboss
parents:
diff changeset
66 let enc = 'latin1'
bc95c6c4bac1 updated for version 7.0191
vimboss
parents:
diff changeset
67 endif
14372
2a4a2dc35c55 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 3256
diff changeset
68 let fname = lang . '.' . enc . '.spl'
651
bc95c6c4bac1 updated for version 7.0191
vimboss
parents:
diff changeset
69
bc95c6c4bac1 updated for version 7.0191
vimboss
parents:
diff changeset
70 " Split the window, read the file into a new buffer.
1185
184d2020d8f1 updated for version 7.1a-001
vimboss
parents: 950
diff changeset
71 " Remember the buffer number, we check it below.
651
bc95c6c4bac1 updated for version 7.0191
vimboss
parents:
diff changeset
72 new
1185
184d2020d8f1 updated for version 7.1a-001
vimboss
parents: 950
diff changeset
73 let newbufnr = winbufnr(0)
3256
ba708ee8d69d Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
74 setlocal bin fenc=
651
bc95c6c4bac1 updated for version 7.0191
vimboss
parents:
diff changeset
75 echo 'Downloading ' . fname . '...'
884
9f184758f277 updated for version 7.0-010
vimboss
parents: 651
diff changeset
76 call spellfile#Nread(fname)
651
bc95c6c4bac1 updated for version 7.0191
vimboss
parents:
diff changeset
77 if getline(2) !~ 'VIMspell'
bc95c6c4bac1 updated for version 7.0191
vimboss
parents:
diff changeset
78 " Didn't work, perhaps there is an ASCII one.
1185
184d2020d8f1 updated for version 7.1a-001
vimboss
parents: 950
diff changeset
79 " Careful: Nread() may have opened a new window for the error message,
184d2020d8f1 updated for version 7.1a-001
vimboss
parents: 950
diff changeset
80 " we need to go back to our own buffer and window.
184d2020d8f1 updated for version 7.1a-001
vimboss
parents: 950
diff changeset
81 if newbufnr != winbufnr(0)
184d2020d8f1 updated for version 7.1a-001
vimboss
parents: 950
diff changeset
82 let winnr = bufwinnr(newbufnr)
184d2020d8f1 updated for version 7.1a-001
vimboss
parents: 950
diff changeset
83 if winnr == -1
184d2020d8f1 updated for version 7.1a-001
vimboss
parents: 950
diff changeset
84 " Our buffer has vanished!? Open a new window.
184d2020d8f1 updated for version 7.1a-001
vimboss
parents: 950
diff changeset
85 echomsg "download buffer disappeared, opening a new one"
184d2020d8f1 updated for version 7.1a-001
vimboss
parents: 950
diff changeset
86 new
3256
ba708ee8d69d Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
87 setlocal bin fenc=
1185
184d2020d8f1 updated for version 7.1a-001
vimboss
parents: 950
diff changeset
88 else
184d2020d8f1 updated for version 7.1a-001
vimboss
parents: 950
diff changeset
89 exe winnr . "wincmd w"
184d2020d8f1 updated for version 7.1a-001
vimboss
parents: 950
diff changeset
90 endif
184d2020d8f1 updated for version 7.1a-001
vimboss
parents: 950
diff changeset
91 endif
184d2020d8f1 updated for version 7.1a-001
vimboss
parents: 950
diff changeset
92 if newbufnr == winbufnr(0)
184d2020d8f1 updated for version 7.1a-001
vimboss
parents: 950
diff changeset
93 " We are back the old buffer, remove any (half-finished) download.
184d2020d8f1 updated for version 7.1a-001
vimboss
parents: 950
diff changeset
94 g/^/d
184d2020d8f1 updated for version 7.1a-001
vimboss
parents: 950
diff changeset
95 else
184d2020d8f1 updated for version 7.1a-001
vimboss
parents: 950
diff changeset
96 let newbufnr = winbufnr(0)
184d2020d8f1 updated for version 7.1a-001
vimboss
parents: 950
diff changeset
97 endif
184d2020d8f1 updated for version 7.1a-001
vimboss
parents: 950
diff changeset
98
14372
2a4a2dc35c55 Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 3256
diff changeset
99 let fname = lang . '.ascii.spl'
651
bc95c6c4bac1 updated for version 7.0191
vimboss
parents:
diff changeset
100 echo 'Could not find it, trying ' . fname . '...'
884
9f184758f277 updated for version 7.0-010
vimboss
parents: 651
diff changeset
101 call spellfile#Nread(fname)
651
bc95c6c4bac1 updated for version 7.0191
vimboss
parents:
diff changeset
102 if getline(2) !~ 'VIMspell'
bc95c6c4bac1 updated for version 7.0191
vimboss
parents:
diff changeset
103 echo 'Sorry, downloading failed'
1185
184d2020d8f1 updated for version 7.1a-001
vimboss
parents: 950
diff changeset
104 exe newbufnr . "bwipe!"
651
bc95c6c4bac1 updated for version 7.0191
vimboss
parents:
diff changeset
105 return
bc95c6c4bac1 updated for version 7.0191
vimboss
parents:
diff changeset
106 endif
bc95c6c4bac1 updated for version 7.0191
vimboss
parents:
diff changeset
107 endif
bc95c6c4bac1 updated for version 7.0191
vimboss
parents:
diff changeset
108
bc95c6c4bac1 updated for version 7.0191
vimboss
parents:
diff changeset
109 " Delete the empty first line and mark the file unmodified.
bc95c6c4bac1 updated for version 7.0191
vimboss
parents:
diff changeset
110 1d
bc95c6c4bac1 updated for version 7.0191
vimboss
parents:
diff changeset
111 set nomod
bc95c6c4bac1 updated for version 7.0191
vimboss
parents:
diff changeset
112
bc95c6c4bac1 updated for version 7.0191
vimboss
parents:
diff changeset
113 let msg = "In which directory do you want to write the file:"
bc95c6c4bac1 updated for version 7.0191
vimboss
parents:
diff changeset
114 for i in range(len(dirlist))
bc95c6c4bac1 updated for version 7.0191
vimboss
parents:
diff changeset
115 let msg .= "\n" . (i + 1) . '. ' . dirlist[i]
bc95c6c4bac1 updated for version 7.0191
vimboss
parents:
diff changeset
116 endfor
bc95c6c4bac1 updated for version 7.0191
vimboss
parents:
diff changeset
117 let dirchoice = confirm(msg, dirchoices) - 2
bc95c6c4bac1 updated for version 7.0191
vimboss
parents:
diff changeset
118 if dirchoice >= 0
1624
18ee39301b82 updated for version 7.2a
vimboss
parents: 1226
diff changeset
119 if exists('*fnameescape')
18ee39301b82 updated for version 7.2a
vimboss
parents: 1226
diff changeset
120 let dirname = fnameescape(dirlist[dirchoice])
18ee39301b82 updated for version 7.2a
vimboss
parents: 1226
diff changeset
121 else
18ee39301b82 updated for version 7.2a
vimboss
parents: 1226
diff changeset
122 let dirname = escape(dirlist[dirchoice], ' ')
18ee39301b82 updated for version 7.2a
vimboss
parents: 1226
diff changeset
123 endif
3256
ba708ee8d69d Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
124 setlocal fenc=
1624
18ee39301b82 updated for version 7.2a
vimboss
parents: 1226
diff changeset
125 exe "write " . dirname . '/' . fname
651
bc95c6c4bac1 updated for version 7.0191
vimboss
parents:
diff changeset
126
bc95c6c4bac1 updated for version 7.0191
vimboss
parents:
diff changeset
127 " Also download the .sug file, if the user wants to.
bc95c6c4bac1 updated for version 7.0191
vimboss
parents:
diff changeset
128 let msg = "Do you want me to try getting the .sug file?\n"
bc95c6c4bac1 updated for version 7.0191
vimboss
parents:
diff changeset
129 let msg .= "This will improve making suggestions for spelling mistakes,\n"
bc95c6c4bac1 updated for version 7.0191
vimboss
parents:
diff changeset
130 let msg .= "but it uses quite a bit of memory."
bc95c6c4bac1 updated for version 7.0191
vimboss
parents:
diff changeset
131 if confirm(msg, "&No\n&Yes") == 2
bc95c6c4bac1 updated for version 7.0191
vimboss
parents:
diff changeset
132 g/^/d
bc95c6c4bac1 updated for version 7.0191
vimboss
parents:
diff changeset
133 let fname = substitute(fname, '\.spl$', '.sug', '')
bc95c6c4bac1 updated for version 7.0191
vimboss
parents:
diff changeset
134 echo 'Downloading ' . fname . '...'
884
9f184758f277 updated for version 7.0-010
vimboss
parents: 651
diff changeset
135 call spellfile#Nread(fname)
1185
184d2020d8f1 updated for version 7.1a-001
vimboss
parents: 950
diff changeset
136 if getline(2) =~ 'VIMsug'
651
bc95c6c4bac1 updated for version 7.0191
vimboss
parents:
diff changeset
137 1d
1624
18ee39301b82 updated for version 7.2a
vimboss
parents: 1226
diff changeset
138 exe "write " . dirname . '/' . fname
1185
184d2020d8f1 updated for version 7.1a-001
vimboss
parents: 950
diff changeset
139 set nomod
184d2020d8f1 updated for version 7.1a-001
vimboss
parents: 950
diff changeset
140 else
184d2020d8f1 updated for version 7.1a-001
vimboss
parents: 950
diff changeset
141 echo 'Sorry, downloading failed'
184d2020d8f1 updated for version 7.1a-001
vimboss
parents: 950
diff changeset
142 " Go back to our own buffer/window, Nread() may have taken us to
184d2020d8f1 updated for version 7.1a-001
vimboss
parents: 950
diff changeset
143 " another window.
184d2020d8f1 updated for version 7.1a-001
vimboss
parents: 950
diff changeset
144 if newbufnr != winbufnr(0)
184d2020d8f1 updated for version 7.1a-001
vimboss
parents: 950
diff changeset
145 let winnr = bufwinnr(newbufnr)
184d2020d8f1 updated for version 7.1a-001
vimboss
parents: 950
diff changeset
146 if winnr != -1
184d2020d8f1 updated for version 7.1a-001
vimboss
parents: 950
diff changeset
147 exe winnr . "wincmd w"
184d2020d8f1 updated for version 7.1a-001
vimboss
parents: 950
diff changeset
148 endif
184d2020d8f1 updated for version 7.1a-001
vimboss
parents: 950
diff changeset
149 endif
184d2020d8f1 updated for version 7.1a-001
vimboss
parents: 950
diff changeset
150 if newbufnr == winbufnr(0)
184d2020d8f1 updated for version 7.1a-001
vimboss
parents: 950
diff changeset
151 set nomod
184d2020d8f1 updated for version 7.1a-001
vimboss
parents: 950
diff changeset
152 endif
651
bc95c6c4bac1 updated for version 7.0191
vimboss
parents:
diff changeset
153 endif
bc95c6c4bac1 updated for version 7.0191
vimboss
parents:
diff changeset
154 endif
bc95c6c4bac1 updated for version 7.0191
vimboss
parents:
diff changeset
155 endif
bc95c6c4bac1 updated for version 7.0191
vimboss
parents:
diff changeset
156
1185
184d2020d8f1 updated for version 7.1a-001
vimboss
parents: 950
diff changeset
157 " Wipe out the buffer we used.
184d2020d8f1 updated for version 7.1a-001
vimboss
parents: 950
diff changeset
158 exe newbufnr . "bwipe"
651
bc95c6c4bac1 updated for version 7.0191
vimboss
parents:
diff changeset
159 endif
bc95c6c4bac1 updated for version 7.0191
vimboss
parents:
diff changeset
160 endfunc
884
9f184758f277 updated for version 7.0-010
vimboss
parents: 651
diff changeset
161
950
f03c3fae0a99 updated for version 7.0-076
vimboss
parents: 884
diff changeset
162 " Read "fname" from the server.
884
9f184758f277 updated for version 7.0-010
vimboss
parents: 651
diff changeset
163 function! spellfile#Nread(fname)
1226
a49d06539452 updated for version 7.1b
vimboss
parents: 1185
diff changeset
164 " We do our own error handling, don't want a window for it.
a49d06539452 updated for version 7.1b
vimboss
parents: 1185
diff changeset
165 if exists("g:netrw_use_errorwindow")
a49d06539452 updated for version 7.1b
vimboss
parents: 1185
diff changeset
166 let save_ew = g:netrw_use_errorwindow
a49d06539452 updated for version 7.1b
vimboss
parents: 1185
diff changeset
167 endif
a49d06539452 updated for version 7.1b
vimboss
parents: 1185
diff changeset
168 let g:netrw_use_errorwindow=0
a49d06539452 updated for version 7.1b
vimboss
parents: 1185
diff changeset
169
950
f03c3fae0a99 updated for version 7.0-076
vimboss
parents: 884
diff changeset
170 if g:spellfile_URL =~ '^ftp://'
f03c3fae0a99 updated for version 7.0-076
vimboss
parents: 884
diff changeset
171 " for an ftp server use a default login and password to avoid a prompt
f03c3fae0a99 updated for version 7.0-076
vimboss
parents: 884
diff changeset
172 let machine = substitute(g:spellfile_URL, 'ftp://\([^/]*\).*', '\1', '')
f03c3fae0a99 updated for version 7.0-076
vimboss
parents: 884
diff changeset
173 let dir = substitute(g:spellfile_URL, 'ftp://[^/]*/\(.*\)', '\1', '')
f03c3fae0a99 updated for version 7.0-076
vimboss
parents: 884
diff changeset
174 exe 'Nread "' . machine . ' anonymous vim7user ' . dir . '/' . a:fname . '"'
f03c3fae0a99 updated for version 7.0-076
vimboss
parents: 884
diff changeset
175 else
f03c3fae0a99 updated for version 7.0-076
vimboss
parents: 884
diff changeset
176 exe 'Nread ' g:spellfile_URL . '/' . a:fname
f03c3fae0a99 updated for version 7.0-076
vimboss
parents: 884
diff changeset
177 endif
1226
a49d06539452 updated for version 7.1b
vimboss
parents: 1185
diff changeset
178
a49d06539452 updated for version 7.1b
vimboss
parents: 1185
diff changeset
179 if exists("save_ew")
a49d06539452 updated for version 7.1b
vimboss
parents: 1185
diff changeset
180 let g:netrw_use_errorwindow = save_ew
a49d06539452 updated for version 7.1b
vimboss
parents: 1185
diff changeset
181 else
a49d06539452 updated for version 7.1b
vimboss
parents: 1185
diff changeset
182 unlet g:netrw_use_errorwindow
a49d06539452 updated for version 7.1b
vimboss
parents: 1185
diff changeset
183 endif
884
9f184758f277 updated for version 7.0-010
vimboss
parents: 651
diff changeset
184 endfunc
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1652
diff changeset
185
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1652
diff changeset
186 " Get a list of writable spell directories and choices for confirm().
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1652
diff changeset
187 function! spellfile#GetDirChoices()
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1652
diff changeset
188 let dirlist = []
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1652
diff changeset
189 let dirchoices = '&Cancel'
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1652
diff changeset
190 for dir in split(globpath(&rtp, 'spell'), "\n")
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1652
diff changeset
191 if filewritable(dir) == 2
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1652
diff changeset
192 call add(dirlist, dir)
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1652
diff changeset
193 let dirchoices .= "\n&" . len(dirlist)
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1652
diff changeset
194 endif
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1652
diff changeset
195 endfor
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1652
diff changeset
196 return [dirlist, dirchoices]
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1652
diff changeset
197 endfunc
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1652
diff changeset
198
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1652
diff changeset
199 function! spellfile#WritableSpellDir()
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1652
diff changeset
200 if has("unix")
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1652
diff changeset
201 " For Unix always use the $HOME/.vim directory
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1652
diff changeset
202 return $HOME . "/.vim/spell"
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1652
diff changeset
203 endif
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1652
diff changeset
204 for dir in split(&rtp, ',')
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1652
diff changeset
205 if filewritable(dir) == 2
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1652
diff changeset
206 return dir . "/spell"
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1652
diff changeset
207 endif
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1652
diff changeset
208 endfor
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1652
diff changeset
209 return ''
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1652
diff changeset
210 endfunction