Emacs Eglot and Tree-Sitter

Abhishek Amralkar
2 min readNov 27, 2023

--

After a long wait, I finally decided to move away from apt-get install Emacs and decided to compile the 2023 stable Emacs release which is 29.

The 2 major reasons why I wanted to move to Emacs 29 eglot and tree-sitter .

To read more about eglot and tree-sitter.

To compile Emacs on Debian based get the dependencies

sudo apt build-dep emacs && \                                                                                                          8s
sudo apt install libgccjit0 libgcc-10-dev libjansson4 libjansson-dev gnutls-bin libtree-sitter-dev

Check GCC version

gcc --version
gcc (Debian 12.2.0-14) 12.2.0
Copyright (C) 2022 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Get the tree-sitter

git clone git@github.com:tree-sitter/tree-sitter.git

Build tree-sitter

cd tree-sitter/
make
sudo make install

Once make install done library should be available `/usr/local/lib`

ls -ltrh /usr/local/lib/libtree-sitter.*
-rwxr-xr-x 1 root root 261K Aug 11 23:22 /usr/local/lib/libtree-sitter.a
-rwxr-xr-x 1 root root 214K Aug 11 23:22 /usr/local/lib/libtree-sitter.so.0.0
lrwxrwxrwx 1 root root 21 Aug 11 23:22 /usr/local/lib/libtree-sitter.so.0 -> libtree-sitter.so.0.0
lrwxrwxrwx 1 root root 21 Aug 11 23:22 /usr/local/lib/libtree-sitter.so -> libtree-sitter.so.0.0

Clone Emacs from the Savannah and compile with native compilation and tree-sitter

git clone --single-branch --branch=emacs-29 http://git.savannah.gnu.org/r/emacs.git emacs-29
cd emacs-29
./autogen.sh
./configure --with-native-compilation --with-tree-sitter
make -j$(nproc)

To check the CPU’s

echo $(nproc)

Check Emacs if it works or not

./src/emacs -Q

C-x C-c to quit Emacs.

To install Emacsand emacsclient to /usr/local/bin along with supporting libraries and man pages using the Makefile

sudo make install

To install in a different location, pass the full path using the --prefix option to make, e.g make install --prefix /yourdirectory/emacs

Now your Emacs is ready to use emacs

Language Grammar for tree-sitter

By default no language grammar is available, so you need to install it on your own

To check if you have language grammar available you can evaluate Elisp expression, M-x ielm

ELISP> (treesit-language-available-p 'python)
t
ELISP> (treesit-language-available-p 'golang)
nil

Emacs will return t if it’s a known language and nil otherwise.

If not you can install using

M-X treesit-install-language-grammar

--

--

Abhishek Amralkar
Abhishek Amralkar

No responses yet