Skip to content

Commit f3934b0

Browse files
author
John Ciolfi
committed
doc/install-matlab-tree-sitter-grammar.org: add windows build from src
1 parent 79c13f6 commit f3934b0

File tree

1 file changed

+41
-4
lines changed

1 file changed

+41
-4
lines changed

doc/install-matlab-tree-sitter-grammar.org

Lines changed: 41 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,10 @@ tree-sitter ABI is 15. There are different methods for installing this.
6161

6262
and install matlab (and other languages tree-sitter shared objects if you'd like).
6363

64-
- Method 2 :: Install from the abi/14 branch
64+
- Method 2 :: Install from the abi/14 branch on *Unix*
6565

6666
Install the C compiler if not installed. When installing from source, you need to use the correct
67-
compiler. If you use the wrong compiler, you'll see undefined errors. For example, Windows Emacs
68-
doesn't work with gcc from MSys2 (you need Visual Studio I think).
67+
compiler.
6968

7069
Debian Emacs was built using gcc and you can get gcc via:
7170

@@ -88,7 +87,7 @@ tree-sitter ABI is 15. There are different methods for installing this.
8887
: Enter the C++ compiler to use (default: auto-detect):
8988
: Install to (default: ~/.emacs.d/tree-sitter):
9089

91-
- Method 3 :: Generate the grammar for ABI 14
90+
- Method 3 :: Generate the grammar for ABI 14 on *Unix*
9291

9392
Install JavaScript node and C compiler if not installed. See above to install the C compiler. This
9493
will install JavaScript node on Debian:
@@ -128,6 +127,44 @@ tree-sitter ABI is 15. There are different methods for installing this.
128127
: Enter the C++ compiler to use (default: auto-detect):
129128
: Install to (default: ~/.emacs.d/tree-sitter):
130129

130+
- Method 4 :: Generate the grammar for ABI 14 on *Windows*
131+
132+
Windows 11 64-bit:
133+
134+
Here we assume we've set HOME=C:\Users\YourUserName.
135+
136+
1. Install the Visual Studio, the [[https://visualstudio.microsoft.com/vs/community/][community version]] should work. Select "Desktop development with
137+
C++".
138+
139+
2. Install Node.js and npm. See https://nodejs.org/
140+
141+
3. Place the tree-sitter CLI tool in some directory, say
142+
=%HOME%\emacs-projects\tree-sitter-cli\tree-sitter-windows-x64.exe=
143+
You can download it from https://github.com/tree-sitter/tree-sitter/releases
144+
145+
4. Get the matlab tree-sitter grammar
146+
#+begin_src bash
147+
cd %HOME%\emacs-projects
148+
git clone https://github.com/acristoffers/tree-sitter-matlab.git
149+
#+end_src
150+
151+
5. Generate matlab tree-sitter grammar for Emacs 30 which uses ABI 14
152+
#+begin_src bash
153+
cd %HOME%\emacs-projects\tree-sitter-matlab
154+
%HOME%\emacs-projects\tree-sitter-cli\tree-sitter-windows-x64.exe generate --abi 14
155+
#+end_src
156+
157+
6. Build
158+
159+
We run vcvars64.bat to put the compiler, cl.exe on the path:
160+
161+
#+begin_src bash
162+
mkdir %HOME%\.emacs.d\tree-sitter
163+
cd %HOME%\emacs-projects\tree-sitter-matlab
164+
"C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvars64.bat"
165+
cl /LD /I src\tree_sitter src\parser.c src\scanner.c /link /out:%HOME%\.emacs.d\tree-sitter\libtree-sitter-matlab.dll
166+
#+end_src
167+
131168
* Setup Emacs to use the MATLAB tree-sitter grammar
132169

133170
Tell Emacs to use *matlab-ts-mode* for MATLAB files by adding the following to your

0 commit comments

Comments
 (0)