Skip to content

Instantly share code, notes, and snippets.

@eduardoarandah
eduardoarandah / context.lua
Created February 4, 2026 23:14
Neovim commands to simplify context creation in markdown files
-----------------------------------------------------------------
-- Neovim commands to simplify context creation in markdown files
--
-- Save as: lua/context.lua
--
-- How to use: require("_context").setup()
--
-----------------------------------------------------------------
local M = {}
@eduardoarandah
eduardoarandah / settings.local.json
Created January 30, 2026 01:38
Claude Code configuration to notify you via telegram .claude/settings.local.json
{
"permissions": {
"allow": [
"Bash(php artisan make:migration:*)",
"Bash(php artisan:*)",
"Bash(find:*)",
"Bash(grep:*)",
"Bash(docker compose exec:*)",
"Bash(mkdir:*)",
"Bash(php:*)",
@eduardoarandah
eduardoarandah / git_clean.zsh
Last active January 26, 2026 23:29
Git branch cleanup function for zsh
# Git branch cleanup function for zsh
git_cleanup_merged_branches() {
# Require main branch parameter
if [[ -z "$1" ]]; then
echo "Usage: git_cleanup_merged_branches <main-branch>"
return 1
fi
local main_branch="$1"
# Check if we're currently on the main branch - must be on main to see what's merged into it
@eduardoarandah
eduardoarandah / hear.lua
Created November 12, 2025 18:29
Command to dictate in Neovim with hear
-- Command to dictate in Neovim with hear
-- Usage: :Hear
-- https://github.com/sveinbjornt/hear
vim.api.nvim_create_user_command("Hear", function()
-- Save current buffer and cursor position
local original_buf = vim.api.nvim_get_current_buf()
local original_win = vim.api.nvim_get_current_win()
local cursor_pos = vim.api.nvim_win_get_cursor(original_win)
-- Create temporary buffer for terminal
local buf = vim.api.nvim_create_buf(false, true)
@eduardoarandah
eduardoarandah / rept.lua
Last active May 30, 2025 18:20
Rept command, replace pattern with placeholders in a line with strings split by pipe '|'
-- ReplaceTemplate replaces each '&' in the given template string
-- with values from the current line, split by the '|' character.
--
-- a|b|c
-- usage: :Rept Hello & wonderful & world &
-- result: Hello a wonderful b world c
function ReplaceTemplate(template)
-- Get the current line where the cursor is
local line = vim.api.nvim_get_current_line()
@eduardoarandah
eduardoarandah / db_tools.lua
Created April 30, 2025 02:19
I made a quick and dirty plugin to describe my database so that I can send it to the LLM it has 3 commands: SQLDefine SQLTables SQLExecute
-- expect a .env file in project root with the following variables:
-- DB_CONNECTION=mysql
-- DB_HOST=db
-- DB_PORT=3306
-- DB_DATABASE=example
-- DB_USERNAME=asdf
-- DB_PASSWORD=asdf
local M = {}
@eduardoarandah
eduardoarandah / init.lua
Created April 6, 2025 03:54
neovim command to copy selection as a code snippet, with filename, line number and then the code snippet
-- Command to copy selection as a code snippet, with filename, line number and then the code snippet
vim.api.nvim_create_user_command("CopyCodeSnippet", function(opts)
local start_line = vim.fn.line("'<") - 1
local end_line = vim.fn.line("'>")
local file_name = vim.fn.expand("%:.")
local lines = vim.api.nvim_buf_get_lines(0, start_line, end_line, false)
local file_type = vim.api.nvim_buf_get_option(0, "filetype")
-- set clipboard
vim.fn.setreg("*", file_name .. " +" .. (start_line + 1) .. "\n\n```" .. file_type .. "\n" .. table.concat(lines, "\n") .. "\n```")
@eduardoarandah
eduardoarandah / llm_context.lua
Created February 25, 2025 20:31
Create context for LLM in neovim, save all your buffers as context.xml with F10
-----------------------------
-- Create context for the LLM
--
-- Save as: lua/llm_context.lua
--
-- How to use: require("llm_context").setup()
--
-- Reference:
-- Long context prompting tips
-- https://docs.anthropic.com/en/docs/build-with-claude/prompt-engineering/long-context-tips#example-quote-extraction
@eduardoarandah
eduardoarandah / commands.lua
Last active February 19, 2025 17:35
create context for the llm in neovim
-----------------------------
-- Create context for the LLM
-- Long context prompting tips
-- https://docs.anthropic.com/en/docs/build-with-claude/prompt-engineering/long-context-tips#example-quote-extraction
-----------------------------
-- Dump context with documents tags
vim.api.nvim_create_user_command("ContextDump", function()
local content = vim.fn.getreg("z")
vim.fn.setreg("+", "<documents>\n" .. content .. "</documents>")
@eduardoarandah
eduardoarandah / commands.lua
Created February 7, 2025 05:43
Copy context in neovim using textobjects
-----------------------------
-- Create context for the LLM
-----------------------------
-- Clear register z
vim.api.nvim_create_user_command("ContextClear", 'let @z=""', { bang = true })
-- Create a user command :CopyFunction that calls our function.
vim.api.nvim_create_user_command("ContextAddFunction", function()
-- Append relative path and line number