Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compiler vlty: support LanguageTool as installed by pacman #1821

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions autoload/vimtex/options.vim
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,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 @@ -1615,7 +1615,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~
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like it better if there's an empty line between the descriptions. Also, I'm curious if lt_command perhaps should be the first entry here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like it better if there's an empty line between the descriptions.

OK, I will insert a blank line.

Also, I'm curious if lt_command perhaps should be the first entry here?

Don't know, which key is more important. But I assume that most people will install LanguageTool "manually".

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

lt_disable~
lt_enable~
Expand All @@ -1634,7 +1637,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 @@ -1649,6 +1652,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 @@ -4060,8 +4064,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 @@ -4072,8 +4080,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