nvim-config
This commit is contained in:
parent
3338d39206
commit
ad5d34530f
14 changed files with 563 additions and 33 deletions
16
lua/custom/keymaps/files.lua
Normal file
16
lua/custom/keymaps/files.lua
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
-- File navigation and Telescope-related keybindings
|
||||
|
||||
-- File explorer
|
||||
vim.keymap.set('n', '<leader>e', ':NvimTreeToggle<CR>', { desc = 'Toggle file explorer' })
|
||||
vim.keymap.set('n', '<leader>fb', ':Telescope file_browser<CR>', { desc = 'Telescope file browser' })
|
||||
|
||||
-- Telescope pickers (additional to Kickstart defaults)
|
||||
-- Note: These require telescope to be loaded, so we'll use pcall for safety
|
||||
local ok, telescope_builtin = pcall(require, 'telescope.builtin')
|
||||
if ok then
|
||||
vim.keymap.set('n', '<leader>ff', telescope_builtin.find_files, { desc = 'Find files' })
|
||||
vim.keymap.set('n', '<leader>fg', telescope_builtin.live_grep, { desc = 'Live grep' })
|
||||
vim.keymap.set('n', '<leader>fh', telescope_builtin.help_tags, { desc = 'Search help' })
|
||||
vim.keymap.set('n', '<leader>fr', telescope_builtin.oldfiles, { desc = 'Recent files' })
|
||||
vim.keymap.set('n', '<leader>fc', telescope_builtin.current_buffer_fuzzy_find, { desc = 'Search in current buffer' })
|
||||
end
|
||||
34
lua/custom/keymaps/general.lua
Normal file
34
lua/custom/keymaps/general.lua
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
-- General keymaps for navigation, editing, and window management
|
||||
|
||||
-- Exit insert mode with jj
|
||||
vim.keymap.set('i', 'jj', '<Esc>', { desc = 'Exit insert mode' })
|
||||
|
||||
-- Split management
|
||||
vim.keymap.set('n', 'sj', '<C-W>w', { desc = 'Move to next window' })
|
||||
vim.keymap.set('n', 'sk', '<C-W>W', { desc = 'Move to previous window' })
|
||||
vim.keymap.set('n', 'su', ':resize +5<CR>', { desc = 'Increase window height' })
|
||||
vim.keymap.set('n', 'si', ':resize -5<CR>', { desc = 'Decrease window height' })
|
||||
vim.keymap.set('n', 'sh', ':vertical resize +5<CR>', { desc = 'Increase window width' })
|
||||
vim.keymap.set('n', 'sl', ':vertical resize -5<CR>', { desc = 'Decrease window width' })
|
||||
vim.keymap.set('n', 'sd', ':hide<CR>', { desc = 'Hide current window' })
|
||||
vim.keymap.set('n', 'so', ':', { desc = 'Open command mode' })
|
||||
vim.keymap.set('n', 'ss', ':split ', { desc = 'Horizontal split' })
|
||||
vim.keymap.set('n', 'sv', ':vsplit ', { desc = 'Vertical split' })
|
||||
|
||||
-- Tab management
|
||||
vim.keymap.set('n', 'th', ':tabfirst<CR>', { desc = 'Go to first tab' })
|
||||
vim.keymap.set('n', 'tj', ':tabnext<CR>', { desc = 'Go to next tab' })
|
||||
vim.keymap.set('n', 'tk', ':tabprev<CR>', { desc = 'Go to previous tab' })
|
||||
vim.keymap.set('n', 'tl', ':tablast<CR>', { desc = 'Go to last tab' })
|
||||
vim.keymap.set('n', 'tt', ':tabedit ', { desc = 'Create new tab' })
|
||||
vim.keymap.set('n', 'tn', ':tabnext<CR>', { desc = 'Go to next tab' })
|
||||
vim.keymap.set('n', 'tm', ':tabm ', { desc = 'Move tab' })
|
||||
vim.keymap.set('n', 'td', ':tabclose<CR>', { desc = 'Close tab' })
|
||||
|
||||
-- Buffer management
|
||||
vim.keymap.set('n', '<C-k>', ':bnext<CR>', { desc = 'Next buffer' })
|
||||
vim.keymap.set('n', '<C-j>', ':bprev<CR>', { desc = 'Previous buffer' })
|
||||
vim.keymap.set('n', '<leader>bd', ':bdelete<CR>', { desc = 'Close current buffer' })
|
||||
|
||||
-- Python debugging
|
||||
vim.keymap.set('n', '<leader>p', 'oimport ipdb; ipdb.set_trace()<Esc>', { desc = 'Insert Python debugger breakpoint' })
|
||||
6
lua/custom/keymaps/git.lua
Normal file
6
lua/custom/keymaps/git.lua
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
-- Git-related keymaps
|
||||
|
||||
-- LazyGit
|
||||
vim.keymap.set('n', '<leader>gg', ':LazyGit<CR>', { desc = 'Open LazyGit' })
|
||||
vim.keymap.set('n', '<leader>gc', ':LazyGitCurrentFile<CR>', { desc = 'LazyGit current file' })
|
||||
vim.keymap.set('n', '<leader>gf', ':LazyGitFilter<CR>', { desc = 'LazyGit filter' })
|
||||
5
lua/custom/keymaps/init.lua
Normal file
5
lua/custom/keymaps/init.lua
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
-- Central loader for all keymap modules
|
||||
require('custom.keymaps.general')
|
||||
require('custom.keymaps.files')
|
||||
require('custom.keymaps.git')
|
||||
require('custom.keymaps.terminal')
|
||||
12
lua/custom/keymaps/terminal.lua
Normal file
12
lua/custom/keymaps/terminal.lua
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
-- Terminal and code execution keymaps
|
||||
|
||||
-- ToggleTerm keybindings
|
||||
-- Note: <c-\> is already mapped in toggleterm config for opening terminal
|
||||
vim.keymap.set('n', '<leader>tt', ':ToggleTerm<CR>', { desc = 'Toggle terminal' })
|
||||
vim.keymap.set('n', '<leader>tf', ':ToggleTerm direction=float<CR>', { desc = 'Toggle floating terminal' })
|
||||
vim.keymap.set('n', '<leader>th', ':ToggleTerm direction=horizontal<CR>', { desc = 'Toggle horizontal terminal' })
|
||||
vim.keymap.set('n', '<leader>tv', ':ToggleTerm direction=vertical<CR>', { desc = 'Toggle vertical terminal' })
|
||||
|
||||
-- Terminal mode mappings to escape easily
|
||||
vim.keymap.set('t', '<Esc><Esc>', '<C-\\><C-n>', { desc = 'Exit terminal mode' })
|
||||
vim.keymap.set('t', 'jj', '<C-\\><C-n>', { desc = 'Exit terminal mode with jj' })
|
||||
63
lua/custom/plugins/bufferline.lua
Normal file
63
lua/custom/plugins/bufferline.lua
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
return {
|
||||
'akinsho/bufferline.nvim',
|
||||
version = '*',
|
||||
dependencies = {
|
||||
'nvim-tree/nvim-web-devicons',
|
||||
},
|
||||
config = function()
|
||||
require('bufferline').setup {
|
||||
options = {
|
||||
mode = 'buffers', -- set to "tabs" to only show tabpages instead
|
||||
themable = true,
|
||||
numbers = 'none', -- "none" | "ordinal" | "buffer_id" | "both"
|
||||
close_command = 'bdelete! %d',
|
||||
right_mouse_command = 'bdelete! %d',
|
||||
left_mouse_command = 'buffer %d',
|
||||
middle_mouse_command = nil,
|
||||
indicator = {
|
||||
icon = '▎',
|
||||
style = 'icon', -- 'icon' | 'underline' | 'none'
|
||||
},
|
||||
buffer_close_icon = '',
|
||||
modified_icon = '●',
|
||||
close_icon = '',
|
||||
left_trunc_marker = '',
|
||||
right_trunc_marker = '',
|
||||
max_name_length = 18,
|
||||
max_prefix_length = 15,
|
||||
truncate_names = true,
|
||||
tab_size = 18,
|
||||
diagnostics = 'nvim_lsp',
|
||||
diagnostics_update_in_insert = false,
|
||||
diagnostics_indicator = function(count, level, diagnostics_dict, context)
|
||||
local icon = level:match('error') and ' ' or ' '
|
||||
return ' ' .. icon .. count
|
||||
end,
|
||||
offsets = {
|
||||
{
|
||||
filetype = 'NvimTree',
|
||||
text = 'File Explorer',
|
||||
text_align = 'center',
|
||||
separator = true,
|
||||
},
|
||||
},
|
||||
color_icons = true,
|
||||
show_buffer_icons = true,
|
||||
show_buffer_close_icons = true,
|
||||
show_close_icon = true,
|
||||
show_tab_indicators = true,
|
||||
show_duplicate_prefix = true,
|
||||
persist_buffer_sort = true,
|
||||
separator_style = 'thin', -- "slant" | "slope" | "thick" | "thin" | { 'any', 'any' }
|
||||
enforce_regular_tabs = false,
|
||||
always_show_bufferline = true,
|
||||
hover = {
|
||||
enabled = true,
|
||||
delay = 200,
|
||||
reveal = { 'close' },
|
||||
},
|
||||
sort_by = 'insert_after_current',
|
||||
},
|
||||
}
|
||||
end,
|
||||
}
|
||||
23
lua/custom/plugins/gruvbox.lua
Normal file
23
lua/custom/plugins/gruvbox.lua
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
return {
|
||||
'ellisonleao/gruvbox.nvim',
|
||||
priority = 1000,
|
||||
config = function()
|
||||
require('gruvbox').setup {
|
||||
contrast = 'medium',
|
||||
palette_overrides = {},
|
||||
overrides = {},
|
||||
dim_inactive = false,
|
||||
transparent_mode = false,
|
||||
italic = {
|
||||
strings = false,
|
||||
emphasis = false,
|
||||
comments = false,
|
||||
operators = false,
|
||||
folds = false,
|
||||
},
|
||||
bold = true,
|
||||
}
|
||||
vim.o.background = 'dark'
|
||||
vim.cmd.colorscheme 'gruvbox'
|
||||
end,
|
||||
}
|
||||
16
lua/custom/plugins/lazygit.lua
Normal file
16
lua/custom/plugins/lazygit.lua
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
return {
|
||||
'kdheepak/lazygit.nvim',
|
||||
dependencies = {
|
||||
'nvim-lua/plenary.nvim',
|
||||
},
|
||||
cmd = {
|
||||
'LazyGit',
|
||||
'LazyGitConfig',
|
||||
'LazyGitCurrentFile',
|
||||
'LazyGitFilter',
|
||||
'LazyGitFilterCurrentFile',
|
||||
},
|
||||
keys = {
|
||||
{ '<leader>gg', '<cmd>LazyGit<cr>', desc = 'LazyGit' },
|
||||
},
|
||||
}
|
||||
97
lua/custom/plugins/lualine.lua
Normal file
97
lua/custom/plugins/lualine.lua
Normal file
|
|
@ -0,0 +1,97 @@
|
|||
return {
|
||||
'nvim-lualine/lualine.nvim',
|
||||
dependencies = {
|
||||
'nvim-tree/nvim-web-devicons',
|
||||
},
|
||||
config = function()
|
||||
require('lualine').setup {
|
||||
options = {
|
||||
icons_enabled = true,
|
||||
theme = 'gruvbox', -- Matches global Gruvbox theme
|
||||
component_separators = { left = '', right = '' },
|
||||
section_separators = { left = '', right = '' },
|
||||
disabled_filetypes = {
|
||||
statusline = { 'NvimTree' },
|
||||
winbar = {},
|
||||
},
|
||||
ignore_focus = {},
|
||||
always_divide_middle = true,
|
||||
globalstatus = true,
|
||||
refresh = {
|
||||
statusline = 1000,
|
||||
tabline = 1000,
|
||||
winbar = 1000,
|
||||
},
|
||||
},
|
||||
sections = {
|
||||
-- Section A: Mode (like airline)
|
||||
lualine_a = { 'mode' },
|
||||
|
||||
-- Section B: Git branch and diff (like airline's VCS info)
|
||||
lualine_b = {
|
||||
'branch',
|
||||
'diff',
|
||||
},
|
||||
|
||||
-- Section C: Filename with readonly/modified status (like airline)
|
||||
lualine_c = {
|
||||
{
|
||||
'filename',
|
||||
file_status = true, -- displays file status (readonly, modified)
|
||||
path = 1, -- 0: filename, 1: relative path, 2: absolute path
|
||||
shorting_target = 40,
|
||||
symbols = {
|
||||
modified = '[+]',
|
||||
readonly = '[-]',
|
||||
unnamed = '[No Name]',
|
||||
},
|
||||
},
|
||||
'diagnostics', -- LSP diagnostics
|
||||
},
|
||||
|
||||
-- Section X: Filetype (like airline)
|
||||
lualine_x = {
|
||||
{
|
||||
'filetype',
|
||||
colored = true,
|
||||
icon_only = false,
|
||||
},
|
||||
},
|
||||
|
||||
-- Section Y: File encoding and format (like airline: utf-8[unix])
|
||||
lualine_y = {
|
||||
{
|
||||
'encoding',
|
||||
fmt = string.upper,
|
||||
},
|
||||
{
|
||||
'fileformat',
|
||||
symbols = {
|
||||
unix = 'LF',
|
||||
dos = 'CRLF',
|
||||
mac = 'CR',
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
-- Section Z: Position (like airline: 10% ☰ 10/100 ln : 20)
|
||||
lualine_z = {
|
||||
'progress',
|
||||
'location',
|
||||
},
|
||||
},
|
||||
inactive_sections = {
|
||||
lualine_a = {},
|
||||
lualine_b = {},
|
||||
lualine_c = { 'filename' },
|
||||
lualine_x = { 'location' },
|
||||
lualine_y = {},
|
||||
lualine_z = {},
|
||||
},
|
||||
tabline = {},
|
||||
winbar = {},
|
||||
inactive_winbar = {},
|
||||
extensions = { 'nvim-tree', 'lazy', 'mason', 'toggleterm' },
|
||||
}
|
||||
end,
|
||||
}
|
||||
20
lua/custom/plugins/nvim-tree.lua
Normal file
20
lua/custom/plugins/nvim-tree.lua
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
return {
|
||||
'nvim-tree/nvim-tree.lua',
|
||||
dependencies = {
|
||||
'nvim-tree/nvim-web-devicons',
|
||||
},
|
||||
config = function()
|
||||
require('nvim-tree').setup {
|
||||
sort_by = 'case_sensitive',
|
||||
view = {
|
||||
width = 30,
|
||||
},
|
||||
renderer = {
|
||||
group_empty = true,
|
||||
},
|
||||
filters = {
|
||||
dotfiles = false,
|
||||
},
|
||||
}
|
||||
end,
|
||||
}
|
||||
50
lua/custom/plugins/telescope.lua
Normal file
50
lua/custom/plugins/telescope.lua
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
return {
|
||||
'nvim-telescope/telescope.nvim',
|
||||
dependencies = {
|
||||
'nvim-lua/plenary.nvim',
|
||||
'nvim-telescope/telescope-fzf-native.nvim',
|
||||
'nvim-telescope/telescope-ui-select.nvim',
|
||||
'nvim-telescope/telescope-file-browser.nvim',
|
||||
},
|
||||
config = function()
|
||||
local telescope = require('telescope')
|
||||
local actions = require('telescope.actions')
|
||||
|
||||
telescope.setup {
|
||||
defaults = {
|
||||
prompt_prefix = '🔍 ',
|
||||
selection_caret = '➤ ',
|
||||
path_display = { 'truncate' },
|
||||
mappings = {
|
||||
i = {
|
||||
['<C-k>'] = actions.move_selection_previous,
|
||||
['<C-j>'] = actions.move_selection_next,
|
||||
['<C-q>'] = actions.send_selected_to_qflist + actions.open_qflist,
|
||||
},
|
||||
},
|
||||
},
|
||||
pickers = {
|
||||
find_files = {
|
||||
theme = 'dropdown',
|
||||
previewer = false,
|
||||
},
|
||||
buffers = {
|
||||
theme = 'dropdown',
|
||||
previewer = false,
|
||||
initial_mode = 'normal',
|
||||
},
|
||||
},
|
||||
extensions = {
|
||||
file_browser = {
|
||||
theme = 'ivy',
|
||||
hijack_netrw = true,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
-- Load extensions
|
||||
pcall(telescope.load_extension, 'fzf')
|
||||
pcall(telescope.load_extension, 'ui-select')
|
||||
pcall(telescope.load_extension, 'file_browser')
|
||||
end,
|
||||
}
|
||||
23
lua/custom/plugins/toggleterm.lua
Normal file
23
lua/custom/plugins/toggleterm.lua
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
return {
|
||||
'akinsho/toggleterm.nvim',
|
||||
version = '*',
|
||||
config = function()
|
||||
require('toggleterm').setup {
|
||||
size = 20,
|
||||
open_mapping = [[<c-\>]],
|
||||
hide_numbers = true,
|
||||
shade_terminals = true,
|
||||
shading_factor = 2,
|
||||
start_in_insert = true,
|
||||
insert_mappings = true,
|
||||
persist_size = true,
|
||||
direction = 'float',
|
||||
close_on_exit = true,
|
||||
shell = vim.o.shell,
|
||||
float_opts = {
|
||||
border = 'curved',
|
||||
winblend = 0,
|
||||
},
|
||||
}
|
||||
end,
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue