Giter VIP home page Giter VIP logo

termux-language-server's Introduction

termux-language-server

readthedocs pre-commit.ci status github/workflow codecov DeepSource

github/downloads github/downloads/latest github/issues github/issues-closed github/issues-pr github/issues-pr-closed github/discussions github/milestones github/forks github/stars github/watchers github/contributors github/commit-activity github/last-commit github/release-date

github/license github/languages github/languages/top github/directory-file-count github/code-size github/repo-size github/v

pypi/status pypi/v pypi/downloads pypi/format pypi/implementation pypi/pyversions

Language server for some specific bash scripts:

This language server only provides extra features which bash-language-server doesn't support:

[package_name]
source = "github"
github = "author_name/repo_name"
use_max_tag = true

Other features:

Screenshots

Diagnostic

diagnostic

Document Link

document link

Hover

keyword

package

Completion

completion

arch

license

depends

How Does It Work

See here.

Read readthedocs to know more.

termux-language-server's People

Contributors

freed-wu 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

termux-language-server's Issues

Termux -style

Go to home dir - cd $HOME # Clone this repository (use gh repo clone adi1090x/termux-style if you want to use the GitHub CLI)- git clone https://github.com/adi1090x/termux-style # Change to termux-style dir - cd termux-style # To install it, run - ./install # And follow the steps, it'll be installed on your system.

[PKGBUILD] Parsing of Bash arrays erroneous

This line arch=("x86_64") results in the following error:

'"' is not one of ['any', 'pentium4', 'i486', 'i686', 'x86_64', 'x86_64_v3', 'arm', 'armv6h', 'armv7h', 'armv8', 'aarch64']

This happens for all Bash arrays. The quotes are recognised as own elements.

license=("MIT") errors with '"' is not one of ['AGPL3', 'Apache', ....

This bug was probably introduced with a fix for #4.

False positive warnings on split packages?

I'm getting the following on the doxygen PKGBUILD:

E   1 # Maintainer: Jakub Klinkovský <lahwaacz at archlinux dot org>     ■ Split PKGBUILD needs additional makedepends ['libfmt.so', 'libspdlog.so', 'libsqlite3.so'] to work properly
    2 # Maintainer: Levente Polyak <anthraxx[at]archlinux[dot]org>
    3 # Contributor: Dan McGee <[email protected]>
    4
    5 pkgbase=doxygen
    6 pkgname=(doxygen doxygen-docs)
W   7 pkgver=1.11.0     ■ pkgver: is unsorted due to pkgbase@file:///home/lahwaacz/doxygen/PKGBUILD:5:1-5:7
W   8 pkgrel=4     ■ pkgrel: is unsorted due to pkgbase@file:///home/lahwaacz/doxygen/PKGBUILD:5:1-5:7
W   9 pkgdesc='Documentation system for C++, C, Java, IDL and PHP'     ■ pkgdesc: is unsorted due to pkgbase@file:///home/lahwaacz/doxygen/PKGBUILD:5:1-5:7
W  10 url='http://www.doxygen.nl'     ■ url: is unsorted due to pkgbase@file:///home/lahwaacz/doxygen/PKGBUILD:5:1-5:7
   11 arch=(x86_64)
...
  103 package_doxygen-docs() {
W 104   pkgdesc='Developer documentation for doxygen'     ■ pkgdesc: is unsorted due to pkgbase@file:///home/lahwaacz/doxygen/PKGBUILD:5:1-5:7
  105
  106   mv -v $pkgname/* "$pkgdir"
  107   install -vDm 644 $pkgbase-Release_${pkgver//./_}/LICENSE -t "$pkgdir/usr/share/licenses/$pkgname/"
  108 }
  109
  110 # vim: ts=2 sw=2 et:

Why does it warn about unsorted pkgver, pkgrel, pkgdesc and url? Also note that a pkgdesc defined in the package_doxygen-docs function is fine too.

Multiple "SKIP" in hash arrays

If there needs to be multiple times "SKIP" in the hash array, an error message like ['SKIP', 'SKIP', 'SKIP', 'SKIP', 'SKIP', 'SKIP', 'SKIP', 'SKIP', 'SKIP', 'SKIP', 'SKIP', 'SKIP', 'SKIP', 'SKIP', 'SKIP', 'SKIP', 'SKIP', 'SKIP', 'SKIP', 'SKIP', '3802c7aae4c26cf23a61c48fedabe1d4bb516bbc07e42573cdb8cdfd19a556cc0b65941eae03ce b1c9cbf3eff2d40742e01eea12f3b420ae0d277c3582368b34'] has non-unique elements occurs. This should probably not be the case for "SKIP" but for all other hashes.

Support for neovim/nvim-lspconfig

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:

  1. Add server configuration file to https://github.com/neovim/nvim-lspconfig/tree/master/lua/lspconfig/server_configurations
  2. Add mapping between lspconfig's name "termux_ls" and mason's name "termux-language-server" to https://github.com/williamboman/mason-lspconfig.nvim/blob/main/lua/mason-lspconfig/mappings/server.lua

Here is setup I've used for testing.

  1. ~/.config/nvim/lua/lspconfig/server_configurations/termux_ls.lua:
local util = require 'lspconfig.util'

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:

```lua
vim.filetype.add {
  extension = {
    -- ArchLinux/Windows Msys2
    install = 'sh.install',
    -- Gentoo
    ebuild = 'sh.ebuild',
    eclass = 'sh.eclass',
    -- Zsh
    mdd = 'sh.mdd',
  },
  filename = {
    -- Android Termux
    ['build.sh'] = 'sh.build',
    -- ArchLinux/Windows Msys2
    ['PKGBUILD'] = 'sh.PKGBUILD',
    ['makepkg.conf'] = 'sh.makepkg.conf',
  },
  pattern = {
    -- Android Termux
    ['.*%.subpackage%.sh'] = 'sh.subpackage',
    -- Gentoo
    ['.*/etc/make%.conf'] = 'sh.make.conf',
    ['.*/etc/portage/make%.conf'] = 'sh.make.conf',
    ['.*/etc/portage/color%.map'] = 'sh.color.map',
  },
}
```
]],
    },
}
  1. Somewhere else in my configs:
    vim.filetype.add {
        extension = {
            -- ArchLinux/Windows Msys2
            install = 'sh.install',
            -- Gentoo
            ebuild = 'sh.ebuild',
            eclass = 'sh.eclass',
            -- Zsh
            mdd = 'sh.mdd',
        },
        filename = {
            -- Android Termux
            ['build.sh'] = 'sh.build',
            -- ArchLinux/Windows Msys2
            ['PKGBUILD'] = 'sh.PKGBUILD',
            ['makepkg.conf'] = 'sh.makepkg.conf',
        },
        pattern = {
            -- Android Termux
            ['.*%.subpackage%.sh'] = 'sh.subpackage',
            -- Gentoo
            ['.*/etc/make%.conf'] = 'sh.make.conf',
            ['.*/etc/portage/make%.conf'] = 'sh.make.conf',
            ['.*/etc/portage/color%.map'] = 'sh.color.map',
        },
    }
  1. At beginning of lspconfig setup (adding our config because it's not supported officially yet):
            local configs = require 'lspconfig.configs'
            if not configs['termux_ls'] then
                configs['termux_ls'] = require 'lspconfig/server_configurations/termux_ls'
            end
            local server = require 'mason-lspconfig.mappings.server'
            server.lspconfig_to_package['termux_ls'] = 'termux-language-server'
            server.package_to_lspconfig['termux-language-server'] = 'termux_ls'

That's it, the rest of setup is usual for lspconfig.

List of known licenses is wrong for Gentoo / generate schema / Sort variable names

For example, here are list of GPL licenses allowed by termux-language-server while checking *.ebuild:

GPL-1.0-only
GPL-1.0-or-later
GPL-2.0-only
GPL-2.0-or-later
GPL-2.0-with-autoconf-exception
GPL-2.0-with-classpath-exception
GPL-2.0-with-font-exception
GPL-2.0-with-GCC-exception
GPL-3.0-linking-exception
GPL-3.0-linking-source-exception
GPL-3.0-only
GPL-3.0-or-later
GPL-3.0-with-autoconf-exception
GPL-3.0-with-GCC-exception
GPL-CC-1.0

but here are actual Gentoo GPL licenses (output of (cd /usr/portage/licenses/ && ls -1 GPL-*)):

GPL-1
GPL-1+
GPL-2
GPL-2+
GPL-2-with-classpath-exception
GPL-2+-with-eCos-exception-2
GPL-2-with-exceptions
GPL-2-with-font-exception
GPL-2-with-linking-exception
GPL-2-with-MySQL-FLOSS-exception
GPL-2+-with-openssl-exception
GPL-2+-with-Pyinstaller-Bootloader-exception
GPL-3
GPL-3+
GPL-3+-with-autoconf-exception
GPL-3-with-font-exception
GPL-3+-with-font-exception
GPL-3-with-openssl-exception

as result I get this error:

$ grep LICENSE termux-language-server-0.0.23.ebuild
LICENSE="GPL-3"
$ termux-language-server --check termux-language-server-0.0.23.ebuild
termux-language-server-0.0.23.ebuild:15:10-15:15:error: 'GPL-3' does not match '(389-exception|Abstyles|CDL-1.0|DOC|...

Errors happen

An error occurs everytime so that the programme does not work at all. I assume the same error repreats. This should be a single instance of it appearing:

Ignoring notification for unknown method "workspace/didChangeConfiguration"
Failed to handle user defined notification "textDocument/didOpen": (DidOpenTextDocumentParams(text_document=TextDocumentItem(uri='file:///home/matheus/aur/cli11/PKGBUILD', language_id='PKGBUILD', version=1, text='#!/usr/bin/env bash\n# shellcheck disable=SC2034\n# shellcheck disable=SC2154\n# The PKGBUILD for Inja.\n# Maintainer: Matheus <[email protected]>\n# Contributor: Matheus <[email protected]>\n\ndeclare -r _tag="17eb440d6792960c1a56d2b8832b9edd23eadab3"\n\npkgname="inja"\npkgver="3.4.0"\npkgrel="1"\npkgdesc="A template engine for modern C++."\narch=("any")\nurl="https://github.com/Spixmaster/${pkgname}"\nlicense=("MIT")\ndepends=("nlohmann-json")\nmakedepends=("cmake" "doxygen")\ncheckdepends=("doctest")\nsource=("${pkgname}::git+${url}.git#tag=${_tag}")\nsha512sums=("SKIP")\n\nbuild()\n{\n    for status in "OFF" "ON"; do\n        cmake -B "${srcdir}"/"${pkgname}"/build/ -D BUILD_BENCHMARK=OFF -D BUILD_TESTING="${status}" -D CMAKE_BUILD_TYPE=None -D CMAKE_INSTALL_PREFIX=/usr/ -D COVERALLS=OFF -D INJA_BUILD_TESTS="${status}" -D INJA_EXPORT=ON -D INJA_INSTALL=ON -D INJA_INSTALL_SINGLE_HEADER=ON -D INJA_USE_EMBEDDED_JSON=OFF -S "${srcdir}"/"${pkgname}"/ -Wno-dev\n        cmake --build "${srcdir}"/"${pkgname}"/build/\n    done\n}\n\ncheck()\n{\n    cd "${srcdir}"/"${pkgname}"/build/ || exit 1\n    ./inja_test\n    ./single_inja_test\n}\n\npackage()\n{\n    # Assure that the directories exist.\n    mkdir -p "${pkgdir}"/usr/share/doc/"${pkgname}"/\n    mkdir -p "${pkgdir}"/usr/share/licenses/"${pkgname}"/\n\n    # Install the software.\n    DESTDIR="${pkgdir}"/ cmake --install "${srcdir}"/"${pkgname}"/build/\n\n    # Install the documentation.\n    install -Dm644 "${srcdir}"/"${pkgname}"/README.md "${pkgdir}"/usr/share/doc/"${pkgname}"/\n\n    cd "${srcdir}"/"${pkgname}"/doc/ || exit 1\n    doxygen Doxyfile\n    cp -r "${srcdir}"/"${pkgname}"/doc/* "${pkgdir}"/usr/share/doc/"${pkgname}"/\n\n    find "${pkgdir}"/usr/share/doc/"${pkgname}"/ -type d -exec chmod 755 {} +\n    find "${pkgdir}"/usr/share/doc/"${pkgname}"/ -type f -exec chmod 644 {} +\n\n    # Install the license.\n    install -Dm644 "${srcdir}"/"${pkgname}"/LICENSE "${pkgdir}"/usr/share/licenses/"${pkgname}"/\n}\n')),)
Traceback (most recent call last):
  File "/usr/lib/python3.11/site-packages/pygls/protocol/lsp_meta.py", line 21, in decorator
    self._execute_notification(user_func, *args, **kwargs)
  File "/usr/lib/python3.11/site-packages/pygls/protocol/json_rpc.py", line 153, in _execute_notification
    handler(*params)
  File "/usr/lib/python3.11/site-packages/termux_language_server/server.py", line 81, in did_change
    diagnostics = get_diagnostics(
                  ^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/lsp_tree_sitter/diagnose.py", line 64, in get_diagnostics
    uri, tree, finders + [cls(filetype) for cls in finder_classes]
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/lsp_tree_sitter/diagnose.py", line 64, in <listcomp>
    uri, tree, finders + [cls(filetype) for cls in finder_classes]
                          ^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/termux_language_server/finders.py", line 42, in __init__
    self.validator = self.schema2validator(get_schema(filetype))
                                           ^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/termux_language_server/utils.py", line 59, in get_schema
    SCHEMAS[filetype] = json.load(f)
                        ^^^^^^^^^^^^
  File "/usr/lib/python3.11/json/__init__.py", line 293, in load
    return loads(fp.read(),
           ^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/json/__init__.py", line 346, in loads
    return _default_decoder.decode(s)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/json/decoder.py", line 353, in raw_decode
    obj, end = self.scan_once(s, idx)
               ^^^^^^^^^^^^^^^^^^^^^^
json.decoder.JSONDecodeError: Expecting property name enclosed in double quotes: line 725 column 5 (char 26919)

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.