Skip to content

Instantly share code, notes, and snippets.

@e2r2fx
e2r2fx / pinPackage.nix
Created August 17, 2025 15:04
pinPackage util
{self, ...}: {
pinPackage = {
commit,
package,
hash ? self.pkgs.lib.fakeHash,
}:
(import (builtins.fetchTarball {
url = "https://github.com/NixOS/nixpkgs/archive/${commit}.tar.gz";
sha256 = hash;
}) {
@e2r2fx
e2r2fx / config.lua
Created August 11, 2025 19:48
fast apply tool for codecompanion using morphllm
opts.strategies.chat.tools = {
["fast_apply"] = {
callback = "strategies.chat.tools.catalog.fast_apply",
description = "Apply code changes to a file using morphllm for fast code modifications",
opts = {
adapter = "openai_compatible",
model = "morph-v3-large",
url = "https://api.morphllm.com/v1",
api_key = "cmd:cat /some/secret/file,
},
@e2r2fx
e2r2fx / openrouter.lua
Created July 31, 2025 20:47
Openrouter adapter with reasoning support for codecomanion.nvim
local log = require("codecompanion.utils.log")
local utils = require("codecompanion.utils.adapters")
---Remove any keys from the message that are not allowed by the API
---@param message table The message to filter
---@return table The filtered message
local function filter_out_messages(message)
local allowed = {
"content",
"role",
@e2r2fx
e2r2fx / image.lua
Created October 22, 2024 16:21
open ai image tool for codecompanion
local xml2lua = require("codecompanion.utils.xml.xml2lua")
local log = require("codecompanion.utils.log")
local function get_secret()
local cmd = os.getenv("HOME") .. "/scripts/get_secret.sh"
local handle = io.popen(cmd, "r")
if handle then
local result = handle:read("*a")
log:trace("Executed cmd: %s", cmd)
handle:close()