marcelomaia/Neovim

โ˜… 0Forks 0LuaGitHub โ†—Compare

README

Neovim Configuration

A modern, productive Neovim setup powered by LazyVim and a curated set of plugins for code navigation, Git integration, and more.

Table of Contents


โœจ Features

  • Fast startup and plugin management with LazyVim
  • Powerful LSP integration and code navigation
  • AI-powered code completion and assistance
  • Git integration with handy shortcuts
  • Fuzzy search and file explorer
  • Easy commenting and table formatting
  • Customizable keymaps for productivity

โšก Requirements


๐Ÿš€ Installation

# Clone the repository
git clone https://github.com/yourusername/neovim-config.git ~/.config/nvim

# Run setup script
cd ~/.config/nvim
scripts/setup.sh

After installation, open Neovim to automatically install plugins:

nvim

๐Ÿ› ๏ธ First Steps

When you first open Neovim, you'll want to:

  • :Lazy โ€” Manage plugins
  • :Mason โ€” Manage LSP servers and tools
  • :checkhealth โ€” Diagnose common issues
  • :LazyExtras โ€” Enable optional plugins

Understanding the Leader Key

The leader key is set to <Space>. When you see <leader> in a keybinding, press Space followed by the specified key(s).


๐Ÿค– AI Features

This configuration includes AI-powered assistance to supercharge your coding workflow and productivity.

GitHub Copilot Integration

GitHub Copilot is an AI pair programmer that offers real-time code suggestions directly in your editor.

Key Features

  • Real-time Suggestions: Receive context-aware code suggestions as you type
  • Multilingual Support: Works across dozens of programming languages
  • Complete Function Suggestions: Generates entire function implementations based on comments or function names

Essential Keyboard Shortcuts

  • <M-CR> (Alt+Enter) โ€” Access the completion panel with alternative suggestions
  • <C-l> (Ctrl+l) โ€” Accept current suggestion
  • <M-[> / <M-]> โ€” Navigate between suggestions (previous/next)
  • <C-]> โ€” Dismiss current suggestion
  • <C-x><C-o> โ€” Trigger manual completion in case automatic suggestions don't appear

Configuration

Copilot is configured through the copilot.lua plugin in lua/plugins/avante_ai.lua:

{
  "zbirenbaum/copilot.lua",
  event = "VeryLazy",
  opts = {
    enabled = true,
    filetypes = {
      markdown = true,
      help = true,
      -- Add other filetypes as needed
    },
    panel = {
      enabled = true,
      layout = {
        position = "right",
        ratio = 0.4,
      },
    },
    suggestion = {
      enabled = true,
      auto_trigger = true,
      debounce = 75,
    },
  },
}

Avante.nvim

Avante.nvim is an AI-assisted coding experience enhancer that works alongside Copilot.

Key Features

  • Context-Aware Suggestions: Provides intelligent suggestions based on project context
  • Semantic Understanding: Understands your codebase at a semantic level
  • Seamless Integration: Works harmoniously with GitHub Copilot

Usage Tips

  • Avante works best when your project has consistent coding conventions
  • It learns from your coding patterns over time
  • For best results, maintain well-structured and documented code

Troubleshooting AI Features

  • Missing Icons: Ensure you have a Nerd Font properly installed and configured
  • Slow Suggestions: Check your internet connection and GitHub Copilot status
  • No Suggestions: Verify your Copilot authentication with :Copilot auth
  • Icons Not Displaying: Reload your configuration after ensuring Nerd Font is active

To get the most out of these AI features, ensure your GitHub Copilot subscription is active and authenticated with :Copilot auth.


๐Ÿ”ฅ Git Shortcuts

  • <leader>gp โ€” Preview Git hunk
  • <leader>gr โ€” Reset Git hunk
  • <leader>gR โ€” Reset Git buffer
  • <leader>gg โ€” Open Neogit (commit/push/etc)
  • <leader>g โ€” More Git commands

Additional Git Commands

  • <leader>gb โ€” Blame line
  • <leader>gd โ€” Diff file
  • <leader>gl โ€” View log

๐Ÿงญ Navigation Shortcuts

  • [g / ]g โ€” Previous/Next Git hunk
  • [w / ]w โ€” Previous/Next warning
  • [e / ]e โ€” Previous/Next error
  • [d / ]d โ€” Previous/Next diagnostic
  • [m / ]m โ€” Previous/Next mark
  • [f / ]f โ€” Previous/Next function
  • gd โ€” Go to definition
  • gr โ€” Go to references
  • gg โ€” Go to top of file
  • G โ€” Go to end of file

