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 / github_pull_request.lua
Created April 19, 2025 06:08
Open pull request in Github easily with MiniGit
local M = {}
M.config = {
remotes = { 'fork', 'origin', 'upstream' },
default_base = nil,
browser_commands = {
mac = 'open',
unix = 'xdg-open',
win = 'start',
},
@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 / switch-kb-variant
Created December 30, 2023 15:31
Switch US keyboard variant from 'intl' to 'default' in Xorg and Wayland (Hyprland).
#!/bin/sh
variant=$1
if [ -z "$WAYLAND_DISPLAY" ]; then
if [ "$variant" = "intl" ]; then
setxkbmap -layout us -variant intl
notify-send -t 2000 "Keyboard layout" "Switched to international"
else
@datsfilipe
datsfilipe / datsvault
Created December 28, 2023 16:49
A custom notes vault management with shell script, jq and git.
#!/bin/sh
config_file="$HOME/.config/datsvault.json"
if [ ! -e "$config_file" ]; then
echo "Config file '$config_file' does not exist. Creating one..."
mkdir -p "$HOME/.config"
echo '{"vault_path": "'"$HOME/.config/datsvault"'", "terminal": "alacritty", "vault_repo": "null"}' > "$config_file"
@datsfilipe
datsfilipe / create_pr_from_nvim.lua
Last active October 1, 2023 23:31
Submit PR's from Neovim with Github CLI.
local M = {}
local function return_project_root()
local path = vim.fn.expand "%:p:h"
local git_path = vim.fn.finddir(".git", path .. ";")
local git_file = vim.fn.findfile(".git", path .. ";")
if git_path == "" and git_file == "" then
return nil
else
return vim.fn.fnamemodify(git_path, ":h")
@datsfilipe
datsfilipe / formatter.lua
Created September 7, 2023 06:52
Only use prettierd with `formatter.nvim` if a prettier config file is found.
local ok, formatter = pcall(require, "formatter")
if not ok then
return
end
local util = require "formatter.util"
local find_git_ancestor = function ()
local path = util.get_current_buffer_file_path()
local root = path
@datsfilipe
datsfilipe / init.lua
Created September 5, 2023 22:04
Min-theme development file.
vim.opt.cmdheight = 1
vim.opt.encoding = "utf-8"
vim.scriptencoding = "utf-8"
vim.opt.fileencoding = "utf-8"
vim.opt.expandtab = true
vim.opt.hidden = true
vim.opt.hlsearch = true
vim.opt.ignorecase = true
vim.opt.incsearch = true
vim.opt.laststatus = 3
@datsfilipe
datsfilipe / vscode-settings.json
Created November 8, 2022 16:22
I do not use Visual Studio Code anymore but there is the config I used and I believe it will be very good for people trying to migrate to neovim or simply trying to lern the neovim like movements
{
"editor.accessibilitySupport": "off",
"editor.cursorSmoothCaretAnimation": false,
"editor.find.addExtraSpaceOnTop": false,
"editor.fontFamily": "JetBrainsMono Nerd Font, JetBrains Mono, Fira Code, monospace",
"editor.fontLigatures": "'ss01', 'ss02', 'ss03', 'ss06', 'zero'",
"editor.fontSize": 14,
"editor.glyphMargin": true,
"editor.guides.bracketPairs": "active",
"editor.inlineSuggest.enabled": true,