Skip to main content
Magictt includes powerful plugins that enhance your editing workflow with smart features for commenting, text manipulation, and code navigation.

Code Commenting: Comment.nvim

Comment.nvim provides intelligent code commenting that understands multiple languages and contexts.

Features

  • Context-Aware: Understands JSX/TSX and adjusts comment style based on cursor position
  • Language Support: Works with all languages supported by tree-sitter
  • Multiple Comment Styles: Line comments and block comments
  • Visual Mode: Comment selections in visual mode

Keybindings

Normal Mode

KeybindingAction
gccToggle line comment
gbcToggle block comment
gc{motion}Comment using motion (e.g., gcip for paragraph)
gb{motion}Block comment using motion

Visual Mode

KeybindingAction
gcToggle line comment for selection
gbToggle block comment for selection

Usage Examples

// Place cursor on line and press gcc
const hello = "world";  // -> // const hello = "world";

// Visual select multiple lines and press gc
function example() {
  return true;
}
// Becomes:
// function example() {
//   return true;
// }

JSX/TSX Context Awareness

Comment.nvim integrates with nvim-ts-context-commentstring to use the correct comment style:
// In JavaScript context: uses //
const Component = () => {
  // In JSX context: uses {/* */}
  return <div>Hello</div>
}

Configuration

Location: lua/magictt/plugins/comment.lua
return {
  "numToStr/Comment.nvim",
  event = { "BufReadPre", "BufNewFile" },
  dependencies = {
    "JoosepAlviste/nvim-ts-context-commentstring",
  },
  config = function()
    local comment = require("Comment")
    local ts_context_commentstring = require(
      "ts_context_commentstring.integrations.comment_nvim"
    )

    comment.setup({
      pre_hook = ts_context_commentstring.create_pre_hook(),
    })
  end,
}

Auto Pairs: nvim-autopairs

nvim-autopairs automatically inserts matching brackets, quotes, and parentheses as you type.

Features

  • Auto Insert: Automatically adds closing pairs
  • Auto Delete: Deletes both pairs when backspacing
  • Fast Wrap: Quick wrapping of text in pairs
  • Treesitter Integration: Smarter pair insertion based on syntax
  • Completion Integration: Works seamlessly with nvim-cmp

Smart Behavior

The plugin is smart enough to:
  • Not add pairs inside strings (Lua)
  • Not add pairs in template strings (JavaScript)
  • Jump over closing pairs instead of inserting duplicates
  • Delete both pairs when backspacing an empty pair

Treesitter Configuration

Special rules for specific languages:
ts_config = {
  lua = { "string" },              -- Don't pair in Lua strings
  javascript = { "template_string" }, -- Don't pair in JS template strings
  java = false,                     -- Don't check treesitter for Java
}

Usage Examples

// Type: (
const func = ()  // -> const func = (|)
//                    cursor placed inside

// Type: " in empty space
const str = ""   // -> const str = "|" 

// Backspace on empty pair
const x = ()     // Backspace -> const x = 

Configuration

Location: lua/magictt/plugins/autopairs.lua
return {
  "windwp/nvim-autopairs",
  event = { "InsertEnter" },
  config = function()
    local autopairs = require("nvim-autopairs")

    autopairs.setup({
      check_ts = true,  -- Enable treesitter integration
      ts_config = {
        lua = { "string" },
        javascript = { "template_string" },
      },
    })

    -- Integration with nvim-cmp
    local cmp_autopairs = require("nvim-autopairs.completion.cmp")
    local cmp = require("cmp")
    cmp.event:on("confirm_done", cmp_autopairs.on_confirm_done())
  end,
}

Surround Text: nvim-surround

nvim-surround provides powerful operators to add, delete, and change surrounding characters (quotes, brackets, tags, etc.).

Core Operations

OperationDescriptionExample
AddAdd surroundingysiw" adds quotes around word
DeleteDelete surroundingds" removes surrounding quotes
ChangeChange surroundingcs"' changes ” to ‘

Keybindings

Add Surroundings (ys)

  • ysiw) - Surround word with ()
  • ysiw] - Surround word with []
  • ysiw} - Surround word with
  • ysiw" - Surround word with ""
  • ysiw' - Surround word with ”
  • ysiwt - Surround word with HTML tag
  • yss) - Surround entire line

Delete Surroundings (ds)

  • ds" - Delete surrounding ""
  • ds' - Delete surrounding ”
  • ds) - Delete surrounding ()
  • ds} - Delete surrounding
  • dst - Delete surrounding HTML tag

Change Surroundings (cs)

  • cs"' - Change ” to ’
  • cs'" - Change ’ to ”
  • cs( - Change ( to other delimiter
  • cs)" - Change ) to ”
  • cst" - Change tag to “

Usage Examples

// Add surroundings
hello          // ysiw" -> "hello"
const x = 5    // yss} -> { const x = 5 }

// Delete surroundings
"hello"        // ds" -> hello
(test)         // ds( -> test

// Change surroundings
"hello"        // cs"' -> 'hello'
(test)         // cs([ -> [test]
'hello'        // cs'<q> -> <q>hello</q>

Visual Mode

Select text in visual mode, then press S followed by the desired surrounding:
  • Select text → S" → wraps in quotes
  • Select text → S) → wraps in parentheses
  • Select text → St → prompts for HTML tag

Configuration

Location: lua/magictt/plugins/surround.lua
return {
  "kylechui/nvim-surround",
  event = { "BufReadPre", "BufNewFile" },
  version = "*",
  config = true,  -- Uses default configuration
}

Quick Substitution: substitute.nvim

substitute.nvim provides a quick way to substitute text without affecting registers.

Features

  • Register Preservation: Doesn’t overwrite your yanked text
  • Motion Support: Works with any Neovim motion
  • Visual Mode: Substitute selected text
  • Quick Operations: Faster than traditional substitute commands

Keybindings

KeybindingModeAction
s{motion}NormalSubstitute using motion
ssNormalSubstitute entire line
SNormalSubstitute from cursor to end of line
sVisualSubstitute visual selection

Workflow

  1. Yank the text you want to use for substitution
  2. Use s operator with a motion (e.g., siw for inner word)
  3. The motion target is replaced with yanked text
  4. Your yank register remains unchanged

Usage Examples

// Yank "world" then:
const hello = "test";  
// Place cursor on "test" and press siw
const hello = "world";  // "test" replaced with "world"

// Substitute entire line
const old = "value";   // Place cursor here and press ss
world                  // Entire line replaced with yanked content

// Substitute to end of line
const test = old;      // Place cursor on "old" and press S
const test = world;    // Everything from cursor replaced

Configuration

Location: lua/magictt/plugins/substitute.lua
return {
  "gbprod/substitute.nvim",
  event = { "BufReadPre", "BufNewFile" },
  config = function()
    local substitute = require("substitute")
    substitute.setup()

    -- Keybindings
    vim.keymap.set("n", "s", substitute.operator, 
      { desc = "Substitute with motion" })
    vim.keymap.set("n", "ss", substitute.line, 
      { desc = "Substitute line" })
    vim.keymap.set("n", "S", substitute.eol, 
      { desc = "Substitute to end of line" })
    vim.keymap.set("x", "s", substitute.visual, 
      { desc = "Substitute in visual mode" })
  end,
}

Keybinding Helper: which-key.nvim

which-key.nvim displays available keybindings in a popup window after you start typing a key sequence.

Features

  • Automatic Display: Shows after 500ms timeout
  • Grouped Keybindings: Organizes keys by functionality
  • Search: Filter keybindings in the popup
  • Learning Aid: Perfect for discovering and remembering keybindings

Defined Key Groups

Magictt defines these leader key groups:
PrefixGroupDescription
<leader>dDiagnosticsLSP diagnostics commands
<leader>eExplorerFile explorer commands
<leader>fFindTelescope find commands
<leader>hHarpoonHarpoon navigation
<leader>lLazyLazy.nvim panels
<leader>mMasonMason LSP installer
<leader>nNoHighlightClear search highlight
<leader>sSplitsWindow split commands
<leader>tTabsTab management
<leader>wWorkspaceSession management
<leader>xTroubleTrouble diagnostics list

Usage

  1. Press <leader> (Space key by default)
  2. Wait 500ms - which-key popup appears
  3. See all available keybindings for that prefix
  4. Press the next key to execute the command

Configuration

Location: lua/magictt/plugins/which-key.lua
return {
  "folke/which-key.nvim",
  event = "VeryLazy",
  init = function()
    vim.o.timeout = true
    vim.o.timeoutlen = 500  -- Show popup after 500ms
  end,
  config = function()
    local wk = require("which-key")
    wk.add({
      { "<leader>d", group = "Diagnostics" },
      { "<leader>e", group = "Explorer" },
      { "<leader>f", group = "Find" },
      -- ... more groups
    })
  end,
}

TODO Comments: todo-comments.nvim

todo-comments.nvim highlights and provides navigation for comment annotations like TODO, HACK, BUG, etc.

Supported Keywords

  • FIX / FIXME: Things that need to be fixed
  • TODO: Tasks to be done
  • HACK: Temporary workarounds
  • WARN / WARNING: Important warnings
  • PERF / PERFORMANCE: Performance-related notes
  • NOTE / INFO: General information
  • TEST: Test-related notes

Keybindings

