summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlbert Cervin <albert@acervin.com>2024-09-12 20:46:42 +0200
committerAlbert Cervin <albert@acervin.com>2024-09-12 20:46:42 +0200
commitedfb9bf03df4555bba520f47bea8db966d4c739e (patch)
treefb1b3261ca6637a534c8ea64ef780cf3a93aeb48
parent405da5f84b072ea97b69359454899f45d92d24b6 (diff)
downloaddged-edfb9bf03df4555bba520f47bea8db966d4c739e.tar.gz
dged-edfb9bf03df4555bba520f47bea8db966d4c739e.tar.xz
dged-edfb9bf03df4555bba520f47bea8db966d4c739e.zip
Update the expectations on grammars
Outside the Nix setup, it will be the responsibility of something else (might be a script) to provide the treesitter grammars.
-rw-r--r--Makefile5
-rw-r--r--README.md22
-rw-r--r--dged.nix3
3 files changed, 24 insertions, 6 deletions
diff --git a/Makefile b/Makefile
index a4cec94..5630d10 100644
--- a/Makefile
+++ b/Makefile
@@ -121,12 +121,11 @@ FILES = $(DEPS) \
$(CC) $(CFLAGS) -c $< -o $@
grammars:
- @if [ -n "$$TREESITTER_GRAMMARS" ]; then \
- IFS=":"; for p in "$$TREESITTER_GRAMMARS"; do \
+ @if [ "$(SYNTAX_ENABLE)" = "true" ] && [ -n "$$BUNDLE_TREESITTER_GRAMMARS" ]; then \
+ IFS=":"; for p in "$$BUNDLE_TREESITTER_GRAMMARS"; do \
cp -rL --no-preserve=mode "$$p"/ grammars; \
done \
else \
- echo "TODO: download and build default set of grammars"; \
mkdir -p ./grammars; \
fi
diff --git a/README.md b/README.md
index 5b44750..c32d60f 100644
--- a/README.md
+++ b/README.md
@@ -21,7 +21,7 @@ expected pre-1.0.0.
- [x] Terminal only
- [x] Mouse-free editing
- [x] Naive and incorrect unicode handling
-- [ ] LSP Client implementation
+- [ ] LSP Client implementation (in progress)
## Contributing
@@ -41,7 +41,25 @@ needed dependencies, issue:
$ nix develop
```
-Currently, tree-sitter grammars can only be automatically fetched when using the Nix setup.
+Tree-sitter grammars are automatically fetched and bundled when using the Nix setup.
+When not using the Nix setup, download/build needed treesitter grammars and set the env
+var $BUNDLE_TREESITTER_GRAMMARS to a folder containing built treesitter grammars. The
+structure should be like
+
+```
+/
+ <lang-1>/
+ parser # the parser binary as a DSO
+ queries/
+ highlights.scm # treesitter queries for highlights
+ <lang-2>/
+ parser
+ queries/
+ highlights.scm
+ ...
+```
+
+where `<lang-1>` is for example `cpp` which corresponds to the language id, see man page.
To build the editor, first create the build folder
diff --git a/dged.nix b/dged.nix
index 6f68df9..6bd4e43 100644
--- a/dged.nix
+++ b/dged.nix
@@ -37,7 +37,8 @@ stdenv.mkDerivation {
# needed for tests to work in sandboxed builds
LOCALE_ARCHIVE = "${glibcLocalesUtf8}/lib/locale/locale-archive";
- TREESITTER_GRAMMARS = with tree-sitter-grammars;
+ TREESITTER_GRAMMARS = "./build/grammars";
+ BUNDLE_TREESITTER_GRAMMARS = with tree-sitter-grammars;
linkFarm "tree-sitter-grammars" rec {
"bash" = tree-sitter-bash;
"c" = tree-sitter-c;