Skip to content

Instantly share code, notes, and snippets.

@Yeshwanthyk
Created December 10, 2025 15:02
Show Gist options
  • Select an option

  • Save Yeshwanthyk/c8ee891a9e7836c624f06efc936e64cb to your computer and use it in GitHub Desktop.

Select an option

Save Yeshwanthyk/c8ee891a9e7836c624f06efc936e64cb to your computer and use it in GitHub Desktop.

Neovim Integration

Setup

Start Neovim with a named socket:

   nvim --listen /tmp/nvim.sock

For Agents (paste this in CLAUDE.md / AGENTS.md)

When I reference "current code", "what I'm looking at", "this function", "my cursor":

  1. Get location:
  nvim --server /tmp/nvim.sock --remote-expr "expand('%:p') . ':' . line('.')"
  # → /path/to/file.py:42
  1. Get context efficiently — don't dump blindly. Use the file:line to target what's needed:
  • Quick look: sed -n '32,52p' file.py
  • Find function bounds: ast-grep --lang python -p 'def $NAME($$$): $$$'
  • Find usages: rg 'symbol' --type py
  • Read file with offset if large
  1. Current line only (when useful):
  nvim --server /tmp/nvim.sock --remote-expr "getline('.')"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment