Closed uwidev closed 2 months ago
Based on a quick look at your config this should work. Do you get any error messages when opening a text file with nvim? It's odd that textlsp's icon in the mason list is gray. Is there any particular reason for that? Could you verify that it is actually installed under ~/.local/share/nvim/mason/packages
?
It's odd that textlsp's icon in the mason list is gray. Is there any particular reason for that?
It's my theme. Whatever my cursor is over colors the line grey.
Do you get any error messages when opening a text file with nvim?
I get no errors whatsoever when opening any .text
files. I tried the .org
and .tex
and no responses at all.
Could you verify that it is actually installed under ~/.local/share/nvim/mason/packages?
~/.local/share/nvim/mason/packages
ls
bash-language-server ruff-lsp stylua
css-lsp rust-analyzer tailwindcss-language-server
docker-compose-language-service shellcheck textlsp
jedi-language-server shfmt typescript-language-server
lua-language-server some-sass-language-server typos-lsp
ls textlsp
mason-receipt.json venv
ls textlsp/venv
bin include lib lib64 pyvenv.cfg share
ls textlsp/venv/bin
activate convert-caffe2-to-onnx httpx numpy-config pip3.12 textlsp
activate.csh convert-onnx-to-caffe2 huggingface-cli openai python torchrun
activate.fish distro isympy pip python3 tqdm
Activate.ps1 f2py normalizer pip3 python3.12 transformers-cli
I forgot to mention this, but I am using neovim v0.11.0-dev-283+gfe5d1279a4
.
Just to confirm, I should have LanguageTool
installed on my system just to test of the plugin can connect, right? I'm using Archlinux and I installed thorugh the AUR. Was that all that had to be done to test if the plugin works?
Addition: If I try to LspStart
the LSP, it doesn't even show up.
I can try an extremely barebones config sometime later, this is really weird.
Accidentally closed.
It seems that manually having require('lspconfig').textlsp.setup({})
allows the LSP to be detected and work just fine, which is to perhaps say that something's is funky with how kickstart's lsp integration interacts with textlsp.
Here's a better import of what I used for lazy. The important stuff is at the bottom.
Update: It seems that for some reason, the textlsp
key-value is not being passed to mason-lspconfig
handler function. A simple print(server_name)
was used to check if textlsp
was even being processed, which it isn't. I confirmed that it actually exists in the table by inspect
ing it.
It seems that it's because textlsp
is not registered in williamboman/mason-lspconfig repository. If you want I can go ahead and issue a pull request over there to implement textlsp. It doesn't look that hard since it seems like it's just 3 line additions across 3 files, but I'm also not sure if you need to do more.
Locally on my machine, I edited mason-lspconfig
to add the mapping for textlsp and the plugin loaded. I have yet to test if the rest of the functionality works.
Update: languagetool
seems to work, however, when trying to use Ollama, I get the following error message.
LSP[textlsp] Unsupported module: textLSP.analysers.ollama
Using this following setup
require('lspconfig').textlsp.setup {
settings = {
textLSP = {
analysers = {
languagetool = {
enabled = false,
},
ollama = {
enabled = true,
check_text = {
on_open = false,
on_save = true,
on_change = false,
},
model = 'phi3:3.8b-instruct', -- smaller but faster model
-- model = "phi3:14b-instruct", -- more accurate
max_token = 50,
},
},
},
},
}
Update 2: Mason registry is on v0.3.0. Manually updating with pip to install the current up to date repo. And it works!
I guess the majority of the problem was not having the mapping integration in mason-registry and mason packages being out of date.
Thanks for looking into this. I'm not familiar with how kickstart is configured, but I tested it with a clean LazyVim installation that uses mason-registry and a simple .config/nvim/lua/plugins/lspconfig.lua
config:
return {
"neovim/nvim-lspconfig",
opts = {
servers = {
textlsp = {},
},
},
}
After installing textlsp with MasonInstall textlsp
manually, it worked. So just for future reference to others running into similar issues since I'm not too familiar with the works of Mason either, what was the main issue? You need to make sure mason-registry
is included in the config or we need to add textlsp to williamboman/mason-lspconfig?
Answering your other questions:
Just to confirm, I should have LanguageTool installed on my system just to test of the plugin can connect, right? I'm using Archlinux and I installed thorugh the AUR. Was that all that had to be done to test if the plugin works?
For the LanguageTool analyser you only need to make sure that Java is installed, the tool itself is installed automatically. Otherwise, it should be good to go (by default only the LanguageTool analyser is enabled).
It seems that it's because textlsp is not registered in williamboman/mason-lspconfig repository. If you want I can go ahead and issue a pull request over there to implement textlsp. It doesn't look that hard since it seems like it's just 3 line additions across 3 files, but I'm also not sure if you need to do more.
It would be nice if you could do that, thanks!
when trying to use Ollama, I get the following error message. LSP[textlsp] Unsupported module: textLSP.analysers.ollama
Yeah, for now Ollama is in the latest github version only. I'll release it to pypi hopefully soon.
So just for future reference to others running into similar issues since I'm not too familiar with the works of Mason either, what was the main issue? You need to make sure mason-registry is included in the config or we need to add textlsp to williamboman/mason-lspconfig?
As far as I'm aware, mason-lspconfig is a wrapper of sorts for mason and nvim-lspconfig. More or less it automatically fetches the related mason package and sets it up for you via lspconfig; it just trivializes the process. That said, it only works if an lsp name passed to it is actually registered. This is because lspconfig and mason use slightly different naming conventions, so this mapping is required to map the mason package to the lspconfig setup.
If you take a look at some of the example pull requests, it's really quite simple. The pull request has been made.
For anyone using mason-lspconfig, their options at the moment are to manually apply the mason-lspconfig edits themselves (as seen above in the pull request) on their local install or manually call setup()
.
textlsp does not seem to be detected after installation using nvim-lspconfig. Is there more I'm supposed to do after adding it under the config?
Relevant but gutted init.lua
```lua require('lazy').setup({ { -- LSP Configuration & Plugins 'neovim/nvim-lspconfig', dependencies = { { 'williamboman/mason.nvim', config = true }, -- NOTE: Must be loaded before dependants 'williamboman/mason-lspconfig.nvim', 'WhoIsSethDaniel/mason-tool-installer.nvim', { 'j-hui/fidget.nvim', opts = {} }, { 'folke/neodev.nvim', opts = {} }, }, config = function() vim.api.nvim_create_autocmd('LspAttach', { group = vim.api.nvim_create_augroup('kickstart-lsp-attach', { clear = true }), callback = function(event) -- keybind mappings would go here -- removed for clarity local client = vim.lsp.get_client_by_id(event.data.client_id) if client and client.server_capabilities.documentHighlightProvider then local highlight_augroup = vim.api.nvim_create_augroup('kickstart-lsp-highlight', { clear = false }) vim.api.nvim_create_autocmd({ 'CursorHold', 'CursorHoldI' }, { buffer = event.buf, group = highlight_augroup, callback = vim.lsp.buf.document_highlight, }) vim.api.nvim_create_autocmd({ 'CursorMoved', 'CursorMovedI' }, { buffer = event.buf, group = highlight_augroup, callback = vim.lsp.buf.clear_references, }) vim.api.nvim_create_autocmd('LspDetach', { group = vim.api.nvim_create_augroup('kickstart-lsp-detach', { clear = true }), callback = function(event2) vim.lsp.buf.clear_references() vim.api.nvim_clear_autocmds { group = 'kickstart-lsp-highlight', buffer = event2.buf } end, }) end end, }) local capabilities = vim.lsp.protocol.make_client_capabilities() capabilities = vim.tbl_deep_extend('force', capabilities, require('cmp_nvim_lsp').default_capabilities()) local servers = { tsserver = { cmd = { 'typescript-language-server', '--stdio' }, }, -- python ruff_lsp = {}, jedi_language_server = {}, -- shell/bash scripting bashls = {}, -- lua lua_ls = { settings = { Lua = { completion = { callSnippet = 'Replace', }, }, }, }, -- regular text textlsp = {}, }, -- Ensure the servers and tools above are installed local ensure_installed = vim.tbl_keys(servers or {}) vim.list_extend(ensure_installed, { 'stylua', -- Used to format Lua code 'shellcheck', 'shfmt', }) require('mason-tool-installer').setup { ensure_installed = ensure_installed } require('mason-lspconfig').setup { handlers = { function(server_name) local server = servers[server_name] or {} -- This handles overriding only values explicitly passed -- by the server configuration above. Useful when disabling -- certain features of an LSP (for example, turning off formatting for tsserver) server.capabilities = vim.tbl_deep_extend('force', {}, capabilities, server.capabilities or {}) require('lspconfig')[server_name].setup(server) end, }, } end, }, }) ```LspInfo
when a buffer is open of filea.text
Mason
I have also tried the default config provided under readme as well as manual defaults from nvim-lspconfig and it also does not work.