diff --git a/lua/custom/plugins/filetree.lua b/lua/custom/plugins/filetree.lua index 3bcff3c..15726e7 100644 --- a/lua/custom/plugins/filetree.lua +++ b/lua/custom/plugins/filetree.lua @@ -16,13 +16,11 @@ return { return end local path = node:get_id() - -- If the node is a directory, just toggle expand/collapse if node.type == 'directory' then state.commands.toggle_node(state, node) return end - -- --- File handling starts here --- -- Reuse already open buffer in any tab safely for _, tab in ipairs(vim.api.nvim_list_tabpages()) do @@ -48,7 +46,6 @@ return { end end end - -- Reuse empty buffer in current tab local wins = vim.api.nvim_tabpage_list_wins(0) local empty_buf = nil @@ -67,13 +64,11 @@ return { end end end - if empty_buf then vim.cmd('edit ' .. vim.fn.fnameescape(path)) else vim.cmd('tabnew ' .. vim.fn.fnameescape(path)) end - -- Always close Neo-tree window if open for _, win in ipairs(vim.api.nvim_list_wins()) do if vim.api.nvim_win_is_valid(win) then @@ -84,7 +79,6 @@ return { end end end - -- Smart_open_split for split windows local function smart_open_split(state, direction) local node = state.tree:get_node() @@ -97,7 +91,6 @@ return { state.commands.toggle_node(state, node) return end - -- Check if file is open in another tab local open_tab, open_win for _, tab in ipairs(vim.api.nvim_list_tabpages()) do @@ -113,7 +106,6 @@ return { break end end - if open_tab then local choice = vim.fn.confirm('File is already open in a tab. Open split here anyway?', '&Yes\n&No', 2) if choice ~= 1 then @@ -124,7 +116,6 @@ return { end -- Else user chose Yes → continue to open split in current tab end - -- Open split in current tab if direction == 'v' then state.commands.open_vsplit(state) @@ -140,7 +131,6 @@ return { vim.cmd('edit ' .. vim.fn.fnameescape(path)) end - require('neo-tree').setup { close_if_last_window = true, popup_border_style = 'rounded', diff --git a/lua/custom/plugins/telescope.lua b/lua/custom/plugins/telescope.lua index ccd7f43..0af5155 100644 --- a/lua/custom/plugins/telescope.lua +++ b/lua/custom/plugins/telescope.lua @@ -30,7 +30,6 @@ return { }, }, } - -- Enable telescope fzf native, if installed pcall(require('telescope').load_extension, 'fzf') @@ -191,7 +190,6 @@ return { end, } end, { desc = 'Switch to Open Buffers' }) - -- Telescope live_grep in git root -- Function to find the git root directory based on the current buffer's path local function find_git_root() @@ -206,7 +204,6 @@ return { -- Extract the directory from the current file's path current_dir = vim.fn.fnamemodify(current_file, ':h') end - -- Find the Git root directory from the current file's path local git_root = vim.fn.systemlist('git -C ' .. vim.fn.escape(current_dir, ' ') .. ' rev-parse --show-toplevel')[1] if vim.v.shell_error ~= 0 then @@ -215,7 +212,6 @@ return { end return git_root end - -- Custom live_grep function to search in git root local function live_grep_git_root() local git_root = find_git_root() @@ -225,9 +221,7 @@ return { } end end - vim.api.nvim_create_user_command('LiveGrepGitRoot', live_grep_git_root, {}) - -- See `:help telescope.builtin` vim.keymap.set('n', '/', function() -- You can pass additional configuration to telescope to change theme, layout, etc. @@ -236,7 +230,6 @@ return { previewer = false, }) end, { desc = '[/] Fuzzily search in current buffer' }) - local function telescope_live_grep_open_files() require('telescope.builtin').live_grep { grep_open_files = true, diff --git a/lua/keymaps.lua b/lua/keymaps.lua index 5ccbfd1..8210251 100644 --- a/lua/keymaps.lua +++ b/lua/keymaps.lua @@ -139,11 +139,27 @@ vim.keymap.set('n', 'll', 'ggVG', { desc = 'Select all' }) vim.keymap.set('n', 'lY', function() -- Get all lines from the buffer local lines = vim.api.nvim_buf_get_lines(0, 0, -1, false) - -- Join them without adding an extra newline local content = table.concat(lines, '\n') -- Set to system clipboard vim.fn.setreg('+', content) vim.fn.setreg('*', content) + -- Highlight the full buffer + local ns = vim.api.nvim_create_namespace 'custom_yank_highlight' + local hl_group = vim.g.highlightedyank_highlight_group or 'IncSearch' + local end_row = #lines - 1 + local end_col = #lines[#lines] + vim.highlight.range( + 0, -- bufnr + ns, + hl_group, + { 0, 0 }, -- start at beginning + { end_row, end_col }, -- end at last line's end + { inclusive = true } + ) + -- Clear highlight after delay + vim.defer_fn(function() + vim.api.nvim_buf_clear_namespace(0, ns, 0, -1) + end, 200) -- Notify vim.schedule(function() vim.notify('Copied all to clipboard', vim.log.levels.INFO)