refactor: cleanup UI and navigation plugins

- Simplify telescope.lua configuration
- Streamline trouble.lua diagnostics
- Refactor oil.lua file manager
- Update harpoon.lua quick file navigation
- Clean up indent.lua, lualine.lua, which-key.lua
This commit is contained in:
Jeremie Fraeys 2026-03-23 20:34:20 -04:00
parent 43104006ae
commit f162354317
No known key found for this signature in database
7 changed files with 59 additions and 183 deletions

View file

@ -14,70 +14,18 @@ return {
dependencies = { 'nvim-lua/plenary.nvim' },
config = function()
local harpoon = require('harpoon')
-- local actions = require('telescope.actions')
-- local action_state = require('telescope.actions.state')
-- local conf = require('telescope.config').values
harpoon:setup({
settings = {
save_on_toggle = true,
sync_on_ui_close = true,
key = function()
return vim.loop.cwd() or 'global'
return vim.uv.cwd() or 'global'
end,
},
})
-- Telescope integration
-- local function toggle_telescope()
-- local list = harpoon:list()
-- local file_paths = {}
--
-- for _, item in ipairs(list.items) do
-- table.insert(file_paths, item.value)
-- end
--
-- require('telescope.pickers')
-- .new({}, {
-- prompt_title = 'Harpoon',
-- finder = require('telescope.finders').new_table({
-- results = file_paths,
-- }),
-- previewer = false,
-- sorter = conf.generic_sorter({}),
-- layout_config = {
-- width = 0.5,
-- height = 0.5,
-- prompt_position = 'top',
-- },
-- layout_strategy = 'vertical',
-- attach_mappings = function(prompt_bufnr, map)
-- map('i', '<C-d>', function()
-- local selection = action_state.get_selected_entry()
-- if not selection then
-- return
-- end
--
-- local target = selection[1]
-- for _, item in ipairs(harpoon:list().items) do
-- if item.value == target then
-- harpoon:list():remove(item)
-- break
-- end
-- end
-- actions.close(prompt_bufnr)
-- toggle_telescope()
-- end)
-- return true
-- end,
-- })
-- :find()
-- end
vim.keymap.set('n', '<leader>a', function()
local harpoon = require('harpoon')
-- Check if we're in an oil buffer
if vim.fn.expand('%:p'):sub(1, 6) == 'oil://' then
local ok_oil, oil = pcall(require, 'oil')
if not ok_oil then
@ -92,9 +40,9 @@ return {
end
local full_path = oil.get_current_dir() .. entry.name
local stat = vim.loop.fs_stat(full_path)
local stat = vim.uv.fs_stat(full_path)
if not stat or stat.type ~= 'file' then
vim.notify('Selected entry is not a file: ' .. full_path, vim.log.levels.INFO)
vim.notify('Not a file: ' .. full_path, vim.log.levels.INFO)
return
end
@ -102,18 +50,16 @@ return {
value = entry.name,
context = { filename = entry.name, cwd = oil.get_current_dir() or 'global' },
})
vim.notify('Added ' .. entry.name .. ' to harpoon', vim.log.levels.INFO)
vim.notify('Added ' .. entry.name .. ' to harpoon')
return
end
-- Regular file buffer
harpoon:list():add()
end, { desc = 'Harpoon: Add file to list (if not already present)' })
end, { desc = 'Harpoon: Add file' })
vim.keymap.set('n', '<C-e>', function()
harpoon.ui:toggle_quick_menu(harpoon:list())
end, { desc = 'Harpoon: Toggle quick menu' })
end)
vim.keymap.set('n', '<C-h>', function()
harpoon:list():select(1)
end)
@ -126,7 +72,6 @@ return {
vim.keymap.set('n', '<C-l>', function()
harpoon:list():select(4)
end)
vim.keymap.set('n', '<C-p>', function()
harpoon:list():prev()
end)

View file

@ -1,25 +1,16 @@
local highlight = {
'Whitespace',
'Function',
}
return {
-- Add indentation guides even on blank lines
'lukas-reineke/indent-blankline.nvim',
main = 'ibl',
event = 'VeryLazy',
event = 'BufReadPost',
opts = {
indent = {
highlight = highlight,
highlight = { 'Whitespace', 'Function' },
char = '',
},
whitespace = {
highlight = highlight,
highlight = { 'Whitespace', 'Function' },
remove_blankline_trail = true,
},
scope = {
enabled = true,
exclude = { language = { 'vim', 'lua', 'go', 'python', 'rust', 'sh', 'json', 'yaml', 'toml', 'markdown' } },
},
scope = { enabled = false }, -- excluded for all your languages anyway
},
}

View file

@ -1,6 +1,7 @@
return {
'nvim-lualine/lualine.nvim',
dependencies = { 'nvim-tree/nvim-web-devicons', 'tpope/vim-fugitive' },
event = 'UIEnter',
dependencies = { 'nvim-tree/nvim-web-devicons', option = true },
config = function()
require('lualine').setup({
options = {
@ -11,24 +12,35 @@ return {
},
sections = {
lualine_a = {
{ 'mode', icons_enabled = true },
},
lualine_b = {
{
'buffers',
show_modified_status = true,
symbols = { modified = '', alternate_file = '#', directory = '' },
symbols = { modified = '', alternate_file = '#', directory = '' },
},
},
lualine_b = {
{ 'mode', icons_enabled = true },
},
lualine_c = {
'branch',
{ 'diff', colored = false, symbols = { added = '', modified = '', removed = '' } },
{
'diagnostics',
sources = { 'nvim_lsp' },
symbols = { error = 'E:', warn = 'W:', info = 'I:', hint = 'H:' },
}, -- shows E/W/H counts
},
lualine_x = {
'encoding',
{ 'fileformat', symbols = { unix = '', mac = '', dos = '' } },
{
display_components = { 'lsp_client_name', 'spinner', { 'title', 'percentage', 'message' } },
},
},
lualine_y = {
{ 'encoding', show_bomb = true },
{ 'fileformat', symbols = { unix = '', mac = '', dos = '' } },
'filetype',
},
lualine_z = { 'location' }, -- line:col
},
extensions = { 'fugitive', 'nvim-tree', 'fzf' },
})

View file

@ -1,5 +1,6 @@
return {
'stevearc/oil.nvim',
cmd = 'Oil',
keys = {
{ '<leader>e', '<CMD>Oil<CR>', desc = 'Open parent directory' },
{
@ -10,45 +11,33 @@ return {
desc = 'Toggle oil floating window',
},
},
dependencies = { 'nvim-tree/nvim-web-devicons' },
dependencies = { { 'nvim-tree/nvim-web-devicons', optional = true } },
config = function()
local oil = require('oil')
oil.setup({
columns = {
'icon',
-- 'permissions',
},
require('oil').setup({
columns = { 'icon' },
keymaps = {
['C-h'] = false,
['M-h'] = 'actions.select_split',
},
view_options = {
show_hidden = true,
['<C-h>'] = false,
['<M-h>'] = 'actions.select_split',
},
view_options = { show_hidden = true },
float = {
padding = 2,
max_width = 80,
max_height = 30,
border = 'rounded',
win_options = {
winblend = 0,
},
win_options = { winblend = 0 },
relative = 'editor',
},
})
-- Theme-aware highlights for oil
local function set_oil_highlights()
if vim.o.background == 'dark' then
-- Monokai colors
vim.api.nvim_set_hl(0, 'OilDir', { fg = '#A6E22E' })
vim.api.nvim_set_hl(0, 'OilFile', { fg = '#D3D0C8' })
vim.api.nvim_set_hl(0, 'OilHiddenFile', { fg = '#75715E' })
vim.api.nvim_set_hl(0, 'OilProgress', { fg = '#66D9EF' })
vim.api.nvim_set_hl(0, 'OilSymlink', { fg = '#F92672' })
else
-- Solarized light colors
vim.api.nvim_set_hl(0, 'OilDir', { fg = '#859900' })
vim.api.nvim_set_hl(0, 'OilFile', { fg = '#657B83' })
vim.api.nvim_set_hl(0, 'OilHiddenFile', { fg = '#93A1A1' })
@ -58,8 +47,8 @@ return {
end
set_oil_highlights()
vim.api.nvim_create_autocmd('OptionSet', {
pattern = 'background',
vim.api.nvim_create_autocmd('ColorScheme', {
callback = set_oil_highlights,
})
end,

View file

@ -1,11 +1,10 @@
return {
-- Fuzzy Finder (files, LSP, etc.)
'nvim-telescope/telescope.nvim',
cmd = 'Telescope',
version = '*',
keys = {
{ '<leader>ff', '<cmd>Telescope find_files<CR>', desc = 'Find Files' },
{ '<leader>fg', '<cmd>Telescope live_grep<CR>', desc = 'Live Grep' },
{ '<leader>fG', '<cmd>LiveGrepGitRoot<CR>', desc = 'Live Grep Git Root' },
{ '<leader>fb', '<cmd>Telescope buffers<CR>', desc = 'Buffers' },
{ '<leader>fh', '<cmd>Telescope help_tags<CR>', desc = 'Help Tags' },
{ '<leader>fr', '<cmd>Telescope oldfiles<CR>', desc = 'Recent Files' },
@ -13,69 +12,46 @@ return {
dependencies = {
'nvim-lua/plenary.nvim',
{ 'nvim-telescope/telescope-fzf-native.nvim', build = 'make' },
'nvim-tree/nvim-web-devicons',
{ 'nvim-tree/nvim-web-devicons', optional = true },
},
config = function()
local telescope = require('telescope')
local actions = require('telescope.actions')
-- Configure Telescope
telescope.setup({
defaults = {
-- prompt_prefix = '🔍 ',
sorting_strategy = 'descending',
layout_strategy = 'flex',
mappings = {
i = {
['<C-u>'] = false, -- Disable Ctrl+u clearing input
['<C-d>'] = false, -- Disable Ctrl+d clearing input
['<C-u>'] = false,
['<C-d>'] = false,
['<CR>'] = function(prompt_bufnr)
-- close first, then center -- this is the correct order
actions.select_default(prompt_bufnr)
vim.cmd('normal! zz')
end,
},
},
-- Attach the global mapping for centering the cursor on selection
attach_mappings = function(prompt_bufnr, _)
local actions = require('telescope.actions')
-- When selecting a result, center it in the middle of the screen
actions.select_default:replace(function()
local line = actions.state.get_selected_entry().lnum
vim.api.nvim_win_set_cursor(0, { line, 0 })
vim.cmd('normal! zz') -- This centers the line in the middle of the screen
actions.close(prompt_bufnr) -- Close the Telescope window
end)
return true
end,
},
extensions = {
fzf = {},
},
extensions = { fzf = {} },
})
-- Load the fzf extension for Telescope
telescope.load_extension('fzf')
-- Function to find git root directory
local function find_git_root()
local current_file = vim.api.nvim_buf_get_name(0)
local current_dir = current_file ~= '' and vim.fn.fnamemodify(current_file, ':h') or vim.fn.getcwd()
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
print('Not a git repository, searching in current directory.')
return vim.fn.getcwd()
end
return git_root
end
-- Function for live_grep within the Git root
local function live_grep_git_root()
local git_root = find_git_root()
if git_root then
require('telescope.builtin').live_grep({ search_dirs = { git_root } })
end
end
-- Command to trigger live_grep_git_root
vim.api.nvim_create_user_command('LiveGrepGitRoot', live_grep_git_root, { desc = 'Live grep in Git root' })
vim.api.nvim_create_user_command('LiveGrepGitRoot', function()
require('telescope.builtin').live_grep({ search_dirs = { find_git_root() } })
end, { desc = 'Live grep in Git root' })
end,
}

View file

@ -1,39 +1,18 @@
return {
'folke/trouble.nvim',
version = '*',
opts = {}, -- for default options, refer to the configuration section for custom setup.
cmd = 'Trouble',
event = 'LspAttach',
keys = {
{
'<leader>xx',
'<cmd>Trouble diagnostics toggle<cr>',
desc = 'Diagnostics (Trouble)',
},
{ '<leader>xx', '<cmd>Trouble diagnostics toggle<cr>', desc = 'Diagnostics (Trouble)' },
{
'<leader>xX',
'<cmd>Trouble diagnostics toggle filter.buf=0<cr>',
desc = 'Buffer Diagnostics (Trouble)',
},
{
'<leader>xs',
'<cmd>Trouble symbols toggle focus=false<cr>',
desc = 'Symbols (Trouble)',
},
{
'<leader>xl',
'<cmd>Trouble lsp toggle focus=false win.position=right<cr>',
desc = 'LSP Definitions / references / ... (Trouble)',
},
{
'<leader>xL',
'<cmd>Trouble loclist toggle<cr>',
desc = 'Location List (Trouble)',
},
{
'<leader>xQ',
'<cmd>Trouble qflist toggle<cr>',
desc = 'Quickfix List (Trouble)',
},
{ '<leader>xs', '<cmd>Trouble symbols toggle focus=false<cr>', desc = 'Symbols (Trouble)' },
{ '<leader>xl', '<cmd>Trouble lsp toggle focus=false win.position=right<cr>', desc = 'LSP Definitions (Trouble)' },
{ '<leader>xL', '<cmd>Trouble loclist toggle<cr>', desc = 'Location List (Trouble)' },
{ '<leader>xQ', '<cmd>Trouble qflist toggle<cr>', desc = 'Quickfix List (Trouble)' },
},
opts = {},
}

View file

@ -16,22 +16,6 @@ return {
Esc = '<Esc> ',
ScrollWheelDown = '<ScrollWheelDown> ',
ScrollWheelUp = '<ScrollWheelUp> ',
NL = '<NL> ',
BS = '<BS> ',
Space = '<Space> ',
Tab = '<Tab> ',
F1 = '<F1>',
F2 = '<F2>',
F3 = '<F3>',
F4 = '<F4>',
F5 = '<F5>',
F6 = '<F6>',
F7 = '<F7>',
F8 = '<F8>',
F9 = '<F9>',
F10 = '<F10>',
F11 = '<F11>',
F12 = '<F12>',
},
},
opts = {