neovim conf part 4 i think

This commit is contained in:
RafayAhmad7548 2025-05-01 07:50:51 +05:00
parent ac7ba4097d
commit d6c19e2e92
12 changed files with 154 additions and 166 deletions

View file

@ -0,0 +1,13 @@
return {
'rmagatti/auto-session',
lazy = false,
---enables autocomplete for opts
---@module "auto-session"
---@type AutoSession.Config
opts = {
suppressed_dirs = { '~/', '~/Downloads', '/' },
}
}

View file

@ -0,0 +1,29 @@
return {
'ThePrimeagen/harpoon',
branch = 'harpoon2',
dependencies = { 'nvim-lua/plenary.nvim' },
config = function()
local harpoon = require('harpoon')
harpoon:setup({
settings = {
save_on_toggle = true,
sync_on_ui_close = true
}
})
vim.keymap.set('n', '<leader>a', function() harpoon:list():add() end)
vim.keymap.set('n', '<C-h>', function() harpoon.ui:toggle_quick_menu(harpoon:list()) end)
vim.keymap.set('n', '<A-1>', function() harpoon:list():select(1) end)
vim.keymap.set('n', '<A-2>', function() harpoon:list():select(2) end)
vim.keymap.set('n', '<A-3>', function() harpoon:list():select(3) end)
vim.keymap.set('n', '<A-q>', function() harpoon:list():select(4) end)
-- -- Toggle previous & next buffers stored within Harpoon list
-- vim.keymap.set('n', '<C-S-P>', function() harpoon:list():prev() end)
-- vim.keymap.set('n', '<C-S-N>', function() harpoon:list():next() end)
end
}

View file

