valentjn / ltex-ls

LTeX Language Server: LSP language server for LanguageTool :mag::heavy_check_mark: with support for LaTeX :mortar_board:, Markdown :pencil:, and others
https://valentjn.github.io/ltex
Mozilla Public License 2.0
717 stars 33 forks source link

`lineCommentRegexString` does not recognize a comment without a whitespace #273

Open Wansmer opened 9 months ago

Wansmer commented 9 months ago

Describe the bug

If there is no space or tab before the comment body after the start of a line comment, lineCommentRegexString will not recognize it as a comment.

Example in Lua:

ltex_comment

I checked in lua, typescript, javascript and rust: similarly, without a space the comment is not recognized. I think the problem #259 is also due to the missing space.

Steps to reproduce

  1. Open new .lua file;
  2. Write comment with typo;
  3. Delete whitespace between -- and comment body;
  4. The diagnostic message disappears.

Expected behavior

A comment without whitespace will be recognizing correctly.

LTeX configuration

This is for Neovim with lspconfig:

```lua local ft = { 'gitcommit', 'markdown', 'org', 'pandoc', 'text', 'lua', 'javascript', 'typescript', 'typescriptreact', 'typescript', 'vue', 'html', 'toml', 'yaml', 'json', 'rust', 'go', } return { filetypes = ft, settings = { ltex = { enabled = ft, checkFrequency = 'save', language = 'en-US', diagnosticSeverity = 'information', setenceCacheSize = 5000, additionalRules = { enablePickyRules = true, }, }, }, } ```

Version information

Additional context/information

I think the fixes are needed in this line: https://github.com/valentjn/ltex-ls/blob/7c031d792110a824951aa003acd3ada158a515b4/src/main/kotlin/org/bsplines/ltexls/parsing/program/ProgramCommentRegexs.kt#L30

Something like this:

"[ \t]*(?:.*?)$(?:\r?\n)?)+)"