Standard escape codes are prefixed with Escape
:
- Ctrl-Key:
^[
- Octal:
\033
- Unicode:
\u001b
- Hexadecimal:
\x1B
- Decimal:
27
---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) |
import Control.Applicative (Alternative) | |
import Control.Monad | |
import GHC.Base (Alternative (empty, (<|>))) | |
-- Proving that Option is a Functor, a Monad, an Applicative and more! | |
data Option a = Some a | None | |
deriving (Show, Eq) | |
-- 1. it is a functor! (surprise) |
-- THIS IS DEPRECATED, USE THE FILE BELOW | |
-- should get bufnr from autocmd or something | |
-- conceal only accepts one character | |
-- thanks to u/Rafat913 for many suggestions and tips | |
local namespace = vim.api.nvim_create_namespace("class_conceal") | |
local group = vim.api.nvim_create_augroup("class_conceal", { clear = true }) | |
local conceal_html_class = function(bufnr) |
scriptencoding utf-8 | |
" This function originates from https://www.reddit.com/r/neovim/comments/eq1xpt/how_open_help_in_floating_windows/; it isn't mine | |
function! CreateCenteredFloatingWindow() abort | |
let width = min([&columns - 4, max([80, &columns - 20])]) | |
let height = min([&lines - 4, max([20, &lines - 10])]) | |
let top = ((&lines - height) / 2) - 1 | |
let left = (&columns - width) / 2 | |
let opts = {'relative': 'editor', 'row': top, 'col': left, 'width': width, 'height': height, 'style': 'minimal'} |
;;; The Y Combinator explained in scheme. | |
;;; with credits to: | |
;;; https://mvanier.livejournal.com/2897.html | |
;;; Status: WIP | |
(define fibonacci | |
(lambda (n) | |
(cond ((= n 0) 0) | |
((= n 1) 1) | |
(else (+ (fibonacci (- n 1)) (fibonacci (- n 2))))))) |
type StringBool = "true"|"false";
interface AnyNumber { prev?: any, isZero: StringBool };
interface PositiveNumber { prev: any, isZero: "false" };
type IsZero<TNumber extends AnyNumber> = TNumber["isZero"];
type Next<TNumber extends AnyNumber> = { prev: TNumber, isZero: "false" };
type Prev<TNumber extends PositiveNumber> = TNumber["prev"];
<script> | |
// A minimal polyfill for copying text to clipboard that works most of the time in most capable browsers. | |
// Note that: | |
// - You may not need this. `navigator.clipboard.writeText()` works directly in all modern browsers as of 2020. | |
// - In Edge, this may call `resolve()` even if copying failed. | |
// - In Safari, this may fail if there is nothing selected on the page. | |
// See https://github.com/lgarron/clipboard-polyfill for a more robust solution. | |
// | |
// License for this Gist: public domain / Unlicense | |
function writeText(str) { |