I’ve created a repository for vr-mode, my new experimental R major mode for Emacs.
A major mode is a library that enables Emacs interactions in a specific context. Most commonly, a major mode enables Emacs specific commands for a certain programming language. In this case, vr-mode supposedly helps Emacs users write R code in Emacs.
I discussed the impetus a bit in the last post, but the main idea is to make an R mode that is sorta modern, sorta minimal, and somewhat easy to maintain. Also, this is fun way to get into lisp again :)
At this point, it is just a tech demo. So far I have a few large hurdles passed:
- Eldoc integration
- LSP integration
The easiest parts to implement were (1) and (2). These features allow R coders to have quick help access and in-buffer source code completions. Since R has a language server available, implementing this is just a matter of figuring out how to connect to the language server. I’ve been able to do this successfully with eglot, but I have not tried lsp-mode yet (though it’s entirely do-able).
- Tree-sitter for syntax highlighting and indentation
Syntax highlighting is also fairly simple, the tree-sitter library takes care of this well. Indentation is a different story. I don’t think the tree-sitter grammar is mature enough yet to allow for indentation, at least full tidyverse style indentation. I expect I will have to lift some code from ESS to handle the indentation aspect of vr-mode.
- REPL interaction via Vterm
The REPL interaction is basic. We can pop open a REPL, send lines of code or a whole buffer, and switch back and forth between buffer and source. We don’t yet have the all important “evaluate function” function implemented. I’ll get to it once I understand tree-sitter a bit more.
Overall, things are coming along. The github page notes some TODOs that I’d like to have completed before I make the installation instructions better1. The hardest functionality to create will be Rmarkdown interaction: I will likely need a whole new tree-sitter grammar to make this.
Personal opinion: my free software should not be easy to install until it’s relatively functional and bug-free↩︎