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.

Where Next?

Popular in Questions Top

JDanielMartinez
Hi! May someone helps me, please! I have two apps into an umbrella project: the first one is Database, which manages queries, and the se...
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
Harrisonl
We have an ECS cluster with 4 services, where each task joins a single cluster, via discovery ECS discovery service. Currently when I de...
New
Werner
Hi, I’m using Ubuntu 18.04 and after updating to OTP-24.0 yesterday i have this warning when I run “mix local.hex”: 14:57:30.512 [warn] ...
New
script
If I have a string “1000 cfu/ml” . I want to remove the characters and / and space . So the string is like this "1000" What is the ...
New
mgjohns61585
Could someone help me? I'm making my first elixir program, number guessing game. I can't figure out how to convert the user's guess from ...
New
qwerescape
Is there a way to get the call stack or stack trace at any point in the code? Not from exceptions, but an expression that returns how the...
New
mathew4509
I have a list say x = ["23gh", "56kh", "97mh"] I would like to pass each element to Val in each iteration. Say, in iteration 1 -------...
New
johnnyicon
Hi all, I've just started learning Elixir and Phoenix Framework, so please pardon my n00bness at this stage. I'm trying to use Postg...
New
baxterw3b
Hi guys, i’m new in the Elixir world, and i have to say, that i love it! i’m having some problem to understand anonymous functions with ...
New

Other popular topics Top

Tee
can someone please explain to me how Enum.reduce works with maps
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
gshaw
What is the idiomatic way of matching for not nil in Elixir? E.g., First way: defp halt_if_not_signed_in(conn, signed_in_account) when...
New
itssasanka
Hi all, Trying to get some more clarity over utc_datetime and naive_datetime for Ecto: https://hexdocs.pm/ecto/Ecto.Schema.html#module-...
New
malloryerik
Hi, this is for people who, like me, have had some friction using .html.heex templates in VSCode. The solution seems to be, in a hyphena...
New
jononomo
I am trying to figure out how Mix knows whether the environment is test, dev, or prod -- where is this set? Thanks.
New
lastday4you
I wanted to check elixir version in phoenix because i found that my elixir is 1.5 but when i use Enum.chunk_by it said the function is un...
New
shahryarjb
Hello, I have map which I want to convert it to string like this: the map: %{last_name: "tavakkoli", name: "shahryar"} the string I ne...
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
lanycrost
Hi everyone! I need implement if…else if…else condition from my elixir code, and anymore of this control flow structures not work proper...
New

We're in Beta

About us Mission Statement