@ -34,6 +34,8 @@ require('lazy').setup({
opts = {},
},
'ThePrimeagen/vim-be-good',
require('config.plugins.oil'),
require('config.plugins.git'),
require('config.plugins.ui'),
@ -41,6 +43,8 @@ require('lazy').setup({
require('config.plugins.blinkcmp'),
require('config.plugins.lsp'),
require('config.plugins.treesitter'),
require('config.plugins.autosession'),
require('config.plugins.harpoon'),
require('config.plugins.molten'),

View file

@ -1,10 +1,13 @@
return {
'stevearc/oil.nvim',
---@module 'oil'
---@type oil.SetupOpts
opts = {
use_default_keymaps = false,
keymaps = {
'stevearc/oil.nvim',
---@module 'oil'
---@type oil.SetupOpts
opts = {
use_default_keymaps = false,
buf_options = {
buflisted = true
},
keymaps = {
['<C-j>'] = { '<Down><C-j>', remap = true },
['<Space>'] = { callback = function()
@ -18,31 +21,31 @@ return {
if cursor_entry.type == 'directory' then
oil.select()
else
vim.cmd.wincmd('h')
local bufname = vim.api.nvim_buf_get_name(0)
local is_empty = bufname == '' and not vim.bo.modified
if is_empty then
vim.cmd(':q')
oil.select({ vertical = true, split = 'topleft' }, function()
vim.cmd.wincmd('l')
vim.api.nvim_win_set_width(0, 40)
vim.cmd.wincmd('h')
end)
else
vim.cmd.wincmd('l')
oil.select({ tab = true })
end
oil.select(nil, function()
vim.cmd.wincmd('h')
local buf_name = vim.api.nvim_buf_get_name(0)
local is_empty = buf_name == '' and not vim.bo.modified
if is_empty then
-- delete empty buffer
vim.cmd('bd')
else
-- close window of not empty buffer
vim.cmd('q')
end
end)
end
end, nowait = true },
-- shift space remapping
['<F26>'] = 'actions.parent',
}
},
-- dependencies = { { 'echasnovski/mini.icons', opts = {} } },
dependencies = { 'nvim-tree/nvim-web-devicons' }, -- use if you prefer nvim-web-devicons
-- Lazy loading is not recommended because it is very tricky to make it work correctly in all situations.
lazy = false,
['<C-w>'] = { callback = function()
vim.cmd('bd')
end, nowait = true }
}
},
-- dependencies = { { 'echasnovski/mini.icons', opts = {} } },
dependencies = { 'nvim-tree/nvim-web-devicons' }, -- use if you prefer nvim-web-devicons
-- Lazy loading is not recommended because it is very tricky to make it work correctly in all situations.
lazy = false,
}

View file

@ -13,7 +13,6 @@ return {
},
config = function()
local actions = require('telescope.actions')
local actions_state = require('telescope.actions.state')
require('telescope').setup({
defaults = {
mappings = {
@ -23,23 +22,10 @@ return {
}
},
pickers = {
find_files = {
mappings = {
i = {
['<CR>'] = function(prompt_bufnr)
local selection = actions_state.get_selected_entry()
actions.close(prompt_bufnr)
local bufname = vim.api.nvim_buf_get_name(0)
local is_empty = bufname == '' and not vim.bo.modified
if is_empty then
vim.cmd('edit' .. vim.fn.fnameescape(selection.path or selection.filename))
else
vim.cmd('tabnew ' .. vim.fn.fnameescape(selection.path or selection.filename))
end
end
}
mappings = {
i = {
['<C-s>'] = actions.file_split,
['<C-v>'] = actions.file_vsplit
}
}
}
@ -50,7 +36,9 @@ return {
local builtin = require('telescope.builtin')
vim.keymap.set('n', '<C-o>', builtin.find_files, { desc = 'Telescope find files' })
vim.keymap.set('n', '<leader>sf', builtin.find_files, { desc = 'Telescope find files' })
vim.keymap.set('n', '<leader>sp', '<cmd>SessionSearch<CR>', { desc = 'Search Sessions' })
vim.keymap.set('n', '<leader>/', function()
-- You can pass additional configuration to Telescope to change the theme, layout, etc.

View file

@ -3,7 +3,7 @@ return {
build = ':TSUpdate',
main = 'nvim-treesitter.configs', -- Sets main module to use for opts
opts = {
ensure_installed = { 'bash', 'c', 'diff', 'html', 'css', 'lua', 'luadoc', 'markdown', 'markdown_inline', 'query', 'vim', 'vimdoc', 'rust', 'python', 'htmldjango' },
ensure_installed = { 'bash', 'c', 'diff', 'html', 'css', 'lua', 'luadoc', 'markdown', 'markdown_inline', 'query', 'vim', 'vimdoc', 'rust', 'python', 'htmldjango', 'r' },
auto_install = false,
highlight = {
enable = true,

View file

@ -1,65 +1,22 @@
return {
{
'nanozuki/tabby.nvim',
dependencies = 'nvim-tree/nvim-web-devicons',
config = function()
local theme = {
-- this is carbonfox theme
fill = 'TabLineFill',
head = { fg = '#75beff', bg = '#1c1e26' },
current_tab = { fg = '#1c1e26', bg = '#75beff' },
tab = { fg = '#c5cdd9', bg = '#1c1e26' },
win = { fg = '#1c1e26', bg = '#75beff' },
tail = { fg = '#75beff', bg = '#1c1e26' },
}
require('tabby.tabline').set(function(line)
return {
{
{ '', hl = theme.head },
line.sep('', theme.head, theme.fill),
},
line.tabs().foreach(function(tab)
local hl = tab.is_current() and theme.current_tab or theme.tab
-- remove count of wins in tab with [n+] included in tab.name()
local name = tab.name()
local index = string.find(name, '%[%d')
local tab_name = index and string.sub(name, 1, index - 1) or name
-- indicate if any of buffers in tab have unsaved changes
local modified = false
local win_ids = require('tabby.module.api').get_tab_wins(tab.id)
for _, win_id in ipairs(win_ids) do
if pcall(vim.api.nvim_win_get_buf, win_id) then
local bufid = vim.api.nvim_win_get_buf(win_id)
if vim.api.nvim_buf_get_option(bufid, 'modified') then
modified = true
break
end
end
end
return {
line.sep('', hl, theme.fill),
tab_name,
modified and '',
line.sep('', hl, theme.fill),
hl = hl,
margin = ' ',
}
end),
line.spacer(),
{
line.sep('', theme.tail, theme.fill),
{ '', hl = theme.tail },
},
hl = theme.fill,
}
end)
end
},
-- {
-- 'akinsho/bufferline.nvim',
-- version = "*",
-- dependencies = 'nvim-tree/nvim-web-devicons',
-- opts = {
-- options = {
-- custom_filter = function(buf, _)
-- local buf_name = vim.api.nvim_buf_get_name(buf)
-- if string.find(buf_name, '^term://') or string.find(buf_name, '^oil://') then
-- return false
-- end
-- return true
-- end,
-- show_buffer_close_icons = false,
-- -- style_preset = require('bufferline').style_preset.minimal
-- }
-- }
-- },
{
'nvim-lualine/lualine.nvim',
dependencies = { 'nvim-tree/nvim-web-devicons' },