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

cspell incorrectly configured for latex input files #4721

Closed
agseaton opened this issue Feb 11, 2024 · 7 comments · Fixed by #4724
Closed

cspell incorrectly configured for latex input files #4721

agseaton opened this issue Feb 11, 2024 · 7 comments · Fixed by #4724
Labels

Comments

@agseaton
Copy link

Information

VIM version

VIM - Vi IMproved 8.2 (2019 Dec 12, compiled Dec 05 2023 17:58:57)
Included patches: 1-579, 1969, 580-1848, 4975, 5016, 5023, 5072, 2068, 1849-1854, 1857, 1855-1857, 13
31, 1858, 1858-1859, 1873, 1860-1969, 1992, 1970-1992, 2010, 1993-2068, 2106, 2069-2106, 2108, 2107-2
109, 2109-3995, 4563, 4646, 4774, 4895, 4899, 4901, 4919, 213, 1840, 1846-1847, 2110-2112, 2121

Operating System: Ubuntu 22.04 LTS

What went wrong

I've installed ALE and cslint to spell-check LaTeX documents. However, cslint doesn't recognise the latex syntax since it is being passed the --language-id flag tex rather than latex. The command used to run cslint is:

['/bin/bash', '-c', '''/path/to/cspell'' lint --no-color --no-progress --no-summary --language-id="tex" -- stdin < ''/tmp/vMX1sQp/3/document.tex''']

It is straightforward to fix this temporarily using let g:ale_cspell_options = "--language-id latex", but it would be ideal to have this automatically configured.

Reproducing the bug

  1. Install cslint
  2. Open a LaTeX document

:ALEInfo

Expand Current Filetype: tex Available Linters: ['alex', 'chktex', 'cspell', 'lacheck', 'proselint', 'redpen', 'texlab', 'textlint', 'vale', 'writegood'] Linter Aliases: 'writegood' -> ['write-good'] Enabled Linters: ['alex', 'chktex', 'cspell', 'lacheck', 'proselint', 'redpen', 'texlab', 'textlint', 'vale', 'writegood'] Ignored Linters: [] Suggested Fixers: 'latexindent' - Indent code within environments, commands, after headings and within special code blocks. 'remove_trailing_lines' - Remove all blank lines at the end of a file. 'textlint' - Fix text files with textlint --fix 'trim_whitespace' - Remove all trailing whitespace characters at the end of every line.

Linter Variables:
let g:ale_tex_chktex_executable = 'chktex'
let g:ale_tex_chktex_options = '-I'
let g:ale_tex_lacheck_executable = 'lacheck'
let g:ale_tex_texlab_config = {}
let g:ale_tex_texlab_executable = 'texlab'
let g:ale_tex_texlab_options = ''

Global Variables:
let g:ale_cache_executable_check_failures = v:null
let g:ale_change_sign_column_color = 0
let g:ale_command_wrapper = ''
let g:ale_completion_delay = v:null
let g:ale_completion_enabled = 0
let g:ale_completion_max_suggestions = v:null
let g:ale_disable_lsp = 'auto'
let g:ale_echo_cursor = 1
let g:ale_echo_msg_error_str = 'Error'
let g:ale_echo_msg_format = '%code: %%s'
let g:ale_echo_msg_info_str = 'Info'
let g:ale_echo_msg_warning_str = 'Warning'
let g:ale_enabled = 1
let g:ale_fix_on_save = 0
let g:ale_fixers = {}
let g:ale_history_enabled = 1
let g:ale_info_default_mode = 'preview'
let g:ale_history_log_output = 1
let g:ale_keep_list_window_open = 0
let g:ale_lint_delay = 200
let g:ale_lint_on_enter = 1
let g:ale_lint_on_filetype_changed = 1
let g:ale_lint_on_insert_leave = 1
let g:ale_lint_on_save = 1
let g:ale_lint_on_text_changed = 'normal'
let g:ale_linter_aliases = {}
let g:ale_linters = {}
let g:ale_linters_explicit = 0
let g:ale_linters_ignore = {'cpp': ['cc', 'clang-format', 'clangcheck'], 'python': ['mypy']}
let g:ale_list_vertical = 0
let g:ale_list_window_size = 10
let g:ale_loclist_msg_format = '%code: %%s'
let g:ale_max_buffer_history_size = 20
let g:ale_max_signs = -1
let g:ale_maximum_file_size = v:null
let g:ale_open_list = 0
let g:ale_pattern_options = v:null
let g:ale_pattern_options_enabled = v:null
let g:ale_root = {}
let g:ale_set_balloons = 0
let g:ale_set_highlights = 1
let g:ale_set_loclist = 1
let g:ale_set_quickfix = 0
let g:ale_set_signs = 1
let g:ale_sign_column_always = 0
let g:ale_sign_error = 'E'
let g:ale_sign_info = 'I'
let g:ale_sign_offset = 1000000
let g:ale_sign_style_error = 'E'
let g:ale_sign_style_warning = 'W'
let g:ale_sign_warning = 'W'
let g:ale_sign_highlight_linenrs = 0
let g:ale_type_map = {}
let g:ale_use_neovim_diagnostics_api = 0
let g:ale_use_global_executables = v:null
let g:ale_virtualtext_cursor = 'disabled'
let g:ale_warn_about_trailing_blank_lines = 1
let g:ale_warn_about_trailing_whitespace = 1

