GithubHelp home page GithubHelp logo

emacs-languagetool / lsp-ltex Goto Github PK

View Code? Open in Web Editor NEW
49.0 3.0 7.0 182 KB

lsp-mode ❤️ LTEX

License: GNU General Public License v3.0

Emacs Lisp 97.90% Makefile 2.10%
emacs lsp languagetool emacs-lsp ltex

lsp-ltex's People

Contributors

abougouffa avatar dependabot[bot] avatar jcs090218 avatar phundrak avatar rathur421 avatar rdiaz02 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

lsp-ltex's Issues

Does not work with `lsp-use-plists`

When one uses lsp-use-plists (set-up according to the lsp-mode documentation), an error occurs while trying to use any code action. For example, trying to include XMonad in the dictionary results in

lsp-ltex--code-action-add-to-dictionary: Wrong type argument: hash-table-p, (:uri "file:<URL>" :words (:en-US ["XMonad"]))

This seems to be because lsp-ltex--action-add-to-rules expects (as the same suggests) action-ht to be a hash-table

(defun lsp-ltex--action-add-to-rules (action-ht key rules-plist &optional store)
  "Execute action ACTION-HT by getting KEY and storing it in the RULES-PLIST.
When STORE is non-nil, this will also store the new plist in the directory
`lsp-ltex-user-rules-path'."
  (let ((args-ht (gethash key action-ht)))
    (dolist (lang (hash-table-keys args-ht))
      (mapc (lambda (rule)
              (lsp-ltex--add-rule lang rule rules-plist)
              (when store
                (lsp-ltex--serialize-symbol rules-plist lsp-ltex-user-rules-path)))
            (gethash lang args-ht)))))

However, this is a plist with the above configuration. Instead of e.g. gethash, the generic lsp-get should be used.

Correct path for LTeX ?

I’m using Doom Emacs and I want to use LTeX on windows (native) and WSL.

On WSL, everything works fine. But on native, I can’t install ltex. I’ve downloaded the latest version, but I don’t know how to put files with new paths

I use the .config structure, so

.config/doom for configuration files
.config/emacs for doom emacs

I’ve put LTeX in .local/cache, .local/cache/.cache, with latest or ltex-1.6.0.0, but none works. Any idea ?

lsp-ltex does not recognize already installed ltex-ls

ltex-ls is already installed on my machine at /usr/bin/ltex-ls (with the AUR’s ltex-ls-bin package), yet each time I try to launch lsp in my org-mode buffer it tries to install the server. Thing is, it fails every time as it tries to install in the same path as the already existing ltex-ls, regardless of the value of lsp-ltex-server-store-path, even if ltex-ls is not already installed.

I tried the following configurations:

(use-package lsp-ltex
  :ensure t
  :defer t
  :straight (:build t)
  :config
  (setq lsp-ltex-mother-tongue "fr-FR"
        lsp-ltex-server-store-path (executable-find "ltex-ls")
        lsp-ltex-version
        (gethash "ltex-ls"
                 (json-parse-string (shell-command-to-string "ltex-ls -V")))))

And

(use-package lsp-ltex
  :defer t
  :straight (:build t)
  :config
  (setq lsp-ltex-mother-tongue "fr-FR"
        lsp-ltex-server-store-path (expand-file-name ".cache/lsp/ltex-ls" user-emacs-directory)
        lsp-ltex-version
        (gethash "ltex-ls"
                 (json-parse-string (shell-command-to-string "ltex-ls -V")))))

Both with the same result.

Adding an error threshold

First of all, thank you for the initiative to publish lsp-ltex that I have just discovered.

I take the initiative to open this issue because I tested lsp-ltex with a text-mode hook (which includes org-mode) and I noticed that lsp-ltex (or LanguageTool) cannot deal well when a file got a too many (~2653) of errors as shown below.

2021-09-10-121859

At each "edit" (can also be for each save) of the file, lsp-ltex contacts LanguageTool with all the content of this file, which takes time and heats up my CPU. To avoid this issue, maybe it would be nice to propose to the user a variable to limit the use of LanguageTool for a file that contains a number of errors reaching a certain threshold. In other words, if lsp-ltex would encounters a file that exceeds a certain number of errors, then it should does nothing or disables itself.

If you wondering, this is the config of lsp-ltex that I use.

(use-package lsp-ltex
  :hook (text-mode . lsp-deferred)
  :custom
  (lsp-ltex-enabled t)
  (lsp-ltex-mother-tongue "fr"))

It is also possible that I can work around this problem by creating my own function that I hook and blacklist some files manually. However, probably an abstract solution to the user would be better.

error on use-package

Error (use-package): lsp-ltex/:catch: Symbol’s function definition is void: lsp-ltex--current-version

.dir-locals.el is not respected by lsp-ltex.

Basically, I want to use lsp-ltex in a directory with Spanish content. I put this into the .dir-local.el inside the folder

;;; Directory Local Variables            -*- no-byte-compile: t -*-
;;; For more information see (info "(emacs) Directory Variables")

((markdown-mode . ((lsp-ltex-language . "es")
                   (ispell-local-dictionary . "spanish"))))

However, the variable lsp-ltex-language is still on "en_US"

image

How could I set the language locally?

How to use the ltex-dictionary variable

I would like to set up a list of technical words for the dictionary used by ltex.
I've tried

(setq lsp-ltex-dictionary "{\"en-US\": [\":~/myConfig/my-words.txt\"]}")

and

(setq lsp-ltex-dictionary "{\"en-US\": [\"quasiparticle\"]}")

but none of them works.
Does anyone know how to set up such a list? Thanks.

lsp-ltex with eglot?

It would be great if lsp-ltex could work with eglot, thinking that it will be merged into master anytime soon.

Best.

How to ignore org-mode syntax?

Thank you for lsp-ltex!
I've got one question: how to make lsp-ltex org-mode aware? Regarding the documentation of the ltex server, org-mode should work out of the box, but for me it does not. lsp-ltex marks org-mode tags (e.g., “#+OPTIONS: …”) as spelling error.

Configuration over Tramp

I frequently edit .txt or .md files on remote machines. Could you please share an example on how to configure and use the package over Tramp? Thanks.

`JAVA_HOME is not defined correctly` error with platform-dependent version

I get the following error when opening a Markdown file:

Error: JAVA_HOME is not defined correctly.
  We cannot execute 

Process ltex-ls stderr finished

I've downloaded ltex-ls-16.0.0-linux-x64.tar.gz and extracted it in the right place, so I think it should work.


I'm on Ubuntu 22.04.2 LTS, on WSL2.

My config w.r.t. this package looks like this:

(use-package
 lsp-ltex
 :hook
 (markdown-mode . lsp)
 (rst-mode . lsp)
 :init (setq lsp-ltex-version "16.0.0"))

Can't get it to work with `rst-mode`

My config looks like this:

(use-package
 lsp-ltex
 :hook
 (markdown-mode . lsp)
 (rst-mode . lsp)
 :init (setq lsp-ltex-version "16.0.0"))

but when I open a .rst file I get:

LSP :: There are no language servers supporting current mode `rst-mode' registered with `lsp-mode'.

I thought ltex-ls supported reStructuredText.

Activating lsp-ltex in other modes

First of all thanks for lsp-ltex!

I got it running in mu4e's mu4e-compose-mode on doomemacs with the following steps:

Before (use-package! lsp-ltex ...), pre-defining lsp-ltex-active-modes makes lsp-ltex take the change. In my case:

(defcustom lsp-ltex-active-modes
  '(text-mode
    bibtex-mode context-mode
    latex-mode LaTeX-mode ;; AUCTeX 14+ has renamed latex-mode to LaTeX-mode
    markdown-mode org-mode
    rst-mode
    mu4e-compose-mode)
  "List of major mode that work with LTEX Language Server."
  :type 'list
  :group 'lsp-ltex)

At that point lsp works when composing, with the following warning:

Warning (lsp-mode): Unable to calculate the languageId for buffer ‘XXX’. Take a look at ‘lsp-language-id-configuration’. The ‘major-mode’ is mu4e-compose-mode

So adding

(after! lsp-ltex
  (appendq! lsp-language-id-configuration
            '((mu4e-compose-mode . "plaintext"))))

gets that solved.

Could there be a more generic setting for the list of modes activated?

Premium features

Hello,

can this package take advantage of LanguageTool's Premium features?

Can't add word to dictionary

This is likely a problem with ltex-ls but I thought I would report it here first and maybe someone can confirm it or help me get more info on the problem.

To maybe reproduce write the following in a buffer with ltex-ls connected

We are looking for a semijoin equivalence.

The word semijoin will be underlined. C-c l a a > Add 'semijoin' to dictionary should make the the occurances of semijoin to be accepted but nothing happens.

New version of lsp-ltex is not started

Several days ago I updated all packages, including this one.
I found lsp-ltex is not started after the update, without error messages.
It was fine before. Is there change that could possibly cause this issue?
Thanks!

Don't seem to be find the lsp-ltex direction

lsp-ltex keep prompting me to install the language server after installing it.  

follow the instruction and downloaded the server and extract it to "~/.emacs.d/.cache/lsp/ltex-ls/ltex-ls-15.2.0"
and yet the package can't seem to find the language server

Emacs version: GNU Emacs 28.0.90 (build 1, x86_64-apple-darwin19.6.0, NS appkit-1894.60 Version 10.15.7 (Build 19H1519)) of 2021-12-13
lsp-ltex version: 20211024.809

Screen Shot 2022-01-18 at 7 04 10 PM

Screen Shot 2022-01-18 at 7 06 59 PM

Suggestions offered by ltex-ls are not shown

ltex-ls often offers suggestions, but these are not shown by lsp-ltex. For example, with a file that contains this

She go home

running ltex-ls (actually, ltex-cli) from the command line will give

 The pronoun 'she' is usually used with a third-person or a past tense verb. [HE_VERB_AGR]
she go home
    Use 'goes'
    Use 'went'

However, in Emacs I do not see the suggestions for using "goes" or "went".
The following is a screen capture
lsp

Minor documentation fix: JAVA_HOME does not need to be setup if using the standalone ltex-ls version that includes java

Minor suggestion to the README.md, that says "P.S. LanguageTool is built with Java, make sure you have environment variable JAVA_HOME set up"

Actually, lsp-ltex runs just fine without setting JAVA_HOME if you download the standalone archives (for example, ltex-ls-15.2.0-linux-x64.tar.gz from https://github.com/valentjn/ltex-ls/releases/download/15.2.0/ltex-ls-15.2.0-linux-x64.tar.gz). I simply downloaded and decompressed under ~/.emacs.d/.cache/lsp/ltex-ls/ .

Possible to read dictionary from file?

I'm wondering, is it possible to read a dictionary of spellcheck-words to ignore from a file?

I've tried using one in a .vscode directory (actually the one VSCode generates), since the ltex-ls docs seem to indicate it will look for that file automatically. But it doesn't seem to find it in emacs.

Ideally, it would also be possible to add words, like #4 is asking about.

Thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.