help-emacs-windows
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: tree-sitter on Windows


From: Juan José García-Ripoll
Subject: Re: tree-sitter on Windows
Date: Sat, 30 Sep 2023 16:11:22 +0200
User-agent: Gnus/5.13 (Gnus v5.13)

Hi Corwin,

thanks for the detailed instructions, but these DLL don't seem to be
available for download from the server indicated below -- it gives an
internal server error.

I had already inspected the Tree Sitter wiki page and all instructions,
the problem was having the DLLs, which could not be downloaded and for
which the automatic build process does not work on Windows.

In the end I have had to compile all the packages myself using MSYS2
using the code below. Only those libraries worked. The tree-sitter-langs
package from melpa is broken, in the sense that the names of the
libraries is wrong, but also when renamed, those libraries do not work.
I don't know if it is because they expect some MSYS2 libraries around
or some Visual Studio C runtime.

Compiling the parser and scanner with MSYS2 UCRT seems fine, but it is
extremely user unfriendly...

Best,

Juanjo

----

(let* ((languages '(c cpp python html ocaml javascript json make julia))
   (msys-path "c:/msys64/usr/bin")
   (mingw-path "c:/msys64/ucrt64/bin")
   (old-path (getenv "PATH")))
    ;; Make sure MSYS2 is installed and that you used
    ;; pacman -S mingw-w64-ucrt-x86_64-gcc
    ;;
    ;; (setenv "PATH" (concat "C:\\msys64\\ucrt64\\bin;" (getenv "PATH")))
    (setq treesit-language-source-alist
          (append '((yaml . ("https://github.com/ikatyang/tree-sitter-yaml";))
                    (ocaml . 
("https://github.com/tree-sitter/tree-sitter-ocaml"; nil "ocaml/src")))
                  (mapcar (lambda (lang)
                            (cons lang (list (format 
"https://github.com/tree-sitter/tree-sitter-%s"; lang))))
                          languages)))
    (dolist (pair treesit-language-source-alist)
  (let ((language (car pair))
            (exec-path (cons mingw-path exec-path)))
        (unless (treesit-language-available-p language)
          (message "Installing language grammar for %s" language)
          (unless (string-match-p (regexp-quote mingw-path) old-path)
            (setenv "PATH" (concat mingw-path ";" msys-path ";" old-path)))
          (let ((ok (treesit-install-language-grammar language)))
            (setenv "PATH" old-path)
            (unless ok
          (error "Failed to install language grammar for %s" language))))))
    nil)



Corwin Brust <corwin@bru.st> writes:
> On Sat, Sep 30, 2023 at 4:23 AM Juan José García-Ripoll
> <juanjose.garciaripoll@gmail.com> wrote:
>>
>> Hi everyone,
>>
>
> Hi Juan José!
>
>>
>> I am having a hard time installing tree-sitter DLL's in Windows. I have
>> installed the treesitter language pack (I believe from MELPA IIRC),
>> which downloads plenty of dlls, but they do not have the prefix
>> "libtree-" and then Emacs cannot find them. I tried renaming them at
>> their location in the package, but that also does not work. I tried
>> copying them to the ~/.emacs.d/tree-sitter and also does not work. I
>> tried modifying exec-path, and that also does not work... It is quite
>> disappointing. How am I supposed to do this?
>>
>
> Sounds frustrating!   I'm assuming you looked at the NEWS file from
> 29.1 and reviewed the information there about getting started.   There
> are also some recently updated notes on the EmacsWiki that might help:
>
> https://www.emacswiki.org/emacs/Tree-sitter
>
> I notice you renamed to "libtree-" so maybe you are missing the
> "sitter-" part from your filenames.  That is, you might be creating
> libtree-FOO.dll when you should create libtree-sitter-FOO.dll, per
> this quote from NEWS;
>
> : link these two files into a shared library named
> : "libtree-sitter-LANG.so" ("libtree-sitter-LANG.dll" on MS-Windows,
> : "libtree-sitter-LANG.dylib" on macOS), where LANG is the name of the
> : language supported by the grammar as it is expected by the Emacs major
> : mode (for example, "c" for 'c-ts-mode', "cpp" for 'c++-ts-mode',
> : "python" for 'python-ts-mode', etc.)
>
> Finally, given you are on Windows and are willing to download some
> DLLs crafted by yours truly, here are some "minimal" instructions that
> I think should "just work":
>
> 1. grab the tree-sitter DLLs that you want to from my site:
> https://corwin.bru.st/emacs-tree-sitter
>
> 2. save them, per NEWS, into the: "tree-sitter" subdirectory of your
> 'user-emacs-directory', or in a directory mentioned in the variable
> 'treesit-extra-load-path'
>
> 3. Per the EmacsWiki page linked above: Customise
> ‘major-mode-remap-alist’ with each entry having as the key the major
> mode you wish to redirect to Tree-sitter, and the value being the
> equivalent “…-ts-…” mode. For example ‘java-mode’ would be remapped to
> ‘java-ts-mode’.
>
> Note, I try to give the tree-sitter grammer DLLs I make the correct
> names; if you try the above and find you need to rename stuff --or
> have other problems I might be able to address-- please let me know.
>
> Kind regards,
>
>> Best,
>>
>> Juanjo
>>
>> --
>> Juan José García Ripoll
>> http://juanjose.garciaripoll.com
>> http://quinfog.hbar.es
>>
>>
>
>

-- 
Juan José García Ripoll
http://juanjose.garciaripoll.com
http://quinfog.hbar.es




reply via email to

[Prev in Thread] Current Thread [Next in Thread]