Skip to content

Instantly share code, notes, and snippets.

View datsfilipe's full-sized avatar
🤍
grinding

datsfilipe.xyz datsfilipe

🤍
grinding
View GitHub Profile
@datsfilipe
datsfilipe / vim_format_in_dir_keymap.lua
Last active January 12, 2025 21:08 — forked from inclooder/vim_format_in_dir
Format all files in directory using Neovim keymap
vim.keymap.set('n', '<leader>f', function()
local ext = vim.fn.expand '%:e'
local confirm =
vim.fn.input('proceed with formatting ' .. ext .. ' files? [y/n] ')
if confirm:lower() ~= 'y' then
print 'operation cancelled'
return
end
@datsfilipe
datsfilipe / prettyUnsafe.nix
Created January 3, 2025 18:11 — forked from jorsn/prettyUnsafe.nix
Unsafely pretty-print Nix values
with builtins;
let
printChild = prefix: x:
let
names = attrNames x;
in
if isAttrs x && length names == 1
then "." + head names + printChild prefix x.${head names}
else " = " + print prefix x
;
" Calls GPT-4 to fill holes in the current file,
" omitting collapsed folds to save prompt space
local M = {}
local function save_visible_lines(dest)
local visible_lines = {}
local lnum = 1
while lnum <= vim.fn.line('$') do
if vim.fn.foldclosed(lnum) == -1 then
@datsfilipe
datsfilipe / autosave.lua
Last active August 17, 2022 13:05 — forked from CyberShadow/autosave.lua
It's a fork from a fork. The intent is to don't save the state while playing mp3 audio files.
-- autosave.lua script
-- Fork from: https://gist.github.com/CyberShadow/2f71a97fb85ed42146f6d9f522bc34ef
local options = require 'mp.options'
local o = {
save_period = 60
}
options.read_options(o)