Open powerman opened 1 month ago
It looks like related to https://github.com/termux/termux-language-server/discussions/10?
It looks like related to #10?
Yes, it is! I was happy to see it's already supported by Mason, it was a pleasant surprise. In theory Mason support is not required to use lspconfig, but in practice everyone depends on Mason, so without it we'll need some hacks and non-standard setup.
Mason also does not work particularly well on Termux itself,
so it would be nice to have official instuctions for setting up
termux-language-server
with lspconfig.
Mason also does not work particularly well on Termux itself
Not sure I understand what you mean. If there are issues with using Mason itself then all you need to use lspconfig (as shown above) without Mason is to make sure your nvim config won't call some mason plugin (e.g mason itself or 'williamboman/mason-lspconfig.nvim' or 'WhoIsSethDaniel/mason-tool-installer.nvim') to install termux-language-server (e.g. with 'termux_ls' item inside 'ensure_installed' list).
Of course, in this case you'll have to install termux-language-server manually.
If there are issues with using Mason itself then all you need to use lspconfig (as shown above) without Mason is to make sure your nvim config won't call some mason plugin
While recommended configuration for Neovim at https://termux-language-server.readthedocs.io/en/latest/resources/configure.html#neovim works it's inconvenient to use together with lspconfig. I propose to add lspconfig support for termux-language-server.
I've already implemented and tested most of it (I've no idea is it exist and if yes then how to detect a "root dir" for Android Termux and ArchLinux projects, so I leave a TODO comment there). Probably needs some polishing and then you can make a couple PRs:
Here is setup I've used for testing.
~/.config/nvim/lua/lspconfig/server_configurations/termux_ls.lua
:return { default_config = { cmd = { 'termux-language-server' }, filetypes = { -- Android Termux 'sh.build', -- build.sh 'sh.subpackage', -- .subpackage.sh -- ArchLinux/Windows Msys2 'sh.PKGBUILD', -- PKGBUILD 'sh.install', -- .install 'sh.makepkg.conf', -- makepkg.conf -- Gentoo 'sh.ebuild', -- .ebuild 'sh.eclass', -- .eclass 'sh.make.conf', -- /etc/make.conf, /etc/portage/make.conf 'sh.color.map', -- /etc/portage/color.map -- Zsh 'sh.mdd', -- *.mdd }, root_dir = function(fname) local gentoo_repo = util.root_pattern 'profiles/repo_name'(fname) -- TODO: Root detection for Termux and ArchLinux? return gentoo_repo or util.find_git_ancestor(fname) end, single_file_support = true, }, docs = { description = [[ Termux is a language server for some specific bash scripts.
You can install termux-language-server using mason or follow the instructions here: https://termux-language-server.readthedocs.io/en/latest/resources/install.html
The file types are not detected automatically, you can register them manually (see below) or override the filetypes:
]], }, }
That's it, the rest of setup is usual for lspconfig.