Skip to content

Instantly share code, notes, and snippets.

View datsfilipe's full-sized avatar
🤍
Grinding

Filipe Lima datsfilipe

🤍
Grinding
View GitHub Profile
" 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,
@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)
@datsfilipe
datsfilipe / .gitconfig
Last active August 18, 2022 04:58
git config file
## type "nvim ~/.gitconfig" on shell and paste the following
[user]
name = # your username
email = # your e-mail
[alias]
ci = commit
co = checkout
cm = checkout main
cb = checkout -b