[nvim] Add thesaurus autodownload

Fix location of thesaurus to follow XDG specification for application
data (in `.local/share/nvim/thesaurus`).

Automatically download thesaurus if it is not found.
This commit is contained in:
Marty Oehme 2020-07-10 10:15:16 +02:00
parent a505976485
commit f8371f0e73
No known key found for this signature in database
GPG key ID: 0CCB0526EFB9611A

View file

@ -2,10 +2,17 @@
let g:tq_map_keys=0
" set custom mthesaur file if we have it
if exists("$XDG_CONFIG_HOME")
let g:tq_mthesaur_file=getenv("XDG_CONFIG_HOME") . "/nvim/thesaurus/mthesaur.txt"
if exists('$XDG_DATA_HOME')
let g:tq_mthesaur_file='$XDG_DATA_HOME' . '/nvim/thesaurus/mthesaur.txt'
else
let g:tq_mthesaur_file=expand("~/.config/nvim/thesaurus/mthesaur.txt")
let g:tq_mthesaur_file=expand('~/.local/share/nvim/thesaurus/mthesaur.txt')
endif
" download if we don't
if !filereadable(glob(g:tq_mthesaur_file))
echom 'No thesaurus file found, attempting to download in background...'
execute '!curl -fLo ' . expand(g:tq_mthesaur_file) . ' --create-dirs
\ http://www.gutenberg.org/files/3202/files/mthesaur.txt'
endif
let g:tq_language=['en', 'de']