| author | |
| committer | |
| log | fe54e9b0c96de1ab3242a9345f071a8b2b0d301c |
| tree | edadc7ed4858fb54d9366099d92f8dbec99992da |
| parent | 300d20bdeec54d19966d7ac31b93334e540eadb4 |
9 files changed, 260 insertions(+), 32 deletions(-)
.gitignore-1| ... | @@ -1,5 +1,4 @@ | ... | @@ -1,5 +1,4 @@ |
| 1 | flake.lock | 1 | flake.lock |
| 2 | .DS_STORE | 2 | .DS_STORE |
| 3 | **/.DS_STORE | ||
| 4 | result | 3 | result |
| 5 | result-* | 4 | result-* |
files/ghostty/cursor-smear-black.glsl created+114| ... | @@ -0,0 +1,114 @@ | ||
| 1 | float getSdfRectangle(in vec2 p, in vec2 xy, in vec2 b) | ||
| 2 | { | ||
| 3 | vec2 d = abs(p - xy) - b; | ||
| 4 | return length(max(d, 0.0)) + min(max(d.x, d.y), 0.0); | ||
| 5 | } | ||
| 6 | |||
| 7 | // Based on Inigo Quilez's 2D distance functions article: https://iquilezles.org/articles/distfunctions2d/ | ||
| 8 | // Potencially optimized by eliminating conditionals and loops to enhance performance and reduce branching | ||
| 9 | |||
| 10 | float seg(in vec2 p, in vec2 a, in vec2 b, inout float s, float d) { | ||
| 11 | vec2 e = b - a; | ||
| 12 | vec2 w = p - a; | ||
| 13 | vec2 proj = a + e * clamp(dot(w, e) / dot(e, e), 0.0, 1.0); | ||
| 14 | float segd = dot(p - proj, p - proj); | ||
| 15 | d = min(d, segd); | ||
| 16 | |||
| 17 | float c0 = step(0.0, p.y - a.y); | ||
| 18 | float c1 = 1.0 - step(0.0, p.y - b.y); | ||
| 19 | float c2 = 1.0 - step(0.0, e.x * w.y - e.y * w.x); | ||
| 20 | float allCond = c0 * c1 * c2; | ||
| 21 | float noneCond = (1.0 - c0) * (1.0 - c1) * (1.0 - c2); | ||
| 22 | float flip = mix(1.0, -1.0, step(0.5, allCond + noneCond)); | ||
| 23 | s *= flip; | ||
| 24 | return d; | ||
| 25 | } | ||
| 26 | |||
| 27 | float getSdfParallelogram(in vec2 p, in vec2 v0, in vec2 v1, in vec2 v2, in vec2 v3) { | ||
| 28 | float s = 1.0; | ||
| 29 | float d = dot(p - v0, p - v0); | ||
| 30 | |||
| 31 | d = seg(p, v0, v3, s, d); | ||
| 32 | d = seg(p, v1, v0, s, d); | ||
| 33 | d = seg(p, v2, v1, s, d); | ||
| 34 | d = seg(p, v3, v2, s, d); | ||
| 35 | |||
| 36 | return s * sqrt(d); | ||
| 37 | } | ||
| 38 | |||
| 39 | vec2 normalize(vec2 value, float isPosition) { | ||
| 40 | return (value * 2.0 - (iResolution.xy * isPosition)) / iResolution.y; | ||
| 41 | } | ||
| 42 | |||
| 43 | float antialising(float distance) { | ||
| 44 | return 1. - smoothstep(0., normalize(vec2(2., 2.), 0.).x, distance); | ||
| 45 | } | ||
| 46 | |||
| 47 | float determineStartVertexFactor(vec2 a, vec2 b) { | ||
| 48 | // Conditions using step | ||
| 49 | float condition1 = step(b.x, a.x) * step(a.y, b.y); // a.x < b.x && a.y > b.y | ||
| 50 | float condition2 = step(a.x, b.x) * step(b.y, a.y); // a.x > b.x && a.y < b.y | ||
| 51 | |||
| 52 | // If neither condition is met, return 1 (else case) | ||
| 53 | return 1.0 - max(condition1, condition2); | ||
| 54 | } | ||
| 55 | |||
| 56 | vec2 getRectangleCenter(vec4 rectangle) { | ||
| 57 | return vec2(rectangle.x + (rectangle.z / 2.), rectangle.y - (rectangle.w / 2.)); | ||
| 58 | } | ||
| 59 | float ease(float x) { | ||
| 60 | return pow(1.0 - x, 3.0); | ||
| 61 | } | ||
| 62 | |||
| 63 | const vec4 TRAIL_COLOR = vec4(0.0, 0.2, 0.5, 0.1); | ||
| 64 | const float DURATION = 0.15; //IN SECONDS | ||
| 65 | |||
| 66 | void mainImage(out vec4 fragColor, in vec2 fragCoord) | ||
| 67 | { | ||
| 68 | #if !defined(WEB) | ||
| 69 | fragColor = texture(iChannel0, fragCoord.xy / iResolution.xy); | ||
| 70 | #endif | ||
| 71 | // Normalization for fragCoord to a space of -1 to 1; | ||
| 72 | vec2 vu = normalize(fragCoord, 1.); | ||
| 73 | vec2 offsetFactor = vec2(-.5, 0.5); | ||
| 74 | |||
| 75 | // Normalization for cursor position and size; | ||
| 76 | // cursor xy has the postion in a space of -1 to 1; | ||
| 77 | // zw has the width and height | ||
| 78 | vec4 currentCursor = vec4(normalize(iCurrentCursor.xy, 1.), normalize(iCurrentCursor.zw, 0.)); | ||
| 79 | vec4 previousCursor = vec4(normalize(iPreviousCursor.xy, 1.), normalize(iPreviousCursor.zw, 0.)); | ||
| 80 | |||
| 81 | // When drawing a parellelogram between cursors for the trail i need to determine where to start at the top-left or top-right vertex of the cursor | ||
| 82 | float vertexFactor = determineStartVertexFactor(currentCursor.xy, previousCursor.xy); | ||
| 83 | float invertedVertexFactor = 1.0 - vertexFactor; | ||
| 84 | |||
| 85 | // Set every vertex of my parellogram | ||
| 86 | vec2 v0 = vec2(currentCursor.x + currentCursor.z * vertexFactor, currentCursor.y - currentCursor.w); | ||
| 87 | vec2 v1 = vec2(currentCursor.x + currentCursor.z * invertedVertexFactor, currentCursor.y); | ||
| 88 | vec2 v2 = vec2(previousCursor.x + currentCursor.z * invertedVertexFactor, previousCursor.y); | ||
| 89 | vec2 v3 = vec2(previousCursor.x + currentCursor.z * vertexFactor, previousCursor.y - previousCursor.w); | ||
| 90 | |||
| 91 | float sdfCurrentCursor = getSdfRectangle(vu, currentCursor.xy - (currentCursor.zw * offsetFactor), currentCursor.zw * 0.5); | ||
| 92 | float sdfTrail = getSdfParallelogram(vu, v0, v1, v2, v3); | ||
| 93 | |||
| 94 | float progress = clamp((iTime - iTimeCursorChange) / DURATION, 0.0, 1.0); | ||
| 95 | float easedProgress = ease(progress); | ||
| 96 | // Distance between cursors determine the total length of the parallelogram; | ||
| 97 | vec2 centerCC = getRectangleCenter(currentCursor); | ||
| 98 | vec2 centerCP = getRectangleCenter(previousCursor); | ||
| 99 | float lineLength = distance(centerCC, centerCP); | ||
| 100 | |||
| 101 | vec4 newColor = vec4(fragColor); | ||
| 102 | // Compute fade factor based on distance along the trail | ||
| 103 | float fadeFactor = 1.0 - smoothstep(lineLength, sdfCurrentCursor, easedProgress * lineLength); | ||
| 104 | |||
| 105 | // Apply fading effect to trail color | ||
| 106 | vec4 fadedTrailColor = TRAIL_COLOR * fadeFactor; | ||
| 107 | |||
| 108 | // Blend trail with fade effect | ||
| 109 | newColor = mix(newColor, fadedTrailColor, antialising(sdfTrail)); | ||
| 110 | // Draw current cursor | ||
| 111 | newColor = mix(newColor, TRAIL_COLOR, antialising(sdfCurrentCursor)); | ||
| 112 | newColor = mix(newColor, fragColor, step(sdfCurrentCursor, 0.)); | ||
| 113 | fragColor = mix(fragColor, newColor, step(sdfCurrentCursor, easedProgress * lineLength)); | ||
| 114 | } | ||
files/ghostty/cursor-smear-blue.glsl created+114| ... | @@ -0,0 +1,114 @@ | ||
| 1 | float getSdfRectangle(in vec2 p, in vec2 xy, in vec2 b) | ||
| 2 | { | ||
| 3 | vec2 d = abs(p - xy) - b; | ||
| 4 | return length(max(d, 0.0)) + min(max(d.x, d.y), 0.0); | ||
| 5 | } | ||
| 6 | |||
| 7 | // Based on Inigo Quilez's 2D distance functions article: https://iquilezles.org/articles/distfunctions2d/ | ||
| 8 | // Potencially optimized by eliminating conditionals and loops to enhance performance and reduce branching | ||
| 9 | |||
| 10 | float seg(in vec2 p, in vec2 a, in vec2 b, inout float s, float d) { | ||
| 11 | vec2 e = b - a; | ||
| 12 | vec2 w = p - a; | ||
| 13 | vec2 proj = a + e * clamp(dot(w, e) / dot(e, e), 0.0, 1.0); | ||
| 14 | float segd = dot(p - proj, p - proj); | ||
| 15 | d = min(d, segd); | ||
| 16 | |||
| 17 | float c0 = step(0.0, p.y - a.y); | ||
| 18 | float c1 = 1.0 - step(0.0, p.y - b.y); | ||
| 19 | float c2 = 1.0 - step(0.0, e.x * w.y - e.y * w.x); | ||
| 20 | float allCond = c0 * c1 * c2; | ||
| 21 | float noneCond = (1.0 - c0) * (1.0 - c1) * (1.0 - c2); | ||
| 22 | float flip = mix(1.0, -1.0, step(0.5, allCond + noneCond)); | ||
| 23 | s *= flip; | ||
| 24 | return d; | ||
| 25 | } | ||
| 26 | |||
| 27 | float getSdfParallelogram(in vec2 p, in vec2 v0, in vec2 v1, in vec2 v2, in vec2 v3) { | ||
| 28 | float s = 1.0; | ||
| 29 | float d = dot(p - v0, p - v0); | ||
| 30 | |||
| 31 | d = seg(p, v0, v3, s, d); | ||
| 32 | d = seg(p, v1, v0, s, d); | ||
| 33 | d = seg(p, v2, v1, s, d); | ||
| 34 | d = seg(p, v3, v2, s, d); | ||
| 35 | |||
| 36 | return s * sqrt(d); | ||
| 37 | } | ||
| 38 | |||
| 39 | vec2 normalize(vec2 value, float isPosition) { | ||
| 40 | return (value * 2.0 - (iResolution.xy * isPosition)) / iResolution.y; | ||
| 41 | } | ||
| 42 | |||
| 43 | float antialising(float distance) { | ||
| 44 | return 1. - smoothstep(0., normalize(vec2(2., 2.), 0.).x, distance); | ||
| 45 | } | ||
| 46 | |||
| 47 | float determineStartVertexFactor(vec2 a, vec2 b) { | ||
| 48 | // Conditions using step | ||
| 49 | float condition1 = step(b.x, a.x) * step(a.y, b.y); // a.x < b.x && a.y > b.y | ||
| 50 | float condition2 = step(a.x, b.x) * step(b.y, a.y); // a.x > b.x && a.y < b.y | ||
| 51 | |||
| 52 | // If neither condition is met, return 1 (else case) | ||
| 53 | return 1.0 - max(condition1, condition2); | ||
| 54 | } | ||
| 55 | |||
| 56 | vec2 getRectangleCenter(vec4 rectangle) { | ||
| 57 | return vec2(rectangle.x + (rectangle.z / 2.), rectangle.y - (rectangle.w / 2.)); | ||
| 58 | } | ||
| 59 | float ease(float x) { | ||
| 60 | return pow(1.0 - x, 3.0); | ||
| 61 | } | ||
| 62 | |||
| 63 | const vec4 TRAIL_COLOR = vec4(0.8, 1.0, 1.0, 0.1); | ||
| 64 | const float DURATION = 0.1; //IN SECONDS | ||
| 65 | |||
| 66 | void mainImage(out vec4 fragColor, in vec2 fragCoord) | ||
| 67 | { | ||
| 68 | #if !defined(WEB) | ||
| 69 | fragColor = texture(iChannel0, fragCoord.xy / iResolution.xy); | ||
| 70 | #endif | ||
| 71 | // Normalization for fragCoord to a space of -1 to 1; | ||
| 72 | vec2 vu = normalize(fragCoord, 1.); | ||
| 73 | vec2 offsetFactor = vec2(-.5, 0.5); | ||
| 74 | |||
| 75 | // Normalization for cursor position and size; | ||
| 76 | // cursor xy has the postion in a space of -1 to 1; | ||
| 77 | // zw has the width and height | ||
| 78 | vec4 currentCursor = vec4(normalize(iCurrentCursor.xy, 1.), normalize(iCurrentCursor.zw, 0.)); | ||
| 79 | vec4 previousCursor = vec4(normalize(iPreviousCursor.xy, 1.), normalize(iPreviousCursor.zw, 0.)); | ||
| 80 | |||
| 81 | // When drawing a parellelogram between cursors for the trail i need to determine where to start at the top-left or top-right vertex of the cursor | ||
| 82 | float vertexFactor = determineStartVertexFactor(currentCursor.xy, previousCursor.xy); | ||
| 83 | float invertedVertexFactor = 1.0 - vertexFactor; | ||
| 84 | |||
| 85 | // Set every vertex of my parellogram | ||
| 86 | vec2 v0 = vec2(currentCursor.x + currentCursor.z * vertexFactor, currentCursor.y - currentCursor.w); | ||
| 87 | vec2 v1 = vec2(currentCursor.x + currentCursor.z * invertedVertexFactor, currentCursor.y); | ||
| 88 | vec2 v2 = vec2(previousCursor.x + currentCursor.z * invertedVertexFactor, previousCursor.y); | ||
| 89 | vec2 v3 = vec2(previousCursor.x + currentCursor.z * vertexFactor, previousCursor.y - previousCursor.w); | ||
| 90 | |||
| 91 | float sdfCurrentCursor = getSdfRectangle(vu, currentCursor.xy - (currentCursor.zw * offsetFactor), currentCursor.zw * 0.5); | ||
| 92 | float sdfTrail = getSdfParallelogram(vu, v0, v1, v2, v3); | ||
| 93 | |||
| 94 | float progress = clamp((iTime - iTimeCursorChange) / DURATION, 0.0, 1.0); | ||
| 95 | float easedProgress = ease(progress); | ||
| 96 | // Distance between cursors determine the total length of the parallelogram; | ||
| 97 | vec2 centerCC = getRectangleCenter(currentCursor); | ||
| 98 | vec2 centerCP = getRectangleCenter(previousCursor); | ||
| 99 | float lineLength = distance(centerCC, centerCP); | ||
| 100 | |||
| 101 | vec4 newColor = vec4(fragColor); | ||
| 102 | // Compute fade factor based on distance along the trail | ||
| 103 | float fadeFactor = 1.0 - smoothstep(lineLength, sdfCurrentCursor, easedProgress * lineLength); | ||
| 104 | |||
| 105 | // Apply fading effect to trail color | ||
| 106 | vec4 fadedTrailColor = TRAIL_COLOR * fadeFactor; | ||
| 107 | |||
| 108 | // Blend trail with fade effect | ||
| 109 | newColor = mix(newColor, fadedTrailColor, antialising(sdfTrail)); | ||
| 110 | // Draw current cursor | ||
| 111 | newColor = mix(newColor, TRAIL_COLOR, antialising(sdfCurrentCursor)); | ||
| 112 | newColor = mix(newColor, fragColor, step(sdfCurrentCursor, 0.)); | ||
| 113 | fragColor = mix(fragColor, newColor, step(sdfCurrentCursor, easedProgress * lineLength)); | ||
| 114 | } | ||
modules/home/default.nix+12-1| ... | @@ -16,7 +16,14 @@ in | ... | @@ -16,7 +16,14 @@ in |
| 16 | imports = mainHomeImports ++ [ | 16 | imports = mainHomeImports ++ [ |
| 17 | ./macos/sketchybar.nix | 17 | ./macos/sketchybar.nix |
| 18 | ]; | 18 | ]; |
| 19 | programs = { | 19 | options = { |
| 20 | programs.ghostty.shader = lib.mkOption { | ||
| 21 | type = lib.types.str; | ||
| 22 | default = { }; | ||
| 23 | description = "set the ghostty shader, relative to 'files/ghostty'"; | ||
| 24 | }; | ||
| 25 | }; | ||
| 26 | config.programs = { | ||
| 20 | home-manager.enable = true; | 27 | home-manager.enable = true; |
| 21 | nix-index.enable = true; | 28 | nix-index.enable = true; |
| 22 | 29 | ||
| ... | @@ -89,5 +96,9 @@ in | ... | @@ -89,5 +96,9 @@ in |
| 89 | test -r '/Users/${user.username}/.opam/opam-init/init.fish' && source '/Users/${user.username}/.opam/opam-init/init.fish' > /dev/null 2> /dev/null; or true | 96 | test -r '/Users/${user.username}/.opam/opam-init/init.fish' && source '/Users/${user.username}/.opam/opam-init/init.fish' > /dev/null 2> /dev/null; or true |
| 90 | ''; | 97 | ''; |
| 91 | }; | 98 | }; |
| 99 | |||
| 100 | ghostty.settings.custom-shader = lib.mkIf ( | ||
| 101 | cfg.ghostty.shader != null | ||
| 102 | ) "${../../files/ghostty}/${cfg.ghostty.shader}"; | ||
| 92 | }; | 103 | }; |
| 93 | } | 104 | } |
modules/macos/default.nix-1| ... | @@ -1,5 +1,4 @@ | ... | @@ -1,5 +1,4 @@ |
| 1 | { | 1 | { |
| 2 | pkgs, | ||
| 3 | lib, | 2 | lib, |
| 4 | ... | 3 | ... |
| 5 | }: | 4 | }: |
modules/neovim/default.nix-21| ... | @@ -184,17 +184,9 @@ | ... | @@ -184,17 +184,9 @@ |
| 184 | }; | 184 | }; |
| 185 | }; | 185 | }; |
| 186 | }; | 186 | }; |
| 187 | |||
| 188 | binds = { | 187 | binds = { |
| 189 | whichKey.enable = true; | 188 | whichKey.enable = true; |
| 190 | cheatsheet.enable = true; | 189 | cheatsheet.enable = true; |
| 191 | # discourages bad keyboard habit, e.g. disables arrow keys, explains better binds | ||
| 192 | # https://github.com/m4xshen/hardtime.nvim | ||
| 193 | hardtime-nvim.enable = true; | ||
| 194 | hardtime-nvim.setupOpts = { | ||
| 195 | disable_mouse = false; | ||
| 196 | restriction_mode = "hint"; # default behavior is lenient | ||
| 197 | }; | ||
| 198 | }; | 190 | }; |
| 199 | ui = { | 191 | ui = { |
| 200 | borders.enable = true; | 192 | borders.enable = true; |
| ... | @@ -206,19 +198,6 @@ | ... | @@ -206,19 +198,6 @@ |
| 206 | enable = false; | 198 | enable = false; |
| 207 | navbuddy.enable = config.vim.ui.breadcrumbs.enable; | 199 | navbuddy.enable = config.vim.ui.breadcrumbs.enable; |
| 208 | }; | 200 | }; |
| 209 | smartcolumn = { | ||
| 210 | enable = true; | ||
| 211 | setupOpts.custom_colorcolumn = { | ||
| 212 | # this is a freeform module, it's `buftype = int;` for configuring column position | ||
| 213 | nix = "110"; | ||
| 214 | ruby = "120"; | ||
| 215 | java = "130"; | ||
| 216 | go = [ | ||
| 217 | "90" | ||
| 218 | "130" | ||
| 219 | ]; | ||
| 220 | }; | ||
| 221 | }; | ||
| 222 | }; | 201 | }; |
| 223 | notes = { | 202 | notes = { |
| 224 | todo-comments.enable = true; | 203 | todo-comments.enable = true; |
users/chloe/configuration.nix+2| ... | @@ -6,6 +6,8 @@ | ... | @@ -6,6 +6,8 @@ |
| 6 | git | 6 | git |
| 7 | ]; | 7 | ]; |
| 8 | 8 | ||
| 9 | services.tailscale.enable = true; | ||
| 10 | |||
| 9 | # configuration for shared modules. | 11 | # configuration for shared modules. |
| 10 | # all custom options in 'shared' for clarity. | 12 | # all custom options in 'shared' for clarity. |
| 11 | shared.darwin = { | 13 | shared.darwin = { |
users/chloe/home.nix+18-2| ... | @@ -10,7 +10,9 @@ in | ... | @@ -10,7 +10,9 @@ in |
| 10 | let | 10 | let |
| 11 | # packages to always install | 11 | # packages to always install |
| 12 | all = [ | 12 | all = [ |
| 13 | ffmpeg | 13 | (ffmpeg.override { |
| 14 | withSvtav1 = true; | ||
| 15 | }) | ||
| 14 | ripgrep | 16 | ripgrep |
| 15 | uv | 17 | uv |
| 16 | nh | 18 | nh |
| ... | @@ -33,12 +35,26 @@ in | ... | @@ -33,12 +35,26 @@ in |
| 33 | }; | 35 | }; |
| 34 | programs = { | 36 | programs = { |
| 35 | # sort-lines:start | 37 | # sort-lines:start |
| 36 | bat.enable = true; | 38 | # bat.enable = true; |
| 37 | btop.enable = true; | 39 | btop.enable = true; |
| 38 | fd.enable = true; | 40 | fd.enable = true; |
| 39 | hyfetch.enable = true; | 41 | hyfetch.enable = true; |
| 40 | # sort-lines:end | 42 | # sort-lines:end |
| 41 | 43 | ||
| 44 | ghostty = { | ||
| 45 | enable = true; | ||
| 46 | shader = "cursor-smear-black.glsl"; | ||
| 47 | package = null; | ||
| 48 | settings = { | ||
| 49 | theme = "catppuccin-latte"; | ||
| 50 | font-family = "AT Name Mono"; | ||
| 51 | adjust-cursor-thickness = 1; | ||
| 52 | minimum-contrast = 1.1; | ||
| 53 | background-opacity = 0.9; | ||
| 54 | background-blur = true; | ||
| 55 | }; | ||
| 56 | }; | ||
| 57 | |||
| 42 | # zsh is the shell i use | 58 | # zsh is the shell i use |
| 43 | zsh = { | 59 | zsh = { |
| 44 | enable = true; | 60 | enable = true; |
users/chloe/vim.nix-6| ... | @@ -14,12 +14,6 @@ _: { | ... | @@ -14,12 +14,6 @@ _: { |
| 14 | foldenable = true; | 14 | foldenable = true; |
| 15 | linebreak = true; | 15 | linebreak = true; |
| 16 | }; | 16 | }; |
| 17 | binds = { | ||
| 18 | hardtime-nvim.setupOpts = { | ||
| 19 | restriction_mode = "block"; | ||
| 20 | disable_mouse = false; | ||
| 21 | }; | ||
| 22 | }; | ||
| 23 | git = { | 17 | git = { |
| 24 | gitsigns.setupOpts = { | 18 | gitsigns.setupOpts = { |
| 25 | current_line_blame = true; | 19 | current_line_blame = true; |