Skip to content

Instantly share code, notes, and snippets.

View echasnovski's full-sized avatar

Evgeni Chasnovski echasnovski

View GitHub Profile
@echasnovski
echasnovski / neovim-default-colorscheme.lua
Created November 30, 2023 17:03
Experimentation script for the new Neovim color scheme
-- Code for tweaking new default Neovim color scheme for PR #?????
-- It defines an overall look based on a handful of hyperparameters.
--
-- General goals:
-- - Be "Neovim branded", i.e. follow outlined example from
-- https://github.com/neovim/neovim/issues/14790
-- That generally means to mostly have "green-blue" feel plus at least one
-- reserved for very occasional attention: red for severe, yellow for mild.
-- - Be extra minimal for `notermguicolors` while allowing more shades for
-- when `termguicolors` is set.
@echasnovski
echasnovski / average_dark.lua
Created April 24, 2023 13:32
Experiment with computing "average popular Neovim color scheme"
-- Made with 'mini.colors' module of https://github.com/echasnovski/mini.nvim
if vim.g.colors_name ~= nil then vim.cmd('highlight clear') end
vim.g.colors_name = "average_dark"
-- Highlight groups
local hi = vim.api.nvim_set_hl
hi(0, "@constant.builtin", { ctermfg = 146, fg = "#8ebbd3" })
hi(0, "@constructor", { ctermfg = 110, fg = "#7fbce4" })
@echasnovski
echasnovski / neovim-survey-summary_00_description.md
Last active May 22, 2023 17:28
Results of Neovim built-in options survey

This Gist contains results of Neovim built-in options survey. Users were asked to execute certain script (see 'neovim-survey_script.lua') and upload text it produced (comma-separated table of all options which differ from default, plus neovim version and leader key).

There were total 227 legible answers provided for period from 2022-11-22 to 2022-12-08.

Here is a link to Reddit announcement

File description:

@echasnovski
echasnovski / neovim-options-survey.lua
Created November 22, 2022 12:48
Source code of script used for "Neovim built-in options survey"
-- Get Neovim version
local version = vim.version()
if version.major == 0 and version.minor < 7 then error('This script needs at least Neovim 0.7.') end
-- Create scratch buffer to better track options and paste output lines
local buf_id = vim.api.nvim_create_buf(true, true)
vim.api.nvim_set_current_buf(buf_id)
-- Define "bad" (non-transferable) options
--stylua: ignore
@echasnovski
echasnovski / random-colorscheme.lua
Created September 9, 2022 09:42
Create and apply randomly generated Base16 color scheme
-- Create and apply randomly generated Base16 color scheme
--
-- Prerequisites:
-- - Install 'mini.nvim' (https://github.com/echasnovski/mini.nvim).
-- - Put code inside a Lua file (like '~/.config/nvim/random-colorscheme.lua').
-- - Source that file. Either with `:source <file path>` or with
-- `require('<module name>')` (if put inside 'lua' subdirectory of your
-- config; won't work more than once due to caching).
-- General idea:
@echasnovski
echasnovski / collapse_simple_statement_ConditionalOnly.diff
Last active July 6, 2022 07:28
'mini.nvim' diffs of running different `stylua` values of possibly new "collapse_simple_statement" option.
diff --git a/.stylua.toml b/.stylua.toml
index 6601564..b865102 100644
--- a/.stylua.toml
+++ b/.stylua.toml
@@ -4,3 +4,4 @@ indent_type = "Spaces"
indent_width = 2
quote_style = "AutoPreferSingle"
no_call_parentheses = false
+collapse_simple_statement = "ConditionalOnly"
diff --git a/lua/mini/base16.lua b/lua/mini/base16.lua
@echasnovski
echasnovski / startup-summary.md
Created November 15, 2021 18:43
Outputs of 'benchmarks/starter/' directory of 'echasnovski/mini.nvim' repository
init file median mean stdev minimum maximum
starter-default 69.0ms 70.8ms 4.3ms 63.6ms 82.7ms
empty 64.1ms 65.8ms 4.3ms 60.0ms 79.4ms
startify-starter 70.2ms 71.9ms 4.5ms 64.3ms 85.7ms
startify-original 80.3ms 82.2ms 4.5ms 76.4ms 107.2ms
startify-alpha 72.1ms 73.8ms 4.3ms 66.5ms 86.9ms
dashboard-starter 68.4ms 70.3ms 4.5ms 63.3ms 102.9ms
dashboard-original 70.6ms 72.3ms 4.4ms 65.5ms 99.6ms
dashboard-alpha 69.8ms 71.5ms 4.4ms 64.7ms 97.2ms
@echasnovski
echasnovski / CycleSample.py
Created April 25, 2020 10:58
Simple class for doing "cycled sampling": iterative sampling when currently sampled element is put in the beginning of sampling pool.
import random
# Used only for exploration
import numpy as np
class CycleSample:
def __init__(self, x, weights=None, preshuffle=True):
self.pool = list(x)
if preshuffle:
@echasnovski
echasnovski / python-snippets-from-r.py
Last active June 17, 2020 10:18
Python snippets to mimic functionality of common R functions (mostly tidyverse)
import numpy as np
import pandas as pd
def nest(df, cols, nest_name="data", keep=False):
"""Nest non-grouping columns into a list-column of data frames
Parameters
----------
df : Data frame.
@echasnovski
echasnovski / geom_parallel_slopes.R
Last active October 29, 2019 14:18
Draft of `geom_parallel_slopes()` for {moderndive} package
library(tidyverse)
# Geom creation -----------------------------------------------------------
StatParallelSlopes <- ggproto(
"StatParallelSlopes", Stat,
required_aes = c("x", "y"),
compute_panel = function(data, scales, se = TRUE, formula = y ~ x, n = 100) {