Skip to content

Commit

Permalink
merge: add lt_command option for vlty
Browse files Browse the repository at this point in the history
refer: #1821
  • Loading branch information
lervag committed Oct 7, 2020
2 parents a59f522 + 49a4015 commit eac991b
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 11 deletions.
1 change: 1 addition & 0 deletions autoload/vimtex/options.vim
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ function! vimtex#options#init() abort " {{{1
\})
call s:init_option('vimtex_grammar_vlty', {
\ 'lt_directory': '~/lib/LanguageTool',
\ 'lt_command': '',
\ 'lt_disable': 'WHITESPACE_RULE',
\ 'lt_enable': '',
\ 'lt_disablecategories': '',
Expand Down
16 changes: 11 additions & 5 deletions compiler/vlty.vim
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ if !executable(s:python)
finish
endif

call system(s:python . ' -c "import sys; assert sys.version_info.major >= 3'
\ . ' and sys.version_info.minor >= 6"')
call system(s:python . ' -c "import sys; assert sys.version_info >= (3, 6)"')
if v:shell_error != 0
call s:installation_error('vlty compiler requires at least Python version 3.6')
finish
Expand All @@ -36,7 +35,12 @@ if s:vlty.server !=# 'lt'
finish
endif

if !filereadable(fnamemodify(s:vlty.lt_directory
if s:vlty.lt_command != ''
if !executable(s:vlty.lt_command)
call s:installation_error('vlty compiler - lt_command not valid')
finish
endif
elseif !filereadable(fnamemodify(s:vlty.lt_directory
\ . '/languagetool-commandline.jar', ':p'))
call s:installation_error('vlty compiler - lt_directory path not valid')
finish
Expand All @@ -51,9 +55,11 @@ let s:language = substitute(s:language, '_', '-', '')

let &l:makeprg =
\ s:python . ' -m yalafi.shell'
\ . ' --lt-directory ' . s:vlty.lt_directory
\ . (s:vlty.lt_command != ''
\ ? ' --lt-command ' . s:vlty.lt_command
\ : ' --lt-directory ' . s:vlty.lt_directory)
\ . (s:vlty.server ==# 'no'
\ ? ''
\ ? ''
\ : ' --server ' . s:vlty.server)
\ . ' --language ' . s:language
\ . ' --disable "' . s:vlty.lt_disable . '"'
Expand Down
26 changes: 20 additions & 6 deletions doc/vimtex.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1627,7 +1627,10 @@ OPTIONS *vimtex-options*
with the following keys (see |vimtex-grammar-vlty| for more details):

lt_directory~
Path to the `LanguageTool` software.
Path to the `LanguageTool` software, if installed manually.

lt_command~
Name of `LanguageTool` executable, if installed via packet manager.

lt_disable~
lt_enable~
Expand All @@ -1646,7 +1649,7 @@ OPTIONS *vimtex-options*
`lt` Contact the Web server provided by `LanguageTool`. In this case,
no local installation is necessary. Please see the following page
for conditions and restrictions:
http://wiki.languagetool.org/public-http-api
https://dev.languagetool.org/public-http-api

shell_options~
Pass additional options to `YaLafi`, e.g., `--equation-punctuation displ`;
Expand All @@ -1661,6 +1664,7 @@ OPTIONS *vimtex-options*
let g:vimtex_grammar_vlty = {
\ 'lt_directory': '~/lib/LanguageTool',
\ 'lt_command': '',
\ 'lt_disable': 'WHITESPACE_RULE',
\ 'lt_enable': '',
\ 'lt_disablecategories': '',
Expand Down Expand Up @@ -4072,8 +4076,12 @@ plain text and combines this with the proofreading software `LanguageTool` [2].

In order to use `vlty`, you need local installations of both components. An
archive of `LanguageTool` can be downloaded from [3]. After uncompressing at
a suitable place, the path to it is specified as shown below. `YaLafi` itself
can be installed with: >
a suitable place, the path to it is specified as shown below. On a system like
`Arch Linux`, `LanguageTool` may also be installed with: >
sudo pacman -S languagetool
`YaLafi` itself can be installed with: >
pip install --user yalafi
Expand All @@ -4084,8 +4092,14 @@ As a minimal example, one could write in |vimrc|: >
set spelllang=en_gb
The given directory has to contain the `LanguageTool` software, including for
instance the file `languagetool-server.jar`. A separated `:compiler vlty` will
raise an error message, if some component cannot be found.
instance the file `languagetool-server.jar`. If `LanguageTool` has been
installed via a packet manager as given above, one would write in |vimrc|: >
let g:vimtex_grammar_vlty = {'lt_command': 'languagetool'}
set spelllang=en_gb
A separated `:compiler vlty` will raise an error message, if some component
cannot be found.

Note: Spell checking with `LanguageTool` is only enabled if a country code is
specified in |'spelllang'|.
Expand Down

0 comments on commit eac991b

Please sign in to comment.