;ELC ;;; Compiled ;;; in Emacs version 28.0.50 ;;; with all optimizations. (byte-code "\300\301!\210\300\302!\210\300\303!\210\300\304!\207" [require seq pp url tar-mode] 2) #@65 The directory where the library `tree-sitter-langs' is located. (defconst tree-sitter-langs--dir (byte-code "\300\301\302!!\207" [file-name-directory locate-library "tree-sitter-langs.el"] 3) (#$ . 186)) (byte-code "\300\301\302\303\304DD\305\306\307\310\311&\207" [custom-declare-variable tree-sitter-langs-grammar-dir funcall function #[0 "\207" [tree-sitter-langs--dir] 1] "The root data directory of `tree-sitter-langs'.\nThe 'bin' directory under this directory is used to stored grammar\nbinaries (either downloaded, or compiled from source).\n\nThis should be set before the grammars are downloaded, e.g. before\n`tree-sitter-langs' is loaded." :group tree-sitter-langs :type directory] 8) #@98 Return the directory to stored grammar binaries. This used for both compilation and downloading. (defalias 'tree-sitter-langs--bin-dir #[0 "\301!\302P\207" [tree-sitter-langs-grammar-dir file-name-as-directory "bin/"] 2 (#$ . 891)]) (defvar tree-sitter-langs--out nil) #@92 Execute BODY with `tree-sitter-langs--out' bound to the temporary buffer. (fn &rest BODY) (defalias 'tree-sitter-langs--with-temp-buffer '(macro . #[128 "\300\301\302BBD\207" [with-temp-buffer let* ((tree-sitter-langs--out (current-buffer)))] 5 (#$ . 1167)])) (byte-code "\300\301\302\303#\300\207" [function-put tree-sitter-langs--with-temp-buffer lisp-indent-function 0] 4) #@145 Call PROGRAM with ARGS, using BUFFER as stdout+stderr. If BUFFER is nil, `princ' is used to forward its stdout+stderr. (fn PROGRAM &rest ARGS) (defalias 'tree-sitter-langs--call #[385 "B\304\305\306#\210\307\310F \203\311 D\202\312\313\314\n\" B\315\316\317\"\")\320!\321>\2048\322\323!\210\202)\324!\211\325U?\205H\326\327#\207" [default-directory tree-sitter-langs--out tree-sitter-langs-grammar-dir process-environment nil message "[tree-sitter-langs] Running %s in %s" :name :command :buffer (:filter (lambda (proc string) (princ string))) format "TREE_SITTER_DIR=%s" apply make-process append process-status (exit failed signal) sleep-for 0.1 process-exit-status 0 error "Error calling %s, exit code is %s"] 12 (#$ . 1552)]) #@136 Return a buffer from NAME, as the DESTINATION of `call-process'. In batch mode, return nil, so that stdout is used instead. (fn NAME) (defalias 'tree-sitter-langs--buffer #[257 "?\205\301!\302!\210ed|\210\303 \210\211\262\207" [noninteractive get-buffer-create pop-to-buffer redisplay] 4 (#$ . 2311)]) (byte-code "\300\301\302\303\304DD\305\306\307\310\311&\207" [custom-declare-variable tree-sitter-langs-git-dir funcall function #[0 "\304\305!\203\n\306\307!\207\310\311\312 !!\3131@\311\312\314\315\310\"r\211q\210\316\317\"\216p \320\321\322\323#\210)\324b\210\325\324\326 \"+\262!!0\202B\210\327\230\203N\312 !\202T\330\331 \"\210\327)\207" [inhibit-message tree-sitter-langs--dir tree-sitter-langs--out default-directory featurep straight straight--repos-dir "tree-sitter-langs" t file-truename file-name-as-directory (error) generate-new-buffer " *temp*" make-closure #[0 "\301\300!\205 \302\300!\207" [V0 buffer-name kill-buffer] 2] tree-sitter-langs--call "git" "rev-parse" "--show-toplevel" 1 buffer-substring-no-properties line-end-position nil message "The directory %s doesn't seem to be a git working dir. Grammar-building functions will not work."] 8] "The git working directory of the repository `tree-sitter-langs'.\nIt needs to be set for grammar-building functionalities to work.\n\nThis is automatically set if you are using `straight.el', or are building from a\ngit checkout." :group tree-sitter-langs :type directory] 8) #@63 Return the directory to store grammar repos, for compilation. (defalias 'tree-sitter-langs--repos-dir #[0 "\204\301\302!\210\303\304P!\207" [tree-sitter-langs-git-dir user-error "Grammar-building functionalities require `tree-sitter-langs-git-dir' to be set" file-name-as-directory "repos"] 3 (#$ . 3782)]) #@88 Return a plist describing the source of the grammar for LANG-SYMBOL. (fn LANG-SYMBOL) (defalias 'tree-sitter-langs--source #[257 "\304!\305 P\306\307\"\310!\205u\311\312\313\314\"r\211q\210\315\316\"\216p\314\317\320\321\322\323\324\306\325\n\"&\210)\326b\210\327\326\330 \"+\262\331\312\313\314\"r\211q\210\315\332\"\216p\314\317\320\333\334\335 %\210)\327\336\337\"+\262\340\341\267\202r\342\202s\343\202s\344\257)\207" [tree-sitter-langs-git-dir default-directory tree-sitter-langs--out inhibit-message symbol-name tree-sitter-langs--repos-dir format "repos/%s" file-directory-p :repo generate-new-buffer " *temp*" t make-closure #[0 "\301\300!\205 \302\300!\207" [V0 buffer-name kill-buffer] 2] tree-sitter-langs--call "git" "config" "--file" ".gitmodules" "--get" "submodule.%s.url" 1 buffer-substring-no-properties line-end-position :version #[0 "\301\300!\205 \302\300!\207" [V0 buffer-name kill-buffer] 2] "submodule" "status" "--cached" 2 9 :paths #s(hash-table size 2 test eq rehash-size 1.5 rehash-threshold 0.8125 purecopy t data (typescript 106 ocaml 110)) ("typescript" "tsx") ("ocaml" "interface") ("")] 15 (#$ . 4099)]) #@68 Return the git submodule status for LANG-SYMBOL. (fn LANG-SYMBOL) (defalias 'tree-sitter-langs--repo-status #[257 "\304\305\306\"r\211q\210\307\310\"\216p \306\311\312\313\314\315\316\317\"%\210*\320f\211\321\267\2028\322\202<\323\202<\324\202<\325\202<\211\211\262\262+\207" [tree-sitter-langs--out tree-sitter-langs-git-dir inhibit-message default-directory generate-new-buffer " *temp*" t make-closure #[0 "\301\300!\205 \302\300!\207" [V0 buffer-name kill-buffer] 2] tree-sitter-langs--call "git" "submodule" "status" "--" format "repos/%s" 1 #s(hash-table size 4 test eq rehash-size 1.5 rehash-threshold 0.8125 purecopy t data (45 40 43 44 85 48 32 52)) :uninitialized :modified :conflicts :synchronized] 10 (#$ . 5268)]) #@56 Call FN in each of the language repositories. (fn FN) (defalias 'tree-sitter-langs--map-repos #[257 "\300 \301\302\303\"\304\305\301\302\306\"\307!\"\"\"\207" [tree-sitter-langs--repos-dir seq-map make-closure #[257 "\211\242\243\300!)\207" [V0 default-directory] 6 "\n\n(fn D)"] seq-filter identity #[257 "\211\301\235?\205\300P\302!\205B\262\207" [V0 ("." "..") file-directory-p] 4 "\n\n(fn NAME)"] directory-files] 10 (#$ . 6016)]) #@29 Update lang repos' remotes. (defalias 'tree-sitter-langs--update-repos #[0 "\300\301!\207" [tree-sitter-langs--map-repos #[257 "\300\301\302\303#\207" [tree-sitter-langs--call "git" "remote" "update"] 5 "\n\n(fn _)"]] 2 (#$ . 6477)]) #@163 Return the latest tags/commits of the language repositories. TYPE should be either `:commits' or `:tags'. If there's no tag, return the latest commit. (fn TYPE) (defalias 'tree-sitter-langs--get-latest #[257 "\300\301!\210\302\303\304\"!\207" [require magit tree-sitter-langs--map-repos make-closure #[257 "\211\300\301=\203\302\303\304\"\202\300\305=\205\306\304!\206\302\303\304\"D\207" [V0 :commits magit-rev-parse "--short=7" "origin/master" :tags magit-get-current-tag] 5 "\n\n(fn NAME)"]] 5 (#$ . 6718)]) #@255 Version of the grammar bundle. This should be bumped whenever a language submodule is updated, which should be infrequent (grammar-only changes). It is different from the version of `tree-sitter-langs', which can change frequently (when queries change). (defconst tree-sitter-langs--bundle-version "0.10.0" (#$ . 7246)) (defconst tree-sitter-langs--bundle-version-file "BUNDLE-VERSION") (defconst tree-sitter-langs--os (byte-code "\301\267\202\f\302\207\303\207\304\207\305\306\"\207" [system-type #s(hash-table size 3 test eq rehash-size 1.5 rehash-threshold 0.8125 purecopy t data (darwin 6 gnu/linux 8 windows-nt 10)) "macos" "linux" "windows" error "Unsupported system-type %s"] 3)) #@74 List of suffixes for shared libraries that define tree-sitter languages. (defconst tree-sitter-langs--suffixes '(".dylib" ".dll" ".so") (#$ . 7942)) #@65 Languages that depend on another, thus requiring 'npm install'. (defconst tree-sitter-langs--langs-with-deps '(cpp typescript) (#$ . 8097)) #@211 Return the grammar bundle file's name, with optional EXT. If VERSION and OS are not spcified, use the defaults of `tree-sitter-langs--bundle-version' and `tree-sitter-langs--os'. (fn &optional EXT VERSION OS) (defalias 'tree-sitter-langs--bundle-file #[768 "\302\303\206\206\f \206\304$\207" [tree-sitter-langs--os tree-sitter-langs--bundle-version format "tree-sitter-grammars-%s-%s.tar%s" ""] 8 (#$ . 8244)]) #@354 Download and compile the grammar for LANG-SYMBOL. This function requires git and tree-sitter CLI. If the optional arg CLEAN is non-nil, compile from the revision recorded in this project (through git submodules), and clean up afterwards. Otherwise, compile from the current state of the grammar repo, without cleanup. (fn LANG-SYMBOL &optional CLEAN) (defalias 'tree-sitter-langs-compile #[513 "\306\307\"\210\310\311!\204\312\313!\210\310\314!\204\312\315!\210\316!\211\203+\317\320 \321!P!\202/\312\322\"\323\324\"\325!\326\327\"\330 \331\323\332\n\"! \333\267\202\205\334\311\335\336\337\340\341\n&\210\202\212\203\212\334\311\342\343#\210)\334\311\335\336\337\340\344\341 &\210\202\212\312\345\"\210\202\212\202\212\312\346\"\210) \235\203\255\334\347\350\351#\210\3521\247\334\347\353\"0\210\202\255\306\354\"\266\211\203\315\211@\317P!\334\314\355\"\210\334\314\356\"\210)A\266\202\202\256\210\211\357\n!\211\203\211@\360\361\"\203\377\362\363\364\"\f\"\203\377\365\361\366#\367!\203\371\370!\210\371\"\266A\266\202\202\323\210) \372=\203>\211\357\n!\211\203<\211@\373\374\"\2035\375!\376P\367!\203/\370!\210\371\"\266A\266\202\202\210)\205W\334\311\377\201@\201A$\210\334\311\201B\201C#*\207" [tree-sitter-langs--out tree-sitter-langs-git-dir default-directory tree-sitter-langs--langs-with-deps tree-sitter-langs--suffixes system-type message "[tree-sitter-langs] Processing %s" executable-find "git" error "Could not find git (needed to download grammars)" "tree-sitter" "Could not find tree-sitter executable (needed to compile grammars)" tree-sitter-langs--source file-name-as-directory tree-sitter-langs--repos-dir symbol-name "Unknown language `%s'" format "repos/%s" tree-sitter-langs--repo-status plist-get :paths tree-sitter-langs--bin-dir tree-sitter-langs--buffer "*tree-sitter-langs-compile %s*" #s(hash-table size 4 test eq rehash-size 1.5 rehash-threshold 0.8125 purecopy t data (:uninitialized 76 :modified 91 :conflicts 121 :synchronized 130)) tree-sitter-langs--call "submodule" "update" "--init" "--checkout" "--" "stash" "push" "--force" "Unresolved conflicts in %s" "Weird status from git-submodule '%s'" "npm" "set" "progress=false" (debug error) "install" "Failed to run 'npm install': %s" "generate" "test" directory-files string-match "_" cl-some make-closure #[257 "\301\300\"\207" [V0 string-suffix-p] 4 "\n\n(fn S)"] replace-regexp-in-string "-" file-exists-p delete-file rename-file darwin string-suffix-p ".so" file-name-base ".dylib" "reset" "--hard" "HEAD" "clean" "-f"] 17 (#$ . 8673)]) #@345 Create a bundle of language grammars. The bundle includes all languages tracked in git submodules. If the optional arg CLEAN is non-nil, compile from the revisions recorded in this project (through git submodules), and clean up afterwards. Otherwise, compile from the current state of the grammar repos, without cleanup. (fn &optional CLEAN) (defalias 'tree-sitter-langs-create-bundle #[256 "\306\307!\204\n\310\311!\210\312\313\314\315\316\"!\"\317\320!\210\315\321\"\216\322\323!!\324 \325Q\326 \327\330!\312\331\332!\"\n\333=\2059\334\335\336\307\337\340\"%\210 \341\342\343\"\315\344\"\216r\211q\210\345 c*rq\210\346\347\211\347\350%\210*\266\202*\266\203)\207" [default-directory tree-sitter-langs--out system-type tree-sitter-langs--bundle-version-file coding-system-for-write tree-sitter-langs--bundle-version executable-find "tar" error "Could not find tar executable (needed to bundle compiled grammars)" seq-filter identity tree-sitter-langs--map-repos make-closure #[257 "\301\302!\210\303!\3041\305\300\"0\207\306\"\207" [V0 message "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" intern (error) tree-sitter-langs-compile vector] 6 "\n\n(fn NAME)"] message "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" #[0 "\300\205\301\302!\210\303\304\305\306\307\300!\"\"\207" [V0 message "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" display-warning tree-sitter-langs format "Could not compile grammars:\n%s" pp-to-string] 6] file-name-as-directory expand-file-name tree-sitter-langs--bundle-file ".gz" tree-sitter-langs--bin-dir tree-sitter-langs--buffer "*tree-sitter-langs-create-bundle*" #[257 "\301\302\303\"\"\205 \211\207" [tree-sitter-langs--suffixes seq-some make-closure #[257 "\301\300\"\207" [V0 string-suffix-p] 4 "\n\n(fn EXT)"]] 5 "\n\n(fn FILE)"] directory-files windows-nt ("--force-local") apply tree-sitter-langs--call "-zcvf" append generate-new-buffer " *temp file*" t #[0 "\301\300!\205 \302\300!\207" [V0 buffer-name kill-buffer] 2] utf-8 write-region nil 0] 14 (#$ . 11298)]) (defconst tree-sitter-langs--queries-dir (byte-code "\301\302P!\207" [tree-sitter-langs--dir file-name-as-directory "queries"] 3)) #@197 Return the URL to download the grammar bundle. If VERSION and OS are not specified, use the defaults of `tree-sitter-langs--bundle-version' and `tree-sitter-langs--os'. (fn &optional VERSION OS) (defalias 'tree-sitter-langs--bundle-url #[512 "\300\301\302\303##\207" [format "https://github.com/ubolonton/tree-sitter-langs/releases/download/%s/%s" tree-sitter-langs--bundle-file ".gz"] 9 (#$ . 13549)]) #@459 Download and install the specified VERSION of the language grammar bundle. If VERSION or OS is not specified, use the default of `tree-sitter-langs--bundle-version' and `tree-sitter-langs--os'. This installs the grammar bundle even if the same version was already installed, unless SKIP-IF-INSTALLED is non-nil. The download bundle file is deleted after installation, unless KEEP-BUNDLE is non-nil. (fn &optional SKIP-IF-INSTALLED VERSION OS KEEP-BUNDLE) (defalias 'tree-sitter-langs-install-grammars #[1024 "\306 \307\310!\204 \311!\210\206\312\313#\314\n!\2058\315\316\317\"r\211q\210\320\321\"\216\322\323\n!\210\324 +\262\3252\303\230\203\\\203T\326\327\"\210\330\325\307\"\210\202b\326\331\"\210\202b\326\332#\210\333\334 \"\335#\210\336\337\340#\210\n\315\341\317\"\320\342\"\216r\211q\210\322c\210*r\211q\210\343\307\211\307\344%\210*\266\204\236\345\346\"\210\347\350!\205\302\351\352\353\"!\205\302r\354!q\210\355\305!\205\301 \205\301\305\356!)0)\207" [tree-sitter-langs--bundle-version default-directory tree-sitter-langs--bundle-version-file coding-system-for-read coding-system-for-write dired-omit-mode tree-sitter-langs--bin-dir nil file-directory-p make-directory tree-sitter-langs--bundle-file ".gz" file-exists-p generate-new-buffer " *temp*" t make-closure #[0 "\301\300!\205 \302\300!\207" [V0 buffer-name kill-buffer] 2] utf-8 insert-file-contents buffer-string --cl-block-nil-- message "tree-sitter-langs: Grammar bundle v%s was already installed; skipped" throw "tree-sitter-langs: Grammar bundle v%s was already installed; reinstalling" "tree-sitter-langs: Installing grammar bundle v%s (was v%s)" url-copy-file tree-sitter-langs--bundle-url ok-if-already-exists tree-sitter-langs--call "tar" "-xvzf" " *temp file*" #[0 "\301\300!\205 \302\300!\207" [V0 buffer-name kill-buffer] 2] write-region 0 delete-file trash called-interactively-p any y-or-n-p format "Show installed grammars in %s? " find-file boundp -1] 17 (#$ . 13965) (byte-code "\302\303\304\" \302F\207" [tree-sitter-langs--bundle-version tree-sitter-langs--os nil read-string "Bundle version: "] 4)]) #@281 Copy highlights.scm file of LANG-SYMBOL to `tree-sitter-langs--queries-dir'. This assumes the repo has already been set up, for example by `tree-sitter-langs-compile'. If the optional arg FORCE is non-nil, any existing file will be overwritten. (fn LANG-SYMBOL &optional FORCE) (defalias 'tree-sitter-langs--copy-query #[513 "\302\211\303 \304!P!\305P!\306P\307!\205F\302\304!P!\310!\204&\311\312\"\210\313\314\"\210\211\307\306!\203?\205C\315\316#\202C\315\")\262\207" [tree-sitter-langs--queries-dir default-directory file-name-as-directory tree-sitter-langs--repos-dir symbol-name "queries" "highlights.scm" file-exists-p file-directory-p make-directory t message "Copying highlights.scm for %s" copy-file :force] 8 (#$ . 16115)]) #@170 Copy highlights.scm files to `tree-sitter-langs--queries-dir'. This assumes the repos have already been cloned set up, for example by `tree-sitter-langs-create-bundle'. (defalias 'tree-sitter-langs--copy-queries #[0 "\300\301!\207" [tree-sitter-langs--map-repos #[257 "\300\301!\302\"\207" [tree-sitter-langs--copy-query intern :force] 4 "\n\n(fn NAME)"]] 2 (#$ . 16877)]) (provide 'tree-sitter-langs-build)