KeybindingAction
]tJump to next TODO comment
[tJump to previous TODO comment
<leader>ftSearch all TODOs with Telescope
<leader>xtOpen TODOs in Trouble list

Usage Examples

// TODO: Implement user authentication
// FIXME: This causes memory leak
// HACK: Temporary fix until API is updated
// NOTE: This is important context
// PERF: Optimize this loop
These comments will be highlighted in different colors and can be easily navigated.

Configuration

Location: lua/magictt/plugins/todo-comments.lua
return {
  "folke/todo-comments.nvim",
  event = { "BufReadPre", "BufNewFile" },
  dependencies = { "nvim-lua/plenary.nvim" },
  config = function()
    local todo_comments = require("todo-comments")

    -- Navigation keymaps
    vim.keymap.set("n", "]t", function()
      todo_comments.jump_next()
    end, { desc = "Next todo comment" })

    vim.keymap.set("n", "[t", function()
      todo_comments.jump_prev()
    end, { desc = "Previous todo comment" })

    todo_comments.setup()
  end,
}

Diagnostic List: trouble.nvim

trouble.nvim provides a beautiful list for viewing diagnostics, references, quickfix items, and more.

Features

  • Diagnostic List: All workspace or document diagnostics
  • Quickfix Integration: Enhanced quickfix list
  • Location List: Better location list display
  • TODO Integration: View all TODO comments in one place
  • Auto-focus: Automatically focuses the trouble window

Keybindings

KeybindingAction
<leader>xwOpen workspace diagnostics
<leader>xdOpen document diagnostics
<leader>xqOpen quickfix list
<leader>xlOpen location list
<leader>xtOpen TODO comments list

Usage Workflow

  1. Code with errors/warnings shows diagnostic indicators
  2. Press <leader>xd to see all document diagnostics
  3. Navigate through the list with j/k
  4. Press Enter to jump to diagnostic location
  5. Press q to close the trouble window

Configuration

Location: lua/magictt/plugins/trouble.lua
return {
  "folke/trouble.nvim",
  dependencies = { 
    "nvim-tree/nvim-web-devicons",
    "folke/todo-comments.nvim"
  },
  opts = {
    focus = true,  -- Auto-focus the trouble window
  },
  cmd = "Trouble",
  keys = {
    { "<leader>xw", "<cmd>Trouble diagnostics toggle<CR>",
      desc = "Open trouble workspace diagnostics" },
    { "<leader>xd", "<cmd>Trouble diagnostics toggle filter.buf=0<CR>",
      desc = "Open trouble document diagnostics" },
    { "<leader>xq", "<cmd>Trouble quickfix toggle<CR>",
      desc = "Open trouble quickfix list" },
    { "<leader>xl", "<cmd>Trouble loclist toggle<CR>",
      desc = "Open trouble location list" },
    { "<leader>xt", "<cmd>Trouble todo toggle<CR>",
      desc = "Open todos in trouble" },
  },
}

Split Maximizer: vim-maximizer

vim-maximizer allows you to temporarily maximize the current split window, hiding all others.

Features

  • Toggle Maximize: Make current split fullscreen and restore
  • Preserved Layout: Original split layout is restored
  • Quick Toggle: Single keybinding to maximize/restore

Keybinding

KeybindingAction
<leader>smToggle maximize/minimize current split

Usage

  1. Open multiple splits
  2. Press <leader>sm to maximize current split
  3. Work in fullscreen
  4. Press <leader>sm again to restore split layout

Configuration

Location: lua/magictt/plugins/vim-maximizer.lua
return {
  "szw/vim-maximizer",
  keys = {
    { "<leader>sm", "<cmd>MaximizerToggle<CR>",
      desc = "Maximize/minimize a split" },
  },
}

Markdown Rendering: markview.nvim

markview.nvim enhances the markdown viewing experience with live rendering.

Features

  • Live Preview: See rendered markdown in the editor
  • Syntax Highlighting: Enhanced markdown syntax
  • Better Visuals: Improved heading styles, lists, and formatting

Configuration

Location: lua/magictt/plugins/markview.lua
return {
  "OXY2DEV/markview.nvim",
  lazy = false,  -- Load immediately for markdown files
}

Keybindings Summary

Quick Reference

PluginKeyAction
CommentgccToggle line comment
Commentgc{motion}Comment with motion
AutopairsAutoPairs automatically
Surroundysiw"Add surround
Surroundds"Delete surround
Surroundcs"'Change surround
Substitutes{motion}Substitute with motion
SubstitutessSubstitute line
Which-key<leader>Show keybindings
TODO]t / [t]Next/prev TODO
Trouble<leader>xdDocument diagnostics
Trouble<leader>xwWorkspace diagnostics
Maximizer<leader>smToggle maximize

Plugin Overview

See all installed plugins

Keybindings

Complete keybinding reference

Build docs developers (and LLMs) love