generated from ModProg/nvim-rust.hatch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Taskfile.yaml
110 lines (99 loc) · 3.49 KB
/
Taskfile.yaml
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
# https://taskfile.dev
version: '3'
env:
# Uncomment to set neovim version directly
# NEOVIM_VERSION: 0.8
# Version of neovim to choose when `NEOVIM_VERSION` environment variable is
# not provided and recognision of system version failed
DEFAULT_NEOVIM_VERSION: '0.9'
# Uncomment to manually set crate name
# CRATE_NAME: crate
# Uncomment to manually set lua module name
# MODULE_NAME: module
# Uncomment to manually set name of plugin folder (only for local installation)
# PROJECT_NAME: project
# code to execute at start of `task run` (remove to disable)
ENTRY_POINT: 'lua require"config".load_config()'
# These contain the computed values, for configuration use `env` section
vars:
# Detects crate name
PACKAGE_METADATA:
sh: cargo metadata --no-deps --format-version 1
CRATE_NAME: '{{.CRATE_NAME | default (mustFirst (mustFromJson .PACKAGE_METADATA).packages).name}}'
MODULE_NAME: '{{.MODULE_NAME | default .CRATE_NAME}}'
# Uses dir name for project name
PROJECT_NAME: '{{.PROJECT_NAME | default (.TASKFILE_DIR | base)}}'
INSTALL_PATH: '~/.local/share/nvim/site/pack/build/start/{{.PROJECT_NAME}}/'
# Detects version of installed neovim
SYSTEM_NEOVIM_VERSION_OUTPUT:
# Ignores the error https://github.com/go-task/task/issues/457
sh: nvim --version || true
SYSTEM_NEOVIM_VERSION: '{{.SYSTEM_NEOVIM_VERSION_OUTPUT | regexFind "\\d+\\.\\d+"}}'
NEOVIM_VERSION: '{{coalesce .NEOVIM_VERSION .SYSTEM_NEOVIM_VERSION .DEFAULT_NEOVIM_VERSION}}'
FEATURE_FLAGS: '-F {{.NEOVIM_VERSION}} --no-default-features'
# On MacOS rust outputs a `.dylib` but lua expects a `.so`
FROM_EXTENSION: '{{OS | get (dict "linux" "so" "darwin" "dylib" "windows" "dll")}}'
TO_EXTENSION: '{{OS | eq "darwin" | ternary "so" .FROM_EXTENSION}}'
tasks:
build:
desc: Builds the plugin and places it in ./lua
cmds:
- 'cargo build --release {{.FEATURE_FLAGS}}'
- mkdir -p lua
- 'cp target/release/lib{{.CRATE_NAME}}.{{.FROM_EXTENSION}} lua/{{.MODULE_NAME}}.{{.TO_EXTENSION}}'
run:
desc: Runs the plugin in neovim
deps: [build]
dir: ./test/project/
env:
XDG_DATA_HOME: ../data
cmds:
- cp -r ../../lua/ ../rtp/
- 'nvim -u NONE --cmd "set runtimepath=../rtp" {{.ENTRY_POINT | empty | ternary "" (list "+" .ENTRY_POINT | join "" | shellQuote)}}'
test:
desc: Runs tests
deps: [build]
cmds:
- 'cargo test {{.FEATURE_FLAGS}}'
clippy:
desc: Runs clippy
cmds:
- 'cargo clippy {{.FEATURE_FLAGS}}'
ci:
deps: [test, clippy]
package:
desc: Builds a zip file ready for installation
deps:
- '{{OS | eq "windows" | ternary "package-windows" "package-unix"}}'
package-windows:
deps: [build]
internal: true
cmds:
- tar.exe -cf release.zip lua
package-unix:
deps: [build]
internal: true
cmds:
- zip -r release.zip lua
clean:
desc: Cleans build files
cmds:
- cargo clean
- rm -r lua test/rtp/lua test/data
install-copy:
desc: Installs plugin in neovim by copying
deps: [build, uninstall]
cmds:
- 'mkdir -p {{.INSTALL_PATH}}'
- 'cp -r lua {{.INSTALL_PATH}}'
install-link:
desc: Installs plugin in neovim by linking (auto updates)
deps: [build, uninstall]
cmds:
- 'mkdir -p {{.INSTALL_PATH}}'
- 'ln -s {{.TASKFILE_DIR}}/lua {{.INSTALL_PATH}}'
uninstall:
desc: Removes plugin from neovim (only when installed through `task install-*`)
ignore_error: true
cmds:
- 'rm -r {{.INSTALL_PATH}}'