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

fix(treesitter): indent size for inspect_tree #28727

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

wookayin
Copy link
Member

@wookayin wookayin commented May 13, 2024

Problem: For :InspectTree, the tree viewer buffer with the filetype
query does not explicitly set the tab size, which can mismatch with
the indent size assumed by the TSTreeView implementation (default: 2).

Solution: Set shiftwidth to be the same as TSTreeViewOpts, which
defaults to 2.

@wookayin
Copy link
Member Author

wookayin commented May 13, 2024

Before (with some indent-line plugin) when user's global &shiftwidth = 4:

Before

After: vim.bo.shiftwidth is now 2.

After

Remark: we could instead set the default indent size for &ft = query (runtime/query.lua), but I chose to configure buffer-local settings because treeview.opts may have a different indent size set on-the-fly other than 2, according to the current implementation.

@wookayin wookayin added this to the 0.10 milestone May 13, 2024
@zeertzjq
Copy link
Member

zeertzjq commented May 13, 2024

I don't think 'tabstop' should be changed, as there are no Tabs in the text. But maybe 'expandtab' is needed?

@wookayin
Copy link
Member Author

Forgot to mention that tabstop, etc. are for the query editor rather than InspectTree. For InspectTree right, we don't have tabs --- but the default options for query editors will be noexpandtab and tabsize=8. I thus have added the expandtab option in set_dev_properties.

@clason
Copy link
Member

clason commented May 13, 2024

Let's leave the query editor for now; the plan is to include the formatter from nvim-treesitter for query files (including the editor).

@justinmk
Copy link
Member

I don't think this needs to block 0.10

@justinmk justinmk modified the milestones: 0.10, 0.11 May 13, 2024
@clason
Copy link
Member

clason commented May 13, 2024

@wookayin During feature freeze, we (only) use the milestone for actual blockers in order to manage the release process. Obviously this can and will be backported after the 0.10 release (and we can re-use the milestone for 0.10.x then).

Problem: For :InspectTree, the tree viewer buffer with the filetype
`query` does not explicitly set the tab size, which can mismatch with
the indent size assumed by the TSTreeView implementation (default: 2).

Solution: Set shiftwidth to be the same as TSTreeViewOpts, which
defaults to 2.
@wookayin wookayin changed the title fix(treesitter): indent size for inspect_tree and query editor fix(treesitter): indent size for inspect_tree May 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants