This commit is contained in:
sharmaharshitnone 2025-05-29 19:04:44 +05:30
parent 3338d39206
commit edc87670eb
16 changed files with 1096 additions and 13 deletions

9
disable_flow_control.sh Normal file
View file

@ -0,0 +1,9 @@
# Disable flow control (Ctrl+S, Ctrl+Q) in the terminal
# This allows Ctrl+S to be used for saving in Neovim
stty -ixon
# Optional: You can also add this line to make Ctrl+S work in programs that use readline
# (like the bash/zsh command line itself)
if [ -t 0 ]; then
bind -r '\C-s' 2>/dev/null || true
fi

View file

@ -102,7 +102,20 @@ vim.g.have_nerd_font = false
vim.o.number = true vim.o.number = true
-- You can also add relative line numbers, to help with jumping. -- You can also add relative line numbers, to help with jumping.
-- Experiment for yourself to see if you like it! -- Experiment for yourself to see if you like it!
-- vim.o.relativenumber = true
vim.o.relativenumber = true
vim.keymap.set('n', '<A-s>', ':w<CR>', { desc = 'Save' })
-- Add keymaps for vertical and horizontal splits
vim.keymap.set('n', '<A-v>', ':vsplit<CR>', { desc = 'Split vertically' })
vim.keymap.set('n', '<A-h>', ':split<CR>', { desc = 'Split horizontally' })
-- Add Alt + f as open foles
vim.keymap.set('n', '<A-f>', ':Ex<CR>', { desc = 'Open file explorer' })
-- Add alt + q to quit
vim.keymap.set('n', '<A-q>', '<cmd>q<cr>', { desc = 'Quit' })
-- Enable mouse mode, can be useful for resizing splits for example! -- Enable mouse mode, can be useful for resizing splits for example!
vim.o.mouse = 'a' vim.o.mouse = 'a'
@ -171,7 +184,9 @@ vim.o.confirm = true
-- Clear highlights on search when pressing <Esc> in normal mode -- Clear highlights on search when pressing <Esc> in normal mode
-- See `:help hlsearch` -- See `:help hlsearch`
vim.keymap.set('n', '<Esc>', '<cmd>nohlsearch<CR>') -- vim.keymap.set('n', '<Esc>', '<cmd>nohlsearch<CR>')
-- Replaced with a better approach that doesn't override Escape's normal function
vim.keymap.set('n', '<leader>/', '<cmd>nohlsearch<CR>', { desc = 'Clear search highlights' })
-- Diagnostic keymaps -- Diagnostic keymaps
vim.keymap.set('n', '<leader>q', vim.diagnostic.setloclist, { desc = 'Open diagnostic [Q]uickfix list' }) vim.keymap.set('n', '<leader>q', vim.diagnostic.setloclist, { desc = 'Open diagnostic [Q]uickfix list' })
@ -182,7 +197,7 @@ vim.keymap.set('n', '<leader>q', vim.diagnostic.setloclist, { desc = 'Open diagn
-- --
-- NOTE: This won't work in all terminal emulators/tmux/etc. Try your own mapping -- NOTE: This won't work in all terminal emulators/tmux/etc. Try your own mapping
-- or just use <C-\><C-n> to exit terminal mode -- or just use <C-\><C-n> to exit terminal mode
vim.keymap.set('t', '<Esc><Esc>', '<C-\\><C-n>', { desc = 'Exit terminal mode' }) vim.keymap.set('t', '<Esc>', '<C-\\><C-n>', { desc = 'Exit terminal mode' })
-- TIP: Disable arrow keys in normal mode -- TIP: Disable arrow keys in normal mode
-- vim.keymap.set('n', '<left>', '<cmd>echo "Use h to move!!"<CR>') -- vim.keymap.set('n', '<left>', '<cmd>echo "Use h to move!!"<CR>')
@ -973,18 +988,18 @@ require('lazy').setup({
-- Here are some example plugins that I've included in the Kickstart repository. -- Here are some example plugins that I've included in the Kickstart repository.
-- Uncomment any of the lines below to enable them (you will need to restart nvim). -- Uncomment any of the lines below to enable them (you will need to restart nvim).
-- --
-- require 'kickstart.plugins.debug', require 'kickstart.plugins.debug',
-- require 'kickstart.plugins.indent_line', require 'kickstart.plugins.indent_line',
-- require 'kickstart.plugins.lint', require 'kickstart.plugins.lint',
-- require 'kickstart.plugins.autopairs', require 'kickstart.plugins.autopairs',
-- require 'kickstart.plugins.neo-tree', require 'kickstart.plugins.neo-tree',
-- require 'kickstart.plugins.gitsigns', -- adds gitsigns recommend keymaps require 'kickstart.plugins.gitsigns', -- adds gitsigns recommend keymaps
-- NOTE: The import below can automatically add your own plugins, configuration, etc from `lua/custom/plugins/*.lua` -- NOTE: The import below can automatically add your own plugins, configuration, etc from `lua/custom/plugins/*.lua`
-- This is the easiest way to modularize your config. -- This is the easiest way to modularize your config.
-- --
-- Uncomment the following line and add your plugins to `lua/custom/plugins/*.lua` to get going. -- Uncomment the following line and add your plugins to `lua/custom/plugins/*.lua` to get going.
-- { import = 'custom.plugins' }, { import = 'custom.plugins' },
-- --
-- For additional information with loading, sourcing and examples see `:help lazy.nvim-🔌-plugin-spec` -- For additional information with loading, sourcing and examples see `:help lazy.nvim-🔌-plugin-spec`
-- Or use telescope! -- Or use telescope!
@ -1014,3 +1029,19 @@ require('lazy').setup({
-- The line beneath this is called `modeline`. See `:help modeline` -- The line beneath this is called `modeline`. See `:help modeline`
-- vim: ts=2 sts=2 sw=2 et -- vim: ts=2 sts=2 sw=2 et
--
-- This changes the current dir of Neovim to the current buffer's directory
vim.api.nvim_create_autocmd('BufEnter', {
pattern = '*',
callback = function()
-- Check if the buffer has a file name and is not a temporary/special buffer
local filePath = vim.api.nvim_buf_get_name(0) -- 0 for current buffer
if filePath and filePath ~= '' and vim.fn.filereadable(filePath) == 1 then
local dir = vim.fn.fnamemodify(filePath, ':p:h') -- :p for full path, :h for head (directory)
if dir and dir ~= '' and vim.fn.isdirectory(dir) == 1 then
vim.cmd('silent! lcd ' .. vim.fn.escape(dir, ' '))
end
end
end,
desc = "Change local CWD to buffer's directory on BufEnter",
})

View file

@ -0,0 +1,93 @@
-- Code Runner configuration
-- https://github.com/CRAG666/code_runner.nvim
return {
"CRAG666/code_runner.nvim",
dependencies = {
"nvim-lua/plenary.nvim",
},
-- Lazy load on commands
cmd = {
"RunCode", "RunFile", "RunProject",
"RunClose", "CRFiletype", "CRProjects"
},
config = function()
require("code_runner").setup({
-- Choose default mode (valid term, tab, float, toggle, buf)
mode = "float",
-- Focus on runner window
focus = true,
-- Start runner when run key is pressed
startinsert = true,
-- Close terminal window after process exit
term = {
position = "bot",
size = 12,
},
float = {
-- Window border and appearance
border = "rounded",
height = 0.7,
width = 0.7,
x = 0.5,
y = 0.5,
border_hl = "FloatBorder",
float_hl = "Normal",
close_on_exit = true,
},
-- Language-specific commands (optimized order)
filetype = {
python = "python3 -u $fileName",
javascript = "node $fileName",
typescript = "ts-node $fileName",
rust = "cargo run",
go = "go run $fileName",
cpp = "g++ $fileName -o $fileNameWithoutExt && ./$fileNameWithoutExt",
c = "gcc $fileName -o $fileNameWithoutExt && ./$fileNameWithoutExt",
java = "cd $dir && javac $fileName && java $fileNameWithoutExt",
sh = "bash $fileName",
lua = "lua $fileName",
php = "php $fileName",
ruby = "ruby $fileName",
perl = "perl $fileName",
r = "Rscript $fileName",
dart = "dart $fileName",
julia = "julia $fileName",
kotlin = "kotlinc $fileName -include-runtime -d $fileNameWithoutExt.jar && java -jar $fileNameWithoutExt.jar",
swift = "swift $fileName",
haskell = "runhaskell $fileName",
lisp = "clisp $fileName",
elixir = "elixir $fileName",
matlab = "matlab -nodisplay -nosplash -nodesktop -r \"run('$fileName');exit;\"",
},
-- Project-specific configuration (optimized)
project = {
name = ".projectile",
-- Patterns to identify project type (ordered by frequency)
patterns = {
["package.json"] = { command = "npm start", name = "npm project" },
["Cargo.toml"] = { command = "cargo run", name = "cargo project" },
["go.mod"] = { command = "go run .", name = "go project" },
["Makefile"] = { command = "make", name = "make project" },
["pom.xml"] = { command = "mvn compile exec:java", name = "maven project" },
},
},
})
end,
-- Define keymaps directly in the keys table for better compatibility
keys = {
{ "<leader>r", ":RunCode<CR>", desc = "Run code" },
{ "<leader>rf", ":RunFile<CR>", desc = "Run current file" },
{ "<leader>rp", ":RunProject<CR>", desc = "Run project" },
{ "<leader>rc", ":RunClose<CR>", desc = "Close runner" },
{ "<leader>crf", ":CRFiletype<CR>", desc = "Run custom command for filetype" },
{ "<leader>crp", ":CRProjects<CR>", desc = "Run custom command for project" },
}
}

View file

View file

@ -0,0 +1,190 @@
-- filepath: /home/kali/.config/nvim/lua/custom/plugins/copilot-chat.lua
-- GitHub Copilot Chat configuration
-- An advanced setup for Copilot Chat in Neovim
-- https://github.com/CopilotC-Nvim/CopilotChat.nvim
-- Declare vim as global
local vim = vim
return {
"CopilotC-Nvim/CopilotChat.nvim",
branch = "main", -- Ensure we're using the stable main branch
dependencies = {
-- Dependencies for CopilotChat
{ "github/copilot.vim" }, -- The base Copilot plugin
{ "nvim-lua/plenary.nvim" }, -- Common Lua functions
{ "nvim-telescope/telescope.nvim" }, -- For nice UI integration
{ "nvim-tree/nvim-web-devicons" }, -- Icons for enhanced UI
},
-- Load after GitHub Copilot and when a file is opened
event = { "VeryLazy" },
config = function()
local chat = require("CopilotChat")
local select = require("CopilotChat.select")
-- Configure the plugin with advanced settings
chat.setup({
-- Show Copilot Chat window border
window = {
border = "rounded", -- Make the window look nice
width = 80, -- Default width
height = 20, -- Default height
title = {
name = "Copilot Chat", -- Custom title
alignment = "center", -- Center the title
},
},
-- File context features
context = {
-- Include 5 lines above and below the cursor for context
cursor_context = 5,
-- Include the entire selection when using visual mode
selection_context = true,
-- Show context-aware commit history
git_context = true,
},
-- Enable debug (set to true only when troubleshooting)
debug = false,
-- Enable syntax highlighting in response
syntax_highlighting = true,
-- Enable auto-sizing of response window
auto_size = true,
-- Define prompts that can be used in commands
prompts = {
-- Default prompts
Explain = {
prompt = "Explain how the following code works in detail:\n```$filetype\n$selection\n```",
},
FixCode = {
prompt = "Fix the following code. Provide the corrected version and explanations for the fixes:\n```$filetype\n$selection\n```",
},
Optimize = {
prompt = "Optimize the following code. Provide the optimized version and explain the improvements:\n```$filetype\n$selection\n```",
},
-- Advanced prompts
Documentation = {
prompt = "Generate comprehensive documentation for this code:\n```$filetype\n$selection\n```\nInclude descriptions of parameters, return values, exceptions, and provide usage examples.",
},
BestPractices = {
prompt = "Review this code for best practices and suggest improvements:\n```$filetype\n$selection\n```",
},
Tests = {
prompt = "Generate unit tests for the following code:\n```$filetype\n$selection\n```",
},
-- Context-aware code generation
Implement = {
prompt = "Implement the following functionality: $input\nMake it work with the following context:\n```$filetype\n$selection\n```",
strategy = "quick_fix", -- Use the quick fix strategy for implementation
},
RefactorToPattern = {
prompt = "Refactor the following code to use the $input design pattern. Explain the benefits of this refactoring:\n```$filetype\n$selection\n```",
},
},
})
-- Add custom keymaps for the chat buffer
vim.api.nvim_create_autocmd("FileType", {
pattern = "copilot-chat",
callback = function()
local buf = vim.api.nvim_get_current_buf()
-- Close window with 'q'
vim.keymap.set("n", "q", function()
vim.cmd("close")
end, { buffer = buf, silent = true })
-- Reset chat with Ctrl+L
vim.keymap.set("n", "<C-l>", function()
chat.reset()
end, { buffer = buf, silent = true })
-- -- Submit prompt with Enter in insert mode
-- vim.keymap.set("i", "<CR>", function()
-- -- require("CopilotChat").submit_prompt()
-- chat.submit_prompt()
-- end, { buffer = buf, silent = true })
-- -- Submit prompt with Enter in normal mode
-- vim.keymap.set("n", "<CR>", function()
-- require("CopilotChat").submit_prompt()
-- end, { buffer = buf, silent = true })
-- Show diff with Ctrl+D
vim.keymap.set("n", "<C-d>", function()
require("CopilotChat").show_diff()
end, { buffer = buf, silent = true })
-- Accept diff with Ctrl+Y
vim.keymap.set("n", "<C-y>", function()
require("CopilotChat").accept_diff()
end, { buffer = buf, silent = true })
end
})
-- Set up key bindings
vim.keymap.set("n", "<leader>cc", "<cmd>CopilotChat<CR>", { desc = "Copilot Chat" })
vim.keymap.set("n", "<leader>ce", "<cmd>CopilotChatExplain<CR>", { desc = "Explain Code" })
vim.keymap.set("n", "<leader>cf", "<cmd>CopilotChatFixCode<CR>", { desc = "Fix Code" })
vim.keymap.set("n", "<leader>co", "<cmd>CopilotChatOptimize<CR>", { desc = "Optimize Code" })
vim.keymap.set("n", "<leader>cd", "<cmd>CopilotChatDocumentation<CR>", { desc = "Generate Documentation" })
vim.keymap.set("n", "<leader>ct", "<cmd>CopilotChatTests<CR>", { desc = "Generate Tests" })
vim.keymap.set("n", "<leader>cb", "<cmd>CopilotChatBestPractices<CR>", { desc = "Check Best Practices" })
-- Visual mode mappings for selected code
vim.keymap.set("v", "<leader>ce", ":CopilotChatExplain<CR>", { desc = "Explain Selected Code" })
vim.keymap.set("v", "<leader>cf", ":CopilotChatFixCode<CR>", { desc = "Fix Selected Code" })
vim.keymap.set("v", "<leader>co", ":CopilotChatOptimize<CR>", { desc = "Optimize Selected Code" })
vim.keymap.set("v", "<leader>cd", ":CopilotChatDocumentation<CR>", { desc = "Document Selected Code" })
vim.keymap.set("v", "<leader>ct", ":CopilotChatTests<CR>", { desc = "Generate Tests for Selected Code" })
-- Create a custom input command with implementation suggestions
vim.keymap.set("v", "<leader>ci", function()
vim.ui.input({ prompt = "What would you like to implement? " }, function(input)
if input then
select.selection()
chat.ask("Implement: " .. input)
end
end)
end, { desc = "Implement Functionality" })
-- Add quick access to buffer context
vim.keymap.set("n", "<leader>cb", function()
chat.ask("What does this code do? Consider the full context of the file.", {
selection = select.buffer,
})
end, { desc = "Explain Buffer" })
-- Refactor the current selection to use a specific design pattern
vim.keymap.set("v", "<leader>cr", function()
vim.ui.input({ prompt = "Which design pattern to refactor to? " }, function(input)
if input then
select.selection()
chat.ask("RefactorToPattern: " .. input)
end
end)
end, { desc = "Refactor to Design Pattern" })
-- Toggle inline chat for quick questions about the current line
vim.keymap.set("n", "<leader>cl", function()
select.line()
chat.toggle()
end, { desc = "Chat About Current Line" })
-- Open Copilot Chat with a custom prompt
vim.keymap.set("n", "<leader>cp", function()
vim.ui.input({ prompt = "Ask Copilot: " }, function(input)
if input then
chat.ask(input)
end
end)
end, { desc = "Ask Copilot" })
end,
}

View file

@ -0,0 +1,32 @@
-- GitHub Copilot configuration
-- https://github.com/github/copilot.vim
return {
"github/copilot.vim",
event = "InsertEnter",
config = function()
-- Disable default mappings
vim.g.copilot_no_maps = true
-- Key mappings
vim.keymap.set('i', '<C-j>', 'copilot#Accept("<CR>")', {
expr = true,
replace_keycodes = false,
silent = true,
})
-- Additional keymaps for Copilot
vim.keymap.set('i', '<C-l>', '<Plug>(copilot-accept-word)', { silent = true })
vim.keymap.set('i', '<C-]>', '<Plug>(copilot-next)', { silent = true })
-- Changed from <C-[> to <M-[> (Alt+[) to avoid conflicting with Escape
vim.keymap.set('i', '<M-[>', '<Plug>(copilot-previous)', { silent = true })
vim.keymap.set('i', '<C-\\>', '<Plug>(copilot-dismiss)', { silent = true })
-- Additional settings
vim.g.copilot_filetypes = {
["*"] = true,
["markdown"] = true,
["help"] = false,
}
end,
}

View file

@ -0,0 +1,87 @@
-- Harpoon configuration
-- https://github.com/ThePrimeagen/harpoon
-- Fast file navigation to frequently used files
return {
"ThePrimeagen/harpoon",
branch = "harpoon2", -- Using harpoon2 for the latest version
dependencies = { "nvim-lua/plenary.nvim" },
event = "VeryLazy",
config = function()
local harpoon = require("harpoon")
-- Set up harpoon with enhanced settings
harpoon:setup({
settings = {
save_on_toggle = true,
sync_on_ui_close = true,
}
})
end,
keys = {
{
"<leader>ha",
function()
require("harpoon"):list():add()
end,
desc = "Harpoon add file"
},
{
"<leader>hm",
function()
local harpoon = require("harpoon")
harpoon.ui:toggle_quick_menu(harpoon:list())
end,
desc = "Harpoon menu"
},
{
"<leader>h1",
function()
require("harpoon"):list():select(1)
end,
desc = "Harpoon file 1"
},
{
"<leader>h2",
function()
require("harpoon"):list():select(2)
end,
desc = "Harpoon file 2"
},
{
"<leader>h3",
function()
require("harpoon"):list():select(3)
end,
desc = "Harpoon file 3"
},
{
"<leader>h4",
function()
require("harpoon"):list():select(4)
end,
desc = "Harpoon file 4"
},
{
"<leader>h5",
function()
require("harpoon"):list():select(5)
end,
desc = "Harpoon file 5"
},
{
"<leader>hn",
function()
require("harpoon"):list():next()
end,
desc = "Harpoon next file"
},
{
"<leader>hp",
function()
require("harpoon"):list():prev()
end,
desc = "Harpoon previous file"
},
}
}

View file

@ -2,4 +2,14 @@
-- I promise not to create any merge conflicts in this directory :) -- I promise not to create any merge conflicts in this directory :)
-- --
-- See the kickstart.nvim README for more information -- See the kickstart.nvim README for more information
return {} return {
-- Load all plugin files in the custom/plugins directory
{ import = "custom.plugins.copilot" },
{ import = "custom.plugins.copilot-chat" },
{ import = "custom.plugins.tab_keymaps" },
{ import = "custom.plugins.code_runner" },
{ import = "custom.plugins.sniprun" },
{ import = "custom.plugins.harpoon" },
{ import = "custom.plugins.lazygit" },
{ import = "custom.plugins.toggleterm" },
}

View file

@ -0,0 +1,36 @@
-- LazyGit integration for Neovim
-- https://github.com/kdheepak/lazygit.nvim
return {
{
"kdheepak/lazygit.nvim",
-- Lazy load on command
cmd = {
"LazyGit",
"LazyGitConfig",
"LazyGitCurrentFile",
"LazyGitFilter",
"LazyGitFilterCurrentFile",
},
-- Lazy load on keymaps
keys = {
{ "<leader>gg", "<cmd>LazyGit<CR>", desc = "Open LazyGit" },
{ "<leader>gc", "<cmd>LazyGitConfig<CR>", desc = "Open LazyGit Config" },
{ "<leader>gf", "<cmd>LazyGitCurrentFile<CR>", desc = "LazyGit Current File" },
},
-- Dependencies
dependencies = {
"nvim-lua/plenary.nvim",
},
-- Plugin configuration
config = function()
-- Configure floating window border
require("lazygit").setup({
floating_window_winblend = 0, -- transparency of floating window
floating_window_scaling_factor = 0.9, -- scaling factor for floating window
floating_window_border_chars = { '', '', '', '', '', '', '', '' }, -- customize floating window border chars
lazygit_floating_window_use_plenary = true, -- use plenary.nvim to manage floating window if available
})
end,
}
}

View file

@ -0,0 +1,246 @@
# LazyGit Guide: A Powerful Git Interface for Your Terminal
![LazyGit Banner](https://raw.githubusercontent.com/jesseduffield/lazygit/assets/logo.png)
## What is LazyGit?
LazyGit is a simple terminal UI for git commands, written in Go with the gocui library. It's designed to make Git operations more intuitive and faster through a clean, keyboard-driven interface that allows you to perform complex git operations with just a few keystrokes.
## Benefits of Using LazyGit
1. **Improved Productivity**: Perform common Git operations in seconds
2. **Intuitive Interface**: Easy-to-navigate TUI (Terminal User Interface)
3. **Visual Representation**: See staged/unstaged changes, branches, commits, and stashes at a glance
4. **Keyboard-Driven**: Everything can be done with keyboard shortcuts
5. **Seamless Integration with Neovim**: Use LazyGit directly from your editor
## Installation
### System Installation
For LazyGit to work in Neovim, you need to install it on your system first:
**Debian/Ubuntu-based systems (like Kali Linux)**:
```bash
LAZYGIT_VERSION=$(curl -s "https://api.github.com/repos/jesseduffield/lazygit/releases/latest" | grep -Po '"tag_name": "v\K[^"]*')
curl -Lo lazygit.tar.gz "https://github.com/jesseduffield/lazygit/releases/latest/download/lazygit_${LAZYGIT_VERSION}_Linux_x86_64.tar.gz"
tar xf lazygit.tar.gz lazygit
sudo install lazygit /usr/local/bin
rm lazygit lazygit.tar.gz
```
**Using your package manager**:
```bash
# On Arch Linux
sudo pacman -S lazygit
# On macOS with Homebrew
brew install lazygit
# On Windows with Scoop
scoop install lazygit
```
### Neovim Plugin Installation
You've already added the plugin to your Neovim configuration. It's registered in:
- `/home/kali/.config/nvim/lua/custom/plugins/lazygit.lua`
- Updated in `/home/kali/.config/nvim/lua/custom/plugins/init.lua`
## Using LazyGit in Neovim
### Basic Commands
| Command | Description | Neovim Keymap |
| --------------------------- | ---------------------------------- | ------------- |
| `:LazyGit` | Open LazyGit in a floating window | `<leader>gg` |
| `:LazyGitConfig` | Open LazyGit config | `<leader>gc` |
| `:LazyGitCurrentFile` | Open LazyGit with current file | `<leader>gf` |
| `:LazyGitFilter` | Open LazyGit with commit filtering | - |
| `:LazyGitFilterCurrentFile` | Filter commits for current file | - |
### LazyGit Interface Overview
When you open LazyGit, you'll see a split interface with multiple panels:
1. **Status Panel** (top left): Shows git status
2. **Files Panel** (middle left): Shows changed files
3. **Branches Panel** (bottom left): Shows branches
4. **Commits Panel** (right): Shows commit history
5. **Stash Panel** (may appear when needed): Shows stashed changes
### Essential Keyboard Shortcuts
#### Navigation
| Key | Action |
| --------- | ----------------------- |
| `Tab` | Switch between panels |
| `h/j/k/l` | Navigate within panels |
| `?` | Show help/keybindings |
| `q` | Close current view/quit |
#### Working with Files
| Key | Action |
| ------- | ------------------------------------------------ |
| `Space` | Toggle staged/unstaged for file (in files panel) |
| `a` | Stage all changes |
| `d` | View diff for file |
| `e` | Edit file |
| `o` | Open file |
| `c` | Commit changes |
| `A` | Amend last commit |
| `C` | Commit changes with editor |
#### Working with Branches
| Key | Action |
| ------- | ----------------------------------------- |
| `n` | Create new branch |
| `Space` | Checkout branch (in branches panel) |
| `M` | Merge selected branch into current branch |
| `P` | Pull from remote |
| `p` | Push to remote |
| `F` | Force push |
#### Working with Commits
| Key | Action |
| --- | --------------------- |
| `s` | Squash down/fixup |
| `r` | Reword commit message |
| `f` | Fixup commit |
| `d` | Delete commit |
| `g` | Reset to commit |
| `t` | Tag commit |
#### Stashing
| Key | Action |
| ------- | ----------------------------- |
| `s` | Create stash (in files panel) |
| `Space` | Apply stash (in stash panel) |
| `g` | Pop stash |
| `d` | Drop stash |
## Advanced Features
### Custom Commands
LazyGit allows you to define custom commands in your config file. For example:
```yaml
customCommands:
- key: "C"
command: "git cz"
context: "files"
description: "commit with commitizen"
- key: "T"
command: "tig {{.SelectedFile.Name}}"
context: "files"
description: "tig selected file"
```
### Bisect Mode
LazyGit supports git bisect to find the commit that introduced a bug:
1. Press `b` to enter bisect mode
2. Mark commits as good/bad using `g`/`b` respectively
3. LazyGit will help you narrow down the problematic commit
### Interactive Rebase
LazyGit makes interactive rebasing visual and intuitive:
1. Navigate to a commit you want to rebase from
2. Press `i` to start an interactive rebase
3. Use the keyboard to reorder/squash/edit commits
4. Press `esc` or `q` to exit the rebase view
## Integrating with Your Workflow
### Working with Remote Repositories
- Use `P` to pull from upstream
- Use `p` to push to origin
- Use `F` to force push (with lease)
### Working with Submodules
- Navigate to the submodule panel
- Use `Enter` to open/interact with a submodule
### Working with Merge Conflicts
When you encounter merge conflicts:
1. The files with conflicts will be highlighted
2. Select the file to see the conflict
3. Press `e` to edit and resolve
4. Stage the resolved files with `Space`
5. Complete the merge with `m`
## Customizing LazyGit
### Configuration File
LazyGit can be configured via `~/.config/lazygit/config.yml`.
Sample configuration:
```yaml
gui:
theme:
activeBorderColor:
- green
- bold
inactiveBorderColor:
- white
optionsTextColor:
- blue
showCommandLog: true
showRandomTip: true
showFileTree: true
showBottomLine: true
git:
paging:
colorArg: always
pager: delta --dark --paging=never
```
## Troubleshooting Common Issues
### LazyGit Is Slow
- Update to the latest version
- Consider disabling file watching: `git config --global core.fsmonitor false`
- Limit the number of commits shown: `git config --global lazygit.commitLimit 100`
### Merge Conflicts Not Resolving
- Make sure your merge tool is properly configured
- Try resolving with a different editor: `git config --global merge.tool vimdiff`
### Visual Issues
- Check your terminal supports true color
- Try a different theme in your configuration
- Ensure your terminal font has the necessary glyphs
## Conclusion
LazyGit is an incredibly powerful tool that can significantly improve your Git workflow. By integrating it with Neovim, you've created a seamless development environment where complex Git operations are just a few keystrokes away.
Start using LazyGit today to experience a faster, more intuitive way to work with Git!
## Additional Resources
- [LazyGit GitHub Repository](https://github.com/jesseduffield/lazygit)
- [LazyGit Documentation](https://github.com/jesseduffield/lazygit/tree/master/docs)
- [Video Tutorials](https://www.youtube.com/results?search_query=lazygit+tutorial)

View file

@ -0,0 +1,45 @@
-- Sniprun plugin configuration
-- https://github.com/michaelb/sniprun
return {
"michaelb/sniprun",
branch = "master",
build = "sh install.sh",
-- Lazy load on keys
config = function()
require("sniprun").setup({
-- Display the output more efficiently
display = {
"Classic", -- Display stdout in the command line
"VirtualTextOk", -- Display successful results as virtual text
"FloatingWindow" -- Display results in a floating window
},
-- Optimize display options
display_options = {
terminal_width = 45,
notification_duration = 5 -- in seconds
},
-- Configure specific languages (focus on the most commonly used)
repl_enable = {
"Python3_original",
"JS_TS_deno",
"Lua_nvim"
},
-- Python interpreter configuration with optimized path
interpreter_options = {
Python3_original = {
command = "/home/kali/.local/share/pipx/venvs/klepto/bin/python",
}
},
})
end,
-- Define keymaps directly in the keys table
keys = {
{ "<leader>Sr", "<Plug>SnipRun", mode = "n", desc = "Run code snippet" },
{ "<leader>Sr", "<Plug>SnipRun", mode = "v", desc = "Run selected code" },
{ "<leader>Sc", "<Plug>SnipClose", desc = "Close sniprun output" },
{ "<leader>SR", "<Plug>SnipReset", desc = "Reset sniprun" },
{ "<leader>Si", "<Plug>SnipInfo", desc = "Sniprun info" },
{ "<F5>", "<Plug>SnipRunOperator", desc = "Sniprun operator mode" },
}
}

View file

@ -0,0 +1,21 @@
-- Tab management keymaps
-- These provide VS Code-like tab navigation and management
-- Create a new empty tab
vim.keymap.set('n', '<leader>tn', ':tabnew<CR>', { desc = 'New tab' })
-- Create a new tab and open Telescope file finder
vim.keymap.set('n', '<leader>to', ':tabnew<CR>:Telescope find_files<CR>', { desc = 'New tab with file' })
-- Close the current tab
vim.keymap.set('n', '<leader>tc', ':tabclose<CR>', { desc = 'Close tab' })
-- Navigate to next tab (similar to VS Code)
vim.keymap.set('n', '<C-PgDn>', 'gt', { desc = 'Next tab' })
-- Navigate to previous tab (similar to VS Code)
vim.keymap.set('n', '<C-PgUp>', 'gT', { desc = 'Previous tab' })
-- Add this keymap group to Which-key if you're using it
-- (the plugin will automatically pick this up on next restart)
return {}

View file

@ -0,0 +1,108 @@
-- ToggleTerm configuration
-- https://github.com/akinsho/toggleterm.nvim
return {
'akinsho/toggleterm.nvim',
version = "*", -- use the latest stable version
event = "VeryLazy", -- lazy load on VeryLazy event
opts = {
-- Configuration options
size = function(term)
if term.direction == "horizontal" then
return 15 -- Set height for horizontal terminal
elseif term.direction == "vertical" then
return vim.o.columns * 0.4 -- 40% of screen width
end
end,
open_mapping = [[<C-\>]], -- Ctrl+\ to toggle terminal
hide_numbers = true, -- hide line numbers
shade_filetypes = {},
shade_terminals = true, -- apply shade to terminal
shading_factor = 2, -- degree of shading (1-3)
start_in_insert = true, -- start terminal in insert mode
insert_mappings = true, -- apply mappings in insert mode
persist_size = true,
direction = "float", -- 'vertical' | 'horizontal' | 'tab' | 'float'
close_on_exit = true, -- close terminal window when process exits
shell = vim.o.shell, -- use default shell
-- Float window settings
float_opts = {
border = "curved", -- 'single' | 'double' | 'shadow' | 'curved'
winblend = 0, -- transparency (0-100)
highlights = {
border = "Normal",
background = "Normal",
}
}
},
config = function(_, opts)
-- Initialize the plugin with provided options
require("toggleterm").setup(opts)
-- Terminal keymaps
function _G.set_terminal_keymaps()
local keymap_opts = {buffer = 0, noremap = true, silent = true}
-- Escape terminal mode with Esc key
vim.keymap.set('t', '<Esc>', [[<C-\><C-n>]], keymap_opts)
-- Terminal navigation
vim.keymap.set('t', '<C-h>', [[<C-\><C-n><C-W>h]], keymap_opts)
vim.keymap.set('t', '<C-j>', [[<C-\><C-n><C-W>j]], keymap_opts)
vim.keymap.set('t', '<C-k>', [[<C-\><C-n><C-W>k]], keymap_opts)
vim.keymap.set('t', '<C-l>', [[<C-\><C-n><C-W>l]], keymap_opts)
-- Paste in terminal mode
vim.keymap.set('t', '<C-v>', [[<C-\><C-n>pi]], keymap_opts)
end
-- Auto-command to apply terminal keymaps when terminal opens
vim.cmd('autocmd! TermOpen term://* lua set_terminal_keymaps()')
-- Create additional keymaps for different terminal layouts
vim.keymap.set('n', '<leader>tf', ':ToggleTerm direction=float<CR>', {noremap = true, desc = "Toggle floating terminal"})
vim.keymap.set('n', '<leader>th', ':ToggleTerm direction=horizontal<CR>', {noremap = true, desc = "Toggle horizontal terminal"})
vim.keymap.set('n', '<leader>tv', ':ToggleTerm direction=vertical<CR>', {noremap = true, desc = "Toggle vertical terminal"})
vim.keymap.set('n', '<leader>tt', ':ToggleTerm direction=tab<CR>', {noremap = true, desc = "Toggle tab terminal"})
-- Numbered terminals
vim.keymap.set('n', '<leader>t1', ':1ToggleTerm<CR>', {noremap = true, desc = "Toggle terminal #1"})
vim.keymap.set('n', '<leader>t2', ':2ToggleTerm<CR>', {noremap = true, desc = "Toggle terminal #2"})
vim.keymap.set('n', '<leader>t3', ':3ToggleTerm<CR>', {noremap = true, desc = "Toggle terminal #3"})
-- Creating a lazygit terminal
local Terminal = require('toggleterm.terminal').Terminal
local lazygit = Terminal:new({
cmd = "lazygit",
dir = "git_dir",
direction = "float",
float_opts = {
border = "curved",
},
-- function to run on opening the terminal
on_open = function(term)
vim.cmd("startinsert!")
-- ESC twice to exit lazygit
vim.api.nvim_buf_set_keymap(term.bufnr, "n", "q", "<cmd>close<CR>", {noremap = true, silent = true})
end,
})
-- Function to toggle lazygit terminal
function _LAZYGIT_TOGGLE()
lazygit:toggle()
end
-- Map lazygit toggle function to a key
vim.keymap.set('n', '<leader>lg', '<cmd>lua _LAZYGIT_TOGGLE()<CR>', {noremap = true, desc = "Toggle LazyGit"})
-- Example for creating a custom Python REPL terminal
local python = Terminal:new({
cmd = "python",
direction = "horizontal",
close_on_exit = false,
})
function _PYTHON_TOGGLE()
python:toggle()
end
vim.keymap.set('n', '<leader>py', '<cmd>lua _PYTHON_TOGGLE()<CR>', {noremap = true, desc = "Toggle Python REPL"})
end,
}

View file

@ -0,0 +1,174 @@
# ToggleTerm.nvim Guide: A Flexible Terminal Integration for Neovim
ToggleTerm is a highly customizable plugin for Neovim that provides enhanced terminal functionality, making it easy to toggle and use multiple terminals directly within your Neovim environment.
## Features
- Multiple terminal instances with persistent state
- Different terminal layouts (floating, horizontal split, vertical split, tab)
- Custom terminal commands and automation
- Terminal toggling with a single keystroke
- Seamless integration with existing Neovim workflow
- Support for terminal-specific keymaps
- Custom commands for specific applications (like lazygit)
## Quick Start Guide
### Basic Usage
1. **Toggle Default Terminal**: Press `<Ctrl-\>` to show/hide the terminal
2. **Exit Terminal Mode**: Press `<Esc>` to switch from terminal mode to normal mode
3. **Navigate Away**: Use regular Neovim window commands (`<Ctrl-w>h/j/k/l`) when in normal mode
### Terminal Layouts
Press these keys in normal mode:
- `<leader>tf` - Toggle floating terminal (appears in the center of your screen)
- `<leader>th` - Toggle horizontal terminal (split at bottom)
- `<leader>tv` - Toggle vertical terminal (split on right)
- `<leader>tt` - Toggle terminal in new tab
### Multiple Terminal Instances
- `<leader>t1` - Toggle terminal #1
- `<leader>t2` - Toggle terminal #2
- `<leader>t3` - Toggle terminal #3
You can have multiple terminal instances running different commands simultaneously.
### Special Terminal Integrations
- `<leader>lg` - Toggle LazyGit in a floating window
- `<leader>py` - Toggle Python REPL in a horizontal split
## Terminal Navigation and Control
When in a terminal buffer:
| Keybinding | Action |
| ---------- | ---------------------------------------- |
| `<Esc>` | Exit terminal mode and enter normal mode |
| `<C-h>` | Move focus to the window on the left |
| `<C-j>` | Move focus to the window below |
| `<C-k>` | Move focus to the window above |
| `<C-l>` | Move focus to the window on the right |
| `<C-v>` | Paste from clipboard in terminal mode |
## Advanced Usage
### Creating Custom Terminal Commands
You can define custom terminals for specific commands in the configuration file. Here's an example:
```lua
-- Creating a custom terminal for a Node.js REPL
local node = Terminal:new({
cmd = "node",
direction = "horizontal",
close_on_exit = false,
})
function _NODE_TOGGLE()
node:toggle()
end
vim.keymap.set('n', '<leader>nd', '<cmd>lua _NODE_TOGGLE()<CR>', {noremap = true})
```
### Running Commands in Terminal
You can run commands in a terminal directly from Neovim:
```lua
-- Example: Run npm commands
local npm_install = Terminal:new({
cmd = "npm install",
dir = "git_dir",
direction = "float",
close_on_exit = true,
on_open = function(term)
vim.cmd("startinsert!")
end,
})
function _NPM_INSTALL()
npm_install:toggle()
end
vim.keymap.set('n', '<leader>ni', '<cmd>lua _NPM_INSTALL()<CR>', {noremap = true})
```
### Terminal-Specific Settings
For custom terminal settings:
```lua
local opts = {
shell = '/bin/zsh', -- Set specific shell
env = { ['VAR'] = 'VALUE' }, -- Set environment variables
clear_env = false, -- Don't clear environment between terminals
}
require("toggleterm").setup(opts)
```
## Troubleshooting Common Issues
### Terminal Not Opening
- Ensure the keybinding (`<Ctrl-\>`) isn't overridden by another plugin
- Check if your terminal size settings are valid (they should be numbers or functions)
### Terminal Looks Incorrect
- Try changing the `border` option in `float_opts` to another value
- Adjust the `shading_factor` if the terminal is too dark/light
### Terminal Not Persisting History
- Check that `persist_size` is set to `true`
- Try setting `close_on_exit = false` to maintain session history
## Customizing Your Terminal Experience
### Changing The Default Terminal Layout
To change the default terminal appearance, modify the `direction` option:
```lua
direction = "horizontal", -- or "vertical", "float", "tab"
```
### Customizing Terminal Appearance
```lua
float_opts = {
border = "double", -- Try "single", "double", "curved", etc.
width = 80, -- Fixed width for floating window
height = 20, -- Fixed height for floating window
},
```
### Customizing Terminal Behavior
```lua
start_in_insert = true, -- Start in insert mode
persist_mode = true, -- Remember if terminal was in insert mode
auto_scroll = true, -- Auto-scroll to bottom when entering terminal
```
## Integration with Other Plugins
ToggleTerm works well with:
- **lazygit**: For Git operations (already configured in our setup)
- **vim-test**: Run tests in a terminal
- **nnn**: File manager in a terminal
- **Any CLI tool**: MySQL client, HTTP clients, etc.
## Conclusion
With ToggleTerm.nvim, you can keep your workflow within Neovim while having powerful terminal functionality at your fingertips. The plugin is highly customizable, allowing you to tailor it precisely to your needs.
For more details and advanced configurations, visit the [ToggleTerm GitHub page](https://github.com/akinsho/toggleterm.nvim).

View file

@ -18,7 +18,7 @@ return {
'nvim-neotest/nvim-nio', 'nvim-neotest/nvim-nio',
-- Installs the debug adapters for you -- Installs the debug adapters for you
'mason-org/mason.nvim', 'williamboman/mason.nvim',
'jay-babu/mason-nvim-dap.nvim', 'jay-babu/mason-nvim-dap.nvim',
-- Add your own debuggers here -- Add your own debuggers here

View file

@ -6,7 +6,8 @@ return {
config = function() config = function()
local lint = require 'lint' local lint = require 'lint'
lint.linters_by_ft = { lint.linters_by_ft = {
markdown = { 'markdownlint' }, -- Commenting out markdownlint to prevent errors
-- markdown = { 'markdownlint' },
} }
-- To allow other plugins to add linters to require('lint').linters_by_ft, -- To allow other plugins to add linters to require('lint').linters_by_ft,