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

Add support for LTeX-LS non-standard commands #30

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

abougouffa
Copy link
Member

Background

There are two commands provided by LTeX-LS, _ltex.checkDocument and _ltex.getServerStatus. This adds an initial implementation of the two.

The idea of this draft is to try to fix an issue with the current lsp-ltex.

The problem

I'm using lsp-ltex while writing Org files, I've noticed it to be too slow when editing big files, which is very annoying.

An idea to mitigate this issue

I don't know much about how LSP mode works internally, even for lsp-ltex, I don't see how LSP figures out what command to call when requesting corrections for the document. However, the _ltex.checkDocument have an interesting feature (maybe, the same behavior can be achieved with other means) which allows requesting document checks for regions of the file.

Here is the interface to send to LTeX-LS when requesting the command execution of _ltex.checkDocument:

interface CheckDocumentCommandParams {
  /**
   * URI of the document.
   */
  uri: string;

  /**
   * Code language ID of the document (e.g., `latex`). Will be determined by the file extension
   * of `uri` if missing.
   */
  codeLanguageId?: string;

  /**
   * Text to check. Will be determined as the contents of the file at `uri` if missing.
   */
  text?: string;

  /**
   * Range inside `text` (or the contents of the file at `uri` if missing) if only a part
   * of the document should be checked. Will be set to the range spanning all of `text` if missing.
   */
  range?: Range;
}

type CheckDocumentCommandResult = ServerCommandResult;

The idea is to leverage this to check the document incrementally, while typing, there is no interest to re-check the whole document if all we care about is the current paragraph! So we can send only the current paragraph (in the :range parameter) to avoid rechecking all the document even if it didn't change!

The current implementation for lsp-ltex-check-document allows checking a region (for now, it is implemented synchronously, which should be changed to an aync implementation later). However, after checking a region, I need to disable and enable flycheck-mode to see the wrong words (I don't know how to force flycheck to take new changes into account).

This is just an idea, discussions are welcome, note that I might be slow to respond these days!

Copy link
Member

@jcs090218 jcs090218 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, not sure how I missed this PR...

@jcs090218
Copy link
Member

Feel free to merge this once it's ready!

@abougouffa
Copy link
Member Author

Hi @jcs090218,

Sorry, I didn't see your comment,

I was experimenting on this a while ago, I didn't manage to get a robust working POC. I will try to revisit it when I get some free time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants