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(#1639): ensure tree autocommands match filetype as well as name #1640

Merged
merged 8 commits into from
Oct 17, 2022

Conversation

alex-courtis
Copy link
Member

@alex-courtis alex-courtis commented Oct 10, 2022

fixes #1639

requires #1629

requires #1632

requires #1637

Autocommands are firing for buffers named *NvimTree_* which are real files.

@alex-courtis
Copy link
Member Author

alex-courtis commented Oct 10, 2022

Test cases:

  • hijack_cursor
  • wipe tree, no quit_on_open
  • enter tree, no watchers and reload_on_bufenter
  • leave window, float.enable and float.quit_on_focus_loss
  • leave window with filter, float.enable and float.quit_on_focus_loss
  • buf leave, full_name
  • cursor move, full_name

create_nvim_tree_autocmd("BufWipeout", {
pattern = "NvimTree_*",
callback = function()
if api.nvim_buf_get_option(0, "filetype") == "NvimTree" then
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

vim.bo.filetype is more luaish

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Today I Learned

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

vim.bo.filetype is also a shorthand for vim.bo[0].filetype.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fantastic. I might merge these checks into is_nvim_tree_buf.

@alex-courtis alex-courtis changed the base branch from 1629-cannot-start-with-buffer-named-NvimTree to master October 15, 2022 01:48
@alex-courtis alex-courtis merged commit 48992fd into master Oct 17, 2022
@alex-courtis alex-courtis deleted the 1639-strict-matching-of-nvim-tree-buffers branch December 16, 2022 04:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Strict Matching Of NvimTree Buffers
3 participants