# Neovim + lsp + formatter (again)

**URL:** https://discourse.julialang.org/t/neovim-lsp-formatter-again/132800
**Category:** Tooling
**Tags:** languageserver, neovim, juliaformatter
**Created:** [October 1, 2025, 8:48am UTC](https://discourse.julialang.org/t/neovim-lsp-formatter-again/132800 "2025-10-01T08:48:17Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![benkj](https://avatars.discourse-cdn.com/v4/letter/b/848f3c/32.png) [@benkj](https://discourse.julialang.org/u/benkj)
#### Post date: [October 1, 2025, 8:48am UTC](https://discourse.julialang.org/t/neovim-lsp-formatter-again/132800/1 "2025-10-01T08:48:17Z")

</div>

This is a common topic, but I find quite hard to find up to date information online. Indeed, the [official wiki](https://github.com/julia-vscode/LanguageServer.jl/wiki/Vim-and-Neovim) is very old.  
There are some information in [this post](https://discourse.julialang.org/t/configuring-julia-formatter-and-linter-with-nvim-lspconfig-for-neovim/114746) and on [lspconfig](https://github.com/neovim/nvim-lspconfig/blob/master/lsp/julials.lua) that can be adapted to nvim 0.11 and make it work. Great.

My question is how to configure Julia Formatter inside the LSP. Is this possible without external plugins (e.g. conform)?

I tried to put

```julia-auto
    settings = {
        julia = {
            format = {
                enable = true,
                yas_style_nesting = true,
                indent = 4,
            },
        },
    }

```

in my julials.lua, but I don’t get the desired _Yas Style_ behavior. Does anybody know how to add JuliaFormatter options for `vim.lsp.buf.format()`?

---

<div class="post-metadata">

### Author: ![Al3cLee](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/al3clee/32/218582_2.png) [@Al3cLee](https://discourse.julialang.org/u/Al3cLee)
#### Post date: [October 14, 2025, 3:00pm UTC](https://discourse.julialang.org/t/neovim-lsp-formatter-again/132800/2 "2025-10-14T15:00:40Z")

</div>

Roughly, the pipeline is like this:

 ![image](https://global.discourse-cdn.com/julialang/original/3X/a/8/a8ed973a4e433f9eb509723dc3b974bee3eba6d0.png)

* * *

**The depend arrow.** Upon installing the `julials` server of `nvim-lspconfig` as instructed [here](https://github.com/neovim/nvim-lspconfig/blob/master/doc/configs.md#julials), one should have a folder

```julia-auto
~/.julia/environments/nvim-lspconfig

```

which looks like

```julia-auto
.
├── Manifest.toml
└── Project.toml

```

and inside `Manifest.toml`, one can find an entry `[[deps.JuliaFormatter]]`, which means that the language server depends on `JuliaFormatter` to do the LSP formatting.

So, to configure the formatting of this LSP, rather than controlling the behavior of some NeoVim plugin, one actually needs to configure the behavior of the `JuliaFormatter.jl` package.

* * *

**The config arrow.** In the docs of `JuliaFormatting.jl`, there is a section on how to use `.JuliaFormatter.toml` files to config the package. The project directory needs to have this dotfile and a `Project.toml` file (the latter is required!).

Note also that, once it sees a `Project.toml`, `JuliaFormatter` regards this as the root of its working directory, and stops searching for config files higher on the tree. See [this issue](https://github.com/mason-org/mason-lspconfig.nvim/issues/172), for example, and [this post](https://discourse.julialang.org/t/neovim-julia-lsp-formatting-on-subfolders-respecting-juliaformatter-toml/105900).

---

<div class="post-metadata">

### Author: ![benkj](https://avatars.discourse-cdn.com/v4/letter/b/848f3c/32.png) [@benkj](https://discourse.julialang.org/u/benkj)
#### Post date: [October 15, 2025, 8:00pm UTC](https://discourse.julialang.org/t/neovim-lsp-formatter-again/132800/3 "2025-10-15T20:00:47Z")

</div>

This makes sense, but I mostly work with single files, so I don’t have any toml in my directories, usually. I tried to put a `.JuliaFormatter.toml` directly in the `nvim-lspconfig` with some non-standard configuration, but it seems that it is not read while I try to `vim.lsp.buf.format()`

---

<div class="post-metadata">

### Author: ![benkj](https://avatars.discourse-cdn.com/v4/letter/b/848f3c/32.png) [@benkj](https://discourse.julialang.org/u/benkj)
#### Post date: [October 15, 2025, 9:41pm UTC](https://discourse.julialang.org/t/neovim-lsp-formatter-again/132800/4 "2025-10-15T21:41:32Z")

</div>

I’ve actually realized that some options work, e.g. `vim.lsp.buf.format({formatting_options={tabSize=2}})` is like passing `indent=2`. The available options are defined in `src/protocol/formatting.jl`. Does it make sense to make a PR to add other available options there? I think only such file and `src/request/features.jl` need to be updated. I’d love the be able to change the `style` option on the fly without resorting to project files.

---

<div class="post-metadata">

### Author: ![Al3cLee](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/al3clee/32/218582_2.png) [@Al3cLee](https://discourse.julialang.org/u/Al3cLee)
#### Post date: [November 2, 2025, 12:50pm UTC](https://discourse.julialang.org/t/neovim-lsp-formatter-again/132800/5 "2025-11-02T12:50:30Z")

</div>

Try using a `$HOME/.JuliaFormatter.toml` file in that case!
