summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 660e6b2b842a2fe57980ab3b5afa7779d89840ad (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# Maintainer: tippfehlr <tippfehlr@tippfehlr.eu>
# Maintainer: Heddxh <g311571057 at gmail dot com>
# Contributor: Chewing_Bever
pkgname=fish-lsp-git
_pkgname=${pkgname%-git}
pkgver=r321.9e1ffad
pkgrel=2
pkgdesc="LSP implementation for the fish shell language"
# tree-sitter contains compiled files
arch=('x86_64')
url="https://github.com/ndonfris/fish-lsp/"
license=('MIT')
depends=('fish' 'nodejs' 'python')
makedepends=('git' 'yarn') # 'typescript' tsc doesn’t work
provides=($_pkgname)
conflicts=($_pkgname)
source=("$pkgname::git+https://github.com/ndonfris/fish-lsp.git")
sha256sums=('SKIP')

pkgver() {
    cd "$pkgname"
    printf "r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short=7 HEAD)"
}

prepare() {
    cd "$pkgname"
    yarn --frozen-lockfile --ignore-scripts
}

build() {
    cd "$pkgname"
    ./node_modules/.bin/tsc
    ./bin/fish-lsp complete >./fish-lsp.fish
}

package() {
    cd "$pkgname"
    mkdir -p "$pkgdir/usr/bin"
    mkdir -p "$pkgdir/usr/lib/node_modules/fish-lsp"

    rm -r node_modules/@types
    cp -r node_modules out package.json fish_files "$pkgdir/usr/lib/node_modules/fish-lsp"
    # nvim-lspconfig doesn’t work without this symlink
    ln -s /usr/lib/node_modules/fish-lsp/node_modules/@esdmr/tree-sitter-fish/tree-sitter-fish.wasm \
        "$pkgdir/usr/lib/node_modules/fish-lsp/"

    printf "%s\n" "#!/usr/bin/env node" "require('/usr/lib/node_modules/fish-lsp/out/cli');" >"$pkgdir/usr/bin/fish-lsp"
    chmod 755 "$pkgdir/usr/bin/fish-lsp"

    install -Dm644 LICENSE.md "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
    install -Dm644 "fish-lsp.fish" "$pkgdir/usr/share/fish/vendor_completions.d/fish-lsp.fish"
}