Skip to content

Instantly share code, notes, and snippets.

View towry's full-sized avatar
🎯
Focusing

Towry Wang towry

🎯
Focusing
View GitHub Profile
@towry
towry / cursorrule.md
Last active May 27, 2025 07:25
Towry's cursor rules
  • Do not add sensitive information about the user or the user's machine to the code or comments
  • Break down large tasks into smaller steps. After completing each step, verify it works before continuing. Do not attempt to complete the entire task in one pass without intermediate validation.
  • Prefer rg or fd command when grepping file content or searching for files
  • Before running a package manager in the project, please detect which package manager is currently being used, like npm or pnpm
  • You can run killport to kill the process that owns a port
  • Follow the DRY coding rule
  • Never use a variable or method that you are not sure exists
  • Do not change the implementation to satisfy the tests
  • Avoid deduplicating mock logic in tests; reimplement when needed to preserve clarity
  • Consider the impact of changes across the module or file
thread 5400255 panic: unhandled error
/Users/towry/workspace/git-repos/ghostty/pkg/apple-sdk/build.zig:43:41: 0x104e23be7 in addPaths (build)
const path = gop.value_ptr.* orelse return switch (target.os.tag) {
^
/Users/towry/workspace/git-repos/ghostty/pkg/libpng/build.zig:20:9: 0x104fd3213 in build (build)
try apple_sdk.addPaths(b, &lib.root_module);
^
/nix/store/fmknjb4j68rnyx60wm8x7zkpamcwdck5-zig-0.13.0/lib/std/Build.zig:2117:24: 0x104f15e6b in runBuild__anon_19560 (build)
.ErrorUnion => try build_zig.build(b),
^
@towry
towry / neo-tree-buffers-switcher.lua
Created July 23, 2024 01:18
use neo-tree buffers to switch buffers
--- depends: folke/flash.nvim
return {
"nvim-neo-tree/neo-tree.nvim",
opts = {
sources = { "filesystem", "buffers" },
source_selector = {
sources = {
{ source = "filesystem", display_name = " File" },
{ source = "buffers", display_name = " Buffers" },
},
#[derive(Debug)]
enum AnyValue {
String(String),
Number(i64),
}
// let a: &'str = convert(&value)
// let b: i64 = convert(&value)
commit ee66f4d2aa9c5361f8d07ec700fba45cf2238bf9
Author: Towry <[email protected]>
Date: Sun Jan 7 09:18:18 2024 +0800
change wilmode
diff --git a/lua/user/config/options.lua b/lua/user/config/options.lua
index 058e439..2700c0d 100644
--- a/lua/user/config/options.lua
+++ b/lua/user/config/options.lua
@towry
towry / wt.fish
Created December 8, 2023 06:18
quickly switch between git workspace folders.
# put this fish function in your fish config.
#
# usage:
# ~:> wt
# or
# ~:> wt path_or_branch_keyword
function wt
set worktree (git worktree list | awk '{print $1, $NF}' | awk -v home="$HOME" '{sub(home, "~"); print $1, $NF}' | fzf --exact --reverse -1 -0 --query=$argv[1] | awk '{print $1}')
if test -n "$worktree"
@towry
towry / doc.md
Last active September 12, 2023 09:19
cd /tmp
# wait treesitter#main setup
nvim --clean -u slow-ts.lua
# exit nvim
# edit test.vue file
nvim --clean -u slow-ts.lua test.vue

steps

@towry
towry / repro.lua
Last active July 16, 2023 03:00
`nvim -u init.lua` to reproduce some neovim plugin repo issue.
vim.g.mapleader = ' '
local root = vim.fn.fnamemodify('./.repro', ':p')
-- set stdpaths to use .repro
for _, name in ipairs({ 'config', 'data', 'state', 'cache' }) do
vim.env[('XDG_%s_HOME'):format(name:upper())] = root .. '/' .. name
end
-- bootstrap lazy
@towry
towry / color_mode.py
Last active March 28, 2025 09:48
macos auto dark mode with kitty+tmux+neovim. read order: install_dark_mode_notify.sh -> ke.bou.dark-mode-notify.plist -> dark_mode_changed.sh -> color_mode.py | YOU NEED TO CHANGE SOME PATH&VARIABLE to make this work.
#!/usr/bin/env python3
import os
import sys
import subprocess
# author: https://github.com/olimorris/dotfiles/blob/main/commands/color_mode.py
kitty_path = "~/.config/kitty"
# starship_path = "~/.config/starship"
This file has been truncated, but you can view the full file.
[{"tid":1,"pid":1,"args":{"n":2,"1":"getbufinfo"},"cat":"function","name":"vim.shared.call","ph":"X","ts":149.235,"dur":34.906},
{"tid":1,"pid":1,"args":{"n":2,"1":"getbufinfo"},"cat":"function","name":"vim.call","ph":"X","ts":143.483,"dur":42.05},
{"tid":1,"pid":1,"args":{"n":2,"1":"getbufinfo"},"cat":"function","name":"vim._editor.call","ph":"X","ts":136.537,"dur":50.048},
{"tid":1,"pid":1,"cat":"function","name":"bufferline.utils.get_buf_count","ph":"X","ts":125.179,"dur":62.234},
{"tid":1,"pid":1,"args":{"n":2,"1":"showtabline"},"cat":"function","name":"vim.api.nvim_get_option_value","ph":"X","ts":191.461,"dur":2.111},
{"tid":1,"pid":1,"cat":"function","name":"bufferline.config.get","ph":"X","ts":195.362,"dur":0.58199999999999},
{"tid":1,"pid":1,"cat":"function","name":"vim.api.nvim_list_bufs","ph":"X","ts":209.087,"dur":1.213},
{"tid":1,"pid":1,"args":{"1":"c"},"cat":"function","name":"vim.shared.is_callable","ph":"X","ts":238.177,"dur":2.956},
{"tid":1,"pid":1,"args":{"1":"c"},"cat":"function","name":"v