Git Product home page Git Product logo

Comments (19)

zeertzjq avatar zeertzjq commented on June 12, 2024

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

from neovim.

jthemenace avatar jthemenace commented on June 12, 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
  -- }
}

from neovim.

wookayin avatar wookayin commented on June 12, 2024

Run nvim with the -V1 option and try:

:verbose set expandtab?
:verbose set tabstop?

and see where this option is set.

from neovim.

jthemenace avatar jthemenace commented on June 12, 2024

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

from neovim.

wookayin avatar wookayin commented on June 12, 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.

from neovim.

jthemenace avatar jthemenace commented on June 12, 2024

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

from neovim.

clason avatar clason commented on June 12, 2024

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

from neovim.

jthemenace avatar jthemenace commented on June 12, 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

from neovim.

clason avatar clason commented on June 12, 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.)

from neovim.

jthemenace avatar jthemenace commented on June 12, 2024

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...

from neovim.

clason avatar clason commented on June 12, 2024

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

from neovim.

jthemenace avatar jthemenace commented on June 12, 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
  --}
}

from neovim.

clason avatar clason commented on June 12, 2024

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

from neovim.

wookayin avatar wookayin commented on June 12, 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.

from neovim.

jthemenace avatar jthemenace commented on June 12, 2024

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.

from neovim.

clason avatar clason commented on June 12, 2024

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

from neovim.

fczuardi avatar fczuardi commented on June 12, 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

from neovim.

gonzaloserrano avatar gonzaloserrano commented on June 12, 2024

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.

from neovim.

jthemenace avatar jthemenace commented on June 12, 2024

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.

from neovim.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.