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

LTeX commands don't work when ltex.enabled is set to false #106

Closed
pierrebrd opened this issue Dec 10, 2024 · 11 comments
Closed

LTeX commands don't work when ltex.enabled is set to false #106

pierrebrd opened this issue Dec 10, 2024 · 11 comments
Assignees
Labels
1-bug 🐛 Issue type: Bug report (something isn't working as expected)

Comments

@pierrebrd
Copy link

Describe the bug

When the setting "ltex.enabled" is set to false, None of the LTeX commands can be launch, and so it si impossible to activate the extension via the "LTeX : Activate Extension" command.

As explained here : https://ltex-plus.github.io/ltex-plus/settings.html#ltexenabled, when ltex.enabled is set to false, it should not check any language but still be able to be activated when needed

Steps to reproduce

  1. Set ltex.enabled to false
  2. Restart VSCode
  3. Try to lauch any LTeX command (for example : LTeX : Activate Extension)
  4. Get the error popup :
    Screenshot From 2024-12-10 19-14-40

Expected behavior
Commands should be available, especially to start the extension.

LTeX+ configuration

"ltex.enabled": false

"LTeX+ Language Server" log file


"LTeX+ Language Client" log file

2024-12-10T18:14:19.969Z Info: Setting LTeX UI language to 'en-us'.
2024-12-10T18:14:19.970Z Info: Loading i18n messages...
2024-12-10T18:14:19.971Z Info: Loading default i18n messages...

Version information

  • Operating system: Ubuntu 24.10
  • VS Code: 1.95.3
  • vscode-ltex-plus: 15.3.0
@pierrebrd pierrebrd 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 Dec 10, 2024
spitzerd added a commit that referenced this issue Dec 13, 2024
@spitzerd
Copy link
Contributor

You can start testing with the next nightly release. Please test carefully, because I had to change the logic significantly.

@spitzerd spitzerd removed the 2-unconfirmed Issue status: Bug that needs to be reproduced (all new bugs have this label) label Dec 13, 2024
@pierrebrd
Copy link
Author

I tried the latest nightly release, with the latest commit included, and it works well

The "LTeX : Activate Extension" works well and can start the extension when ltex.enabled is set to false.
However, if LTeX has been closed with the "LTeX : Close LTeX+" command, the "LTeX : Activate Extension" can't restart it and I need to use the "LTeX : Reset and Restart" command. This little problem was already there before so it is not related to the nightly version.

However, I still find the way LTeX is triggered and started a bit weird (it is not related to the nightly release, the behavior is the same in older versions) :

When ltex.enabled = false, I need to manually activate the extension with "LTeX : Activate Extension" command. Then, I need to use the "LTeX : Check Current Document" command to start checking a document, but it doesn't work well : for a .tex file, it checks the document but I have to run the command everytime I want to check the text again. The document is checked but I see this in the server logs :
Dec 15, 2024 2:12:38 PM org.bsplines.ltexls.server.DocumentChecker checkAnnotatedTextFragment
FINE: Skipping text check as LTeX has been disabled for files with code language ID 'latex' via ltex.enabled

But for a markdown document, the "LTeX : Check Current Document" command doesn't work, and in the server logs I see :
Dec 15, 2024 2:18:32 PM org.bsplines.ltexls.server.DocumentChecker checkAnnotatedTextFragment
FINE: Skipping text check as LTeX has been disabled for files with code language ID 'markdown' via ltex.enabled

Note : in the .md document, I can still use the "LTeX : Check selection" command to check the entire file.

Server Logs (at the beginning I use the "LTeX : Check Current Document" command for a .tex file, and at the end for a .md file :


[Info  - 2:11:55 PM] Starting ltex-ls...
Dec 15, 2024 2:12:08 PM org.bsplines.ltexls.server.LtexLanguageServer initialize
INFO: ltex-ls 18.4.0-alpha.nightly.2024-12-10 - initializing...
Dec 15, 2024 2:12:08 PM org.bsplines.ltexls.tools.I18n setLocale
INFO: Setting locale to 'en'
Dec 15, 2024 2:12:20 PM org.bsplines.ltexls.settings.SettingsManager$Companion logDifferentSettings
FINE: Reinitializing LanguageTool due to different settings for language 'fr': setting 'settings', old 'null', new 'non-null'
Dec 15, 2024 2:12:38 PM org.bsplines.ltexls.server.DocumentChecker checkAnnotatedTextFragment
FINE: Skipping text check as LTeX has been disabled for files with code language ID 'latex' via ltex.enabled
Dec 15, 2024 2:12:38 PM org.bsplines.ltexls.server.DocumentChecker checkAnnotatedTextFragment
FINE: Skipping text check as LTeX has been disabled for files with code language ID 'latex' via ltex.enabled
Dec 15, 2024 2:12:38 PM org.bsplines.ltexls.server.DocumentChecker checkAnnotatedTextFragment
FINE: Skipping text check as LTeX has been disabled for files with code language ID 'latex' via ltex.enabled
Dec 15, 2024 2:12:38 PM org.bsplines.ltexls.server.DocumentChecker checkAnnotatedTextFragment
FINE: Skipping text check as LTeX has been disabled for files with code language ID 'latex' via ltex.enabled
Dec 15, 2024 2:12:38 PM org.bsplines.ltexls.server.DocumentChecker logTextToBeChecked
FINER: Checking the following text in language 'fr' via LanguageTool: ""
Dec 15, 2024 2:12:38 PM org.bsplines.ltexls.server.DocumentChecker logTextToBeChecked
FINEST: annotatedTextParts = [MARKUP("% LTeX: enabled=true"), FAKE_CONTENT("")]
Dec 15, 2024 2:12:38 PM org.bsplines.ltexls.languagetool.LanguageToolJavaInterface logResultCache
FINER: matchesCache.size() = 0
Dec 15, 2024 2:12:38 PM org.bsplines.ltexls.languagetool.LanguageToolJavaInterface logResultCache
FINER: remoteMatchesCache.size() = 0
Dec 15, 2024 2:12:38 PM org.bsplines.ltexls.languagetool.LanguageToolJavaInterface logResultCache
FINER: sentenceCache.size() = 0
Dec 15, 2024 2:12:38 PM org.bsplines.ltexls.languagetool.LanguageToolJavaInterface logResultCache
FINEST: matchesCache = {}
Dec 15, 2024 2:12:38 PM org.bsplines.ltexls.languagetool.LanguageToolJavaInterface logResultCache
FINEST: remoteMatchesCache = {}
Dec 15, 2024 2:12:38 PM org.bsplines.ltexls.languagetool.LanguageToolJavaInterface logResultCache
FINEST: sentenceCache = {}
Dec 15, 2024 2:12:39 PM org.bsplines.ltexls.server.DocumentChecker checkAnnotatedTextFragment
FINER: Checking done in 338ms
Dec 15, 2024 2:12:39 PM org.bsplines.ltexls.server.DocumentChecker checkAnnotatedTextFragment
FINE: Obtained 0 rule matches
Dec 15, 2024 2:12:39 PM org.bsplines.ltexls.server.DocumentChecker logTextToBeChecked
FINER: Checking the following text in language 'fr' via LanguageTool: "\n\n[L] [R] [C] \n\n\n\n\n\n\n\nProfesseur : \n\n\n\n\n\n\n\n\n\nparagraph.4. . \n\nBien le bonsoir \u00E0 tous, je siis Pierre.\n\nhey, je suis un paragriphe.\n\n"
Dec 15, 2024 2:12:39 PM org.bsplines.ltexls.server.DocumentChecker logTextToBeChecked
FINEST: annotatedTextParts = [MARKUP("\n\n%% Header and footer\n\\usepackage{fancyhdr}\n\\pagestyle{fancy} \n\\fancyhf{} % Clear all header and footer fields (jsp a quoi \u00E7a sert)\n\\fancyhead"), FAKE_CONTENT("\n\n"), TEXT("[L]"), MARKUP("{\\Title} \n\\fancyhead"), FAKE_CONTENT(" "), TEXT("[R]"), MARKUP("{\\rightmark}"), FAKE_CONTENT(""), TEXT(" "), MARKUP("\\fancyfoot"), FAKE_CONTENT(""), TEXT("[C]"), MARKUP("{\\thepage} \n\\setlength{\\headheight}{15pt}\n\n%% Style des titres\n\\sectionfont{\\color{deepblue}}\n\\subsectionfont{\\color{blue}}\n\\subsubsectionfont{\\color{darkgrey}}\n\n\n\\begin{document}\n\n%% Infos du cours\n\\newcommand{\\Course}{Cours}\n\\newcommand{\\Title}{Titre} % Title et non pas title qui est d\u00E9ja une commande interne \u00E0 Latex !\n\\newcommand{\\Teachers}{Prof}\n\\newcommand{\\Authors}{Pierre \\textsc{Bordeau}} % \\textsc pour mettre en petites majuscules\n\\newcommand{\\Date}{2024}\n\n% Version Cours\n\\begin{titlepage}\n    \\vspace*{\\fill}\n    \\centering\n    {\\Large\\bfseries\\textcolor{deepblue}{\\Course}\\par}\n    \\vspace{0.2in}\n    {\\huge\\textcolor{deepblue}{\\Title}\\par}\n    \\vspace{0.2in}\n    {\\Large\\textcolor{deepblue}{"), FAKE_CONTENT(" \n\n\n\n\n\n\n\n"), TEXT("Professeur : "), MARKUP("\\Teachers}\\par}\n    \\vspace{0.5in}\n    \\includegraphics[width=0.2\\textwidth]{/home/pierre/Documents/ENSTA/logo.png}\n\n    \\vspace{0.5in}\n    {\\Large\\textcolor{blue}{\\Authors}\\par}\n    \\vspace{0.2in}\n    {\\textcolor{blue}{\\Date}\\par}\n    \\vspace*{\\fill}\n\\end{titlepage}\n\n% Version Rapport\n% \\begin{titlepage}\n%     \\vspace*{\\fill}\n%     \\centering\n%     {\\Large\\bfseries\\textcolor{deepblue}{\\Course}\\par}\n%     \\vspace{0.2in}\n%     {\\huge\\textcolor{deepblue}{\\Title}\\par}\n%     \\vspace{0.5in}\n%     {\\Large\\textcolor{blue}{\\Authors}\\par}\n%     \\vspace{0.2in}\n%     {\\textcolor{blue}{\\Date}\\par}\n%     \\vspace{0.5in}\n%     \\includegraphics[width=0.2\\textwidth]{/home/pierre/Documents/ENSTA/logo.png}\n%     \\vspace*{\\fill}\n% \\end{titlepage}\n\n\n\\newpage\n\n\\tableofcontents\n\n\\setlength{\\parskip}{0.5\\baselineskip plus 0.3\\baselineskip minus 0.2\\baselineskip} % Permet d'ajouter automatiquement un espace entre les paragraphes. Pour juste aller \u00E0 la ligne sans sauter de ligne, \u00E9crirer \\\\ puis \u00E9crire ce qui sera sur la nouvelle ligne \n\\makeatletter\n\\renewcommand\\paragraph{\\@startsection{"), FAKE_CONTENT("\n\n\n\n\n\n\n\n\n\n"), TEXT("paragraph"), MARKUP("}{"), FAKE_CONTENT("."), TEXT("4"), MARKUP("}{\\z@}{0pt}{-1em}{\\normalfont\\normalsize\\bfseries}}"), FAKE_CONTENT(". ."), TEXT(" "), MARKUP("\\makeatother\n\n\n"), FAKE_CONTENT("\n\n"), TEXT("Bien le bonsoir \u00E0 tous, je siis Pierre.\n\nhey, je suis un paragriphe."), MARKUP("\n\n\n\n\n\\end{document}"), FAKE_CONTENT("\n\n")]
Dec 15, 2024 2:12:39 PM org.bsplines.ltexls.languagetool.LanguageToolJavaInterface logResultCache
FINER: matchesCache.size() = 0
Dec 15, 2024 2:12:39 PM org.bsplines.ltexls.languagetool.LanguageToolJavaInterface logResultCache
FINER: remoteMatchesCache.size() = 0
Dec 15, 2024 2:12:39 PM org.bsplines.ltexls.languagetool.LanguageToolJavaInterface logResultCache
FINER: sentenceCache.size() = 0
Dec 15, 2024 2:12:39 PM org.bsplines.ltexls.languagetool.LanguageToolJavaInterface logResultCache
FINEST: matchesCache = {}
Dec 15, 2024 2:12:39 PM org.bsplines.ltexls.languagetool.LanguageToolJavaInterface logResultCache
FINEST: remoteMatchesCache = {}
Dec 15, 2024 2:12:39 PM org.bsplines.ltexls.languagetool.LanguageToolJavaInterface logResultCache
FINEST: sentenceCache = {}
Dec 15, 2024 2:12:42 PM org.bsplines.ltexls.server.DocumentChecker checkAnnotatedTextFragment
FINER: Checking done in 3555ms
Dec 15, 2024 2:12:42 PM org.bsplines.ltexls.server.DocumentChecker checkAnnotatedTextFragment
FINE: Obtained 4 rule matches
Dec 15, 2024 2:18:32 PM org.bsplines.ltexls.parsing.markdown.MarkdownAnnotatedTextBuilder addCode
FINEST: flexmarkAst = Document[0, 65]
  Paragraph[0, 64] isTrailingBlankLine
    Text[0, 33] chars:[0, 33, "Bien  … mis !"]
    SoftLineBreak[33, 34]
    Text[34, 63] chars:[34, 63, "J'esp … biin."]

Dec 15, 2024 2:18:32 PM org.bsplines.ltexls.server.DocumentChecker checkAnnotatedTextFragment
FINE: Skipping text check as LTeX has been disabled for files with code language ID 'markdown' via ltex.enabled

Client logs :

2024-12-15T13:11:41.338Z Info: Setting LTeX UI language to 'en-us'.
2024-12-15T13:11:41.338Z Info: Loading i18n messages...
2024-12-15T13:11:41.339Z Info: Loading default i18n messages...
2024-12-15T13:11:54.692Z Info: 
2024-12-15T13:11:54.692Z Info: ltex.ltex-ls.path not set.
2024-12-15T13:11:54.692Z Info: Searching for ltex-ls in '/home/pierre/.vscode/extensions/ltex-plus.vscode-ltex-plus-15.3.1-alpha.nightly.2024-12-15/lib'...
2024-12-15T13:11:54.692Z Info: ltex-ls found in '/home/pierre/.vscode/extensions/ltex-plus.vscode-ltex-plus-15.3.1-alpha.nightly.2024-12-15/lib/ltex-ls-plus-18.4.0-alpha.nightly.2024-12-10'.
2024-12-15T13:11:54.692Z Info: 
2024-12-15T13:11:54.692Z Info: Using ltex-ls from '/home/pierre/.vscode/extensions/ltex-plus.vscode-ltex-plus-15.3.1-alpha.nightly.2024-12-15/lib/ltex-ls-plus-18.4.0-alpha.nightly.2024-12-10'.
2024-12-15T13:11:54.692Z Info: Using Java bundled with ltex-ls as ltex.java.path is not set.
2024-12-15T13:11:54.694Z Info: Testing ltex-ls...
2024-12-15T13:11:54.694Z Info:   Command: "/home/pierre/.vscode/extensions/ltex-plus.vscode-ltex-plus-15.3.1-alpha.nightly.2024-12-15/lib/ltex-ls-plus-18.4.0-alpha.nightly.2024-12-10/bin/ltex-ls-plus"
2024-12-15T13:11:54.694Z Info:   Arguments: ["--version"]
2024-12-15T13:11:54.694Z Info:   env['JAVA_HOME']: undefined
2024-12-15T13:11:54.694Z Info:   env['JAVA_OPTS']: "-Xms64m -Xmx1024m"
2024-12-15T13:11:55.441Z Info: Test successful!
2024-12-15T13:11:55.441Z Info: 
2024-12-15T13:11:55.446Z Info: Starting ltex-ls...
2024-12-15T13:11:55.446Z Info:   Command: "/home/pierre/.vscode/extensions/ltex-plus.vscode-ltex-plus-15.3.1-alpha.nightly.2024-12-15/lib/ltex-ls-plus-18.4.0-alpha.nightly.2024-12-10/bin/ltex-ls-plus"
2024-12-15T13:11:55.446Z Info:   Arguments: []
2024-12-15T13:11:55.446Z Info:   env['JAVA_HOME']: undefined
2024-12-15T13:11:55.446Z Info:   env['JAVA_OPTS']: "-Xms64m -Xmx1024m"
2024-12-15T13:11:55.446Z Info: 

If ltex.enabled is set to [], the behavior is the same.

But if there is at least one language in the ltex.enabled list (ex : ltex.enabled = ["markdown"]), the extension is triggered for every language in the default ltex.enabled list, even if the current language is not in the ltex.enabled list in the settings (if ltex.enabled = ["markdown"], opening a .tex document launches the extension as if I've run "LTeX : Activate Extension", but the problems with checking documents are the same as above)

So the problem is that we have to choose between

  1. setting ltex.enabled to false or [], but then checking a document after having manually activated the extension is difficult
  2. setting ltex.enabled to a list with at least 1 language, but then the Java server process is triggered automatically for all the languages in the default ltex.enabled list, and if we want to manually check a document for a language that is not in our custom ltex.enabled list, we have the same difficulties than in 1.

Currently the best solution for me is to keep the default ltex.enabled and manually close LTeX when I don't want it

I guess it would be difficult to change this behavior and it is not a really big issue for most users, so maybe a fix is not really required.

PS: Thanks for the amazing work you're doing on this extension. I might be pointing out some minor issues, but overall, the extension is excellent and much more stable than the classic LTeX.

@spitzerd
Copy link
Contributor

Thank you for your gratitude.

The activation logic of LTeX+ (and also the original LTeX) is as follows:

  1. LTeX+ is triggered by the activation events which are listed in package.json:
"activationEvents": [
    "onCommand:_ltex.openMarkdownExample",
    "onCommand:_ltex.openLatexExample",
    "onLanguage:bibtex",
    "onLanguage:context",
    "onLanguage:context.tex",
    "onLanguage:html",
    "onLanguage:latex",
    "onLanguage:markdown",
    "onLanguage:mdx",
    "onLanguage:typst",
    "onLanguage:org",
    "onLanguage:quarto",
    "onLanguage:restructuredtext",
    "onLanguage:rsweave",
    "onNotebook:*"
  ],

If you open a document with a file type mentioned in the activationEvents, LTeX+ is triggered. Your setting of ltex.enabled does not matter.
Using LTeX : Activate Extension, it has the same effect.

  1. If ltex.enabled is set to false or to an empty array, the Java language server does not start. Otherwise, the language server starts.

The setting ltex.enabled is passed to the language server. Thus, the language server refuses to check the document. I don't know why it's working when you are using LTeX : Check selection.

New in LTeX+ with commit 881b76d is following logic: If you run LTeX : Activate Extension, it also starts the language server if ltex.enabled is set to false or to an empty array. The settings ltex.enabled is still passed to the language server.

LTeX : Activate Extension should work after LTeX : Close LTeX+. For me it's working, but I am using Windows. I have a guess what is maybe the reason. I will fix it.

I see your point that the logic of LTeX+ is quite weird. In my opinion, following logic is the most convenient for most of the users:
LTeX+ is activated everytime VS Code starts. LTeX+ does only check the settings of ltex.enabled, nothing else. Once a file is opened and its file type is included in ltex.enabled, the language server starts and LTeX+ starts checking. If you run LTeX : Check Document, the setting of ltex.enabled is ignored and the document is checked in any case. Consequently, there is no need for LTeX : Activate Extension anymore.

This would be a breaking change and needs more work.

@spitzerd
Copy link
Contributor

I have to correct my previous statement: I have no clue why LTeX : Activate Extensionis not working after LTeX : Close LTeX+. Do you face an error message?

@pierrebrd
Copy link
Author

Thank you for your explanations.

If you open a document with a file type mentioned in the activationEvents, LTeX+ is triggered. Your setting of ltex.enabled does not matter.
Using LTeX : Activate Extension, it has the same effect.
2. If ltex.enabled is set to false or to an empty array, the Java language server does not start. Otherwise, the language server starts.

On my computer, LTeX : Activate Extension forces the Java language server to start, even if ltex.enabled is set to false or []

I have to correct my previous statement: I have no clue why LTeX : Activate Extension is not working after LTeX : Close LTeX+. Do you face an error message?

I don't have any error message, and here are the logs for after doing LTeX : Activate Extension, LTeX : Close LTeX+ and LTeX : Activate Extension (after the last LTeX : Activate Extension, nothing appears in the sever logs (the last line show it has exited) but in client seems to think that the server is running (cf the last line of the client logs)) :

client logs :

2024-12-16T21:22:29.409Z Info: Setting LTeX UI language to 'en-us'.
2024-12-16T21:22:29.409Z Info: Loading i18n messages...
2024-12-16T21:22:29.410Z Info: Loading default i18n messages...
2024-12-16T21:23:08.464Z Info: 
2024-12-16T21:23:08.465Z Info: ltex.ltex-ls.path not set.
2024-12-16T21:23:08.466Z Info: Searching for ltex-ls in '/home/pierre/.vscode-insiders/extensions/ltex-plus.vscode-ltex-plus-15.3.1-alpha.nightly.2024-12-15/lib'...
2024-12-16T21:23:08.468Z Info: ltex-ls found in '/home/pierre/.vscode-insiders/extensions/ltex-plus.vscode-ltex-plus-15.3.1-alpha.nightly.2024-12-15/lib/ltex-ls-plus-18.4.0-alpha.nightly.2024-12-10'.
2024-12-16T21:23:08.468Z Info: 
2024-12-16T21:23:08.468Z Info: Using ltex-ls from '/home/pierre/.vscode-insiders/extensions/ltex-plus.vscode-ltex-plus-15.3.1-alpha.nightly.2024-12-15/lib/ltex-ls-plus-18.4.0-alpha.nightly.2024-12-10'.
2024-12-16T21:23:08.468Z Info: Using Java bundled with ltex-ls as ltex.java.path is not set.
2024-12-16T21:23:08.476Z Info: Testing ltex-ls...
2024-12-16T21:23:08.476Z Info:   Command: "/home/pierre/.vscode-insiders/extensions/ltex-plus.vscode-ltex-plus-15.3.1-alpha.nightly.2024-12-15/lib/ltex-ls-plus-18.4.0-alpha.nightly.2024-12-10/bin/ltex-ls-plus"
2024-12-16T21:23:08.476Z Info:   Arguments: ["--version"]
2024-12-16T21:23:08.476Z Info:   env['JAVA_HOME']: undefined
2024-12-16T21:23:08.476Z Info:   env['JAVA_OPTS']: "-Xms64m -Xmx2048m"
2024-12-16T21:23:09.698Z Info: Test successful!
2024-12-16T21:23:09.699Z Info: 
2024-12-16T21:23:09.707Z Info: Starting ltex-ls...
2024-12-16T21:23:09.707Z Info:   Command: "/home/pierre/.vscode-insiders/extensions/ltex-plus.vscode-ltex-plus-15.3.1-alpha.nightly.2024-12-15/lib/ltex-ls-plus-18.4.0-alpha.nightly.2024-12-10/bin/ltex-ls-plus"
2024-12-16T21:23:09.707Z Info:   Arguments: []
2024-12-16T21:23:09.707Z Info:   env['JAVA_HOME']: undefined
2024-12-16T21:23:09.707Z Info:   env['JAVA_OPTS']: "-Xms64m -Xmx2048m"
2024-12-16T21:23:09.707Z Info: 
[Trace - 10:23:09 PM] Sending request 'initialize - (0)'.
Params: {
    "processId": 1292443,
    "clientInfo": {
        "name": "Visual Studio Code - Insiders",
        "version": "1.97.0-insider"
    },
    "locale": "en",
    "rootPath": "/home/pierre/Documents/test_ltex",
    "rootUri": "file:///home/pierre/Documents/test_ltex",
    "capabilities": {
        "workspace": {
            "applyEdit": true,
            "workspaceEdit": {
                "documentChanges": true,
                "resourceOperations": [
                    "create",
                    "rename",
                    "delete"
                ],
                "failureHandling": "textOnlyTransactional",
                "normalizesLineEndings": true,
                "changeAnnotationSupport": {
                    "groupsOnLabel": true
                }
            },
            "configuration": true,
            "didChangeWatchedFiles": {
                "dynamicRegistration": true,
                "relativePatternSupport": 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
                    ]
                },
                "resolveSupport": {
                    "properties": [
                        "location.range"
                    ]
                }
            },
            "codeLens": {
                "refreshSupport": true
            },
            "executeCommand": {
                "dynamicRegistration": true
            },
            "didChangeConfiguration": {
                "dynamicRegistration": true
            },
            "workspaceFolders": true,
            "foldingRange": {
                "refreshSupport": true
            },
            "semanticTokens": {
                "refreshSupport": true
            },
            "fileOperations": {
                "dynamicRegistration": true,
                "didCreate": true,
                "didRename": true,
                "didDelete": true,
                "willCreate": true,
                "willRename": true,
                "willDelete": true
            },
            "inlineValue": {
                "refreshSupport": true
            },
            "inlayHint": {
                "refreshSupport": true
            },
            "diagnostics": {
                "refreshSupport": 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
                        ]
                    },
                    "labelDetailsSupport": true
                },
                "insertTextMode": 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
                    ]
                },
                "completionList": {
                    "itemDefaults": [
                        "commitCharacters",
                        "editRange",
                        "insertTextFormat",
                        "insertTextMode",
                        "data"
                    ]
                }
            },
            "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": true
            },
            "codeLens": {
                "dynamicRegistration": true
            },
            "formatting": {
                "dynamicRegistration": true
            },
            "rangeFormatting": {
                "dynamicRegistration": true,
                "rangesSupport": 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,
                "foldingRangeKind": {
                    "valueSet": [
                        "comment",
                        "imports",
                        "region"
                    ]
                },
                "foldingRange": {
                    "collapsedText": false
                }
            },
            "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",
                    "decorator"
                ],
                "tokenModifiers": [
                    "declaration",
                    "definition",
                    "readonly",
                    "static",
                    "deprecated",
                    "abstract",
                    "async",
                    "modification",
                    "documentation",
                    "defaultLibrary"
                ],
                "formats": [
                    "relative"
                ],
                "requests": {
                    "range": true,
                    "full": {
                        "delta": true
                    }
                },
                "multilineTokenSupport": false,
                "overlappingTokenSupport": false,
                "serverCancelSupport": true,
                "augmentsSyntaxTokens": true
            },
            "linkedEditingRange": {
                "dynamicRegistration": true
            },
            "typeHierarchy": {
                "dynamicRegistration": true
            },
            "inlineValue": {
                "dynamicRegistration": true
            },
            "inlayHint": {
                "dynamicRegistration": true,
                "resolveSupport": {
                    "properties": [
                        "tooltip",
                        "textEdits",
                        "label.tooltip",
                        "label.location",
                        "label.command"
                    ]
                }
            },
            "diagnostic": {
                "dynamicRegistration": true,
                "relatedDocumentSupport": false
            }
        },
        "window": {
            "showMessage": {
                "messageActionItem": {
                    "additionalPropertiesSupport": true
                }
            },
            "showDocument": {
                "support": true
            },
            "workDoneProgress": true
        },
        "general": {
            "staleRequestSupport": {
                "cancel": true,
                "retryOnContentModified": [
                    "textDocument/semanticTokens/full",
                    "textDocument/semanticTokens/range",
                    "textDocument/semanticTokens/full/delta"
                ]
            },
            "regularExpressions": {
                "engine": "ECMAScript",
                "version": "ES2020"
            },
            "markdown": {
                "parser": "marked",
                "version": "1.1.0"
            },
            "positionEncodings": [
                "utf-16"
            ]
        },
        "notebookDocument": {
            "synchronization": {
                "dynamicRegistration": true,
                "executionSummarySupport": true
            }
        }
    },
    "initializationOptions": {
        "customCapabilities": {
            "workspaceSpecificConfiguration": true
        }
    },
    "trace": "verbose",
    "workspaceFolders": [
        {
            "uri": "file:///home/pierre/Documents/test_ltex",
            "name": "test_ltex"
        }
    ]
}


[Trace - 10:23:29 PM] Received response 'initialize - (0)' in 19842ms.
Result: {
    "capabilities": {
        "textDocumentSync": 1,
        "completionProvider": {},
        "codeActionProvider": {
            "codeActionKinds": [
                "quickfix.ltex.acceptSuggestions"
            ]
        },
        "executeCommandProvider": {
            "commands": [
                "_ltex.checkDocument",
                "_ltex.getServerStatus"
            ]
        }
    }
}


[Trace - 10:23:29 PM] Sending notification 'initialized'.
Params: {}


[Trace - 10:23:29 PM] Sending notification 'workspace/didChangeConfiguration'.
Params: {
    "settings": {
        "ltex": {
            "enabled": false,
            "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": "finest",
                "languageToolHttpServerUri": "",
                "languageToolOrgUsername": "",
                "languageToolOrgApiKey": ""
            },
            "java": {
                "path": "",
                "initialHeapSize": 64,
                "maximumHeapSize": 2048
            },
            "sentenceCacheSize": 2000,
            "completionEnabled": false,
            "diagnosticSeverity": "information",
            "checkFrequency": "edit",
            "clearDiagnosticsWhenClosingFile": true,
            "statusBarItem": false,
            "trace": {
                "server": "verbose"
            }
        }
    }
}


[Trace - 10:23:57 PM] Sending request 'shutdown - (1)'.
[Trace - 10:23:57 PM] Received response 'shutdown - (1)' in 19ms.
Result: {}


[Trace - 10:23:57 PM] Sending notification 'exit'.
No parameters provided.


2024-12-16T21:24:15.020Z Info: ltex-ls was already started. No need to start another instance.

server logs :

[Info  - 10:23:09 PM] Starting ltex-ls...
Dec 16, 2024 10:23:29 PM org.bsplines.ltexls.server.LtexLanguageServer initialize
INFO: ltex-ls 18.4.0-alpha.nightly.2024-12-10 - initializing...
Dec 16, 2024 10:23:29 PM org.bsplines.ltexls.tools.I18n setLocale
INFO: Setting locale to 'en'
Dec 16, 2024 10:23:57 PM org.bsplines.ltexls.server.LtexLanguageServer shutdown
INFO: Shutting down ltex-ls...
Dec 16, 2024 10:23:57 PM org.bsplines.ltexls.server.LtexLanguageServer exit
INFO: Exiting ltex-ls...
[Error - 10:23:58 PM] Server process exited with code 0.

I'm using VSCode on Ubuntu with no extensions, LTeX+ latest nightly and the only settings are :

"ltex.ltex-ls.logLevel": "finest",
"ltex.trace.server": "verbose",
"ltex.enabled": false

