summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 77918ba3287946c7ddfed64a9595f25a08e19018 (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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
# Maintainer:
# Contributor: Hanatomizu <chart11from21 at outlook dot com>
# Contributor: edward-p <edward AT edward-p DOT xyz>

_pkgname="lunarvim"
pkgname="$_pkgname-git"
pkgver=1.4.0.r5.gaa51c20
pkgrel=3
pkgdesc="An IDE layer for Neovim with sane defaults"
url="https://github.com/LunarVim/LunarVim"
license=('GPL-3.0-only')
arch=('any')

depends=(
  'fzf'
  'git'
  'lua'
  'neovim'
  'neovim-remote'
  'nodejs'
  'tree-sitter'
  'yarn'
)
makedepends=(
  'git'
  'parallel'
  'tree-sitter-cli'
)
optdepends=(
  'ripgrep: optional dependencies for telescope.nvim'
  'lazygit: enables <leader>gg to launch lazygit for intergrated and enhanced Git experience while in lvim'
)

_pkgsrc="$_pkgname"
source=(
  "$_pkgsrc"::"git+$url.git"
  "nvim-treesitter"::"git+https://github.com/nvim-treesitter/nvim-treesitter.git#tag=v0.10.0"
  'langs.lua'
)
sha256sums=(
  'SKIP'
  'b4a7931c690c2f2326398fede61e87a19686f065d9b7c32664a885cbbb3f827d'
  '165e39c90fb14aa220b7e0c8082e6b95109f4302acede816ef572f9b5f951ff7'
)

pkgver() {
  cd "$_pkgsrc"
  git describe --long --tags --abbrev=7 --exclude='*[a-zA-Z][a-zA-Z]*' \
    | sed -E 's/^[^0-9]*//;s/([^-]*-g)/r\1/;s/-/./g'
}

build() {
  cd "$srcdir/nvim-treesitter"
  runtime="$srcdir/nvim-treesitter"

  echo "::: step 1"
  nvim --clean --cmd "set runtimepath+=${runtime}" -l "$srcdir/langs.lua"

  echo "::: step 2"
  langs=$(< langs.txt)

  for lang in ${langs[@]}; do
    if [[ ! -e "$runtime/parser/$lang.so" ]]; then
      echo "nvim --clean --cmd 'set runtimepath+=$runtime' --headless +'TSUpdateSync $lang' +qall"
    fi
  done | parallel -j $(nproc)
}

package() {
  cd "$_pkgsrc"

  mkdir -pm755 "$pkgdir/usr/share/lunarvim"{,/ftplugin}
  cp -r {lua,snapshots,init.lua} "$pkgdir/usr/share/lunarvim"

  mkdir -pm755 "$pkgdir/usr/share/lunarvim/prebuild/nvim-treesitter/parser"{,-info}

  for parser in "$srcdir/nvim-treesitter/parser"/*.so; do
    install -Dm755 "$parser" "$pkgdir/usr/share/lunarvim/prebuild/nvim-treesitter/parser/${parser##/*/}"
  done

  for info in "$srcdir/nvim-treesitter/parser-info"/*; do
    install -Dm755 "$info" "$pkgdir/usr/share/lunarvim/prebuild/nvim-treesitter/parser-info/${info##/*/}"
  done

  install -Dm755 /dev/stdin "$pkgdir/usr/bin/lvim" << 'END'
#!/usr/bin/env sh

export LUNARVIM_RUNTIME_DIR="${LUNARVIM_RUNTIME_DIR:-$HOME/.local/share/lunarvim}"
export LUNARVIM_CONFIG_DIR="${LUNARVIM_CONFIG_DIR:-$HOME/.config/lvim}"
export LUNARVIM_CACHE_DIR="${LUNARVIM_CACHE_DIR:-$HOME/.cache/lvim}"

exec nvim -u "$LUNARVIM_RUNTIME_DIR/lvim/init.lua" "$@"
END

  install -Dm755 /dev/stdin "$pkgdir/usr/share/lunarvim/init-lvim.sh" << 'END'
#!/usr/bin/env bash

mkdir -p ~/.config/lvim
cat > ~/.config/lvim/config.lua << EOL
-- Read the docs: https://www.lunarvim.org/docs/configuration
-- Example configs: https://github.com/LunarVim/starter.lvim
EOL

mkdir -p ~/.local/share/lunarvim
ln -s /usr/share/lunarvim ~/.local/share/lunarvim/lvim

echo -e "\033[1;32m==> Installing dependencies of NodeJS & Rust...\033[0m"
yarn global add neovim
yarn global add tree-sitter-cli
cargo install fd-find
cargo install ripgrep

echo -e "\033[1;32m==> Preparing Lazy setup...\033[0m"
lvim --headless -c 'quitall'

[ ! -f "$LUNARVIM_CONFIG_DIR/config.lua" ] \
  && cp /usr/share/doc/lunarvim/config.example.lua ~/.config/lvim/config.lua

echo -e "\033[1;32m==> Installing treesitter parsers..\033[0m"
ln -s /usr/share/lunarvim/prebuild/nvim-treesitter/parser/* \
  ~/.local/share/lunarvim/site/pack/lazy/opt/nvim-treesitter/parser/
ln -s /usr/share/lunarvim/prebuild/nvim-treesitter/parser-info/* \
  ~/.local/share/lunarvim/site/pack/lazy/opt/nvim-treesitter/parser-info/

echo -e "\033[1;32m==> Generate the new ftplugin template files..\033[0m"
lvim --headless +LvimUpdate +q

echo -e "\033[1;32m===============================================\033[0m"
echo "lunarvim runtime is inited for $(whoami)"
echo "clean up by:"
echo "    rm -rf ~/.config/lvim ~/.local/share/lunarvim"
echo -e "\033[1;32m===============================================\033[0m"
END
}