Window Navigation

  • <C-h> / <C-j> / <C-k> / <C-l> โ€” Navigate between windows
  • <C-w>v โ€” Split window vertically
  • <C-w>s โ€” Split window horizontally
  • <C-w>c โ€” Close current window

๐Ÿ” Search & File Shortcuts

  • <leader>ff โ€” Find file
  • <leader>sg โ€” Grep content in files
  • <leader>ss โ€” LSP symbol search
  • <leader>sr โ€” Search and replace
  • <leader>s โ€” More search options

Advanced Search Options

  • <leader>sw โ€” Search word under cursor
  • <leader>sb โ€” Search in open buffers
  • <leader>sh โ€” Search help tags
  • <leader>sH โ€” Search command history

๐Ÿ—‚๏ธ Explorer Shortcuts

  • <leader>e โ€” Toggle file explorer
  • d โ€” Delete file
  • y โ€” Yank file path
  • c โ€” Copy file
  • a โ€” Add file
  • r โ€” Rename file
  • <M-h> โ€” Toggle hidden files
  • [g / ]g โ€” Previous/Next changed Git file

๐Ÿง‘โ€๐Ÿ’ป LSP & Code Navigation

  • gd โ€” Go to definition
  • gD โ€” Go to declaration
  • gI โ€” Go to implementation
  • gr โ€” Show references
  • K โ€” Show documentation (hover)
  • <leader>ca โ€” Code actions
  • <leader>cr โ€” Rename symbol
  • <leader>cf โ€” Format buffer or selection
  • <leader>x โ€” Diagnostics/Quick fix
  • <leader>ss โ€” Show LSP symbols

๐Ÿ’ฌ Commenting

  • gcc โ€” Toggle comment (line)
  • gc โ€” Toggle comment (selection in visual mode)
  • gcO โ€” Add comment on line above
  • gco โ€” Add comment on line below
  • gcA โ€” Add comment at end of line

๐Ÿ“Š Table Formatting

Align tables easily using Tabularize:

Before:

|start| eat| left |
| 12   | 5 | 7         |
| 20| 5  | 15   |

After running :Tabularize /| or <leader>t|:

| start | eat | left |
| 12    | 5   | 7    |
| 20    | 5   | 15   |

๐Ÿ’ก Other Useful Shortcuts

  • q โ€” Quit (mapped to q1)
  • w โ€” Save file (mapped to w2)
  • wq โ€” Save and quit (mapped to wq1)
  • <leader>qq โ€” Quit all
  • <leader>n โ€” Notification history
  • :vs file_path โ€” Open file vertically
  • :sp file_path โ€” Open file horizontally
  • gf โ€” Open file under cursor
  • zz โ€” Center cursor
  • zb โ€” Cursor at bottom
  • zt โ€” Cursor at top

๐Ÿ›Ÿ Troubleshooting

Common Issues

  1. Icons not displaying correctly

    • Ensure you have installed a Nerd Font and configured your terminal to use it
    • Check if your terminal supports Unicode characters
  2. LSP not working

    • Verify the language server is installed via :Mason
    • Check for errors with :LspInfo and :LspLog
    • Make sure necessary dependencies are installed for your language server
  3. Plugin errors

    • Run :Lazy and check for any plugin errors
    • Use :checkhealth for diagnostics
    • Check :messages for error details

Fixing Configuration Issues

If you encounter configuration issues:

  1. Try resetting your configuration: rm -rf ~/.local/share/nvim/lazy
  2. Start Neovim with minimal settings: nvim -u NONE
  3. Check for conflicting plugins in lua/plugins/

๐ŸŽจ Customization

Adding Your Own Plugins

Create a new file in the lua/plugins/ directory:

-- lua/plugins/my_plugins.lua
return {
  {
    "plugin-author/plugin-name",
    config = function()
      -- your config here
    end,
  },
}

Modifying Key Mappings

Edit your keymaps in lua/config/keymaps.lua:

-- lua/config/keymaps.lua
local keymap = vim.keymap.set

-- Add your custom keymaps
keymap("n", "<leader>x", "<cmd>YourCommand<cr>", { desc = "Your Command" })

Changing Theme

Add or modify theme configuration in lua/plugins/colorscheme.lua.


๐Ÿ™ Credits

Contributors

marcelomaiamarcelo-ssc

Issues