mirror of
https://github.com/preservim/vim-wordy.git
synced 2025-11-14 21:03:47 -05:00
mark words dynamically: don't need 2 sets of dicts
The dic file is read in a list, a new list is created with the "!" replaced with "?", the new list is saved in a temporary file, which is used as the dic file. Finally, after used, the temporary file is deleted.
This commit is contained in:
committed by
Suraj N. Kurapati
parent
210dd1077d
commit
03680e115b
@@ -31,11 +31,17 @@ function! wordy#init(...) abort
|
||||
let l:encoding = get(l:args, 'encoding', 'utf-8')
|
||||
for l:dict in l:dicts
|
||||
let l:data_dir = g:wordy_dir . '/data'
|
||||
if has('nvim')
|
||||
let l:data_dir = l:data_dir . '-neovim'
|
||||
endif
|
||||
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)
|
||||
endif
|
||||
let l:spell_dir = g:wordy_dir . '/spell'
|
||||
if !isdirectory(l:spell_dir)
|
||||
call mkdir(expand(l:spell_dir), "p")
|
||||
@@ -52,6 +58,9 @@ 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