diff --git a/home/private_dot_config/nvim/init.lua b/home/private_dot_config/nvim/init.lua index e10a774..4cae470 100644 --- a/home/private_dot_config/nvim/init.lua +++ b/home/private_dot_config/nvim/init.lua @@ -1,4 +1,2 @@ require("settings") - require("lazy-nvim") - diff --git a/home/private_dot_config/nvim/lua/lazy-nvim.lua b/home/private_dot_config/nvim/lua/lazy-nvim.lua index 078ad35..741e65b 100644 --- a/home/private_dot_config/nvim/lua/lazy-nvim.lua +++ b/home/private_dot_config/nvim/lua/lazy-nvim.lua @@ -27,4 +27,3 @@ require("lazy").setup({ -- Automatically check for plugin updates checker = { enabled = true }, }) - diff --git a/home/private_dot_config/nvim/lua/plugins/nvim-tree.lua b/home/private_dot_config/nvim/lua/plugins/nvim-tree.lua new file mode 100644 index 0000000..1e9abd5 --- /dev/null +++ b/home/private_dot_config/nvim/lua/plugins/nvim-tree.lua @@ -0,0 +1,41 @@ +return { + 'nvim-tree/nvim-tree.lua', + dependencies = { 'nvim-tree/nvim-web-devicons' }, + lazy = false, + keys = { + { 'e', 'NvimTreeToggle', desc = 'Toggle file explorer' }, + }, + init = function() + -- disable netrw + vim.g.loaded_netrw = 1 + vim.g.loaded_netrwPlugin = 1 + end, + config = function() + require('nvim-tree').setup({ + view = { width = 32 }, + sync_root_with_cwd = true, + update_focused_file = { enable = true }, + + actions = { + open_file = { + window_picker = { enable = true }, + }, + }, + + on_attach = function(bufnr) + local api = require('nvim-tree.api') + + -- Keep all default keymaps + api.config.mappings.default_on_attach(bufnr) + + local function opts(desc) + return { desc = 'nvim-tree: ' .. desc, buffer = bufnr, noremap = true, silent = true, nowait = true } + end + + -- Swap 'd'/'D' + vim.keymap.set({ 'n', 'x' }, 'd', api.fs.trash, opts('Trash')) + vim.keymap.set({ 'n', 'x' }, 'D', api.fs.remove, opts('Delete')) + end, + }) + end, +} diff --git a/home/private_dot_config/nvim/lua/plugins/treesitter.lua b/home/private_dot_config/nvim/lua/plugins/treesitter.lua index 1b92cae..978eaca 100644 --- a/home/private_dot_config/nvim/lua/plugins/treesitter.lua +++ b/home/private_dot_config/nvim/lua/plugins/treesitter.lua @@ -27,6 +27,11 @@ return { vim.api.nvim_create_autocmd('FileType', { group = ts_autoinstall_group, callback = function(args) + -- Skip UI/special buffers (file explorers, help, terminals, quickfix, ecc.) + if vim.bo[args.buf].buftype ~= '' then + return + end + local lang = vim.treesitter.language.get_lang(args.match) or args.match -- Try starting right away: if it works, the parser was already installed @@ -54,4 +59,3 @@ return { }) end, } - diff --git a/home/private_dot_config/nvim/lua/settings.lua b/home/private_dot_config/nvim/lua/settings.lua index 7bd1225..394a40e 100644 --- a/home/private_dot_config/nvim/lua/settings.lua +++ b/home/private_dot_config/nvim/lua/settings.lua @@ -11,6 +11,7 @@ vim.opt.cursorline = true -- Highlight the current line vim.opt.colorcolumn = "80,120" -- Show vertical ruler vim.opt.scrolloff = 8 -- Keep at least 8 lines between the cursor and the borders vim.opt.wrap = false -- Don't wrap long lines +vim.opt.laststatus = 3 -- Single global status bar -- Show whitespace characters (tabs, trailing spaces, etc.) vim.opt.list = true @@ -25,7 +26,6 @@ vim.api.nvim_create_autocmd('BufWritePre', { local save_view = vim.fn.winsaveview() vim.cmd([[%s/\s\+$//e]]) -- Remove trailing whitespace on every line vim.cmd([[%s/\n\+\%$//e]]) -- Remove all trailing blank lines - vim.fn.append(vim.fn.line('$'), '') -- Always append exactly one blank line at the end vim.fn.winrestview(save_view) -- Restore the window to where it was before the edits end, }) @@ -61,4 +61,3 @@ vim.opt.smartindent = true -- Auto-indent new lines based on syntax (e.g. after -- Search vim.opt.ignorecase = true -- Case-insensitive search... vim.opt.smartcase = true -- ...unless you type an explicit uppercase letter - diff --git a/setup-script/roles/editor/tasks/main.yaml b/setup-script/roles/editor/tasks/main.yaml index dc90abd..15bb61f 100644 --- a/setup-script/roles/editor/tasks/main.yaml +++ b/setup-script/roles/editor/tasks/main.yaml @@ -19,4 +19,7 @@ - gcc - curl - tar + + # nvim-tree + - trash-cli when: chezmoi.osRelease.id == "arch"