hangyav / textLSP

Language server for text spell and grammar check with various tools.
GNU General Public License v3.0
51 stars 3 forks source link

question: how to get other text files to identify as text #2

Closed tanj closed 1 year ago

tanj commented 1 year ago

I'm trying to get a reStructuredText document (extention .rst) to behave as text and be spell check, but I don't seem to get any checking done.

Is there a config for this or should any document type that isn't one that is known be processed as text?

hangyav commented 1 year ago

Yes, all unknown file types should be checked as plain text file. However, you need to set the .rst file type in your config to be checked. What text editor do you use and how does your config look like?

tanj commented 1 year ago

I'm using helix

I took the sample config from the README.md and converted to toml. I'm not sure where to add an extension to be included in checked files.

[[language]]
name = "rst"
language-servers = ["esbonio-lsp", "text-lsp"]
language-id = "restructuredtext"

# other config removed for clarity

[language-server.text-lsp]
command = "C:/Python310/Scripts/textlsp"

[language-server.text-lsp.config.analysers.languagetool]
enabled=true
check_text={on_open=true,on_save=true,on_change=false}

[language-server.text-lsp.config.analysers.gramformer]
enabled=false
gpu=false
check_text={on_open=false,on_save=true,on_change=false}

[language-server.text-lsp.config.analysers.hf_checker]
enabled=true
gpu=false
model='pszemraj/flan-t5-large-grammar-synthesis'
min_length=40
check_text={on_open=false,on_save=true,on_change=false}

[language-server.text-lsp.config.analysers.hf_completion]
enabled=true
gpu=false
model='bert-base-multilingual-cased'
topk=5

[language-server.text-lsp.config.documents]
org={ org_todo_keywords=['TODO','IN_PROGRESS','DONE']}
txt={parse=true}

helix sends this to configure

{
  "jsonrpc": "2.0",
  "method": "workspace/didChangeConfiguration",
  "params": {
    "settings": {
      "analysers": {
        "gramformer": {
          "check_text": {
            "on_change": false,
            "on_open": false,
            "on_save": true
          },
          "enabled": false,
          "gpu": false
        },
        "hf_checker": {
          "check_text": {
            "on_change": false,
            "on_open": false,
            "on_save": true
          },
          "enabled": true,
          "gpu": false,
          "min_length": 40,
          "model": "pszemraj/flan-t5-large-grammar-synthesis"
        },
        "hf_completion": {
          "enabled": true,
          "gpu": false,
          "model": "bert-base-multilingual-cased",
          "topk": 5
        },
        "languagetool": {
          "check_text": {
            "on_change": false,
            "on_open": true,
            "on_save": true
          },
          "enabled": true
        }
      },
      "documents": {
        "org": {
          "org_todo_keywords": [
            "TODO",
            "IN_PROGRESS",
            "DONE"
          ]
        },
        "rst": {
          "parse": true
        },
        "txt": {
          "parse": true
        }
      }
    }
  }
}
hangyav commented 1 year ago

Your config looks good in general. The only issue is that in the config table you need to put everything (analysers and documents) under textLSP, e.g.: [language-server.text-lsp.config.textLSP.analysers.languagetool]. It works for me using helix version 23.05 and the following minimal config:

[[language]]
name = "rst"
language-server = { command="textlsp", language-id = "restructuredtext" }
config = {textLSP={analysers={languagetool={enabled=true,check_text={on_open=true, on_save=true,on_change=false}}}}}
tanj commented 1 year ago

ok, I was able to get diagnostics showing up with the fix to the config. (I also disabled the hf analysers because that seemed to be causing me issues)

Now, I'm getting Code action is not supported for range. errors.

hangyav commented 1 year ago

Great!

What issues do you have with the HF analysers (is it hf_checker or hf_completion, or both)?