diff --git a/.gitignore b/.gitignore index 68bed546..c0dddf0d 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,4 @@ **/*.rs.bk **/*.elc grammars/ -tree-sitter-dyn.* +lisp/tree-sitter-dyn.* diff --git a/Cask b/Cask index 602e6672..0c96185b 100644 --- a/Cask +++ b/Cask @@ -1,10 +1,10 @@ -(package-file "tree-sitter.el") +(package-file "lisp/tree-sitter.el") -(files "*.el" +(files "lisp/*.el" "README.md" - "tree-sitter-dyn.dylib" - "tree-sitter-dyn.so" - "tree-sitter-dyn.dll" + "lisp/tree-sitter-dyn.dylib" + "lisp/tree-sitter-dyn.so" + "lisp/tree-sitter-dyn.dll" "Cargo.toml" "Cargo.lock" "src") diff --git a/README.md b/README.md index 4ccc9624..0a2ec1b9 100644 --- a/README.md +++ b/README.md @@ -118,7 +118,7 @@ For consistency with Emacs's conventions, this binding has some differences comp ## Setup for Development -Clone this repo and add it to `load-path`. +Clone this repo and add its `lisp` directory to `load-path`. If you want to hack on the high-level features (in Lisp) only: - Evaluate this (once) to download the necessary binaries: diff --git a/bin/build b/bin/build index d4a38105..ef01e8d6 100755 --- a/bin/build +++ b/bin/build @@ -19,5 +19,5 @@ source "$here/env.bash" cargo build --all $extra MODULE_DIR="$PROJECT_ROOT/target/$TARGET" - cp -f "$MODULE_DIR/$MODULE_ORIGINAL" "./$MODULE_RENAMED" + cp -f "$MODULE_DIR/$MODULE_ORIGINAL" "./lisp/$MODULE_RENAMED" ) diff --git a/bin/build.ps1 b/bin/build.ps1 index 3bc3fbff..0d376ae6 100644 --- a/bin/build.ps1 +++ b/bin/build.ps1 @@ -19,4 +19,4 @@ cargo build --all $extra Pop-Location -Copy-Item $module_dir\$module_name.dll $project_root\$module_renamed.dll +Copy-Item $module_dir\$module_name.dll $project_root\lisp\$module_renamed.dll diff --git a/bin/env.bash b/bin/env.bash index 0431f152..c17ba91e 100644 --- a/bin/env.bash +++ b/bin/env.bash @@ -18,5 +18,4 @@ export PROJECT_ROOT export MODULE_ORIGINAL=${MODULE_ORIGINAL:-libtree_sitter_dyn.$ext} export MODULE_NAME=${MODULE_NAME:-tree-sitter-dyn} export MODULE_RENAMED=${MODULE_NAME}.$ext -export TEST_FILE=tree-sitter-tests.el export EMACS=${EMACS:-emacs} diff --git a/bin/test b/bin/test index 8294c4b1..a47c8e68 100755 --- a/bin/test +++ b/bin/test @@ -13,8 +13,8 @@ if [[ $* == "watch" ]]; then ) else $EMACS --batch \ - --directory "$PROJECT_ROOT" \ + --directory "$PROJECT_ROOT/lisp" \ -l ert \ - -l "$TEST_FILE" \ + -l tree-sitter-tests.el \ -f ert-run-tests-batch-and-exit fi diff --git a/bin/test.ps1 b/bin/test.ps1 index 9f3d3d53..098c5757 100644 --- a/bin/test.ps1 +++ b/bin/test.ps1 @@ -20,8 +20,8 @@ if ($args[0] -eq "watch") { # https://stackoverflow.com/questions/2095088/error-when-calling-3rd-party-executable-from-powershell-when-using-an-ide $ErrorActionPreference = 'Continue' emacs --batch ` - --directory $project_root ` + --directory "$project_root\lisp" ` -l ert ` - -l tree-sitter-tests ` + -l tree-sitter-tests.el ` -f ert-run-tests-batch-and-exit } diff --git a/tree-sitter--mac-load.el b/lisp/tree-sitter--mac-load.el similarity index 100% rename from tree-sitter--mac-load.el rename to lisp/tree-sitter--mac-load.el diff --git a/tree-sitter-cli.el b/lisp/tree-sitter-cli.el similarity index 100% rename from tree-sitter-cli.el rename to lisp/tree-sitter-cli.el diff --git a/tree-sitter-core.el b/lisp/tree-sitter-core.el similarity index 100% rename from tree-sitter-core.el rename to lisp/tree-sitter-core.el diff --git a/tree-sitter-debug.el b/lisp/tree-sitter-debug.el similarity index 100% rename from tree-sitter-debug.el rename to lisp/tree-sitter-debug.el diff --git a/tree-sitter-langs.el b/lisp/tree-sitter-langs.el similarity index 97% rename from tree-sitter-langs.el rename to lisp/tree-sitter-langs.el index 624317f1..a0bc28ea 100644 --- a/tree-sitter-langs.el +++ b/lisp/tree-sitter-langs.el @@ -78,9 +78,13 @@ If VERSION and OS are not spcified, use the defaults of "List of language symbols and their corresponding grammar sources.") (defconst tree-sitter-langs--grammars-dir - (file-name-as-directory - (concat (file-name-directory (locate-library "tree-sitter-langs")) - "grammars")) + (concat + (let ((this-dir (file-name-directory (locate-library "tree-sitter-langs")))) + (if (file-exists-p (concat this-dir "Cargo.toml")) + this-dir + (file-name-directory + (directory-file-name this-dir)))) + "grammars") "Directory to store grammar repos, for compilation.") (defun tree-sitter-langs--source (lang-symbol) diff --git a/tree-sitter-tests.el b/lisp/tree-sitter-tests.el similarity index 97% rename from tree-sitter-tests.el rename to lisp/tree-sitter-tests.el index ee1b35a2..371b763f 100644 --- a/tree-sitter-tests.el +++ b/lisp/tree-sitter-tests.el @@ -27,7 +27,9 @@ (defun ts-test-full-path (relative-path) "Return full path from project RELATIVE-PATH." - (concat (file-name-directory (locate-library "tree-sitter")) relative-path)) + (concat (file-name-directory + (directory-file-name + (file-name-directory (locate-library "tree-sitter")))) relative-path)) (defun ts-test-tree-sexp (sexp) "Check that the current syntax tree's sexp representation is SEXP." @@ -130,7 +132,7 @@ tree is held (since nodes internally reference the tree)." (garbage-collect))) (ert-deftest conversion::position<->ts-point () - (ts-test-with-temp-buffer "tree-sitter-tests.el" + (ts-test-with-temp-buffer "lisp/tree-sitter-tests.el" (ert-info ("Testing buffer boundaries") (let ((min (point-min)) (max (point-max))) diff --git a/tree-sitter.el b/lisp/tree-sitter.el similarity index 100% rename from tree-sitter.el rename to lisp/tree-sitter.el