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

ignore nodes in code comments #224

Open
qRoC opened this issue Feb 22, 2023 · 1 comment · May be fixed by #238
Open

ignore nodes in code comments #224

qRoC opened this issue Feb 22, 2023 · 1 comment · May be fixed by #238
Labels
1-bug 🐛 Issue type: Bug report (something isn't working as expected) 2-unconfirmed Issue status: Bug that needs to be reproduced (all new bugs have this label)

Comments

@qRoC
Copy link

qRoC commented Feb 22, 2023

Describe the bug

In the official document:

LTEX assumes comments are written in Markdown, except for Python, where reStructuredText is used.

I try set ignore to CodeBlock and FencedCodeBlock nodes in markdown.nodes, but this does not work.

Screenshot 2023-02-22 at 21 05 58

Tested in 15.2.0 and 16.0.0-alpha.1.nightly.2023-02-22.

Sample document

/// This is the main module
///
/// ```
/// assert_eq!(2 + 2, 4);
/// assert_eq!(FromStr::from_str("123"), 123)
/// ```
fn main() {}

LTeX configuration

lspconfig.ltex.setup {
    settings = {
      ltex = {
        -- https://valentjn.github.io/ltex/settings.html
        enabled = {
          "javascript",
          "c",
          "cpp",
          "rust",
          "lua",
          "go",
          "shellscript",
          "php",
          "html",
          "typescript",
          "markdown",
          "restructuredtext",
          "sql",
          "git-commit",
        },
        checkFrequency = "edit",
        language = "en-US",
        dictionary = {
          ["en-US"] = words,
        },
        diagnosticSeverity = "warning",
        sentenceCacheSize = 5000,
        additionalRules = {
          enablePickyRules = false,
          motherTongue = "en",
        },
       ["ltex-ls"] = { logLevel = "finest" },
        trace = { server = "verbose" },
        markdown = {
          -- https://javadoc.io/static/com.vladsch.flexmark/flexmark/0.62.2/com/vladsch/flexmark/ast/package-summary.html
          nodes = {
            CodeBlock = "ignore",
            FencedCodeBlock = "ignore",
            AutoLink = "dummy",
            Code = "dummy",
          },
        },
      },
    },
    cmd = { vim.fn.expand "$XDG_DATA_HOME/.bin/ltex-ls/bin/ltex-ls" },
    filetypes = {
      "javascript",
      "c",
      "cpp",
      "rust",
      "lua",
      "go",
      "bash",
      "php",
      "html",
      "typescript",
      "tsx",
      "markdown",
      "rst",
      "sql",
      "gitcommit",
    },
  }

LTeX LS log
Paste the log (output) of LTeX LS here:


'SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".\nSLF4J: Defaulting to no-operation (NOP) logger implementation'
"\nSLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.\n"
org.bsplines.ltexls.server.LtexLanguageServer initialize\nINFO: ltex-ls 16.0.0-alpha.1.nightly.2023-02-22 - initializing...\n"
org.bsplines.ltexls.settings.SettingsManager$Companion logDifferentSettings\nFINE: Reinitializing LanguageTool due to different settings for language 'en-US': setting 'additionalRules.motherTongue', old '', new 'en'; setting 'sentenceCacheSize', old '2000', new '5000'\n"
org.bsplines.ltexls.parsing.markdown.MarkdownAnnotatedTextBuilder addCode\nFINEST: flexmarkAst = Document[0, 23]\n  Paragraph[0, 23]\n    Text[0, 23] chars:[0, 23, "This  … odule"]\n\n'
org.bsplines.ltexls.parsing.markdown.MarkdownAnnotatedTextBuilder addCode\nFINEST: flexmarkAst = Document[0, 3]\n  FencedCodeBlock[0, 3] open:[0, 3, "```"] lines[0]\n\n'
org.bsplines.ltexls.parsing.markdown.MarkdownAnnotatedTextBuilder addCode\nFINEST: flexmarkAst = Document[0, 21]\n  Paragraph[0, 21]\n    Text[0, 21] chars:[0, 21, "asser … , 4);"]\n\n'
org.bsplines.ltexls.parsing.markdown.MarkdownAnnotatedTextBuilder addCode\nFINEST: flexmarkAst = Document[0, 41]\n  Paragraph[0, 41]\n    Text[0, 41] chars:[0, 41, "asser …  123)"]\n\n'
org.bsplines.ltexls.parsing.markdown.MarkdownAnnotatedTextBuilder addCode\nFINEST: flexmarkAst = Document[0, 3]\n  FencedCodeBlock[0, 3] open:[0, 3, "```"] lines[0]\n\n'
org.bsplines.ltexls.server.DocumentChecker logTextToBeChecked\nFINER: Checking the following text in language 'en-US' via LanguageTool: \"\\n\\n\\nThis is the main module\\n\\n\\n\\nassert_eq!(2 + 2, 4);\\nassert_eq!(FromStr::from_str(\\\"123\\\"), 123)\\n\"\n"
org.bsplines.ltexls.server.DocumentChecker logTextToBeChecked\nFINEST: annotatedTextParts = [MARKUP(""), FAKE_CONTENT("\\n\\n"), MARKUP("/// "), FAKE_CONTENT("\\n"), TEXT("This is the main module"), MARKUP("\\n"), MARKUP("///\\n"), FAKE_CONTENT("\\n\\n"), MARKUP("/// "), FAKE_CONTENT("\\n"), MARKUP("```"), MARKUP("\\n/// "), FAKE_CONTENT("\\n"), TEXT("assert_eq!(2 + 2, 4);"), MARKUP("\\n/// "), FAKE_CONTENT("\\n"), TEXT("assert_eq!(FromStr::from_str(\\"123\\"), 123)"), MARKUP("\\n/// "), FAKE_CONTENT("\\n"), MARKUP("```"), MARKUP("\\n"), MARKUP("fn main() {}\\n")]\n'
org.bsplines.ltexls.languagetool.LanguageToolJavaInterface logResultCache\nFINER: matchesCache.size() = 0\n"
org.bsplines.ltexls.languagetool.LanguageToolJavaInterface logResultCache\nFINER: remoteMatchesCache.size() = 0\n"
org.bsplines.ltexls.languagetool.LanguageToolJavaInterface logResultCache\nFINER: sentenceCache.size() = 0\n"
org.bsplines.ltexls.languagetool.LanguageToolJavaInterface logResultCache\nFINEST: matchesCache = {}\n"
org.bsplines.ltexls.languagetool.LanguageToolJavaInterface logResultCache\nFINEST: remoteMatchesCache = {}\n"
org.bsplines.ltexls.languagetool.LanguageToolJavaInterface logResultCache\nFINEST: sentenceCache = {}\n"
org.bsplines.ltexls.server.DocumentChecker checkAnnotatedTextFragment\nFINER: Checking done in 2108ms\n"
org.bsplines.ltexls.server.DocumentChecker checkAnnotatedTextFragment\nFINE: Obtained 1 rule match\n"
@qRoC qRoC added 1-bug 🐛 Issue type: Bug report (something isn't working as expected) 2-unconfirmed Issue status: Bug that needs to be reproduced (all new bugs have this label) labels Feb 22, 2023
@qRoC
Copy link
Author

qRoC commented Feb 22, 2023

Without nvim:

main.rs:

/// This is the main module
///
/// ```
/// assert_eq!(2 + 2, 4);
/// assert_eq!(FromStr::from_str("123"), 123)
/// ```
fn main() {}

settings.json:

{
  "ltex.enabled": ["rust"],
  "ltex.diagnosticSeverity": "warning",
  "ltex.ltex-ls.logLevel": "finest",
  "ltex.trace.server": "verbose",
  "ltex.markdown.nodes": {
    "FencedCodeBlock": "ignore",
  }
}

Run script:

ltex-cli main.rs --client-configuration=settings.json --verbose

Output:

INFO: Initializing language server...
Feb 22, 2023 9:29:03 PM org.bsplines.lspcli.client.Checker checkFile
INFO: Checking 'main.rs'...
Feb 22, 2023 9:29:03 PM org.bsplines.lspcli.client.Checker checkFile
INFO: Waiting for diagnostics for file 'main.rs'...
main.rs:5:16: warning: 'FromStr': Possible spelling mistake found. [MORFOLOGIK_RULE_EN_US]
/// assert_eq!(FromStr::from_str("123"), 123)
               Use 'Frost'
               Use 'Frosts'
               Use 'Frosty'

@qRoC qRoC linked a pull request Mar 16, 2023 that will close this issue
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1-bug 🐛 Issue type: Bug report (something isn't working as expected) 2-unconfirmed Issue status: Bug that needs to be reproduced (all new bugs have this label)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant