aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJongwook Choi <wookayin@gmail.com>2024-10-01 12:07:30 -0400
committerGitHub <noreply@github.com>2024-10-01 09:07:30 -0700
commit5331f87f6145f705c73c5c23f365cecb9fbc5067 (patch)
treebef2281db3348c630461d02b627b928eecf5d183
parentbb7604eddafb31cd38261a220243762ee013273a (diff)
downloadrneovim-5331f87f6145f705c73c5c23f365cecb9fbc5067.tar.gz
rneovim-5331f87f6145f705c73c5c23f365cecb9fbc5067.tar.bz2
rneovim-5331f87f6145f705c73c5c23f365cecb9fbc5067.zip
fix(treesitter): indent size for inspect_tree #28727
Problem: For :InspectTree, indent size (`&shiftwidth`) for the tree viewer may be incorrect. This is because the tree viewer buffer with the filetype `query` does not explicitly configures the tab size, which can mismatch with the default indent size (2) assumed by TSTreeView's implementation. Solution: Set shiftwidth to be the same as TSTreeViewOpts specifies, which defaults to 2.
-rw-r--r--runtime/lua/vim/treesitter/dev.lua10
1 files changed, 8 insertions, 2 deletions
diff --git a/runtime/lua/vim/treesitter/dev.lua b/runtime/lua/vim/treesitter/dev.lua
index 6a2f7ae936..90c3720b80 100644
--- a/runtime/lua/vim/treesitter/dev.lua
+++ b/runtime/lua/vim/treesitter/dev.lua
@@ -158,7 +158,8 @@ end
---@param w integer
---@param b integer
-local function set_dev_options(w, b)
+---@param opts nil|{ indent?: integer }
+local function set_dev_options(w, b, opts)
vim.wo[w].scrolloff = 5
vim.wo[w].wrap = false
vim.wo[w].foldmethod = 'expr'
@@ -170,6 +171,11 @@ local function set_dev_options(w, b)
vim.bo[b].bufhidden = 'wipe'
vim.bo[b].filetype = 'query'
vim.bo[b].swapfile = false
+
+ opts = opts or {}
+ if opts.indent then
+ vim.bo[b].shiftwidth = opts.indent
+ end
end
--- Updates the cursor position in the inspector to match the node under the cursor.
@@ -360,7 +366,7 @@ function M.inspect_tree(opts)
vim.b[buf].dev_inspect = w
vim.b[b].dev_base = win -- base window handle
vim.b[b].disable_query_linter = true
- set_dev_options(w, b)
+ set_dev_options(w, b, { indent = treeview.opts.indent })
local title --- @type string?
local opts_title = opts.title