mirror of
https://github.com/preservim/vim-wordy.git
synced 2025-11-08 09:53:50 -05:00
use tempname() for portability; map(), docs, style
Use tempname() for portably obtaining a temporary filename. Use map() instead of a for-loop. Add comment explaining the purpose of the newly added code. Add l: prefix to keep coding style in-line with rest of code.
This commit is contained in:
@@ -34,13 +34,11 @@ function! wordy#init(...) abort
|
||||
let l:src_path = l:data_dir . '/' . l:lang . '/' . l:dict . '.dic'
|
||||
if filereadable(l:src_path)
|
||||
if has('nvim')
|
||||
let wlist = readfile(l:src_path)
|
||||
let nlist = []
|
||||
for witem in wlist
|
||||
call add(nlist, substitute(witem, '!$', '?', ''))
|
||||
endfor
|
||||
let l:src_path = "/tmp/" . "_wordy_" . l:dict
|
||||
call writefile(nlist, l:src_path)
|
||||
" Dynamically convert SpellBad words into SpellRare words under NeoVim.
|
||||
" See issue 15 for details: https://github.com/reedes/vim-wordy/pull/15
|
||||
let l:rare_dic = map(readfile(l:src_path), "substitute(v:val, '!$', '?', '')")
|
||||
let l:src_path = tempname()
|
||||
call writefile(l:rare_dic, l:src_path)
|
||||
endif
|
||||
let l:spell_dir = g:wordy_dir . '/spell'
|
||||
if !isdirectory(l:spell_dir)
|
||||
@@ -58,9 +56,6 @@ function! wordy#init(...) abort
|
||||
else
|
||||
let l:msg = 'Unable to read target: ' . l:dst_path
|
||||
endif
|
||||
if has('nvim')
|
||||
call delete(l:src_path)
|
||||
endif
|
||||
else
|
||||
let l:msg = 'Unable to read source: ' . l:src_path
|
||||
endif
|
||||
|
||||
Reference in New Issue
Block a user