aboutsummaryrefslogtreecommitdiff
path: root/.config/nvim/lua/tree.lua
blob: 4615e61e067f58a78cf023f17a30dfcf48b95368 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
require("nvim-tree").setup({
	sort = {
		sorter = "case_sensitive",
	},
	view = {
		float = {
			enable = true,
			quit_on_focus_loss = true,
			open_win_config = function()
				local screen_w = vim.opt.columns:get()
				local screen_h = vim.opt.lines:get() - vim.opt.cmdheight:get()
				local window_w = screen_w * 0.5
				local window_h = screen_h * 0.3
				local window_w_int = math.floor(window_w)
				local window_h_int = math.floor(window_h)
				local center_x = (screen_w - window_w) / 2
				local center_y = ((vim.opt.lines:get() - window_h) / 2) - vim.opt.cmdheight:get()
				return {
					border = "rounded",
					relative = "editor",
					row = center_y,
					col = center_x,
					width = window_w_int,
					height = window_h_int,
				}
			end,
		}
	},
	renderer = {
		group_empty = true,
		icons = {
			glyphs = {
				git = {
					unstaged = "",
					staged = "",
					unmerged = "UM",
					renamed = "",
					deleted = "󰆴",
					untracked = "",
					ignored = "",
				}
			}
		}
	},
	filters = {
		dotfiles = true,
	},
})

vim.api.nvim_create_autocmd({ 'WinEnter', 'BufWinEnter' }, {
	pattern = 'NvimTree*',
	callback = function()
		local def = vim.api.nvim_get_hl_by_name('Cursor', true)
		vim.api.nvim_set_hl(0, 'Cursor', vim.tbl_extend('force', def, { blend = 100 }))
		vim.opt.guicursor:append('a:Cursor/lCursor')
	end,
})

vim.api.nvim_create_autocmd({ 'BufLeave', 'WinClosed' }, {
	pattern = 'NvimTree*',
	callback = function()
		local def = vim.api.nvim_get_hl_by_name('Cursor', true)
		vim.api.nvim_set_hl(0, 'Cursor', vim.tbl_extend('force', def, { blend = 0 }))
		vim.opt.guicursor = 'n-v-c-sm:block,i-ci-ve:ver25,r-cr-o:hor20'
	end,
})