Skip to content

Instantly share code, notes, and snippets.

View icholy's full-sized avatar
💥
breaking things

Ilia Choly icholy

💥
breaking things
View GitHub Profile
--- this shells out to https://llm.datasette.io/en/stable/
vim.api.nvim_create_user_command("LLM", function(opts)
local system = [[
You are a neovim expert.
You help users write commands.
When a user asks a question, your output will be copied directly into the neovim command prompt.
Do not add any explanation.
Since the output is being copied in the command line, it should all be on a single line.
]]
local output = vim.system(
#!/usr/bin/expect -f
# Set timeout to prevent the script from hanging
set timeout -1
# Get the search pattern as a command line argument
if {[llength $argv] != 0} {
set pattern [lindex $argv 0]
} else {
puts "Error: search pattern not provided"
@icholy
icholy / lsptest.go
Last active September 11, 2023 00:35
package main
import (
"context"
"encoding/json"
"io"
"log"
"os"
"os/exec"
"path/filepath"
@icholy
icholy / nvim_lsp_status_airline.lua
Last active January 3, 2022 18:52
TypeScript LSP status in Airline
-- The TypeScript LSP server takes a while before it's responsive. This is a janky way of indicating the server status in
-- airline. It works by adding "..." to the statusline when the LSP connects, and then removing the "..." when the first
-- set of diagnostics come in.
vim.cmd([[
let g:lsp_wait_added = 0
let g:lsp_wait_done = 0
function! LspWait(...)
let builder = a:1
let context = a:2
{
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"schemes": [
"https"
],
package bufutil
import (
"bufio"
"bytes"
)
// SkipTo finds the first instance of delim and discards everything before it.
func SkipTo(br *bufio.Reader, delim []byte) (err error) {
min := len(delim)
package main
import (
"fmt"
"math"
"strings"
)
func main() {
g := Game{
package main

//go:noinline
func thing(values ...string) {
	for _, v := range values {
		println(v)
	}
}
@icholy
icholy / shift.go
Last active January 8, 2021 17:06
package binutil
// ShiftLeft performs a left bit shift operation on the provided bytes.
// If the bits count is negative, a right bit shift is performed.
func ShiftLeft(data []byte, bits int) {
n := len(data)
if bits < 0 {
bits = -bits
for i := n - 1; i > 0; i-- {
data[i] = data[i-1]<<(8-bits) | data[i]>>bits
package contextutil
import (
"context"
"time"
)
// ResetFunc resets the context timeout timer
type ResetFunc func()