Skip to content

Instantly share code, notes, and snippets.

View datsfilipe's full-sized avatar
🤍
Grinding

Filipe Lima datsfilipe

🤍
Grinding
View GitHub Profile
@MariaSolOs
MariaSolOs / builtin-compl.lua
Last active November 14, 2024 22:10
Built-in completion + snippet Neovim setup
---Utility for keymap creation.
---@param lhs string
---@param rhs string|function
---@param opts string|table
---@param mode? string|string[]
local function keymap(lhs, rhs, opts, mode)
opts = type(opts) == 'string' and { desc = opts }
or vim.tbl_extend('error', opts --[[@as table]], { buffer = bufnr })
mode = mode or 'n'
vim.keymap.set(mode, lhs, rhs, opts)
" Calls GPT-4 to fill holes in the current file,
" omitting collapsed folds to save prompt space
function! SaveVisibleLines(dest)
let l:visibleLines = []
let lnum = 1
while lnum <= line('$')
if foldclosed(lnum) == -1
call add(l:visibleLines, getline(lnum))
let lnum += 1
function! project#Switch(path) abort
if tabpagenr('$') == 1
%bd
endif
execute 'cd ' . a:path
execute 'Dirvish'
endfunction
function! s:ReturnProjectRoot() abort
" TODO: This doesn't work on non git projects
return system('git rev-parse --show-toplevel')->substitute('\n', '', '')
endfunction
function! github#pr#CreatePr() abort
let l:template_path = s:ReturnProjectRoot() . '/.github/pull_request_template.md'
call execute('tabe ' . tempname())
function! TransformSplitIntoTab() abort
let l:path = expand('%')
call execute(':wq!')
call execute(':tabnew ' . l:path)
endfunction
nnoremap <c-w>! :call TransformSplitIntoTab()<cr>

Examples

[@import stdlib.http.v1];

(x => y => (x_plus_y: x + y) => );

((A, x))
(f: () -> (A: *, x: A)) =>
  (A, x) = (f ());
@lkhphuc
lkhphuc / nvim_highlight_update.md
Last active December 25, 2023 06:20
A simple utility function to override and update any colorscheme in Neovim.

I like to have my neovim to bold the language keywords, italicize the comments, or both italicize and bold all the builtin functions, type or constants etc. And I want this to be consistent across colorschemes.

In vim/neovim, to update a highlight group it is as simple as highlight HighlightGroupToModified gui=bold,italic,underline. But this is problematic if the HighlightGroupToModified is defined as a link to other highlight group. For example highlight TSInclude might be linked to Include by your colorscheme, so executing hi TSInclude gui=bold will apply bold to TSInclude but wipe out any foreground and background color information that was originally defined by linking to Include highlight group.

Since every colorschemes can arbitrarily choose to define a highlight group explicitly or by linking, adding hi TSConstant gui=bold to your config are bound to break when you switch colorschemes. A manual approach is to recursively go down the linking chain defined by colorscheme, e.g TSConstant

@AngeloCore
AngeloCore / permissions
Last active June 14, 2024 14:02
All discord.js permissions | discord.js permissions list, hasPermission, permissionFor and more
* Numeric permission flags. All available properties:
* * `CREATE_INSTANT_INVITE` (create invitations to the guild)
* * `KICK_MEMBERS`
* * `BAN_MEMBERS`
* * `ADMINISTRATOR` (implicitly has *all* permissions, and bypasses all channel overwrites)
* * `MANAGE_CHANNELS` (edit and reorder channels)
* * `MANAGE_GUILD` (edit the guild information, region, etc.)
* * `ADD_REACTIONS` (add new reactions to messages)
* * `VIEW_AUDIT_LOG`
* * `PRIORITY_SPEAKER`
-- autosave.lua
--
-- Periodically saves "watch later" data during playback, rather than only saving on quit.
-- This lets you easily recover your position in the case of an ungraceful shutdown of mpv (crash, power failure, etc.).
--
-- You can configure the save period by creating a "lua-settings" directory inside your mpv configuration directory.
-- Inside the "lua-settings" directory, create a file named "autosave.conf".
-- The save period can be set like so:
--
-- save_period=60