From 3b236f6ab4a29b1d480e065010cf5ac23599bf59 Mon Sep 17 00:00:00 2001 From: Henrik Hautakoski Date: Tue, 13 May 2025 23:02:40 +0200 Subject: [PATCH] adding nvim/lua/user/plugins/ui/nvimtree.lua --- nvim/lua/user/icons.lua | 12 ++- nvim/lua/user/keymaps.lua | 2 +- nvim/lua/user/plugins/ui.lua | 3 +- nvim/lua/user/plugins/ui/nvimtree.lua | 112 ++++++++++++++++++++++ nvim/lua/user/plugins/ui/statuscolumn.lua | 3 +- 5 files changed, 128 insertions(+), 4 deletions(-) create mode 100644 nvim/lua/user/plugins/ui/nvimtree.lua diff --git a/nvim/lua/user/icons.lua b/nvim/lua/user/icons.lua index a9ebc0e..afe60c2 100644 --- a/nvim/lua/user/icons.lua +++ b/nvim/lua/user/icons.lua @@ -155,8 +155,18 @@ return { modified = iconset.circle, readonly = iconset.lock, hidden = iconset.eye_disabled, + bookmarked = iconset.star, + }, + folder = { + arrow_closed = iconset.caret.right, + arrow_open = iconset.caret.down, + closed = iconset.folder.closed, + open = iconset.folder.open, + empty = iconset.folder.empty, + empty_open = iconset.folder.empty_open, + symlink = iconset.folder.symlink, + symlink_open = iconset.folder.symlink_open, }, - folder = iconset.folder, diff = { added = iconset.plus, modified = iconset.square, diff --git a/nvim/lua/user/keymaps.lua b/nvim/lua/user/keymaps.lua index 60ba2d1..d559119 100644 --- a/nvim/lua/user/keymaps.lua +++ b/nvim/lua/user/keymaps.lua @@ -118,7 +118,7 @@ vim.keymap.set('n', "ts", "Neotest summary", { desc = "Toggle t -- -- File explorer -- -vim.keymap.set('n', ".", "Neotree toggle", { desc = "Toggle Neotree" }) +vim.keymap.set('n', ".", "NvimTreeFocus", { desc = "Toggle Nvimtree" }) -- -- Git diff --git a/nvim/lua/user/plugins/ui.lua b/nvim/lua/user/plugins/ui.lua index 27c928b..2ac3e24 100644 --- a/nvim/lua/user/plugins/ui.lua +++ b/nvim/lua/user/plugins/ui.lua @@ -11,7 +11,8 @@ return { { import = "user.plugins.ui.statuscolumn" }, { import = "user.plugins.ui.gitsigns" }, -- File explorer - { import = "user.plugins.ui.neotree" }, + -- { import = "user.plugins.ui.neotree" }, + { import = "user.plugins.ui.nvimtree" }, { "folke/which-key.nvim", event = "VeryLazy" }, diff --git a/nvim/lua/user/plugins/ui/nvimtree.lua b/nvim/lua/user/plugins/ui/nvimtree.lua new file mode 100644 index 0000000..7762864 --- /dev/null +++ b/nvim/lua/user/plugins/ui/nvimtree.lua @@ -0,0 +1,112 @@ +local icons = require('user.icons') + +local options = { + hijack_cursor = true, + select_prompts = true, + update_focused_file = { + enable = true, + }, + view = { + number = false, + relativenumber = false, + signcolumn = "yes", + width = 40, + }, + filters = { + dotfiles = true, + exclude = { + ".env", + } + }, + diagnostics = { + enable = true, + icons = { + hint = icons.diagnostics.hint, + info = icons.diagnostics.info, + warning = icons.diagnostics.warn, + error = icons.diagnostics.error + } + }, + modified = { + enable = true, + }, + renderer = { + root_folder_label = ":t", + hidden_display = "simple", + highlight_opened_files = "name", + highlight_hidden = "name", + special_files = { "Cargo.toml", "Makefile", "README.md", "readme.md", "composer.json" }, + icons = { + git_placement = "signcolumn", + diagnostics_placement = "right_align", + modified_placement = "right_align", + show = { + -- folder_arrow = false + }, + glyphs = { + default = icons.files.default, + symlink = icons.files.symlink, + bookmark = icons.file_status.bookmarked, + modified = icons.file_status.modified, + hidden = icons.file_status.hidden, + folder = { + arrow_closed = icons.folder.arrow_closed, + arrow_open = icons.folder.arrow_open, + default = icons.folder.closed, + open = icons.folder.open, + empty = icons.folder.empty, + empty_open = icons.folder.empty_open, + symlink = icons.folder.symlink, + symlink_open = icons.folder.symlink_open, + }, + git = { + unstaged = icons.gitsigns.unstaged, + staged = icons.gitsigns.staged, + unmerged = "", + renamed = icons.gitsigns.renamed, + untracked = icons.gitsigns.untracked, + deleted = icons.gitsigns.deleted, + ignored = icons.gitsigns.ignored, + }, + }, + }, + indent_markers = { + enable = false, + inline_arrows = false, + icons = { + corner = icons.tree.nodelast, + edge = icons.tree.vertical, + item = icons.tree.node, + bottom = icons.tree.horizontal, + }, + } + }, + actions = { + change_dir = { + enable = true, + global = true, + restrict_above_cwd = true, + }, + } +} + +return { + 'nvim-tree/nvim-tree.lua', + opts = options, + config = function (_, opts) + require('nvim-tree').setup(opts) + + local augroup = vim.api.nvim_create_augroup("nvim-tree", {}) + + vim.api.nvim_create_autocmd({"BufEnter", "BufWinEnter"}, { + group = augroup, + pattern = "*", + callback = function(args) + if vim.bo[args.buf].filetype == 'NvimTree' then + vim.opt_local.fillchars:append("vert:▕") + vim.opt_local.statuscolumn = '' + end + end + }) + end +} diff --git a/nvim/lua/user/plugins/ui/statuscolumn.lua b/nvim/lua/user/plugins/ui/statuscolumn.lua index e9d20bf..fea6c39 100644 --- a/nvim/lua/user/plugins/ui/statuscolumn.lua +++ b/nvim/lua/user/plugins/ui/statuscolumn.lua @@ -7,7 +7,8 @@ local opts = function() relculright = true, ft_ignore = { 'help', - 'alpha' + 'alpha', + 'NvimTree', }, segments = { {