hangyav / textLSP

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

Analyziers can not work except languagetool. #37

Closed fatbadfrog closed 2 months ago

fatbadfrog commented 2 months ago

It is great for providing such excellent module. But when I followed the intructions in README, only languagetool can work correctly in the Neovim. I have installed ollamma manually. It seemed that ollamma and hf_checker can run normally if I tested it under terminal. However, in the neovim, it can not work. I use nvm-lspconfig to set textlsp. When I put the settings provided in the README in require("lspconfig").textlsp.setup({}) , it can not take effect. For example, even I set 'enabled = false' in languagetool section, the languagetool can still lanuch and analyze my latex code. Could you help me solving this problem?

languagetool works in my neovim. neovide_LF1nHSlxN9

code action also work 32JdFVU07o

fatbadfrog commented 2 months ago

I think i solve this problem. Here are key points (suppose you are using miniconda and kickstart):

  1. using miniconda install textlsp, ollama (also rember download some model, in my config, i use phi3:mini) and grammarformer;
  2. creat lspconfig.lua in ~/.config/nvim/lua/custom/plugins/ (if your neovim config is not kickstart nor your neovim config folder is not located in ~/.config/, please put lspconfig.lua in the right place);
  3. put code below in your lspconfig.lua

return { require("lspconfig").textlsp.setup({ cmd = { "/home/ffw/miniconda3/bin/textlsp" }, (very important, use the textlsp installed by miniconda, not Mason. For me textlsp installed by Mason has some problems.) settings = { textLSP = { analysers = { languagetool = { enabled = false, }, ollama = { enabled = true, check_text = { on_open = false, on_save = true, on_change = false, }, model = "phi3:mini", -- smaller but faster model -- model = "phi3:14b-instruct", -- more accurate max_token = 50, }, gramformer = { -- gramformer dependency needs to be installed manually enabled = false, gpu = false, check_text = { on_open = false, on_save = false, on_change = false, }, }, hf_checker = { enabled = false, gpu = false, quantize = 32, model = "pszemraj/flan-t5-large-grammar-synthesis", min_length = 40, check_text = { on_open = false, on_save = false, on_change = false, }, }, hf_instruction_checker = { enabled = true, gpu = false, quantize = 32, model = "grammarly/coedit-large", min_length = 40, check_text = { on_open = false, on_save = false, on_change = false, }, }, hf_completion = { enabled = true, gpu = false, quantize = 32, model = "bert-base-multilingual-cased", topk = 5, }, }, }, }, }), }

Now everything should be all right. Textlsp analyzer is enabled according to yourself. For me, ollama, hf_instruction_checker and hf_completion is enabled. But I feel hf_instruction_checker is not good.