cohama / lexima.vim

Auto close parentheses and repeat by dot dot dot...
995 stars 46 forks source link

Indentation fail for certain filetypes #151

Closed matthew-nm closed 5 months ago

matthew-nm commented 5 months ago

I have the same issue as here: https://github.com/cohama/lexima.vim/issues/114

It manifests for .py and .dart files at least. My .sh files seem to work fine.

For python files, it auto indents too far, and it indents the bottom bracket to match. For .dart files, it doesn't indent at all, but when I exit insert more, it indents the bottom bracket.

If I only have Lazy (package manager) and lexima in my nvim lua configuration, this still happens, so I don't think it's interacting with any other setting or plugin.

Any way I could help debug this issue?

Much thanks!

cohama commented 5 months ago

For python files, it auto indents too far

Does it means following?

def foo(
        arg,  # you want 4 spaces but 8 spaces

If so, this may not be the lexima's issue. lexima.vim respects vim's indent settings (e.g. indentexpr=python#GetIndent(v:lnum) for python file).

You can confirm this by the following steps.

  1. disable lexima.vim (comment out lua setting)
  2. open a new python file
  3. input def foo(<CR>
  4. check indent width
matthew-nm commented 5 months ago

Thank you for the response! I was looking around further last night and I am getting the same issues with another auto pairing plugin (nvim-autopairs), so I think the issue is on my end somehow and not with lexima.

Yes, when I do your test I get the following,

def foo(
        |
        )

with 8 spaces instead of 4, and the bottom closure is indented automatically as well.

Do I need a require(...) statement somewhere in my configs? I am using lua configs with neovim on a mac. I tried adding require('lexima.vim').setup() but it threw an error saying it couldn't find the module "lexima.vim".

Currently all I have is the entry {'cohama/lexima.vim'} in my Lazy plugins list.

Much thanks!

EDIT: I've removed lexima and added nvim-autopairs and was getting similar results, so then I removed both and now I get strange behavior with indentation sometimes respecting my config and sometimes not... So idk what's going on but my nvim seems screwed up. I've done tests before on another machine and with minimal configs and couldn't a straight answer. Might not be a lexima config issue after all but an nvim issue.

matthew-nm commented 5 months ago

OK, fixed! My treesitter seemed to be broken (although I wasn't getting error messages until I started messing with it.) I had to install a more up-to-date version of gcc on my mac via brew install gcc, then I uninstalled all treesitter plugins and reinstalled.

Seems to work now for Python and Lua well. Also seems to work with Dart, but there was a 2 second delay after hitting and when the brackets open up. Disabling treesitter made it fast, but gave me the odd behavior where the lower bracket would end up in the wrong place. I tracked that issue down to this (https://github.com/nvim-treesitter/nvim-treesitter/issues/4945), so I've disabled folding for now and things seem to be flowing smoothly.

Wasn't lexima's fault whatsoever so I really appreciate your time and attention! Hopefully this helps others in the future.

Regards.

EDIT: Turns out disabling the treesitter fold wasn't the issue. It's still slow to indent upon for the first in each use, then faster from there regardless of using the foldexpr or not. So not sure what that's about but it's livable for now and still not lexima's fault.