Still futszin' with Tree Sitter
This commit is contained in:
parent
6295e56fd8
commit
eaa547e445
1 changed files with 40 additions and 34 deletions
|
@ -212,34 +212,36 @@ Next, using the =tree-sitter= command line tool, create the [[/Users/howard.abra
|
||||||
|
|
||||||
Normally, you would need to add all the projects to directory clones in =~/src=, e.g.
|
Normally, you would need to add all the projects to directory clones in =~/src=, e.g.
|
||||||
#+begin_src sh :dir ~/src
|
#+begin_src sh :dir ~/src
|
||||||
git clone https://github.com/tree-sitter/tree-sitter-css ~/src/tree-sitter-css
|
while read REPO
|
||||||
|
do
|
||||||
git clone https://github.com/tree-sitter/tree-sitter-json ~/src/tree-sitter-json
|
LOCATION=~/src/$(basename ${REPO})
|
||||||
cd ~/src/tree-sitter-json && make install
|
if [ ! -d ${LOCATION} ]
|
||||||
|
then
|
||||||
git clone https://github.com/tree-sitter/tree-sitter-python ~/src/tree-sitter-python
|
git clone ${REPO} ${LOCATION}
|
||||||
cd ~/src/tree-sitter-python && npm install
|
fi
|
||||||
|
cd ${LOCATION}
|
||||||
git clone https://github.com/tree-sitter/tree-sitter-bash ~/src/tree-sitter-bash
|
git pull origin
|
||||||
cd ~/src/tree-sitter-bash && npm install
|
npm install
|
||||||
|
done <<EOL
|
||||||
git clone https://github.com/tree-sitter/tree-sitter-ruby ~/src/tree-sitter-ruby
|
https://github.com/tree-sitter/tree-sitter-css
|
||||||
cd ~/src/tree-sitter-ruby && make install
|
https://github.com/tree-sitter/tree-sitter-json
|
||||||
|
https://github.com/tree-sitter/tree-sitter-python
|
||||||
git clone https://github.com/camdencheek/tree-sitter-dockerfile ~/src/tree-sitter-dockerfile
|
https://github.com/tree-sitter/tree-sitter-bash
|
||||||
cd ~/src/tree-sitter-dockerfile && npm install
|
https://github.com/tree-sitter/tree-sitter-ruby
|
||||||
|
https://github.com/camdencheek/tree-sitter-dockerfile
|
||||||
git clone https://github.com/ikatyang/tree-sitter-yaml ~/src/tree-sitter-yaml
|
https://github.com/alemuller/tree-sitter-make
|
||||||
cd ~/src/tree-sitter-yaml && npm install tree-sitter-yaml tree-sitter
|
https://github.com/ikatyang/tree-sitter-yaml
|
||||||
# Sigh ... why can they fail so often?
|
https://github.com/Wilfred/tree-sitter-elisp
|
||||||
|
EOL
|
||||||
#+end_src
|
#+end_src
|
||||||
And then compile them:
|
|
||||||
|
The =npm install= /usually/ works, but I may work on some sort of various process, for instance:
|
||||||
#+begin_src sh
|
#+begin_src sh
|
||||||
for TSS in ~/src/tree-sitter-*
|
for TSS in ~/src/tree-sitter-*
|
||||||
do
|
do
|
||||||
cd $TSS
|
cd $TSS
|
||||||
cargo build ; npm install # Various build processes!?
|
npm install || cargo build || make install # Various build processes!?
|
||||||
done
|
done
|
||||||
#+end_src
|
#+end_src
|
||||||
At this point, we can now parse stuff using: =tree-sitter parse <source-code-file>=
|
At this point, we can now parse stuff using: =tree-sitter parse <source-code-file>=
|
||||||
|
|
||||||
|
@ -254,12 +256,15 @@ However, Emacs already has the ability to download and install grammars, so foll
|
||||||
(interactive)
|
(interactive)
|
||||||
(sit-for 10)
|
(sit-for 10)
|
||||||
(dolist (grammar
|
(dolist (grammar
|
||||||
'((bash "https://github.com/tree-sitter/tree-sitter-bash")
|
'((bash "https://github.com/tree-sitter/tree-sitter-bash")
|
||||||
(css "https://github.com/tree-sitter/tree-sitter-css")
|
(make "https://github.com/alemuller/tree-sitter-make")
|
||||||
(json "https://github.com/tree-sitter/tree-sitter-json")
|
(css "https://github.com/tree-sitter/tree-sitter-css")
|
||||||
(python "https://github.com/tree-sitter/tree-sitter-python")
|
(json "https://github.com/tree-sitter/tree-sitter-json")
|
||||||
(ruby "https://github.com/tree-sitter/tree-sitter-ruby")
|
(html "https://github.com/tree-sitter/tree-sitter-html")
|
||||||
(yaml "https://github.com/ikatyang/tree-sitter-yaml")))
|
;; (javascript "https://github.com/tree-sitter/tree-sitter-javascript" "master" "src")
|
||||||
|
(python "https://github.com/tree-sitter/tree-sitter-python")
|
||||||
|
(ruby "https://github.com/tree-sitter/tree-sitter-ruby")
|
||||||
|
(yaml "https://github.com/ikatyang/tree-sitter-yaml")))
|
||||||
(add-to-list 'treesit-language-source-alist grammar)
|
(add-to-list 'treesit-language-source-alist grammar)
|
||||||
(treesit-install-language-grammar (car grammar))))
|
(treesit-install-language-grammar (car grammar))))
|
||||||
|
|
||||||
|
@ -270,6 +275,7 @@ However, Emacs already has the ability to download and install grammars, so foll
|
||||||
;; this does *not* extend to hooks! Make sure you migrate them also
|
;; this does *not* extend to hooks! Make sure you migrate them also
|
||||||
(dolist (mapping '((css-mode . css-ts-mode)
|
(dolist (mapping '((css-mode . css-ts-mode)
|
||||||
(json-mode . json-ts-mode)
|
(json-mode . json-ts-mode)
|
||||||
|
;; (makefile-mode . makefile-ts-mode)
|
||||||
(python-mode . python-ts-mode)
|
(python-mode . python-ts-mode)
|
||||||
(ruby-mode . ruby-ts-mode)
|
(ruby-mode . ruby-ts-mode)
|
||||||
(sh-mode . bash-ts-mode)
|
(sh-mode . bash-ts-mode)
|
||||||
|
@ -868,8 +874,8 @@ Doing a lot of [[https://github.com/yoshiki/yaml-mode][YAML work]], but this pro
|
||||||
(if (string-search "TREE_SITTER" system-configuration-features)
|
(if (string-search "TREE_SITTER" system-configuration-features)
|
||||||
(progn
|
(progn
|
||||||
(use-package yaml-ts-mode
|
(use-package yaml-ts-mode
|
||||||
:mode (rx ".y" (optional "a") "ml" string-end)
|
:mode ((rx ".y" (optional "a") "ml" string-end)
|
||||||
(rx (optional ".") "yamllint")
|
(rx (optional ".") "yamllint"))
|
||||||
:hook (yaml-ts-mode . display-line-numbers-mode))
|
:hook (yaml-ts-mode . display-line-numbers-mode))
|
||||||
|
|
||||||
(use-package yaml-pro
|
(use-package yaml-pro
|
||||||
|
|
Loading…
Reference in a new issue