* fix(#1629): nvim start with file named *NvimTree* opens tree instead of buffer
* Revert "fix(#1629): nvim start with file named *NvimTree* opens tree instead of buffer"
This reverts commit e7136078f7.
* fix(#1629): nvim start with file named *NvimTree* treats file as tree
* fix(#1629): nvim start with file named *NvimTree* treats file as tree
* fix(#1639): ensure tree autocommands match filetype as well as name
* fix(#1639): fix bad merge
* fix(#1639): ensure tree autocommands match filetype as well as name
This commit is contained in:
committed by
GitHub
parent
c995ce0878
commit
48992fd3e8
@@ -468,13 +468,23 @@ function M.inject_node(f)
|
||||
end
|
||||
end
|
||||
|
||||
---Is the buffer a tree? Like /path/to/NvimTree_2 and not a readable file.
|
||||
---@param bufnr number
|
||||
---Is the buffer named NvimTree_[0-9]+ a tree? filetype is "NvimTree" or not readable file.
|
||||
---This is cheap, as the readable test should only ever be needed when resuming a vim session.
|
||||
---@param bufnr number may be 0 or nil for current
|
||||
---@return boolean
|
||||
function M.is_nvim_tree_buf(bufnr)
|
||||
if bufnr == nil then
|
||||
bufnr = 0
|
||||
end
|
||||
if vim.fn.bufexists(bufnr) then
|
||||
local bufname = a.nvim_buf_get_name(bufnr)
|
||||
return vim.fn.fnamemodify(bufname, ":t"):match "^NvimTree_[0-9]+$" and vim.fn.filereadable(bufname) == 0
|
||||
if vim.fn.fnamemodify(bufname, ":t"):match "^NvimTree_[0-9]+$" then
|
||||
if vim.bo[bufnr].filetype == "NvimTree" then
|
||||
return true
|
||||
elseif vim.fn.filereadable(bufname) == 0 then
|
||||
return true
|
||||
end
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user