Command History:

(executable check - failure) alex
(executable check - success) chktex
(finished - exit code 2) ['/bin/bash', '-c', '''chktex'' -v0 -p stdin -q -s TabSize=1 -I < ''/tmp/vMX1sQp/2/report.tex''']

<<>>
stdinTabSize=140TabSize=146TabSize=18TabSize=1Wrong length of dash may have been used.
stdinTabSize=147TabSize=16TabSize=11TabSize=1Command terminated with space.
stdinTabSize=186TabSize=154TabSize=18TabSize=1Wrong length of dash may have been used.
stdinTabSize=1111TabSize=117TabSize=11TabSize=1Command terminated with space.
stdinTabSize=1129TabSize=11TabSize=124TabSize=1Delete this space to maintain correct pagereferences.
stdinTabSize=1137TabSize=117TabSize=18TabSize=1Wrong length of dash may have been used.
stdinTabSize=1363TabSize=164TabSize=113TabSize=1Intersentence spacing (`@') should perhaps be used.
stdinTabSize=1397TabSize=110TabSize=126TabSize=1You ought to remove spaces in front of punctuation.
stdinTabSize=1424TabSize=13TabSize=18TabSize=1Wrong length of dash may have been used.
stdinTabSize=1425TabSize=13TabSize=18TabSize=1Wrong length of dash may have been used.
stdinTabSize=1426TabSize=13TabSize=18TabSize=1Wrong length of dash may have been used.
stdinTabSize=1427TabSize=13TabSize=18TabSize=1Wrong length of dash may have been used.
stdinTabSize=1428TabSize=13TabSize=18TabSize=1Wrong length of dash may have been used.
stdinTabSize=1429TabSize=13TabSize=18TabSize=1Wrong length of dash may have been used.
stdinTabSize=1430TabSize=13TabSize=18TabSize=1Wrong length of dash may have been used.
stdinTabSize=1431TabSize=13TabSize=18TabSize=1Wrong length of dash may have been used.
stdinTabSize=1432TabSize=13TabSize=18TabSize=1Wrong length of dash may have been used.
stdinTabSize=1433TabSize=13TabSize=18TabSize=1Wrong length of dash may have been used.
stdinTabSize=1434TabSize=13TabSize=18TabSize=1Wrong length of dash may have been used.
<<>>

(executable check - success) /path/to/cspell
(finished - exit code 1) ['/bin/bash', '-c', '''/path/to/cspell'' lint --no-color --no-progress --no-summary --language-id="tex" -- stdin < ''/tmp/vMX1sQp/3/report.tex''']

<<>>
./:1:2 - Unknown word (documentclass)
./:1:16 - Unknown word (letterpaper)
./:1:29 - Unknown word (twocolumn)
./:14:2 - Unknown word (setlength)
./:14:13 - Unknown word (marginparwidth)
./:16:2 - Unknown word (usepackage)
./:17:2 - Unknown word (usepackage)
./:17:13 - Unknown word (nidanfloat)
./:18:2 - Unknown word (usepackage)
./:19:2 - Unknown word (usepackage)
./:19:13 - Unknown word (graphicx)
./:20:2 - Unknown word (usepackage)
./:20:13 - Unknown word (tabularx)
./:21:13 - Unknown word (xltabular)
./:22:13 - Unknown word (booktabs)
./:23:13 - Unknown word (pdfpages)
./:24:13 - Unknown word (hyperref)
./:25:13 - Unknown word (textsize)
./:25:22 - Unknown word (footnotesize)
./:25:36 - Unknown word (todonotes)
./:27:13 - Unknown word (chngcntr)
./:28:2 - Unknown word (counterwithin)
./:29:2 - Unknown word (counterwithin)
./:31:6 - Unknown word (projectname)
./:33:2 - Unknown word (renewcommand)
./:33:16 - Unknown word (familydefault)
./:33:32 - Unknown word (sfdefault)
./:37:4 - Unknown word (includepdf)
./:38:2 - Unknown word (includepdf)
./:40:9 - Unknown word (textbf)
./:40:17 - Unknown word (projectname)
./:44:2 - Unknown word (onecolumn)
./:45:2 - Unknown word (pagenumbering)
./:49:2 - Unknown word (noindent)
./:55:2 - Unknown word (noindent)
./:55:12 - Unknown word (includegraphics)
./:55:39 - Unknown word (textwidth)
./:59:2 - Unknown word (noindent)
./:63:2 - Unknown word (noindent)
./:66:2 - Unknown word (newpage)
./:67:2 - Unknown word (pagenumbering)
./:68:2 - Unknown word (maketitle)
./:70:2 - Unknown word (tableofcontents)
./:72:2 - Unknown word (twocolumn)
./:74:4 - Unknown word (newgeometry)
./:78:2 - Unknown word (textbf)
./:91:2 - Unknown word (textbf)
./:101:2 - Unknown word (newpage)
./:102:2 - Unknown word (textbf)
./:111:2 - Unknown word (restoregeometry)
./:112:2 - Unknown word (twocolumn)
./:122:2 - Unknown word (textit)
./:122:61 - Unknown word (projectname)
./:352:2 - Unknown word (clearpage)
./:353:2 - Unknown word (newpage)
./:357:2 - Unknown word (newcommand)
./:357:14 - Unknown word (glossentry)
./:357:35 - Unknown word (textbf)
./:357:53 - Unknown word (textit)
./:360:6 - Unknown word (glossentry)
./:363:6 - Unknown word (glossentry)
./:365:6 - Unknown word (glossentry)
./:368:6 - Unknown word (glossentry)
./:383:2 - Unknown word (newpage)
./:390:2 - Unknown word (noindent)
./:411:2 - Unknown word (onecolumn)
./:415:2 - Unknown word (renewcommand)
./:415:16 - Unknown word (arraystretch)
./:416:8 - Unknown word (xltabular)
./:416:23 - Unknown word (textwidth)
./:418:7 - Unknown word (raggedright)
./:418:19 - Unknown word (arraybackslash)
./:419:7 - Unknown word (raggedright)
./:419:19 - Unknown word (arraybackslash)
./:420:7 - Unknown word (raggedright)
./:420:19 - Unknown word (arraybackslash)
./:421:2 - Unknown word (toprule)
./:423:2 - Unknown word (midrule)
./:450:2 - Unknown word (bottomrule)
./:454:6 - Unknown word (xltabular)
./:456:4 - Unknown word (includepdf)
./:457:2 - Unknown word (includepdf)
<<>>

(executable check - success) lacheck
(finished - exit code 0) ['/bin/bash', '-c', '''lacheck'' ''/tmp/vMX1sQp/4/report.tex''']

<<>>
"/tmp/vMX1sQp/4/report.tex", line 397: Whitespace before punctation mark in " ?"
"/tmp/vMX1sQp/4/report.tex", line 417: possible unwanted space at "{"
<<>>

(executable check - failure) proselint
(executable check - failure) redpen
(executable check - failure) texlab
(executable check - failure) textlint
(executable check - failure) vale
(executable check - failure) write-good

@agseaton agseaton added the bug label Feb 11, 2024
@hsanson
Copy link
Contributor

hsanson commented Feb 21, 2024

Language Id is set using the filetype (see cspell.vim#L19)

From what I read in vim/nvim there is no latex filetype and they use tex for latex documents: (see g:tex_flavor).

I cannot find documented what language-id values are supported by cspell so cannot be sure, but a possible solution is to create a map between cspell language-id and vim filetypes for those that do not match exactly. For example map filetype tex to language-id latex and filetype plaintex to language-id tex, etc.

@agseaton
Copy link
Author

Yes, that does seem to be what is causing this issue.

I guess if we could take into account the g:tex_flavor variable that would solve this particular issue. Though that page you linked has multiple other file types with ambiguities so it would be nicer to have a more general solution.

@hsanson
Copy link
Contributor

hsanson commented Feb 22, 2024

@agseaton quick hack to fix this: #4724 appreciated if you can test it.

@agseaton
Copy link
Author

I'd be happy to test it out, but I'm not sure how. I used vim-plug to install ale. If you have some quick instructions I can follow I can test it out for you.

@hsanson
Copy link
Contributor

hsanson commented Feb 24, 2024

First figure out where vim-plug is downloading the ALE plugin... usually is in $HOME/.nvim/bundle/ale but can be different depending on you configuration. Then

cd $HOME/.nvim/bundle/ale  
git fetch origin pull/4724/head:fix-4724
git checkout fix-4724

After the above you should have the PR in you local. Proceed to test if this fixes the problem for you.

Afterwards you may want to revert back to master branch:

cd $HOME/.nvim/bundle/ale  
git checkout master

@agseaton
Copy link
Author

Got it, thanks for the explanation! Busy tomorrow but I'll give it a go on Sunday most likely.

@agseaton
Copy link
Author

Tested it out just now and seems to work. Thanks again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants