0

I've recently gotten into Nvim, and I've noticed that in C/C++-like languages, auto-indentation and tabstop work perfectly fine, but in python, it's completely different and works like nothing I've configured.

The cursor positions, python acting strangely and c++ acting perfectly

(The top is python, the bottom is c++)

I'm wondering if this is anything that has to do with COC, since I use coc-python and jedi for the language server. Here's some of my init.vim:

:set tabstop=2 shiftwidth=2 expandtab

:set smarttab

:set autoindent
paxous
  • 119
  • 10

1 Answers1

1

I think that your problem could be solved by using nvim-treesitter.

If you don't know that Treesitter is here is a quote from the official website:

Tree-sitter is a parser generator tool and an incremental parsing library. It can build a concrete syntax tree for a source file and efficiently update the syntax tree as the source file is edited.

and NeoVim uses it for highlighting, folding and indentation if possibile.

Here is the output of my

:checkhealth

enter image description here

After you installed nvim-treesitter plugin you need to:

  1. TSInstall
  2. in you init.lua add
require'nvim-treesitter.configs'.setup { indent = { enable = true }, }
C3n21
  • 46
  • 2
  • I've gotten Treesitter installed, but I'm not sure how it's supposed to fix things. I still get the same behavior with python syntax. – paxous Jun 18 '22 at 13:47
  • Did you install python's parser and enabled it using ``` require'nvim-treesitter.configs'.setup { indent = { enable = true }, } ``` ? – C3n21 Jun 18 '22 at 14:28
  • YES! tysm! I was just configuring the file and didn't realize I needed that. As a bonus, I've also gotten some sick syntax highlighting :) – paxous Jun 18 '22 at 14:37