navigation-file 1

This commit is contained in:
Tomas Mirchev 2025-10-15 19:43:51 +03:00
parent 6c73a15f21
commit 90c5d70a5a
8 changed files with 243 additions and 84 deletions

View File

@ -20,7 +20,7 @@ require('config.keymaps')
require('config.autocmds') require('config.autocmds')
require('config.clipboard') require('config.clipboard')
require('config.terminal') require('config.terminal')
require('custom.navigation')
require('lazy').setup({ require('lazy').setup({
spec = { { import = 'plugins' } }, spec = { { import = 'plugins' } },
change_detection = { notify = false }, change_detection = { notify = false },

View File

@ -1,12 +1,12 @@
{ {
"conform.nvim": { "branch": "master", "commit": "fbcb4fa7f34bfea9be702ffff481a8e336ebf6ed" }, "conform.nvim": { "branch": "master", "commit": "fbcb4fa7f34bfea9be702ffff481a8e336ebf6ed" },
"fzf-lua": { "branch": "main", "commit": "58ebb27333bd12cb497f27b7da07a677116bc0ef" }, "fzf-lua": { "branch": "main", "commit": "58ebb27333bd12cb497f27b7da07a677116bc0ef" },
"invero.nvim": { "branch": "main", "commit": "ff1b124ef709686965afdf338d989142e5e60602" },
"lazy.nvim": { "branch": "main", "commit": "1ea3c4085785f460fb0e46d2fe1ee895f5f9e7c1" }, "lazy.nvim": { "branch": "main", "commit": "1ea3c4085785f460fb0e46d2fe1ee895f5f9e7c1" },
"mason.nvim": { "branch": "main", "commit": "ad7146aa61dcaeb54fa900144d768f040090bff0" }, "mason.nvim": { "branch": "main", "commit": "ad7146aa61dcaeb54fa900144d768f040090bff0" },
"nvim-autopairs": { "branch": "master", "commit": "7a2c97cccd60abc559344042fefb1d5a85b3e33b" }, "nvim-autopairs": { "branch": "master", "commit": "7a2c97cccd60abc559344042fefb1d5a85b3e33b" },
"nvim-lint": { "branch": "master", "commit": "9da1fb942dd0668d5182f9c8dee801b9c190e2bb" }, "nvim-lint": { "branch": "master", "commit": "9da1fb942dd0668d5182f9c8dee801b9c190e2bb" },
"nvim-tree.lua": { "branch": "master", "commit": "321bc61580fd066b76861c32de3319c3a6d089e7" }, "nvim-tree.lua": { "branch": "master", "commit": "321bc61580fd066b76861c32de3319c3a6d089e7" },
"nvim-treesitter": { "branch": "master", "commit": "42fc28ba918343ebfd5565147a42a26580579482" }, "nvim-treesitter": { "branch": "master", "commit": "42fc28ba918343ebfd5565147a42a26580579482" },
"nvim-ts-autotag": { "branch": "main", "commit": "c4ca798ab95b316a768d51eaaaee48f64a4a46bc" } "nvim-ts-autotag": { "branch": "main", "commit": "c4ca798ab95b316a768d51eaaaee48f64a4a46bc" },
"rose-pine": { "branch": "main", "commit": "72a04c4065345b51b56aed4859ea1d884f734097" }
} }

View File

@ -25,7 +25,7 @@ vim.g.have_nerd_font = true
vim.opt.termguicolors = false vim.opt.termguicolors = false
vim.opt.textwidth = 100 vim.opt.textwidth = 100
vim.opt.colorcolumn = '+0' -- vim.opt.colorcolumn = '+0'
vim.opt.signcolumn = 'no' vim.opt.signcolumn = 'no'
vim.opt.number = true vim.opt.number = true
@ -33,8 +33,14 @@ vim.opt.relativenumber = true
vim.opt.cursorline = true vim.opt.cursorline = true
vim.opt.guicursor = 'n-v-i-c:block' vim.opt.guicursor = 'n-v-i-c:block'
vim.opt.statusline = '%F%m%r%h%w%=%l,%c %P ' -- vim.opt.statusline = ' %f %h%w%m%r%= '
vim.opt.statusline = '> %f %h%w%m%r %= %l,%c - %L '
vim.opt.fillchars:append({ stl = '', stlnc = '' })
vim.opt.winborder = 'rounded' vim.opt.winborder = 'rounded'
vim.opt.laststatus = 3
vim.opt.showcmd = false
-- vim.opt.cmdheight = 0
-- Wrap -- Wrap
vim.opt.wrap = false vim.opt.wrap = false
@ -59,7 +65,7 @@ vim.opt.mouse = 'a' -- Enable mouse support
vim.opt.ignorecase = true vim.opt.ignorecase = true
vim.opt.smartcase = true -- Override ignorecase if search contains upper case chars vim.opt.smartcase = true -- Override ignorecase if search contains upper case chars
vim.opt.inccommand = 'split' -- Live substitution preview vim.opt.inccommand = 'split' -- Live substitution preview
vim.opt.completeopt = { 'menuone' } vim.opt.completeopt = { 'menu,menuone,noselect' }
-- Splits -- Splits
vim.opt.splitright = true vim.opt.splitright = true

View File

@ -0,0 +1,162 @@
vim.keymap.set('n', '<leader>f', function()
vim.cmd('FuzzyLive')
end, { desc = 'Open fuzzy file finder' })
-- Minimal realtime fuzzy finder in pure Neovim Lua (no plugins)
local Fuzzy = {}
function Fuzzy.open()
if Fuzzy.active then
Fuzzy.close()
end
Fuzzy.active = true
-- Collect all files once (cached for speed)
Fuzzy.files = vim.fn.globpath('.', '**/*', 0, 1)
Fuzzy.matches = Fuzzy.files
Fuzzy.cursor = 1
-- Create input and result buffers
Fuzzy.input_buf = vim.api.nvim_create_buf(false, true)
Fuzzy.result_buf = vim.api.nvim_create_buf(false, true)
-- Floating window sizes
local width = math.floor(vim.o.columns * 0.6)
local height = 15
local row = math.floor((vim.o.lines - height) / 2)
local col = math.floor((vim.o.columns - width) / 2)
-- Input window (top)
Fuzzy.input_win = vim.api.nvim_open_win(Fuzzy.input_buf, true, {
relative = 'editor',
row = row,
col = col,
width = width,
height = 1,
style = 'minimal',
border = 'rounded',
})
vim.api.nvim_buf_set_option(Fuzzy.input_buf, 'buftype', 'prompt')
vim.fn.prompt_setprompt(Fuzzy.input_buf, 'Search: ')
-- Results window (below)
Fuzzy.result_win = vim.api.nvim_open_win(Fuzzy.result_buf, false, {
relative = 'editor',
row = row + 2,
col = col,
width = width,
height = height - 2,
style = 'minimal',
border = 'single',
})
-- Draw initial result list
Fuzzy:update_results('')
------------------------------------------------------------------
-- 🟢 Real-time fuzzy filtering
------------------------------------------------------------------
vim.api.nvim_create_autocmd({ 'TextChangedI', 'TextChangedP' }, {
buffer = Fuzzy.input_buf,
callback = function()
local text = vim.fn.getline('.')
text = text:gsub('^Search:%s*', '')
Fuzzy:update_results(text)
end,
})
------------------------------------------------------------------
-- 🟢 Keybindings in input window
------------------------------------------------------------------
vim.keymap.set('i', '<C-n>', function()
if not Fuzzy.matches or #Fuzzy.matches == 0 then
return
end
Fuzzy.cursor = math.min(Fuzzy.cursor + 1, #Fuzzy.matches)
Fuzzy:highlight_selection()
end, { buffer = Fuzzy.input_buf })
vim.keymap.set('i', '<C-p>', function()
if not Fuzzy.matches or #Fuzzy.matches == 0 then
return
end
Fuzzy.cursor = math.max(Fuzzy.cursor - 1, 1)
Fuzzy:highlight_selection()
end, { buffer = Fuzzy.input_buf })
vim.keymap.set('i', '<CR>', function()
local choice = Fuzzy.matches[Fuzzy.cursor]
if choice then
Fuzzy.close()
vim.cmd('edit ' .. vim.fn.fnameescape(choice))
end
end, { buffer = Fuzzy.input_buf })
vim.keymap.set('i', '<Esc>', function()
Fuzzy.close()
end, { buffer = Fuzzy.input_buf })
vim.cmd('startinsert')
end
--------------------------------------------------------------------
-- 🔵 Core update + display logic
--------------------------------------------------------------------
function Fuzzy:update_results(text)
if text == '' then
Fuzzy.matches = Fuzzy.files
else
Fuzzy.matches = vim.fn.matchfuzzy(Fuzzy.files, text)
end
if #Fuzzy.matches == 0 then
vim.api.nvim_buf_set_lines(Fuzzy.result_buf, 0, -1, false, { '-- no matches --' })
Fuzzy.cursor = 1
return
end
-- Limit to first 50 results for performance
local display = {}
for i = 1, math.min(#Fuzzy.matches, 50) do
table.insert(display, Fuzzy.matches[i])
end
vim.api.nvim_buf_set_lines(Fuzzy.result_buf, 0, -1, false, display)
Fuzzy.cursor = 1
Fuzzy:highlight_selection()
end
--------------------------------------------------------------------
-- 🔵 Highlight the selected file
--------------------------------------------------------------------
function Fuzzy:highlight_selection()
if not Fuzzy.result_buf then
return
end
vim.api.nvim_buf_clear_namespace(Fuzzy.result_buf, 0, 0, -1)
if Fuzzy.matches and Fuzzy.matches[Fuzzy.cursor] then
vim.api.nvim_buf_add_highlight(Fuzzy.result_buf, 0, 'Visual', Fuzzy.cursor - 1, 0, -1)
end
end
--------------------------------------------------------------------
-- 🔴 Clean up
--------------------------------------------------------------------
function Fuzzy.close()
if Fuzzy.input_win and vim.api.nvim_win_is_valid(Fuzzy.input_win) then
vim.api.nvim_win_close(Fuzzy.input_win, true)
end
if Fuzzy.result_win and vim.api.nvim_win_is_valid(Fuzzy.result_win) then
vim.api.nvim_win_close(Fuzzy.result_win, true)
end
Fuzzy.active = false
end
--------------------------------------------------------------------
-- 🧩 Command to launch
--------------------------------------------------------------------
vim.api.nvim_create_user_command('FuzzyLive', function()
Fuzzy.open()
end, {})
return Fuzzy

View File

@ -0,0 +1,66 @@
-- return {
-- 'rose-pine/neovim',
-- name = 'rose-pine',
-- config = function()
-- vim.cmd('colorscheme rose-pine-dawn')
-- end,
-- }
return {
'triimdev/invero.nvim',
lazy = false,
priority = 1000,
dev = true,
config = function()
vim.api.nvim_create_user_command('ReloadInvero', function()
require('invero').invalidate_cache()
vim.cmd('Lazy reload invero.nvim')
end, {})
require('invero').setup({
highlights = function(c, tool)
c.bg_float = tool(152)
return {
-- Normal = { fg = c.text, bg = c.base },
-- StatusLine = { fg = tool(231), bg = c.outline, bold = false }, -- Active statusline (where filename)
-- StatusLineNC = { fg = c.surface, bg = c.outline, bold = false }, -- Active statusline (where filename)
-- NormalFloat = { fg = c.text, bg = c.none },
-- FzfLuaFzfGutter = { bg = c.base },
-- FzfLuaBorder = { fg = c.outline, bg = c.bg_float },
-- FzfLuaCursor = 'IncSearch',
-- FzfLuaDirPart = { fg = c.muted },
-- FzfLuaFilePart = 'FzfLuaFzfNormal',
-- FzfLuaFzfCursorLine = 'Visual',
-- FzfLuaFzfNormal = { fg = c.text },
-- FzfLuaFzfPointer = { fg = c.magenta },
-- FzfLuaFzfSeparator = { fg = c.orange, bg = c.bg_float },
-- -- FzfLuaHeaderBind = '@punctuation.special',
-- FzfLuaHeaderBind = { fg = c.green, bg = c.base },
-- FzfLuaHeaderText = 'Title',
-- FzfLuaNormal = { fg = c.text, bg = c.bg_float },
-- FzfLuaPath = 'Directory',
-- FzfLuaPreviewTitle = { fg = c.surface, bg = c.bg_float },
-- FzfLuaTitle = { fg = c.orange, bg = c.bg_float },
-- FzfLuaBorder = { fg = c.border_highlight, bg = c.bg_float },
-- FzfLuaCursor = 'IncSearch',
-- FzfLuaDirPart = { fg = c.fg_dark },
-- FzfLuaFilePart = 'FzfLuaFzfNormal',
-- FzfLuaFzfCursorLine = 'Visual',
-- FzfLuaFzfNormal = { fg = c.fg },
-- FzfLuaFzfPointer = { fg = c.magenta2 },
-- FzfLuaFzfSeparator = { fg = c.orange, bg = c.bg_float },
-- FzfLuaHeaderBind = '@punctuation.special',
-- FzfLuaHeaderText = 'Title',
-- FzfLuaNormal = { fg = c.fg, bg = c.bg_float },
-- FzfLuaPath = 'Directory',
-- FzfLuaPreviewTitle = { fg = c.border_highlight, bg = c.bg_float },
-- FzfLuaTitle = { fg = c.orange, bg = c.bg_float },
}
end,
})
vim.o.background = 'light'
vim.cmd.colorscheme('invero')
end,
}

View File

@ -1,26 +0,0 @@
return {
{ 'windwp/nvim-ts-autotag', config = true },
{ 'windwp/nvim-autopairs', event = 'InsertEnter', config = true },
{
'triimdev/invero.nvim',
lazy = false,
priority = 1000,
config = function()
vim.api.nvim_create_user_command('ReloadInvero', function()
require('invero').invalidate_cache()
vim.cmd('Lazy reload invero.nvim')
end, {})
-- require('invero').setup({
-- highlights = function(C, tool)
-- return {
-- -- Statement = { fg = C.none, italic = true },
-- }
-- end,
-- })
vim.o.background = 'light'
vim.cmd.colorscheme('invero')
end,
},
}

View File

@ -1,52 +0,0 @@
return {
'ibhagwan/fzf-lua',
opts = {},
}
-- return {
-- 'nvim-telescope/telescope.nvim',
-- event = 'VimEnter',
-- branch = '0.1.x',
-- dependencies = {
-- 'nvim-lua/plenary.nvim',
-- {
-- 'nvim-telescope/telescope-fzf-native.nvim',
-- build = 'make',
-- cond = function()
-- return vim.fn.executable('make') == 1
-- end,
-- },
-- { 'nvim-telescope/telescope-ui-select.nvim' },
-- },
-- config = function()
-- require('telescope').setup({
-- defaults = {
-- layout_strategy = 'vertical',
-- layout_config = {
-- width = { 0.95, max = 100 },
-- height = 0.95,
-- preview_cutoff = 1,
-- preview_height = 0.7,
-- },
-- mappings = {
-- n = {
-- ['d'] = 'delete_buffer',
-- },
-- },
-- },
-- })
--
-- pcall(require('telescope').load_extension, 'fzf')
-- pcall(require('telescope').load_extension, 'ui-select')
--
-- local builtin = require('telescope.builtin')
-- vim.keymap.set('n', '<leader>sk', builtin.keymaps)
-- vim.keymap.set('n', '<leader>sf', builtin.find_files)
-- vim.keymap.set('n', '<leader>sw', builtin.grep_string)
-- vim.keymap.set('n', '<leader>ss', builtin.current_buffer_fuzzy_find)
-- vim.keymap.set('n', '<leader>sg', builtin.live_grep)
-- vim.keymap.set('n', '<leader>sd', builtin.diagnostics)
-- vim.keymap.set('n', '<leader>sr', builtin.lsp_references)
-- vim.keymap.set('n', '<leader>s.', builtin.oldfiles)
-- vim.keymap.set('n', '<leader><leader>', builtin.buffers)
-- end,
-- }

View File

@ -23,6 +23,9 @@ vim.lsp.enable({ 'json_ls' })
return { return {
{ 'mason-org/mason.nvim', config = true }, { 'mason-org/mason.nvim', config = true },
{ 'windwp/nvim-ts-autotag', config = true },
{ 'windwp/nvim-autopairs', event = 'InsertEnter', config = true },
-- { 'saghen/blink.cmp', version = '1.*' }, -- { 'saghen/blink.cmp', version = '1.*' },
{ {
'nvim-treesitter/nvim-treesitter', 'nvim-treesitter/nvim-treesitter',