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

Opening multiple files with -p with nightly neovim has different tabstop & expandtab values on second tab #28759

Closed
jthemenace opened this issue May 15, 2024 · 19 comments
Labels
needs:repro We need minimal steps to reproduce the issue

Comments

@jthemenace
Copy link

Problem

When running on neovim nightly and nvim-treesitter is enabled, when I open 2 files using the -p command, the second tab doesn't have my configured tabstop & expandtab values from my config, however the first tab does. If I don't load nvim-treesitter it works perfectly fine.

Steps to reproduce

nvim -p file1.php file2.php
go to second tab, view settings of expandtab and tabstop
:set expandtab?
:set tabstop?

compare them with values from first tab, see that they are different

Expected behavior

I expect all tabs to have the same value from my config for expandtab & tabstop

Neovim version (nvim -v)

NVIM v0.10.0-dev-3122+ga0a189a8e

Vim (not Nvim) behaves the same?

no

Operating system/version

Debian Linux 12.5

Terminal name/version

iTerm 2 3.5

$TERM environment variable

tmux-256color

Installation

appimage

@jthemenace jthemenace added the bug issues reporting wrong behavior label May 15, 2024
@zeertzjq
Copy link
Member

zeertzjq commented May 15, 2024

How did you set these options in your config? How did you load nvim-treesitter?

@zeertzjq zeertzjq added needs:response waiting for reply from the author needs:repro We need minimal steps to reproduce the issue labels May 15, 2024
@jthemenace
Copy link
Author

jthemenace commented May 15, 2024

In my lua config, I have the following 2 lines

vim.opt.tabstop = 2
vim.opt.expandtab = true

I use the "lazy" plugin manager. I have this line in my main plugin lua file

{'nvim-treesitter/nvim-treesitter', build = ":TSUpdate"},

Then my setup for treesitter is

require'nvim-treesitter.configs'.setup {
  ensure_installed = { "c", "lua", "vim", "vimdoc", "query", "php", "javascript", "json5", "tsx",
                       "typescript", "html", "vue", "json", "bash", "python", "diff", "markdown", "sql"},
  highlight = {
    enable = true,
    additional_vim_regex_highlighting = false,
  },
  -- indent = {
  --   enable = true
  -- }
}

@github-actions github-actions bot removed the needs:response waiting for reply from the author label May 15, 2024
@wookayin
Copy link
Member

Run nvim with the -V1 option and try:

:verbose set expandtab?
:verbose set tabstop?

and see where this option is set.

@jthemenace
Copy link
Author

When I run nvim -V1 -p file1.php file2.php
when in the first tab for the first file it says
expandtab
Last set from ~/.config/nvim/lua/options.lua line 8
tabstop=2
Last set from ~/.config/nvim/lua/options.lua line 7

when in the second tab for the second file it says
noexpandtab
tabstop=8

@wookayin
Copy link
Member

wookayin commented May 15, 2024

Please remember to provide full reproducible steps as instructed in the issue template. If one has to make a guess, the lines 7, 8 in ~/.config/nvim/lua/options.lua seems to be:

vim.opt.tabstop = 2
vim.opt.expandtab = true

The noexpandtab tabstop=8 config for the second tab seems to be the factory default, and I don't think this has something to do with nvim-treesitter.

@jthemenace
Copy link
Author

In my lua config, I have the following 2 lines, for line numbers 7 & 8.

vim.opt.tabstop = 2
vim.opt.expandtab = true

This problem doesn't exist with the exact same config files and neovim version 0.9.5

@clason
Copy link
Member

clason commented May 15, 2024

Can you reproduce this with a file containing only these two lines and nvim --clean -u test.lua ...?

@jthemenace
Copy link
Author

jthemenace commented May 15, 2024

when running the following with the nightly

vi -V1 -p --clean -u ~/test.lua file1.php file2.php

it works as expected, the issue isn't present

test.lua only contains the following 2 lines as suggested

vim.opt.tabstop = 2
vim.opt.expandtab = true

@clason
Copy link
Member

clason commented May 15, 2024

Then your problem lies somewhere in your config. Add stuff to the minimal test file until you can reproduce. (The issue is usually some plugin.)

@jthemenace
Copy link
Author

If I don't load the nvim-treesitter plugin it works fine. I tried opening a bug with nvim-treesitter and they closed it saying it can't be caused by that...

@clason
Copy link
Member

clason commented May 15, 2024

But is nvim-treesitter the only plugin you load? What is your configuration for thst plugin? (Don't install all languages blindly.)

@jthemenace
Copy link
Author

jthemenace commented May 15, 2024

I use the "lazy" plugin manager and install the following plugins

return {
  {'folke/tokyonight.nvim', lazy = false, priority = 1000},
  {'neovim/nvim-lspconfig', lazy = true},
  {'nvim-treesitter/nvim-treesitter', build = ":TSUpdate"}, 
  {'lewis6991/gitsigns.nvim', lazy = true},
  {'stevearc/aerial.nvim', lazy = true},
  {'tpope/vim-fugitive', cmd = "Git", lazy = true},
  { 'nvim-lualine/lualine.nvim',
    dependencies = { 'nvim-tree/nvim-web-devicons', lazy = true }
  },
  {
    'nvim-telescope/telescope.nvim',
    dependencies = { {'nvim-lua/plenary.nvim', lazy = true} },
  },
}

My config for nvim-treesitter is

require'nvim-treesitter.configs'.setup {
  ensure_installed = { "c", "lua", "vim", "vimdoc", "query", "php", "javascript", "json5", "tsx",
                       "typescript", "html", "vue", "json", "bash", "python", "diff", "markdown", "sql"},
  highlight = {
    enable = true,
    additional_vim_regex_highlighting = false,
  },
  --indent = {
  --  enable = true
  --}
}

@clason
Copy link
Member

clason commented May 15, 2024

Yeah, that's too many. Reduce to the absolute minimum.

@clason clason closed this as not planned Won't fix, can't repro, duplicate, stale May 15, 2024
@wookayin
Copy link
Member

wookayin commented May 15, 2024

I tried several things based on your snippets, but I still can't reproduce the issue OP is describing, with and without nvim-treesitter. Once you manage to find a full, self-contained, clear reproduction steps based on https://github.com/neovim/neovim/blob/master/contrib/minimal.lua (please don't use lazy.nvim), please feel free to ask further help.

@wookayin wookayin removed the bug issues reporting wrong behavior label May 15, 2024
@jthemenace
Copy link
Author

I tried some more things this morning to try and get it to happen on the nightly without using lazy and very minimal config, but wasn't able to get it to happen that way. I'm just going to go back to neovim 0.9.5 for now where this problem doesn't occur and hope that whatever the underlying issue is gets fixed when 0.10 gets fully released.

@clason
Copy link
Member

clason commented May 16, 2024

Neovim 0.10 is being released right now. So keep testing.

@fczuardi
Copy link

fczuardi commented May 17, 2024

@jthemenace have you tried adding:

vim.opt.shiftwidth = 2
vim.opt.expandtab = true

or

vim.opt.tabstop = 2
vim.opt.shiftwidth = 0
vim.opt.expandtab = true

both works for me, while:

vim.opt.tabstop = 2
vim.opt.expandtab = true

(without shiftwidth) will make the tab size be 8 spaces.

Looks like a bug to me, I am on v0.10.0

@gonzaloserrano
Copy link
Sponsor

I have the same or similar issue but the way to reproduce it is different. I'm on macOS, neovim 0.10.0 installed with brew and many plugins for Go dev.

So if I open 2 Go files, i.e nvim -V1 -p f1.go f1_test.go, ts is correctly set to 4 as per my ~/.config/nvim/init.lua definition of vim.opt.tabstop = 4.

But if I navigate to a different file via LSP go to definition vim.lsp.buf.definition(), the opened file has the ts set to 2 as per /opt/homebrew/Cellar/neovim/0.10.0/share/nvim/runtime/lua/editorconfig.lua.

This was not happening in neovim 0.9.5.

@jthemenace
Copy link
Author

After this issue was closed, I opened one with lazy.nvim here

Someone mentioned it was a duplicate of this one that had the fix / answer.

I had to put my expandtab / tabstop setting(along with a few others) in my config BEFORE the lazy plugin manager is loaded. Once I did that it started working fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs:repro We need minimal steps to reproduce the issue
Projects
None yet
Development

No branches or pull requests

6 participants