Skip to content

Instantly share code, notes, and snippets.

View itsfrank's full-sized avatar

Francis O'Brien itsfrank

View GitHub Profile
@itsfrank
itsfrank / modulestate.luau
Created April 6, 2024 20:18
Temporary workaround for lune issue with module caching
-- this file is only necessary because lune currently does not cache modules properly
-- see: https://github.com/lune-org/lune/issues/138
if _G._modulestate == nil then
_G._modulestate = {}
end
local modulestate = {}
-- if the state has not been initialized yet, we will use init to set values
function modulestate.get_state(s: string, init: { [any]: any }?): { [any]: any }
@itsfrank
itsfrank / luaurc.lua
Created April 9, 2024 02:57
luau-lsp.nvim luaurc aliases
-- reads .luaurc in dir if it exists and returns a table that can be passed to luau-lsp.nvim
-- requires plenary: https://github.com/nvim-lua/plenary.nvim
function read_luaurc_aliases(dir)
local p = require("plenary.path")
local luaurc_path = p:new(dir, ".luaurc")
if not luaurc_path:exists() then
return nil
end
local luaurc_data = luaurc_path:read()
@itsfrank
itsfrank / gc.rs
Last active October 22, 2024 17:00
Silly rust gc wrappers
#![feature(coerce_unsized, unsize)]
use std::cell::{Ref, RefCell, RefMut};
use std::marker::Unsize;
use std::ops::CoerceUnsized;
use std::rc::{Rc, Weak};
// immutable garbage-collected pointer
#[derive(Debug, Default)]
pub struct Gc<T: ?Sized> {
@itsfrank
itsfrank / codecompanion-save.lua
Last active April 26, 2025 00:01
Snippet to add the ability to save/load CodeCompanion chats in neovim
-- add 2 commands:
-- CodeCompanionSave [space delimited args]
-- CodeCompanionLoad
-- Save will save current chat in a md file named 'space-delimited-args.md'
-- Load will use a telescope filepicker to open a previously saved chat
-- create a folder to store our chats
local Path = require("plenary.path")
local data_path = vim.fn.stdpath("data")
local save_folder = Path:new(data_path, "cc_saves")
@itsfrank
itsfrank / commands.lua
Last active October 30, 2024 19:01
localhost tcp based notification system for neovim
-- some place where you define user commands
---@type uv_tcp_t?
local notify_server = nil
vim.api.nvim_create_user_command("StartNotifyServer", function()
if notify_server and not notify_server:is_closing() then
return
end
local try_notify_server, err = require("notify_server").start_server()
if err then