Vscode-neovim: Cursor position desync in tab-indented Python files

Created on 15 Jan 2020  路  6Comments  路  Source: asvetliakov/vscode-neovim

For .py files, NeoVim defaults to tabstop=8. This completely breaks the cursor positioning in vscode-neovim for tab-indented files.

This can be reproduced with a simple file with .py extension without modeline. My init.vim does not contain any settings related to indentation.

  • VSCode 1.41.1-1576681836
  • NeoVim 0.5.0+ubuntu1+git202001122018-05ea3c1-00e710e-8b2f2dc~ubuntu18.04.1
  • vscode-neovim 0.0.49
bug

Most helpful comment

With autocmd WinEnter,WinNew,BufAdd * ..., vscode-neovim works as expected. In plain nvim, I need to change out of the buffer and back until tabstop=1 is applied.

I also found the command let g:python_recommended_style = 0. Adding this to init.vim disables the tabstop override (and some other settings) from ftplugin/python.vim, which seems to be a better solution: all autocmds work as expected now, and vscode-neovim behaves correctly even without any of the autocmds.

All 6 comments

Does something like this fix the problem?
autocmd FileType python :setlocal tabstop=1

Yes, running the command from VSCode fixes the issue for newly opened Python files. Adding it to init.vim doesn't have any effect (neither in vscode-neovim nor in plain nvim).

@schiffermtq Did you reload the init.vim so $MYVIMRC after change ?

Also try autocmd FileType * ...

  • I restarted VSCode/nvim completely
  • No change with autocmd FileType * .... I assume that nvim already registers an autocmd that changes this by default, but after loading init.vim?

FileType should be executed after default filetype handler, so it should work. Curious.

Try autocmd WinEnter,WinNew,BufAdd * ... then

With autocmd WinEnter,WinNew,BufAdd * ..., vscode-neovim works as expected. In plain nvim, I need to change out of the buffer and back until tabstop=1 is applied.

I also found the command let g:python_recommended_style = 0. Adding this to init.vim disables the tabstop override (and some other settings) from ftplugin/python.vim, which seems to be a better solution: all autocmds work as expected now, and vscode-neovim behaves correctly even without any of the autocmds.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

DrakeXiang picture DrakeXiang  路  3Comments

bogdan0083 picture bogdan0083  路  4Comments

pieterdd picture pieterdd  路  4Comments

kkorus picture kkorus  路  4Comments

RAbraham picture RAbraham  路  4Comments