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> |
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
| -- Check requirements | |
| local all_requirements = 1 | |
| for _, requirement in ipairs({ "git", "rg", "node", "npm" }) do | |
| if vim.fn.executable(requirement) == 0 then | |
| print("plugins require " .. requirement) | |
| all_requirements = 0 | |
| end | |
| end | |
| if all_requirements == 0 then |
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
| # run ubuntu in docker | |
| docker run -it --rm --name myubuntu ubuntu:latest | |
| ## requirements | |
| apt update | |
| apt -y install software-properties-common dirmngr apt-transport-https lsb-release ca-certificates build-essential git ripgrep nodejs npm | |
| ## add neovim | |
| add-apt-repository ppa:neovim-ppa/stable -y | |
| apt update |