-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1184d2b
commit e7229cb
Showing
1 changed file
with
35 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,6 +18,8 @@ that is appreciated by most Go programmers, see for example the following | |
|
||
- [Installation](#installation) | ||
- [Usage](#usage) | ||
- [CLI](#cli) | ||
- [Editor integration](#editor-integration) | ||
- [Checking formatting](#checking-formatting) | ||
- [Formatting specification](#formatting-specification) | ||
|
||
|
@@ -30,6 +32,8 @@ Pkg.add(url = "https://github.com/fredrikekre/Runic.jl") | |
|
||
## Usage | ||
|
||
### CLI | ||
|
||
The main interface to Runic is the command line interface (CLI) through the `main` function | ||
invoked with the `-m` flag. See the output of `julia -m Runic --help` for details: | ||
|
||
|
@@ -97,6 +101,37 @@ OPTIONS | |
In addition to the CLI there is also the two function `Runic.format_file` and | ||
`Runic.format_string`. See their respective docstrings for details. | ||
### Editor integration | ||
#### Neovim | ||
Runic can be as a formatter in [Neovim](https://neovim.io/) using | ||
[`conform.nvim`](https://github.com/stevearc/conform.nvim). Refer to the `conform.nvim` | ||
repository for installation and setup instructions. | ||
Runic is not (yet) available directly in `conform.nvim` so the following configuration needs | ||
to be passed to the setup function: | ||
```lua | ||
require("conform").setup({ | ||
formatters = { | ||
runic = { | ||
command = "julia", | ||
args = {"[email protected]", "-e", "using Runic; exit(Runic.main(ARGS))", "--", "-o", "-", "-"}, | ||
}, | ||
}, | ||
formatters_by_ft = { | ||
julia = {"runic"}, | ||
}, | ||
}) | ||
``` | ||
Finally, Runic needs to be installed in the package environment that the command above uses | ||
(`@conform.nvim`). This can be done with the following command: | ||
```sh | ||
julia [email protected] -e 'using Pkg; Pkg.add(url = "https://github.com/fredrikekre/Runic.jl")' | ||
``` | ||
## Checking formatting | ||
|
e7229cb
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cc @Klafyvel since I believe you use neovim and have tried out Runic 🙂
e7229cb
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks nice, I'll have a look. :)
e7229cb
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It works like a charm almost from the first try! Some observations:
conform.nvim
documentation, but since you provide a copy and paste configuration for this plugin, maybe just adding thevim.opt.runtimepath:append(vim.fs.joinpath(rocks_config.rocks_path, "lib", "luarocks", "rocks-5.1", "rocks.nvim", "*"))
line can be nice, so we have right away thegq
command working.conform.nvim
's timeout limit because of precompilation. I don't think it needs to be mitigated, but it can be interesting to mention it,e7229cb
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't used rocks, can you point me to something that describes what that command does? FYI, I used lazy.nvim
Yea. I don't think it hurts to recommend an increased time out limit since normal runs are quick.
Yea good idea, will add this. Maybe it should just be
@runic
then since it wouldn't be specific to conform.nvim.e7229cb
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops, I copied the wrong line from my config, I meant
vim.o.formatexpr = "v:lua.require'conform'.formatexpr()"
Yeah, I essentially did: