Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Autoindent gone wrong #64

Open
benbrastmckie opened this issue Dec 5, 2022 · 2 comments
Open

Autoindent gone wrong #64

benbrastmckie opened this issue Dec 5, 2022 · 2 comments

Comments

@benbrastmckie
Copy link

I'm getting more indentation that I would like, for instance when I'm in an enumerate environment, each new item is indented an extra tab:

\begin{enumerate}
  \item[\it Label:] 
    \item[\it Label:] 
      \item[\it Label:] 

\end{enumerate}

I also notice that opening braces indents a line on a line following an indented line. I have tried turning off autoindent and smartindent, but to no avail, and so thought maybe treesitter is where this is coming from. Any thoughts or pointers would be much appreciated.

@pfoerster
Copy link
Member

and so thought maybe treesitter is where this is coming from

Sorry for the late response. It does not look like the tree-sitter grammar is causing this issue. Your snippet yields the following parse tree. Note that the \item commands are on the same layer of the syntax tree. It might be some other plugin interfering with indentation. Maybe, you can try turning each plugin off one-by-one and find out which plugin is causing the issue.
Note that the grammar in this repo does not control identation on its own. This repo is essentially just a parser.

(source_file [0, 0] - [5, 15]
  (generic_environment [0, 0] - [5, 15]
    begin: (begin [0, 0] - [0, 17]
      name: (curly_group_text [0, 6] - [0, 17]
        text: (text [0, 7] - [0, 16]
          word: (word [0, 7] - [0, 16]))))
    (enum_item [1, 2] - [1, 19]
      label: (brack_group_text [1, 7] - [1, 19]
        text: (text [1, 8] - [1, 18]
          word: (generic_command [1, 8] - [1, 11]
            command: (command_name [1, 8] - [1, 11]))
          word: (word [1, 12] - [1, 18]))))
    (enum_item [2, 4] - [2, 21]
      label: (brack_group_text [2, 9] - [2, 21]
        text: (text [2, 10] - [2, 20]
          word: (generic_command [2, 10] - [2, 13]
            command: (command_name [2, 10] - [2, 13]))
          word: (word [2, 14] - [2, 20]))))
    (enum_item [3, 6] - [3, 23]
      label: (brack_group_text [3, 11] - [3, 23]
        text: (text [3, 12] - [3, 22]
          word: (generic_command [3, 12] - [3, 15]
            command: (command_name [3, 12] - [3, 15]))
          word: (word [3, 16] - [3, 22]))))
    end: (end [5, 0] - [5, 15]
      name: (curly_group_text [5, 4] - [5, 15]
        text: (text [5, 5] - [5, 14]
          word: (word [5, 5] - [5, 14]))))))

@forestchen1224
Copy link

The problem is about the vim runtime filetype default setting.
To erase the indent in the environments using item:
add let g:tex_indent_items = 0 in vim config
or vim.g.tex_indent_items=0 in lua

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants