mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
treesitter: enhance script and add README
The script now updates a `treesitter_commit_sha.txt` file to keep track of which commit/branch/tag we're at.
This commit is contained in:
parent
f5fbe8e3b5
commit
662688817b
@ -3,14 +3,16 @@
|
|||||||
# This script will update the treesitter runtime to the provided commit.
|
# This script will update the treesitter runtime to the provided commit.
|
||||||
# Usage :
|
# Usage :
|
||||||
# $0 <tree-sitter commit sha>
|
# $0 <tree-sitter commit sha>
|
||||||
|
set -e
|
||||||
|
|
||||||
ts_source_dir="/tmp/tree-sitter"
|
ts_source_dir="/tmp/tree-sitter"
|
||||||
ts_url="https://github.com/tree-sitter/tree-sitter.git"
|
ts_url="https://github.com/tree-sitter/tree-sitter.git"
|
||||||
|
|
||||||
base_dir="$(cd "$(dirname $(dirname $0))" && pwd)"
|
base_dir="$(cd "$(dirname $(dirname $0))" && pwd)"
|
||||||
ts_dest_dir="$base_dir/src/tree_sitter/"
|
ts_dest_dir="$base_dir/src/tree_sitter/"
|
||||||
|
ts_current_commit="$ts_dest_dir/treesitter_commit_hash.txt"
|
||||||
|
|
||||||
echo "$ts_dest_dir"
|
echo "Updating treesitter runtime from $(cat "$ts_current_commit") to $1..."
|
||||||
|
|
||||||
if [ ! -d "$ts_source_dir" ]; then
|
if [ ! -d "$ts_source_dir" ]; then
|
||||||
echo "Cloning treesitter..."
|
echo "Cloning treesitter..."
|
||||||
@ -20,16 +22,17 @@ else
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Checking out $1..."
|
echo "Checking out $1..."
|
||||||
cd "$ts_source_dir"
|
|
||||||
git -C "$ts_source_dir" checkout $1
|
git -C "$ts_source_dir" checkout $1
|
||||||
|
|
||||||
echo "Removing old files..."
|
echo "Removing old files..."
|
||||||
find "$ts_dest_dir" -not -name "LICENSE" -not -type d -delete
|
find "$ts_dest_dir" -not -name "LICENSE" -not -name "README.md" -not -type d -delete
|
||||||
|
|
||||||
echo "Copying files..."
|
echo "Copying files..."
|
||||||
cp -t "$ts_dest_dir" -r "$ts_source_dir/lib/src"/*
|
cp -t "$ts_dest_dir" -r "$ts_source_dir/lib/src"/*
|
||||||
cp -t "$ts_dest_dir" "$ts_source_dir/lib/include/tree_sitter"/*
|
cp -t "$ts_dest_dir" "$ts_source_dir/lib/include/tree_sitter"/*
|
||||||
|
|
||||||
cd "$base_dir"
|
echo "$1" > "$ts_current_commit"
|
||||||
|
|
||||||
make
|
make
|
||||||
TEST_FILE="$base_dir/test/functional/lua/treesitter_spec.lua" make test
|
TEST_FILE="$base_dir/test/functional/lua/treesitter_spec.lua" make test
|
||||||
|
|
||||||
|
16
src/tree_sitter/README.md
Normal file
16
src/tree_sitter/README.md
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
Tree-sitter vendor runtime
|
||||||
|
==========================
|
||||||
|
|
||||||
|
This is the vendor runtime code for treesitter.
|
||||||
|
|
||||||
|
The original code can be found [here](https://github.com/tree-sitter/tree-sitter).
|
||||||
|
|
||||||
|
As this code is not ours, if you find any bugs, feel free to open an issue, so that we can
|
||||||
|
investigate and determine if this should go upstream.
|
||||||
|
|
||||||
|
# Updating
|
||||||
|
|
||||||
|
To update the treesitter runtime, use the `update-ts-runtime.sh` script in the `scripts` directory:
|
||||||
|
```sh
|
||||||
|
./scripts/update-ts-runtime.sh <commit you want to update to>
|
||||||
|
```
|
1
src/tree_sitter/treesitter_commit_hash.txt
Normal file
1
src/tree_sitter/treesitter_commit_hash.txt
Normal file
@ -0,0 +1 @@
|
|||||||
|
9a82dcc666d06617cbab3061467075019fae0b0d
|
Loading…
Reference in New Issue
Block a user