vegabook

vegabook

Neovim indentation bug with more than one |> on a line (keeps wrongly adding another indentation)

I’m using Neovim with an nvim-treesitter plugin for elixir configured as follows:

  {
      "nvim-treesitter/nvim-treesitter",
      build = ":TSUpdate",
      config = function () 
        local configs = require("nvim-treesitter.configs")

        configs.setup({
            ensure_installed = { "python", "c", "lua", "vim", "vimdoc", 
              "query", "erlang", "heex", "eex", "elixir", "javascript", "html" },
            sync_install = false,
            highlight = { enable = true },
            indent = { enable = true },  
          })
      end
  },

So basically elixir is in there. But as you can see from this short asciinema quite often when I add another pipe |> on a line where it already exists, the whole line gets indented more, which obviously I don’t want.

There are some other “bugs” (?) where it will indent a pipe sometimes wrongly by two places under a variable, or will sometimes completely unindent a line with pipes in it.

Has anyone experienced this and is there a fix? Any ideas on which neovim plugin combinations work best? For guide my whole init.lua is here

Most Liked

josh.nz

josh.nz

I noticed a bunch of indentation issues when I briefly tested it out, esp around case → indenting and multi-line list construction. I’ve mostly been sucking into configuring Neovim, rather than using it, to date.

I did try playing around with a Treesitter query at one stage and while I know little about this, it seemed like Treesitter just didn’t have enough information to correctly indent code in all situations.

FWIW, I’m also noticing issues with Treesitter based Lua indenting, even on basic indenting situations.

I haven’t yet had a chance to come back to investigate this further (ref my comment about config :).

I have these notes in my Treesitter config:

      highlight = {
        enable = true,
        -- Some languages depend on vim's regex highlighting system (such as Ruby) for indent rules.
        -- If you are experiencing weird indenting issues, add the language to
        -- the list of additional_vim_regex_highlighting and disabled languages for indent.
        additional_vim_regex_highlighting = { "ruby", "elixir" },
      },
      indent = {
        enable = true,
        disable = { "ruby", "elixir" },
      },

This came from kickstart.nvim. I added the elixir entries, but haven’t tried it out yet, so don’t know if this helps or makes things worse. I suspect it will makes things worse, since I don’t see any built in Elixir syntax file.

I will also add that I’m not using the elixir-tools plugin. A quick scan of that doesn’t suggest it would help with indentation.

Finally, I will add make sure you’re using 0.10.0. There were changes to the Elixir ftplugin between 0.9.0 and 0.10.0 that do help. If you can’t upgrade, you can try patching your local file. Check here for the latest file content.

What I was doing when I briefly tested Elixir code, was to just periodically run vim.lsp.buf.format({ async = true }). It wasn’t ideal, but worked.

Last Post!

vegabook

vegabook

indentkeys=0#,!^F,o,O,0=after,0=catch,0=do,0=else,0=end,0=rescue,0->,0|>,0},0],0),>

Where Next?

Popular in Questions Top

RisingFromAshes
I’ve read in another post that it may be possible with a router helper - but I couldn’t find an appropriate one, and tbh, I’m still just ...
New
vertexbuffer
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
New
vonH
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New
jononomo
For some reason my phoenix channels are working for me in my local dev environment, but as soon as I deploy via Docker, I get a 403 error...
New
sergio_101
I am VERY much an elixir newbie. I have taken one elixir course and one phoenix course on Udemy. During that course, I saw the instructor...
New
stefanluptak
Hello everybody, usually, I use a 29" ultra-wide monitor for VSCode which can easily accomodate explorer (files panel) + file with code ...
New
marius95
Hello everyone, I try to use an Javascript Event Handler in my root.html.leex file. Therefore I created a function in the app.js file: ...
New

Other popular topics Top

joaquinalcerro
Hi there, I am working with Ecto-Postgresql and I need to call all of the records from a specific table but the table has 40,000 records...
New
dogweather
I wrote this comment on r/haskell, and it’s not popular there. :wink: But I think I’m on to something… Haskell reminds me of Java, and e...
New
greenz1
I have a phoenix application from which a user can download multiple(5-6) files of size 1MB. I couldn’t find anything related to sending ...
New
axelson
This post is a wiki (feel free to hit the edit button near the bottom right of this post to add your own changes!) This post collects co...
239 49084 226
New
gausby
I asked this very same question on twitter and got some interesting feedback, but I thought it would be a good question to ask here as we...
1207 40042 209
New
AstonJ
Posting this to see if we can make things easier for people to get into Neovim. If you use Neovim and have a favourite distro please let ...
New

We're in Beta

About us Mission Statement