This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; lie and say it's clojure for highlighting | |
; vim: ft=clojure | |
; this is a hack that won't be necessary if/when we add `get-option` to the macro environment | |
(local meta-enabled (-> _SCOPE.specials.doc | |
(pcall (list (sym :doc) (sym :doc)) _SCOPE _CHUNK))) | |
(fn meta/when-enabled [...] | |
"Execute body in an implicit `do` when metadata is enabled. Otherwise, | |
contents are excluded from compiled output." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; lie to gist's syntax highlight and say it's clojure | |
; vim: ft=clojure | |
(require-macros :fnl.fennel-nvim.macros.metadata) | |
(local (mpack Session Tcp) (values (require :mpack) | |
(require :nvim.session) | |
(require :nvim.tcp_stream))) | |
(local fmt string.format) | |
(fn get-api-doc [] | |
(let [fh (io.open "./fnl/fennel-nvim/api.mpack") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; trick gist syntax highlighting | |
; vim: ft=clojure | |
(local (fmt searchpath) (values string.format package.searchpath)) | |
(var *ns-module-root* nil) | |
(λ *ns-module-root! [?val] | |
"Sets or gets the name of the root module name; used for namespacing | |
require-import. Can only be set once, before `require-include` is ever used." | |
(if (not ?val) *ns-module-root* | |
(do (assert (not *ns-module-root*) | |
"module-root-name! can only be called once") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- shim lua API on nvim < 0.5.x | |
-- requires nvim.lua from https://github.com/norcalli/nvim.lua | |
local vim = vim | |
vim.startswith = vim.startswith or function(s, n) return s:sub(1, #n) == n end | |
vim.endswith = vim.endswith or function(s, n) return s:sub(-#n) == n end | |
vim.cmd = vim.cmd or vim.api.nvim_command | |
local helpers = {'fn', 'g', 'v', 'o', 'env', 'wo', 'bo'} | |
for _, method in ipairs(helpers) do | |
vim[method] = vim[method] or require('nvim')[method] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; fake clojure for highlighting | |
; vim: ft=clojure | |
(macro take-values [n ...] | |
(assert (and (= :number (type n)) (= n (math.floor n)) (> n 0)) | |
"take-values requires first arg to be n > 0") | |
(local bindings (list)) | |
(for [i 1 n] (tset bindings i (gensym))) | |
`(let [,bindings ,...] (values ,(unpack bindings)))) | |
(foo (take-values 2 (bar))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/sh | |
FNL_LUA="${FNL_LUA:-$(command -v lua)}" | |
FNL_LUAJIT="${FNL_LUAJIT:-$(command -v luajit)}" | |
FNL="${FNL:-$(command -v fennel)}" | |
FNL_EXE=''; | |
function error() { >&2 printf "\u001b[31m%s\n\u001b[0m" "$@"; exit 1; } | |
use_jit=1; | |
args=""; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
## | |
# For this to work, put emojidata.tsv in $HOME/.local/share/myemoji | |
# or set the EMOJI_FILE env var to its local before running. | |
## | |
data_dir="${XDG_DATA_HOME:-$HOME/.local/share}/myemoji" | |
EMOJI_FILE="${EMOJI_FILE:-$data_dir/emojidata.tsv}" | |
tabular() { cat - | column -t -s $'\t'; } | |
firstcol() { awk '{ print $1 }' -; } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; vi: ft=clojure | |
(macro make [receiver classtable ...] | |
`(local ,receiver (doto (class ,(tostring receiver) ,classtable) | |
,...))) | |
; Handler that takes a single argument 'username' | |
(make UserHandler turbo.web.RequestHandler | |
(tset :get (fn [self name] | |
(self:write (.. "Username is " name))))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Based on: https://gist.github.com/XVilka/8346728 | |
awk -v term_cols="${width:-$(tput cols || echo 80)}" 'BEGIN{ | |
s="/\\"; | |
for (colnum = 0; colnum<term_cols; colnum++) { | |
r = 255-(colnum*255/term_cols); | |
g = (colnum*510/term_cols); | |
b = (colnum*255/term_cols); | |
if (g>255) g = 510-g; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# vi:ft=readline | |
set show-all-if-ambiguous On | |
set enable-bracketed-paste On | |
set blink-matching-paren On |