This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- 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```") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
----------------------------- | |
-- 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
----------------------------- | |
-- 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>") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
----------------------------- | |
-- 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" Duplicate class | |
command! -nargs=1 DuplicateClass :call DuplicateClass(<f-args>) | |
function! DuplicateClass(new_class) | |
let l:original_class = expand('%:t:r') | |
let l:original_extension = expand('%:e') | |
let l:new_full_path = expand('%:h').'/'. a:new_class.'.'.l:original_extension | |
" Copy contents of original file to new file | |
execute 'silent execute "write ' .l:new_full_path.'"' | |
execute 'silent execute "edit ' .l:new_full_path.'"' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- GOAL: replace placeholders with values | |
-- | |
-- FIELDS EXAMPLE: | |
-- title,text,link | |
-- hello,world,something.com | |
-- good,morning,example.com | |
-- another,line,asdf.com | |
-- last,line,asdf.com | |
-- | |
-- PATTERN EXAMPLE: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- show a floating popup | |
local function show_popup(size_percentage, filetype, title, lines) | |
-- build buffer | |
local buf = vim.api.nvim_create_buf(false, true) | |
vim.api.nvim_buf_set_option(buf, "bufhidden", "wipe") | |
vim.api.nvim_buf_set_option(buf, "filetype", filetype) | |
vim.api.nvim_buf_set_keymap(buf, "n", "<esc>", ":bd<cr>", { nowait = true, noremap = true, silent = true }) | |
vim.api.nvim_open_win(buf, true, { | |
style = "minimal", | |
relative = "editor", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://www.digitalocean.com/community/tutorials/how-to-install-and-set-up-laravel-with-docker-compose-on-ubuntu-22-04 | |
FROM php:7.4-cli | |
# Arguments defined in docker-compose.yml | |
ARG user | |
ARG uid | |
# Install system dependencies | |
RUN apt-get update && apt-get install -y \ | |
git \ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Copy filename, line number and branch | |
-- example: src/filename.js +123 # branch master | |
vim.api.nvim_create_user_command("CopyPathLineNumberBranch", function() | |
local branch = vim.fn.systemlist("git branch --show-current") | |
local comment = "" | |
if not string.find(branch[1], "not a git repository") then | |
comment = " # branch " .. branch[1] | |
end | |
vim.fn.setreg("*", vim.fn.expand("%") .. " +" .. vim.api.nvim_win_get_cursor(0)[1] .. comment) | |
end, args) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script setup lang="ts"> | |
interface IFoo { | |
id: number; | |
name: string; | |
} | |
const foos: Array<IFoo> = [ | |
{ id: 1, name: "aaa" }, | |
{ id: 2, name: "bbb" }, | |
]; | |
</script> |
NewerOlder