This file contains 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 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 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 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 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 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 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 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 |
This file contains 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
function! CloseEmptyBuffers() | |
let buffers = filter(range(1, bufnr('$')), 'buflisted(v:val) && empty(bufname(v:val)) && bufwinnr(v:val)<0 && !getbufvar(v:val, "&mod")') | |
if !empty(buffers) | |
exe 'bw ' . join(buffers, ' ') | |
endif | |
endfunction | |
command! CloseEmptyBuffers :call CloseEmptyBuffers() |
This file contains 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
------------------------------------------------------------------------------------- | |
-- 1) Copy this file anywhere, | |
-- 2) Paste your options in "opts" | |
-- 3) Source it with :source % | |
-- | |
-- If you get "unknown option" then remove it from opts and put it in "globals" | |
-- | |
-- checkopts() checks for values that already are defaults. Remove this function when you're done | |
-- checkglobals() the same but for globals | |
-- |
NewerOlder