I see your point that the logic of LTeX+ is quite weird. In my opinion, following logic is the most convenient for most of the users:
LTeX+ is activated everytime VS Code starts. LTeX+ does only check the settings of ltex.enabled, nothing else. Once a file is opened and its file type is included in ltex.enabled, the language server starts and LTeX+ starts checking. If you run LTeX : Check Document, the setting of ltex.enabled is ignored and the document is checked in any case. Consequently, there is no need for LTeX : Activate Extension anymore.

I agree that this would be a really intuitive logic.

I don't know anything about JavaScript/TypeScript so I can't really help in case you're willing to make those changes

@spitzerd
Copy link
Contributor

spitzerd commented Dec 17, 2024

On my computer, LTeX : Activate Extension forces the Java language server to start, even if ltex.enabled is set to false or []

The original LTeX does not start the language server in this case. LTeX+ does it (see 881b76d)

I don't have any error message, and here are the logs for after doing LTeX : Activate Extension, LTeX : Close LTeX+ and LTeX : Activate Extension (after the last LTeX : Activate Extension, nothing appears in the sever logs (the last line show it has exited) but in client seems to think that the server is running (cf the last line of the client logs)) :

I think there is no need to run LTeX : Check selection after LTeX : Close LTeX+

Please do following steps:

  1. Create a folder with a plain text file and a .vscode/settings.json file with ltex.enabled set to false and open VS Code with this workspace
  2. Run LTeX : Check selection or LTeX : Check Document on the plain text file . You should face an error message, because LTeX+ is not activated yet. Plaintext is not part of the activation events of LTeX+.
  3. Run LTeX : Activate Extension.
  4. Run LTeX : Check selection or LTeX : Check Document again and you should see the spelling mistakes.
  5. Run LTeX : Close LTeX+. The Java process should disappear.
  6. Run LTeX : Check selection or LTeX : Check Document and you should see the spelling mistakes again. The Java process is starting automatically.

@pierrebrd
Copy link
Author

  1. When I open VS Code with those settings, the extension and the server are not started
  2. When I try LTeX : Check selection or LTeX : Check Document on the text file, I get an error, LTeX has not been initialized due to an earlier error.
  3. I run LTeX : Activate Extension and both the extension and the Java language server starts
  4. I run LTeX : Check Document and the spelling mistakes appear
  5. I run LTeX : Close LTeX+ : the mistakes disappear and the Java process shuts down
  6. If I run LTeX : Check Document or LTeX : Check selection, the Java process restarts and the spelling mistakes appear.

But if in 6. I do LTeX : Activate Extension instead of a LTeX : Check ... command, the java process doesn't start and the client log indicates : Info: ltex-ls was already started. No need to start another instance.

So yes, after the initial LTeX : Activate Extension, there is no need to run the command again, a "Check" command is enough.

But there is another problem : If I try this on a .md or .tex file instead of a plain text file, the document is not checked when I runLTeX : Check Document in 3. or 6. and the server logs indicates (here for a .md file) : FINE: Skipping text check as LTeX has been disabled for files with code language ID 'latex' via ltex.enabled

This behavior is the same for every file that is not plain text, not only for the languages that are in the default ltex.enabled array. For example, if I try to check a .py file (containing only sentences, not real python code), nothing is checked and I get FINE: Skipping text check as LTeX has been disabled for files with code language ID 'python' via ltex.enabled in the server logs.
If I try it on a file with an extension that doesn't correspond to any language known by VS Code (like .jfjflss or even .txt), the file is checked as it was a plain text file (when I say plain text file, I mean a file without extension)

@spitzerd
Copy link
Contributor

FINE: Skipping text check as LTeX has been disabled for files with code language ID 'latex' via ltex.enabled

You set ltex.enabled to false, so the response of the server is reasonable. What do you expect?

@pierrebrd
Copy link
Author

You set ltex.enabled to false, so the response of the server is reasonable. What do you expect?

I think that setting ltex.enabled to false should disable automatic checking, but here we can not even force the extension to check a file. The extension should bypass the ltex.enabled setting when we do a manual check with the LTeX : Check Current Document command

@spitzerd
Copy link
Contributor

It's fixed now. You can test again with the next nightly release.

@pierrebrd
Copy link
Author

It's fixed now. You can test again with the next nightly release.

I tested it and it seems fixed 👍

I see your point that the logic of LTeX+ is quite weird. In my opinion, following logic is the most convenient for most of the users:
LTeX+ is activated everytime VS Code starts. LTeX+ does only check the settings of ltex.enabled, nothing else. Once a file is opened and its file type is included in ltex.enabled, the language server starts and LTeX+ starts checking. If you run LTeX : Check Document, the setting of ltex.enabled is ignored and the document is checked in any case. Consequently, there is no need for LTeX : Activate Extension anymore.

I think this idea is still relevant because even after the fixes you made, they are still some inconsistencies : for example, if a language is not in ltex.enabled but we force the document to be checked with LTeX : Check Current Document, it is checked once but is not checked on edit or save accordingly to ltex.checkFrequency. The workaround is to add the language to ltex.enabled, but then the Java process is triggered every time we open a document of a language that is in the "activationEvents" list.
I don't think this problem requires a fix, because this may not be what other people want (some probably prefer the LTeX : Check Current Document to check a document only once).

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)
Projects
None yet
Development

No branches or pull requests

2 participants