nverno / r-ts-mode

R major-mode using tree-sitter

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

R major mode using tree-sitter

License: GPL v3

This package is compatible with and was tested against the tree-sitter grammar for R found at tree-sitter-r.

This mode provides:

  • indentation
  • font-locking

TODO:

  • imenu
  • navigation

example

Installing

Emacs 29.1 or above with tree-sitter support is required.

Tree-sitter starter guide: https://git.savannah.gnu.org/cgit/emacs.git/tree/admin/notes/tree-sitter/starter-guide?h=emacs-29

Install tree-sitter parser for R

Add the source to treesit-language-source-alist.

(add-to-list
 'treesit-language-source-alist
 '(r "https://github.com/r-lib/tree-sitter-r"))

Then run M-x treesit-install-language-grammar and select r to install.

Install r-ts-mode.el from source

  • Clone this repository
  • Add the following to your emacs config
(require "[cloned nverno/r-ts-mode]/r-ts-mode.el")

Troubleshooting

If you get the following warning:

⛔ Warning (treesit): Cannot activate tree-sitter, because tree-sitter
library is not compiled with Emacs [2 times]

Then you do not have tree-sitter support for your emacs installation.

If you get the following warnings:

⛔ Warning (treesit): Cannot activate tree-sitter, because language grammar for r is unavailable (not-found): (libtree-sitter-r libtree-sitter-r.so) No such file or directory

then the R grammar files are not properly installed on your system.

About

R major-mode using tree-sitter

License:GNU General Public License v3.0


Languages

Language:Emacs Lisp 53.9%Language:R 38.3%Language:Makefile 5.6%Language:Ruby 2.1%