Skip to content

Instantly share code, notes, and snippets.

@eduardoarandah
eduardoarandah / commands.lua
Last active October 6, 2022 15:54
neovim lua command to copy filename, line number and branch
-- 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)
@eduardoarandah
eduardoarandah / bug1.vue
Created August 30, 2022 16:59
bugs in volar
<script setup lang="ts">
interface IFoo {
id: number;
name: string;
}
const foos: Array<IFoo> = [
{ id: 1, name: "aaa" },
{ id: 2, name: "bbb" },
];
</script>
@eduardoarandah
eduardoarandah / ok.lua
Created August 25, 2022 19:37
#tip don’t run some files in your config if requirements are needed.
-- 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
@eduardoarandah
eduardoarandah / script.sh
Created August 25, 2022 13:18
neovim is your config REALLY portable?
# 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
@eduardoarandah
eduardoarandah / a.vim
Created August 24, 2022 20:42
Close all empty buffers with this function
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()
@eduardoarandah
eduardoarandah / init.lua
Last active July 6, 2022 17:50
vim to neovim migration helper
-------------------------------------------------------------------------------------
-- 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
--
version: "3.8"
volumes:
mysql57:
name: mysql57
mysql57conf:
name: mysql57conf # docker run -it -v mysql57conf:/app --rm busybox
services:
db: # docker compose exec db mysql -u root -pasdf -e "create database if not exists laravel;"
@eduardoarandah
eduardoarandah / minimal_init.lua
Created January 21, 2022 19:55
minimal lsp config for github issue
local on_windows = vim.loop.os_uname().version:match 'Windows'
local function join_paths(...)
local path_sep = on_windows and '\\' or '/'
local result = table.concat({ ... }, path_sep)
return result
end
vim.cmd [[set runtimepath=$VIMRUNTIME]]
@eduardoarandah
eduardoarandah / .vimrc
Created January 12, 2022 19:56
My .vimrc configuration
" I split my config into separate files so my real ~/.vimrc is just:
" source ~/scripts/.vimrc
" source ~/scripts/.vimrcplugins
" Update everthing:
" PlugUpgrade
" PlugUpdate
" CocUpdate
scriptencoding utf-8 " basic
set nocompatible " basic
@eduardoarandah
eduardoarandah / UploadController.php
Last active November 3, 2023 17:11
File upload with dropzone and alpine js
<?php
namespace App\Http\Controllers\Admin;
use App\Http\Controllers\Controller;
use App\Models\User;
use Illuminate\Http\Request;
use Storage;
class UploadController extends Controller