chore: hide nvim-tree on small window
parent
e56382a546
commit
d808160678
|
@ -256,10 +256,10 @@ require("lazy").setup({
|
||||||
|
|
||||||
-- https://github.com/nvim-tree/nvim-tree.lua/wiki/Open-At-Startup
|
-- https://github.com/nvim-tree/nvim-tree.lua/wiki/Open-At-Startup
|
||||||
local function open_nvim_tree(data)
|
local function open_nvim_tree(data)
|
||||||
-- buffer is a real file on the disk
|
-- Buffer is a real file on the disk
|
||||||
local real_file = vim.fn.filereadable(data.file) == 1
|
local real_file = vim.fn.filereadable(data.file) == 1
|
||||||
|
|
||||||
-- buffer is a [No Name]
|
-- Buffer is a [No Name]
|
||||||
local no_name = data.file == "" and vim.bo[data.buf].buftype == ""
|
local no_name = data.file == "" and vim.bo[data.buf].buftype == ""
|
||||||
|
|
||||||
if not real_file and not no_name then
|
if not real_file and not no_name then
|
||||||
|
@ -273,11 +273,17 @@ require("lazy").setup({
|
||||||
-- &ft
|
-- &ft
|
||||||
local filetype = vim.bo[data.buf].ft
|
local filetype = vim.bo[data.buf].ft
|
||||||
|
|
||||||
-- skip ignored filetypes
|
-- Skip ignored filetypes
|
||||||
if vim.tbl_contains(IGNORED_FT, filetype) then
|
if vim.tbl_contains(IGNORED_FT, filetype) then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Ignore small window
|
||||||
|
-- https://stackoverflow.com/a/42648387
|
||||||
|
if vim.api.nvim_win_get_width(0) < 800 then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
require("nvim-tree.api").tree.toggle({ focus = false })
|
require("nvim-tree.api").tree.toggle({ focus = false })
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue