annotate runtime/autoload/spellfile.vim @ 29370:02ed4800c675

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