Skip to content

ignore nodes in code comments #224

@qRoC

Description

@qRoC

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"

Metadata

Metadata

Assignees

No one assigned

    Labels

    1-bug 🐛Issue type: Bug report (something isn't working as expected)2-unconfirmedIssue status: Bug that needs to be reproduced (all new bugs have this label)

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions