Skip to content

Commit 7c5d21d

Browse files
committed
chore: rerun tree-sitter init
1 parent 436b3f9 commit 7c5d21d

36 files changed

+1704
-212
lines changed

.gitattributes

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,7 @@
22

33
# Example of a `.gitattributes` file which reclassifies `.nu` files as Nushell:
44
*.nu linguist-language=Nushell
5+
6+
# Zig bindings
7+
build.zig linguist-generated
8+
build.zig.zon linguist-generated

.github/workflows/ci.yml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
paths:
7+
- grammar.js
8+
- src/**
9+
- test/**
10+
- bindings/**
11+
- binding.gyp
12+
pull_request:
13+
paths:
14+
- grammar.js
15+
- src/**
16+
- test/**
17+
- bindings/**
18+
- binding.gyp
19+
20+
concurrency:
21+
group: ${{github.workflow}}-${{github.ref}}
22+
cancel-in-progress: true
23+
24+
jobs:
25+
test:
26+
name: Test parser
27+
runs-on: ${{matrix.os}}
28+
strategy:
29+
fail-fast: false
30+
matrix:
31+
os: [ubuntu-latest, windows-latest, macos-14]
32+
steps:
33+
- name: Checkout repository
34+
uses: actions/checkout@v4
35+
- name: Set up tree-sitter
36+
uses: tree-sitter/setup-action/cli@v2
37+
- name: Set up examples
38+
shell: bash
39+
run: |-
40+
git clone https://github.com/nushell/nu_scripts examples/nu_scripts -q --single-branch --depth=1
41+
- name: Run tests
42+
uses: tree-sitter/parser-test-action@v2
43+
with:
44+
generate: false
45+
test-rust: true
46+
test-node: true
47+
test-python: true
48+
test-go: true
49+
test-swift: false
50+
- name: Parse examples
51+
uses: tree-sitter/parse-action@v4
52+
with:
53+
files: |-
54+
examples/nu_scripts/**/*.nu
55+
invalid-files-list: script/known-failures.txt

.github/workflows/main.yml

Lines changed: 0 additions & 32 deletions
This file was deleted.

.github/workflows/publish.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Publish packages
2+
3+
on:
4+
push:
5+
tags: ["*"]
6+
7+
permissions:
8+
contents: write
9+
id-token: write
10+
attestations: write
11+
12+
jobs:
13+
github:
14+
uses: tree-sitter/workflows/.github/workflows/release.yml@main
15+
with:
16+
generate: true
17+
attestations: true
18+
# npm:
19+
# uses: tree-sitter/workflows/.github/workflows/package-npm.yml@main
20+
# secrets:
21+
# NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
22+
# with:
23+
# generate: true
24+
# crates:
25+
# uses: tree-sitter/workflows/.github/workflows/package-crates.yml@main
26+
# secrets:
27+
# CARGO_REGISTRY_TOKEN: ${{secrets.CARGO_REGISTRY_TOKEN}}
28+
# with:
29+
# generate: true
30+
# pypi:
31+
# uses: tree-sitter/workflows/.github/workflows/package-pypi.yml@main
32+
# secrets:
33+
# PYPI_API_TOKEN: ${{secrets.PYPI_API_TOKEN}}
34+
# with:
35+
# generate: true

.gitignore

Lines changed: 41 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,48 @@
1-
node_modules/
2-
log.html
1+
# Rust artifacts
32
target/
43

5-
/build/
4+
# Node artifacts
5+
build/
6+
prebuilds/
7+
node_modules/
8+
9+
# Swift artifacts
10+
.build/
11+
12+
# Go artifacts
13+
_obj/
14+
15+
# Python artifacts
16+
.venv/
17+
dist/
18+
*.egg-info
19+
*.whl
20+
21+
# C artifacts
22+
*.a
23+
*.so
24+
*.so.*
25+
*.dylib
26+
*.dll
27+
*.pc
28+
*.exp
29+
*.lib
630

7-
# C lsp cache
8-
.ccls-cache/
31+
# Zig artifacts
32+
.zig-cache/
33+
zig-cache/
34+
zig-out/
935

10-
# Workspace Config
11-
.nvim/
12-
# .vscode/
36+
# Example dirs
37+
/examples/*/
38+
/script/example-files.txt
1339

14-
# MSVC compile output
15-
/parser.exp
16-
/parser.lib
17-
/parser.obj
40+
# Grammar volatiles
1841
*.wasm
42+
*.obj
43+
*.o
1944

20-
# macOS junk
21-
.DS_Store
45+
# Archives
46+
*.tar.gz
47+
*.tgz
48+
*.zip

CMakeLists.txt

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
cmake_minimum_required(VERSION 3.13)
2+
3+
project(tree-sitter-nu
4+
VERSION "0.0.1"
5+
DESCRIPTION "Nu grammar for tree-sitter"
6+
HOMEPAGE_URL "https://github.com/nushell/tree-sitter-nu"
7+
LANGUAGES C)
8+
9+
option(BUILD_SHARED_LIBS "Build using shared libraries" ON)
10+
option(TREE_SITTER_REUSE_ALLOCATOR "Reuse the library allocator" OFF)
11+
12+
set(TREE_SITTER_ABI_VERSION 14 CACHE STRING "Tree-sitter ABI version")
13+
if(NOT ${TREE_SITTER_ABI_VERSION} MATCHES "^[0-9]+$")
14+
unset(TREE_SITTER_ABI_VERSION CACHE)
15+
message(FATAL_ERROR "TREE_SITTER_ABI_VERSION must be an integer")
16+
endif()
17+
18+
find_program(TREE_SITTER_CLI tree-sitter DOC "Tree-sitter CLI")
19+
20+
add_custom_command(OUTPUT "${CMAKE_CURRENT_SOURCE_DIR}/src/parser.c"
21+
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/src/grammar.json"
22+
COMMAND "${TREE_SITTER_CLI}" generate src/grammar.json
23+
--abi=${TREE_SITTER_ABI_VERSION}
24+
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
25+
COMMENT "Generating parser.c")
26+
27+
add_library(tree-sitter-nu src/parser.c)
28+
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/src/scanner.c)
29+
target_sources(tree-sitter-nu PRIVATE src/scanner.c)
30+
endif()
31+
target_include_directories(tree-sitter-nu
32+
PRIVATE src
33+
INTERFACE $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/bindings/c>
34+
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
35+
36+
37+
target_compile_definitions(tree-sitter-nu PRIVATE
38+
$<$<BOOL:${TREE_SITTER_REUSE_ALLOCATOR}>:TREE_SITTER_REUSE_ALLOCATOR>
39+
$<$<CONFIG:Debug>:TREE_SITTER_DEBUG>)
40+
41+
set_target_properties(tree-sitter-nu
42+
PROPERTIES
43+
C_STANDARD 11
44+
POSITION_INDEPENDENT_CODE ON
45+
SOVERSION "${TREE_SITTER_ABI_VERSION}.${PROJECT_VERSION_MAJOR}"
46+
DEFINE_SYMBOL "")
47+
48+
configure_file(bindings/c/tree-sitter-nu.pc.in
49+
"${CMAKE_CURRENT_BINARY_DIR}/tree-sitter-nu.pc" @ONLY)
50+
51+
include(GNUInstallDirs)
52+
53+
install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/bindings/c/tree_sitter"
54+
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
55+
FILES_MATCHING PATTERN "*.h")
56+
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/tree-sitter-nu.pc"
57+
DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/pkgconfig")
58+
install(TARGETS tree-sitter-nu
59+
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}")
60+
61+
add_custom_target(ts-test "${TREE_SITTER_CLI}" test
62+
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
63+
COMMENT "tree-sitter test")

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ description = "nu grammar for the tree-sitter parsing library"
44
version = "0.0.1"
55
keywords = ["incremental", "parsing", "nu"]
66
categories = ["parsing", "text-editors"]
7-
repository = "https://github.com/tree-sitter/tree-sitter-nu"
7+
repository = "https://github.com/nushell/tree-sitter-nu"
88
edition = "2018"
99
license = "MIT"
1010

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ $(PARSER): $(SRC_DIR)/grammar.json
8888

8989
install: all
9090
install -d '$(DESTDIR)$(INCLUDEDIR)'/tree_sitter '$(DESTDIR)$(PCLIBDIR)' '$(DESTDIR)$(LIBDIR)'
91-
install -m644 bindings/c/$(LANGUAGE_NAME).h '$(DESTDIR)$(INCLUDEDIR)'/tree_sitter/$(LANGUAGE_NAME).h
91+
install -m644 bindings/c/tree_sitter/$(LANGUAGE_NAME).h '$(DESTDIR)$(INCLUDEDIR)'/tree_sitter/$(LANGUAGE_NAME).h
9292
install -m644 $(LANGUAGE_NAME).pc '$(DESTDIR)$(PCLIBDIR)'/$(LANGUAGE_NAME).pc
9393
install -m644 lib$(LANGUAGE_NAME).a '$(DESTDIR)$(LIBDIR)'/lib$(LANGUAGE_NAME).a
9494
install -m755 lib$(LANGUAGE_NAME).$(SOEXT) '$(DESTDIR)$(LIBDIR)'/lib$(LANGUAGE_NAME).$(SOEXTVER)

binding.gyp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,14 @@
1111
"sources": [
1212
"bindings/node/binding.cc",
1313
"src/parser.c",
14-
"src/scanner.c",
1514
],
15+
"variables": {
16+
"has_scanner": "<!(node -p \"fs.existsSync('src/scanner.c')\")"
17+
},
1618
"conditions": [
19+
["has_scanner=='true'", {
20+
"sources+": ["src/scanner.c"],
21+
}],
1722
["OS!='win'", {
1823
"cflags_c": [
1924
"-std=c11",

bindings/c/tree-sitter-nu.pc.in

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
prefix=@PREFIX@
2-
libdir=@LIBDIR@
3-
includedir=@INCLUDEDIR@
1+
prefix=@CMAKE_INSTALL_PREFIX@
2+
libdir=${prefix}/@CMAKE_INSTALL_LIBDIR@
3+
includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@
44

55
Name: tree-sitter-nu
6-
Description: Nu grammar for tree-sitter
7-
URL: @URL@
8-
Version: @VERSION@
9-
Requires: @REQUIRES@
10-
Libs: -L${libdir} @ADDITIONAL_LIBS@ -ltree-sitter-nu
6+
Description: @PROJECT_DESCRIPTION@
7+
URL: @PROJECT_HOMEPAGE_URL@
8+
Version: @PROJECT_VERSION@
9+
Libs: -L${libdir} -ltree-sitter-nu
1110
Cflags: -I${includedir}

0 commit comments

Comments
 (0)