https://github.com/JuliaEditorSupport/julia-ts-mode
Experimental Emacs Julia major mode using tree-sitter
https://github.com/JuliaEditorSupport/julia-ts-mode
Last synced: 9 months ago
JSON representation
Experimental Emacs Julia major mode using tree-sitter
- Host: GitHub
- URL: https://github.com/JuliaEditorSupport/julia-ts-mode
- Owner: JuliaEditorSupport
- License: mit
- Created: 2022-12-19T14:10:21.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2025-01-15T14:49:38.000Z (over 1 year ago)
- Last Synced: 2025-02-05T10:14:46.493Z (over 1 year ago)
- Language: Julia
- Size: 105 KB
- Stars: 37
- Watchers: 6
- Forks: 9
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Julia major mode using tree-sitter
Emacs major mode for the Julia programming language using tree-sitter for
font-lock, indentation, imenu, and navigation. It is derived from
[`julia-mode`](https://github.com/JuliaEditorSupport/julia-emacs).
# Installation
## Dependencies
This package requires:
1. Emacs 29 or newer built with tree-sitter support;
2. [Julia tree-sitter grammar](https://github.com/tree-sitter/tree-sitter-julia); and
3. The package [`julia-mode`](https://github.com/JuliaEditorSupport/julia-emacs).
## Installation from MELPA
`julia-ts-mode` is available on MELPA. The recommended way to install it is
using `use-package`. The following code installs `julia-ts-mode` and selects it
as the default major mode for Julia files:
``` emacs-lisp
(use-package julia-ts-mode
:ensure t
:mode "\\.jl$")
```
## Installation from source
You can install this package from source by cloning this directory and adding
the following lines to your Emacs configuration:
``` emacs-lisp
(add-to-list 'load-path "")
(require 'julia-ts-mode)
```
## Installing Julia Tree-Sitter Grammar
The recommended way to install the tree-sitter grammar is using the package
[treesit-auto](https://github.com/renzmann/treesit-auto). In this case, the
Julia tree-sitter grammar will be automatically downloaded and compiled when a
Julia file is opened using the major mode `julia-ts-mode`. For more information
on how to install and configure `treesit-auto`, check the package documentation.
### Upgrading grammar after a package update
Note that the [tree-sitter grammar for
Julia](https://github.com/tree-sitter/tree-sitter-julia) is under active
development, and breaking changes are often introduced between versions. To
provide maximum compatibility, the exact version of the grammar library is fixed
in `julia-ts-mode.el`, with planned regular updates to both the grammar version
and the tree-sitter queries built on top of it. However, the grammar library
itself isn't updated automatically by Emacs. If, after a `julia-ts-mode` package
update, you get some quirky tree-sitter error messages, and font-locking fails
to work in a `julia-ts-mode` buffer, run `M-x treesit-install-language-grammar
RET julia RET` to upgrade the grammar library. This should resolve the issues.
# LSP Configuration
This mode is derived from `julia-mode`. Hence, most of the feature available for
it will also work in `julia-ts-mode`. However, the LSP requires additional
configuration. First, it is necessary to install the package
[`lsp-julia`](https://github.com/gdkrmr/lsp-julia), and apply the desired
configuration as stated in its documentation. Afterward, add the following code
to your Emacs configuration file:
``` emacs-lisp
(add-to-list 'lsp-language-id-configuration '(julia-ts-mode . "julia"))
(lsp-register-client
(make-lsp-client :new-connection (lsp-stdio-connection 'lsp-julia--rls-command)
:major-modes '(julia-mode ess-julia-mode julia-ts-mode)
:server-id 'julia-ls
:multi-root t))
```