valentjn / vscode-ltex

LTeX: Grammar/spell checker :mag::heavy_check_mark: for VS Code using LanguageTool with support for LaTeX :mortar_board:, Markdown :pencil:, and others
https://valentjn.github.io/ltex
Mozilla Public License 2.0
818 stars 29 forks source link

`lang:` YAML variable used by Pandoc Markdown leads to markdown file being ignored for spell check #684

Open paulenit opened 2 years ago

paulenit commented 2 years ago

Describe the bug I tried to spell check a markdown document (in Pandoc's markdown flavor) but LTeX did not mark any errors despite them present. The document contained a YAML header (delimited by ---) with the lang: en_US value.

The issue disappears when:

The LTeX server log leads me to believe that LTeX is trying to use the language defined by the lang tag instead of the one set in the VSCode settings but fails at that consequently skipping the entire document.

I might have overlooked the ability for LTeX to assert the language to check for from the document contents because when setting lang: de-DE LTeX flags non-German words as errors. So this YAML attribute clearly gets read by LTeX. However, in this case this should in my opinion not be fixable by inserting a blank line before the YAML block...

Steps to reproduce Steps to reproduce the behavior:

Install latest version of VSCode and LTeX, paste the sample document and start a check

Expected behavior Spell checking.

Sample document If the bug occurs for a specific document (e.g. LaTeX), please paste it here. If your document is very long or confidential, please create and attach a smaller example for which the bug still occurs so that we can reproduce it.

``` --- # General Pandoc and pacdoc-citeproc options title: Title lang: en_US --- # Introduction Hellook ```

LTeX configuration Please paste all configuration settings starting with ltex. from your settings.json. You can help us by temporarily removing some irrelevant settings from your settings.json and see if the bug still occurs.

``` { "ltex.checkFrequency": "save", "ltex.statusBarItem": true, } ```

"LTeX Language Server" log file First, reproduce the bug. Then, go to ViewOutput and select LTeX Language Server in the drop-down list. Paste this log here:

``` [Info - 3:56:34 PM] Starting ltex-ls... Aug 18, 2022 3:56:36 PM org.bsplines.ltexls.server.LtexLanguageServer initialize INFO: ltex-ls 15.2.0 - initializing... Aug 18, 2022 3:56:36 PM org.bsplines.ltexls.tools.I18n setLocale INFO: Setting locale to 'en' Aug 18, 2022 3:56:36 PM org.bsplines.ltexls.server.DocumentChecker logTextToBeChecked FINE: Checking the following text in language 'en-US' via LanguageTool: "\n\n\n\n\nIntroduction\n\nHellook" Aug 18, 2022 3:56:38 PM org.bsplines.ltexls.server.LtexTextDocumentItem raiseExceptionIfCanceled FINE: Canceling check due to incoming check request... Aug 18, 2022 3:56:38 PM org.bsplines.ltexls.server.DocumentChecker logTextToBeChecked FINE: Checking the following text in language 'en-US' via LanguageTool: "\n\n\n\n\nIntroduction\n\nHellook" Aug 18, 2022 3:56:38 PM org.bsplines.ltexls.server.DocumentChecker checkAnnotatedTextFragment FINE: Obtained 1 rule match Aug 18, 2022 3:56:43 PM org.bsplines.ltexls.server.DocumentChecker logTextToBeChecked FINE: Checking the following text in language 'en-US' via LanguageTool: "\n\n\n\n\nIntroduction\n\nHellook" Aug 18, 2022 3:56:43 PM org.bsplines.ltexls.server.DocumentChecker checkAnnotatedTextFragment FINE: Obtained 1 rule match Aug 18, 2022 3:56:46 PM org.bsplines.ltexls.settings.SettingsManager$Companion logDifferentSettings FINE: Reinitializing LanguageTool due to different settings for language 'en_US': setting 'settings', old 'null', new 'non-null' Aug 18, 2022 3:56:46 PM org.bsplines.ltexls.languagetool.LanguageToolJavaInterface SEVERE: 'en_US' is not a recognized language. Leaving LanguageTool uninitialized, checking disabled. Aug 18, 2022 3:56:46 PM org.bsplines.ltexls.server.DocumentChecker checkAnnotatedTextFragment WARNING: Skipping text check as LanguageTool has not been initialized Aug 18, 2022 3:56:49 PM org.bsplines.ltexls.server.DocumentChecker checkAnnotatedTextFragment WARNING: Skipping text check as LanguageTool has not been initialized ```

"LTeX Language Client" log file First, set the ltex.trace.server setting in your settings.json to "verbose". Then, reload the VS Code window and reproduce the bug. Go to ViewOutput and select LTeX Language Client in the drop-down list. Paste this log here (note: it will contain your checked document):

``` 2022-08-18T14:03:18.974Z Info: Setting LTeX UI language to 'en-us'. 2022-08-18T14:03:18.974Z Info: Loading i18n messages... 2022-08-18T14:03:18.975Z Info: Loading default i18n messages... 2022-08-18T14:03:18.976Z Info: 2022-08-18T14:03:18.976Z Info: ltex.ltex-ls.path not set. 2022-08-18T14:03:18.976Z Info: Searching for ltex-ls in '/home/paulenit/.vscode-oss/extensions/valentjn.vscode-ltex-13.1.0/lib'... 2022-08-18T14:03:18.976Z Info: ltex-ls found in '/home/paulenit/.vscode-oss/extensions/valentjn.vscode-ltex-13.1.0/lib/ltex-ls-15.2.0'. 2022-08-18T14:03:18.976Z Info: 2022-08-18T14:03:18.976Z Info: Using ltex-ls from '/home/paulenit/.vscode-oss/extensions/valentjn.vscode-ltex-13.1.0/lib/ltex-ls-15.2.0'. 2022-08-18T14:03:18.976Z Info: Using Java bundled with ltex-ls as ltex.java.path is not set. 2022-08-18T14:03:18.979Z Info: Testing ltex-ls... 2022-08-18T14:03:18.979Z Info: Command: "/home/paulenit/.vscode-oss/extensions/valentjn.vscode-ltex-13.1.0/lib/ltex-ls-15.2.0/bin/ltex-ls" 2022-08-18T14:03:18.979Z Info: Arguments: ["--version"] 2022-08-18T14:03:18.979Z Info: env['JAVA_HOME']: undefined 2022-08-18T14:03:18.979Z Info: env['JAVA_OPTS']: "-Xms64m -Xmx512m" 2022-08-18T14:03:19.300Z Info: Test successful! 2022-08-18T14:03:19.301Z Info: 2022-08-18T14:03:19.303Z Info: Starting ltex-ls... 2022-08-18T14:03:19.303Z Info: Command: "/home/paulenit/.vscode-oss/extensions/valentjn.vscode-ltex-13.1.0/lib/ltex-ls-15.2.0/bin/ltex-ls" 2022-08-18T14:03:19.303Z Info: Arguments: [] 2022-08-18T14:03:19.303Z Info: env['JAVA_HOME']: undefined 2022-08-18T14:03:19.303Z Info: env['JAVA_OPTS']: "-Xms64m -Xmx512m" 2022-08-18T14:03:19.303Z Info: [Trace - 4:03:19 PM] Sending request 'initialize - (0)'. Params: { "processId": 33602, "clientInfo": { "name": "Code - OSS", "version": "1.70.1" }, "locale": "en-us", "rootPath": "/home/paulenit/Documents/ltex-bugreport", "rootUri": "file:///home/paulenit/Documents/ltex-bugreport", "capabilities": { "workspace": { "applyEdit": true, "workspaceEdit": { "documentChanges": true, "resourceOperations": [ "create", "rename", "delete" ], "failureHandling": "textOnlyTransactional", "normalizesLineEndings": true, "changeAnnotationSupport": { "groupsOnLabel": true } }, "didChangeConfiguration": { "dynamicRegistration": true }, "didChangeWatchedFiles": { "dynamicRegistration": true }, "symbol": { "dynamicRegistration": true, "symbolKind": { "valueSet": [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26 ] }, "tagSupport": { "valueSet": [ 1 ] } }, "codeLens": { "refreshSupport": true }, "executeCommand": { "dynamicRegistration": true }, "configuration": true, "workspaceFolders": true, "semanticTokens": { "refreshSupport": true }, "fileOperations": { "dynamicRegistration": true, "didCreate": true, "didRename": true, "didDelete": true, "willCreate": true, "willRename": true, "willDelete": true } }, "textDocument": { "publishDiagnostics": { "relatedInformation": true, "versionSupport": false, "tagSupport": { "valueSet": [ 1, 2 ] }, "codeDescriptionSupport": true, "dataSupport": true }, "synchronization": { "dynamicRegistration": true, "willSave": true, "willSaveWaitUntil": true, "didSave": true }, "completion": { "dynamicRegistration": true, "contextSupport": true, "completionItem": { "snippetSupport": true, "commitCharactersSupport": true, "documentationFormat": [ "markdown", "plaintext" ], "deprecatedSupport": true, "preselectSupport": true, "tagSupport": { "valueSet": [ 1 ] }, "insertReplaceSupport": true, "resolveSupport": { "properties": [ "documentation", "detail", "additionalTextEdits" ] }, "insertTextModeSupport": { "valueSet": [ 1, 2 ] } }, "completionItemKind": { "valueSet": [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25 ] } }, "hover": { "dynamicRegistration": true, "contentFormat": [ "markdown", "plaintext" ] }, "signatureHelp": { "dynamicRegistration": true, "signatureInformation": { "documentationFormat": [ "markdown", "plaintext" ], "parameterInformation": { "labelOffsetSupport": true }, "activeParameterSupport": true }, "contextSupport": true }, "definition": { "dynamicRegistration": true, "linkSupport": true }, "references": { "dynamicRegistration": true }, "documentHighlight": { "dynamicRegistration": true }, "documentSymbol": { "dynamicRegistration": true, "symbolKind": { "valueSet": [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26 ] }, "hierarchicalDocumentSymbolSupport": true, "tagSupport": { "valueSet": [ 1 ] }, "labelSupport": true }, "codeAction": { "dynamicRegistration": true, "isPreferredSupport": true, "disabledSupport": true, "dataSupport": true, "resolveSupport": { "properties": [ "edit" ] }, "codeActionLiteralSupport": { "codeActionKind": { "valueSet": [ "", "quickfix", "refactor", "refactor.extract", "refactor.inline", "refactor.rewrite", "source", "source.organizeImports" ] } }, "honorsChangeAnnotations": false }, "codeLens": { "dynamicRegistration": true }, "formatting": { "dynamicRegistration": true }, "rangeFormatting": { "dynamicRegistration": true }, "onTypeFormatting": { "dynamicRegistration": true }, "rename": { "dynamicRegistration": true, "prepareSupport": true, "prepareSupportDefaultBehavior": 1, "honorsChangeAnnotations": true }, "documentLink": { "dynamicRegistration": true, "tooltipSupport": true }, "typeDefinition": { "dynamicRegistration": true, "linkSupport": true }, "implementation": { "dynamicRegistration": true, "linkSupport": true }, "colorProvider": { "dynamicRegistration": true }, "foldingRange": { "dynamicRegistration": true, "rangeLimit": 5000, "lineFoldingOnly": true }, "declaration": { "dynamicRegistration": true, "linkSupport": true }, "selectionRange": { "dynamicRegistration": true }, "callHierarchy": { "dynamicRegistration": true }, "semanticTokens": { "dynamicRegistration": true, "tokenTypes": [ "namespace", "type", "class", "enum", "interface", "struct", "typeParameter", "parameter", "variable", "property", "enumMember", "event", "function", "method", "macro", "keyword", "modifier", "comment", "string", "number", "regexp", "operator" ], "tokenModifiers": [ "declaration", "definition", "readonly", "static", "deprecated", "abstract", "async", "modification", "documentation", "defaultLibrary" ], "formats": [ "relative" ], "requests": { "range": true, "full": { "delta": true } }, "multilineTokenSupport": false, "overlappingTokenSupport": false }, "linkedEditingRange": { "dynamicRegistration": true } }, "window": { "showMessage": { "messageActionItem": { "additionalPropertiesSupport": true } }, "showDocument": { "support": true }, "workDoneProgress": true }, "general": { "regularExpressions": { "engine": "ECMAScript", "version": "ES2020" }, "markdown": { "parser": "marked", "version": "1.1.0" } } }, "initializationOptions": { "locale": "en", "customCapabilities": { "workspaceSpecificConfiguration": true } }, "trace": "verbose", "workspaceFolders": [ { "uri": "file:///home/paulenit/Documents/ltex-bugreport", "name": "ltex-bugreport" } ] } [Trace - 4:03:21 PM] Received response 'initialize - (0)' in 2284ms. Result: { "capabilities": { "textDocumentSync": 1, "completionProvider": {}, "codeActionProvider": { "codeActionKinds": [ "quickfix.ltex.acceptSuggestions" ] }, "executeCommandProvider": { "commands": [ "_ltex.checkDocument", "_ltex.getServerStatus" ] } } } [Trace - 4:03:21 PM] Sending notification 'initialized'. Params: {} [Trace - 4:03:21 PM] Sending notification 'workspace/didChangeConfiguration'. Params: { "settings": { "ltex": { "enabled": [ "bibtex", "context", "context.tex", "html", "latex", "markdown", "org", "restructuredtext", "rsweave" ], "language": "en-US", "dictionary": {}, "disabledRules": {}, "enabledRules": {}, "hiddenFalsePositives": {}, "bibtex": { "fields": {} }, "latex": { "commands": {}, "environments": {} }, "markdown": { "nodes": {} }, "configurationTarget": { "dictionary": "workspaceFolderExternalFile", "disabledRules": "workspaceFolderExternalFile", "hiddenFalsePositives": "workspaceFolderExternalFile" }, "additionalRules": { "enablePickyRules": false, "motherTongue": "", "languageModel": "", "neuralNetworkModel": "", "word2VecModel": "" }, "languageToolHttpServerUri": "", "languageToolOrg": { "username": "", "apiKey": "" }, "ltex-ls": { "path": "", "logLevel": "fine", "languageToolHttpServerUri": "", "languageToolOrgUsername": "", "languageToolOrgApiKey": "" }, "java": { "path": "", "initialHeapSize": 64, "maximumHeapSize": 512 }, "sentenceCacheSize": 2000, "completionEnabled": false, "diagnosticSeverity": "information", "checkFrequency": "save", "clearDiagnosticsWhenClosingFile": true, "statusBarItem": true, "trace": { "server": "verbose" } } } } [Trace - 4:03:21 PM] Sending notification 'textDocument/didOpen'. Params: { "textDocument": { "uri": "file:///home/paulenit/Documents/ltex-bugreport/test.md", "languageId": "markdown", "version": 1, "text": "---\n# General Pandoc and pacdoc-citeproc options\ntitle: Title\nlang: en_US\n---\n\n# Introduction\n\nHellook" } } [Trace - 4:03:21 PM] Sending request 'textDocument/codeAction - (1)'. Params: { "textDocument": { "uri": "file:///home/paulenit/Documents/ltex-bugreport/test.md" }, "range": { "start": { "line": 3, "character": 8 }, "end": { "line": 3, "character": 8 } }, "context": { "diagnostics": [] } } [Trace - 4:03:21 PM] Received request 'window/workDoneProgress/create - (1)'. Params: { "token": "{\"uri\":\"file:///home/paulenit/Documents/ltex-bugreport/test.md\",\"operation\":\"checkDocument\",\"uuid\":\"f3e1384e-0ffb-45ad-4ad9-ab9f1f31526e\"}" } [Trace - 4:03:21 PM] Sending response 'window/workDoneProgress/create - (1)'. Processing request took 0ms No result returned. [Trace - 4:03:21 PM] Received response 'textDocument/codeAction - (1)' in 7ms. Result: [] [Trace - 4:03:21 PM] Received notification '$/progress'. Params: { "token": "{\"uri\":\"file:///home/paulenit/Documents/ltex-bugreport/test.md\",\"operation\":\"checkDocument\",\"uuid\":\"f3e1384e-0ffb-45ad-4ad9-ab9f1f31526e\"}", "value": { "kind": "begin", "title": "Checking document", "cancellable": false, "message": "file:///home/paulenit/Documents/ltex-bugreport/test.md" } } [Trace - 4:03:21 PM] Received request 'workspace/configuration - (2)'. Params: { "items": [ { "scopeUri": "file:///home/paulenit/Documents/ltex-bugreport/test.md", "section": "ltex" } ] } [Trace - 4:03:21 PM] Sending response 'workspace/configuration - (2)'. Processing request took 0ms Result: [ { "enabled": [ "bibtex", "context", "context.tex", "html", "latex", "markdown", "org", "restructuredtext", "rsweave" ], "language": "en-US", "dictionary": {}, "disabledRules": {}, "enabledRules": {}, "hiddenFalsePositives": {}, "bibtex": { "fields": {} }, "latex": { "commands": {}, "environments": {} }, "markdown": { "nodes": {} }, "configurationTarget": { "dictionary": "workspaceFolderExternalFile", "disabledRules": "workspaceFolderExternalFile", "hiddenFalsePositives": "workspaceFolderExternalFile" }, "additionalRules": { "enablePickyRules": false, "motherTongue": "", "languageModel": "", "neuralNetworkModel": "", "word2VecModel": "" }, "languageToolHttpServerUri": "", "languageToolOrg": { "username": "", "apiKey": "" }, "ltex-ls": { "path": "", "logLevel": "fine", "languageToolHttpServerUri": "", "languageToolOrgUsername": "", "languageToolOrgApiKey": "" }, "java": { "path": "", "initialHeapSize": 64, "maximumHeapSize": 512 }, "sentenceCacheSize": 2000, "completionEnabled": false, "diagnosticSeverity": "information", "checkFrequency": "save", "clearDiagnosticsWhenClosingFile": true, "statusBarItem": true, "trace": { "server": "verbose" } } ] [Trace - 4:03:21 PM] Received request 'ltex/workspaceSpecificConfiguration - (3)'. Params: { "items": [ { "scopeUri": "file:///home/paulenit/Documents/ltex-bugreport/test.md", "section": "ltex" } ] } [Trace - 4:03:21 PM] Sending response 'ltex/workspaceSpecificConfiguration - (3)'. Processing request took 18ms Result: [ { "dictionary": { "auto": [], "ar": [], "ast-ES": [], "be-BY": [], "br-FR": [], "ca-ES": [], "ca-ES-valencia": [], "da-DK": [], "de": [], "de-AT": [], "de-CH": [], "de-DE": [], "de-DE-x-simple-language": [], "el-GR": [], "en": [], "en-AU": [], "en-CA": [], "en-GB": [], "en-NZ": [], "en-US": [], "en-ZA": [], "eo": [], "es": [], "es-AR": [], "fa": [], "fr": [], "ga-IE": [], "gl-ES": [], "it": [], "ja-JP": [], "km-KH": [], "nl": [], "nl-BE": [], "pl-PL": [], "pt": [], "pt-AO": [], "pt-BR": [], "pt-MZ": [], "pt-PT": [], "ro-RO": [], "ru-RU": [], "sk-SK": [], "sl-SI": [], "sv": [], "ta-IN": [], "tl-PH": [], "uk-UA": [], "zh-CN": [] }, "disabledRules": { "auto": [], "ar": [], "ast-ES": [], "be-BY": [], "br-FR": [], "ca-ES": [], "ca-ES-valencia": [], "da-DK": [], "de": [], "de-AT": [], "de-CH": [], "de-DE": [], "de-DE-x-simple-language": [], "el-GR": [], "en": [], "en-AU": [], "en-CA": [], "en-GB": [], "en-NZ": [], "en-US": [], "en-ZA": [], "eo": [], "es": [], "es-AR": [], "fa": [], "fr": [], "ga-IE": [], "gl-ES": [], "it": [], "ja-JP": [], "km-KH": [], "nl": [], "nl-BE": [], "pl-PL": [], "pt": [], "pt-AO": [], "pt-BR": [], "pt-MZ": [], "pt-PT": [], "ro-RO": [], "ru-RU": [], "sk-SK": [], "sl-SI": [], "sv": [], "ta-IN": [], "tl-PH": [], "uk-UA": [], "zh-CN": [] }, "enabledRules": { "auto": [], "ar": [], "ast-ES": [], "be-BY": [], "br-FR": [], "ca-ES": [], "ca-ES-valencia": [], "da-DK": [], "de": [], "de-AT": [], "de-CH": [], "de-DE": [], "de-DE-x-simple-language": [], "el-GR": [], "en": [], "en-AU": [], "en-CA": [], "en-GB": [], "en-NZ": [], "en-US": [], "en-ZA": [], "eo": [], "es": [], "es-AR": [], "fa": [], "fr": [], "ga-IE": [], "gl-ES": [], "it": [], "ja-JP": [], "km-KH": [], "nl": [], "nl-BE": [], "pl-PL": [], "pt": [], "pt-AO": [], "pt-BR": [], "pt-MZ": [], "pt-PT": [], "ro-RO": [], "ru-RU": [], "sk-SK": [], "sl-SI": [], "sv": [], "ta-IN": [], "tl-PH": [], "uk-UA": [], "zh-CN": [] }, "hiddenFalsePositives": { "auto": [], "ar": [], "ast-ES": [], "be-BY": [], "br-FR": [], "ca-ES": [], "ca-ES-valencia": [], "da-DK": [], "de": [], "de-AT": [], "de-CH": [], "de-DE": [], "de-DE-x-simple-language": [], "el-GR": [], "en": [], "en-AU": [], "en-CA": [], "en-GB": [], "en-NZ": [], "en-US": [], "en-ZA": [], "eo": [], "es": [], "es-AR": [], "fa": [], "fr": [], "ga-IE": [], "gl-ES": [], "it": [], "ja-JP": [], "km-KH": [], "nl": [], "nl-BE": [], "pl-PL": [], "pt": [], "pt-AO": [], "pt-BR": [], "pt-MZ": [], "pt-PT": [], "ro-RO": [], "ru-RU": [], "sk-SK": [], "sl-SI": [], "sv": [], "ta-IN": [], "tl-PH": [], "uk-UA": [], "zh-CN": [] } } ] [Trace - 4:03:21 PM] Received notification '$/progress'. Params: { "token": "{\"uri\":\"file:///home/paulenit/Documents/ltex-bugreport/test.md\",\"operation\":\"checkDocument\",\"uuid\":\"f3e1384e-0ffb-45ad-4ad9-ab9f1f31526e\"}", "value": { "kind": "end" } } [Trace - 4:03:21 PM] Received notification 'textDocument/publishDiagnostics'. Params: { "uri": "file:///home/paulenit/Documents/ltex-bugreport/test.md", "diagnostics": [] } ```

Version information List here the version information of the relevant software.

Additional context/information You can add any other context or information about the problem here.

ProphetLamb commented 2 years ago

I can confirm the bug as described. The empty new-line before the metadata header works as a workaround. Thought, this disables syntax-highligting.

A check to determine the pandoc flavoured markdown would be appreciated.

BOF
---
yaml
---
markdown
EOF
max06 commented 2 years ago

I can also confirm this issue, and I can offer another workaround: Putting the language string into quotes also helps.

ghost commented 1 year ago

Same bug on Ventura, thanks !