├── docs ├── anki.md ├── img │ ├── key.png │ ├── debug.png │ ├── comment.png │ ├── outline.png │ ├── overview.png │ ├── snippet.png │ ├── checkhealth.png │ ├── code-runner.png │ ├── autocomplete.png │ ├── search-files.png │ ├── outline-symbols.png │ └── workspace-symbols.png ├── nvim-plugin.md ├── nvim-bug.md ├── zellij.md ├── nvim-tab.md ├── tig.md ├── nix-kernel-dev.md ├── terminals.md ├── ccls-vs-clangd.md ├── tmux.md └── rime.md ├── config ├── npmrc ├── cargo.toml ├── zellij │ ├── default.kdl │ ├── code.kdl │ ├── solarized-dark.kdl │ ├── the-default.kdl │ ├── docs.kdl │ └── default.swap.kdl.bak ├── kitty │ ├── session.conf │ └── kitty.conf ├── sh │ ├── tmux.sh │ ├── wez-opacity.sh │ └── test.c ├── tmux-code.yaml ├── tmux-note.yaml ├── tmux-note-private.yaml ├── windows │ ├── install.ps1 │ └── pwsh.ps1 ├── zathurarc ├── wtf.yml ├── nix.conf ├── gnome-terminal.conf ├── gdbinit ├── gitui │ ├── theme.ron │ └── key_bindings.ron ├── pueue.yml ├── alacritty.toml ├── gitconfig ├── starship.toml ├── atuin.toml ├── tigrc.conf ├── tmux.conf ├── zsh └── proxychain.conf ├── nvim ├── lsp │ ├── efm.lua │ ├── clangd.lua │ ├── nixd.lua │ ├── pyright.lua │ ├── ccls.lua │ └── lua_ls.lua ├── lua │ └── usr │ │ ├── neovide.lua │ │ ├── colorscheme.lua │ │ ├── version.lua │ │ ├── bufferline.lua │ │ ├── hydra.lua │ │ ├── lualine.lua │ │ ├── code_runner.lua │ │ ├── nvim-treesitter.lua │ │ ├── mason.lua │ │ ├── orgmode.lua │ │ ├── telescope.lua │ │ ├── init.lua │ │ ├── nvim-tree.lua │ │ ├── toggleterm.lua │ │ ├── options.lua │ │ ├── cmp.lua │ │ └── util.lua ├── snippets │ ├── cpp.snippets │ ├── markdown.snippets │ └── c.snippets ├── efm.yaml └── init.vim ├── rime ├── double_pinyin_flypy.custom.yaml ├── default.custom.yaml ├── luna_pinyin.martins3.dict.yaml ├── luna_pinyin.my_words.dict.yaml ├── luna_pinyin_simp.custom.yaml └── linux-install.sh ├── _config.yml ├── .github └── ISSUE_TEMPLATE │ ├── i-have-a-question.md │ ├── feature_request.md │ └── it-doesn-t-work-for-me.md ├── scripts ├── lint-md.sh ├── nix │ ├── env │ │ ├── bcc.nix │ │ ├── gnuefi.nix │ │ ├── oomd.nix │ │ ├── rime.nix │ │ ├── mdadm.nix │ │ ├── shim.nix │ │ ├── ublksrv.nix │ │ ├── crash.nix │ │ ├── glibc.nix │ │ ├── edk2.nix │ │ ├── numactl.nix │ │ ├── static.nix │ │ ├── fio.nix │ │ ├── systemd.nix │ │ ├── dpdk.nix │ │ ├── util-linux.nix │ │ ├── busybox.nix │ │ ├── libiscsi.nix │ │ ├── grub.nix │ │ ├── c.nix │ │ ├── llvm.nix │ │ ├── rdma.nix │ │ ├── qemu-static.nix │ │ ├── wayland.nix │ │ ├── crash.sh │ │ ├── xen.nix │ │ ├── edk2-cross.nix │ │ ├── ipxe.nix │ │ ├── nettrace.nix │ │ ├── tlpi.sh │ │ ├── tlpi.nix │ │ ├── install.sh │ │ ├── xdp.nix │ │ ├── procmon.nix │ │ ├── bear.nix │ │ ├── rasdaemon.nix │ │ ├── uboot.nix │ │ ├── rocket.nix │ │ ├── perftest.nix │ │ ├── xiangshang.nix │ │ ├── wine.nix │ │ ├── libvirt.nix │ │ ├── libbpf.nix │ │ ├── qemu.nix │ │ ├── README.md │ │ ├── rust-simple.nix │ │ ├── rust-best.nix │ │ ├── spdk.nix │ │ ├── linux.nix │ │ └── rust-complex.nix │ └── nix-channel.sh ├── backup.ps1 ├── legacy.lua ├── nixos-install.sh ├── check-dead-plugin.sh ├── install.ps1 └── install.sh ├── nixpkgs ├── opt.nix ├── home.nix ├── config.nix ├── sys │ ├── kernel-419.nix │ ├── boot.nix │ ├── kernel-options.nix │ ├── cli.nix │ ├── kernel-config.nix │ ├── gui.nix │ └── net.nix ├── patches │ ├── dma_ops.patch │ └── amd_iommu.patch ├── home │ ├── cli.nix │ ├── gui.nix │ └── app │ │ └── gnome.nix └── system.nix ├── .lintmdrc.json ├── nvim-mini ├── README.md └── init.lua ├── .editorconfig ├── .gitignore ├── .pre-commit-config.yaml ├── CHANGELOG.md ├── osc.diff ├── barbecue.diff ├── readme.md └── ibus.diff /docs/anki.md: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /config/npmrc: -------------------------------------------------------------------------------- 1 | prefix=~/.npm-packages 2 | # registry=https://registry.npm.taobao.org/ 3 | -------------------------------------------------------------------------------- /docs/img/key.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Martins3/My-Linux-Config/HEAD/docs/img/key.png -------------------------------------------------------------------------------- /docs/img/debug.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Martins3/My-Linux-Config/HEAD/docs/img/debug.png -------------------------------------------------------------------------------- /nvim/lsp/efm.lua: -------------------------------------------------------------------------------- 1 | return { 2 | filetypes = { "sh" }, 3 | command = "efm-langserver", 4 | } 5 | -------------------------------------------------------------------------------- /rime/double_pinyin_flypy.custom.yaml: -------------------------------------------------------------------------------- 1 | patch: 2 | translator/dictionary: luna_pinyin.my_words 3 | -------------------------------------------------------------------------------- /docs/img/comment.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Martins3/My-Linux-Config/HEAD/docs/img/comment.png -------------------------------------------------------------------------------- /docs/img/outline.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Martins3/My-Linux-Config/HEAD/docs/img/outline.png -------------------------------------------------------------------------------- /docs/img/overview.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Martins3/My-Linux-Config/HEAD/docs/img/overview.png -------------------------------------------------------------------------------- /docs/img/snippet.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Martins3/My-Linux-Config/HEAD/docs/img/snippet.png -------------------------------------------------------------------------------- /docs/img/checkhealth.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Martins3/My-Linux-Config/HEAD/docs/img/checkhealth.png -------------------------------------------------------------------------------- /docs/img/code-runner.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Martins3/My-Linux-Config/HEAD/docs/img/code-runner.png -------------------------------------------------------------------------------- /docs/img/autocomplete.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Martins3/My-Linux-Config/HEAD/docs/img/autocomplete.png -------------------------------------------------------------------------------- /docs/img/search-files.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Martins3/My-Linux-Config/HEAD/docs/img/search-files.png -------------------------------------------------------------------------------- /_config.yml: -------------------------------------------------------------------------------- 1 | title: 工欲善其事,必先利其器 2 | remote_theme: pages-themes/cayman@v0.2.0 3 | plugins: 4 | - jekyll-remote-theme 5 | -------------------------------------------------------------------------------- /docs/img/outline-symbols.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Martins3/My-Linux-Config/HEAD/docs/img/outline-symbols.png -------------------------------------------------------------------------------- /docs/img/workspace-symbols.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Martins3/My-Linux-Config/HEAD/docs/img/workspace-symbols.png -------------------------------------------------------------------------------- /config/cargo.toml: -------------------------------------------------------------------------------- 1 | [source.crates-io] 2 | replace-with = 'tuna' 3 | 4 | [source.tuna] 5 | registry = "https://mirrors.tuna.tsinghua.edu.cn/git/crates.io-index.git" 6 | -------------------------------------------------------------------------------- /nvim/lsp/clangd.lua: -------------------------------------------------------------------------------- 1 | return { 2 | cmd = { 'clangd', '--background-index' }, 3 | root_markers = { 'compile_commands.json' }, 4 | filetypes = { 'c', 'cpp' }, 5 | } 6 | -------------------------------------------------------------------------------- /docs/nvim-plugin.md: -------------------------------------------------------------------------------- 1 | - https://github.com/nvzone/menu : menu 组件 2 | 3 | - https://zignar.net/2023/06/10/debugging-lua-in-neovim/ 4 | - https://github.com/YaroSpace/lua-console.nvim 5 | -------------------------------------------------------------------------------- /nvim/lua/usr/neovide.lua: -------------------------------------------------------------------------------- 1 | vim.g.neovide_opacity = 0.9 2 | vim.g.neovide_scale_factor = 1 3 | -- vim.g.neovide_cursor_vfx_mode = "railgun" 4 | vim.g.neovide_cursor_animate_in_insert_mode = false 5 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/i-have-a-question.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: I don't understand the code 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: '' 6 | assignees: Martins3 7 | 8 | --- 9 | -------------------------------------------------------------------------------- /scripts/lint-md.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | lint-md "docs/**/*" -c .lintmdrc.json --threads 3 | 4 | if [[ $? ]]; then 5 | lint-md -f "docs/**/*" -c .lintmdrc.json --threads 6 | else 7 | exit 1 8 | fi 9 | -------------------------------------------------------------------------------- /config/zellij/default.kdl: -------------------------------------------------------------------------------- 1 | layout { 2 | pane size=1 borderless=true { 3 | plugin location="zellij:tab-bar" 4 | } 5 | pane 6 | } 7 | 8 | session_name "martins3 yyds" 9 | attach_to_session true 10 | -------------------------------------------------------------------------------- /scripts/nix/env/bcc.nix: -------------------------------------------------------------------------------- 1 | with import {}; 2 | let 3 | pythonPackages = python3.pkgs; 4 | in 5 | stdenv.mkDerivation rec { 6 | name = "bcc-env"; 7 | buildInputs = [ 8 | bcc 9 | ]; 10 | } 11 | -------------------------------------------------------------------------------- /scripts/nix/env/gnuefi.nix: -------------------------------------------------------------------------------- 1 | { pkgs ? import { } }: 2 | 3 | pkgs.stdenv.mkDerivation { 4 | name = "gnuefi"; 5 | buildInputs = with pkgs; [ 6 | gnu-efi 7 | pkg-config 8 | ]; 9 | } 10 | -------------------------------------------------------------------------------- /config/kitty/session.conf: -------------------------------------------------------------------------------- 1 | launch --title="Martins3" /bin/sh -c "/usr/bin/env tmux attach || /usr/bin/env tmux" 2 | # new_tab R 3 | # launch --title="R" --type=tab sh -c "ssh -X -t martins3@192.168.23.126 \"tmux attach || /usr/bin/env tmux\"" 4 | -------------------------------------------------------------------------------- /rime/default.custom.yaml: -------------------------------------------------------------------------------- 1 | patch: 2 | schema_list: 3 | - schema: double_pinyin_flypy # 小鹤 4 | - schema: luna_pinyin_simp # 全拼 5 | menu: 6 | page_size: 5 7 | ascii_composer: 8 | switch_key: 9 | Shift_L: commit_code 10 | -------------------------------------------------------------------------------- /nvim/lsp/nixd.lua: -------------------------------------------------------------------------------- 1 | -- 配置方法,参考 https://github.com/NixOS/nixfmt ,也算是学到了 2 | local opts = { 3 | settings = { 4 | nixd = { 5 | formatting = { 6 | command = { "nixfmt" }, 7 | }, 8 | }, 9 | }, 10 | } 11 | 12 | return opts 13 | -------------------------------------------------------------------------------- /nvim/lsp/pyright.lua: -------------------------------------------------------------------------------- 1 | return { 2 | settings = { 3 | python = { 4 | analysis = { 5 | typeCheckingMode = "on", 6 | autoSearchPaths = true, 7 | useLibraryCodeForTypes = true, 8 | }, 9 | }, 10 | }, 11 | } 12 | -------------------------------------------------------------------------------- /scripts/nix/env/oomd.nix: -------------------------------------------------------------------------------- 1 | # https://github.com/numactl/numactl 2 | 3 | { pkgs ? import { } }: 4 | 5 | pkgs.stdenv.mkDerivation { 6 | name = "autoconf"; 7 | buildInputs = with pkgs; [ 8 | pkg-config 9 | jsoncpp 10 | ]; 11 | } 12 | -------------------------------------------------------------------------------- /scripts/nix/env/rime.nix: -------------------------------------------------------------------------------- 1 | let 2 | pkgs = import { }; 3 | in 4 | pkgs.llvmPackages.stdenv.mkDerivation { 5 | name = "rime"; 6 | buildInputs = with pkgs; [ 7 | libclang 8 | librime 9 | ]; 10 | LIBCLANG_PATH="${pkgs.libclang.lib}/lib"; 11 | } 12 | -------------------------------------------------------------------------------- /rime/luna_pinyin.martins3.dict.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | name: luna_pinyin.martins3 3 | version: "1.0" 4 | sort: by_weight 5 | use_preset_vocabulary: true 6 | ... 7 | 8 | 访存 fang cun 1 9 | 系统态 xi tong tai 1 10 | 中州韻輸入法引擎 rime 2 11 | 为什么 wsm 1 12 | 什么 sm 1 13 | 北京志凌海纳科技有限公司 smartx 1 14 | -------------------------------------------------------------------------------- /nixpkgs/opt.nix: -------------------------------------------------------------------------------- 1 | let 2 | homeDirectory = builtins.getEnv "HOME"; # 使用环境变量 HOME 3 | optConfig = if (builtins.pathExists "${homeDirectory}/opt-local.nix") 4 | then import "${homeDirectory}/opt-local.nix" 5 | else {}; 6 | in 7 | { 8 | isGui = true; 9 | } // optConfig 10 | -------------------------------------------------------------------------------- /scripts/nix/env/mdadm.nix: -------------------------------------------------------------------------------- 1 | # git clone https://kernel.googlesource.com/pub/scm/utils/mdadm/mdadm 2 | { pkgs ? import { } }: 3 | 4 | pkgs.stdenv.mkDerivation { 5 | name = "mdadm"; 6 | buildInputs = with pkgs; [ 7 | udev 8 | ]; 9 | } 10 | # 无需额外配置,直接 make 就可以了 11 | -------------------------------------------------------------------------------- /scripts/nix/env/shim.nix: -------------------------------------------------------------------------------- 1 | # https://github.com/rhboot/shim 2 | { pkgs ? import { } }: 3 | 4 | pkgs.stdenv.mkDerivation { 5 | name = "hello"; 6 | buildInputs = with pkgs; [ 7 | # 如果缺少 gcc-ar,不要去安装 libgccjit 8 | gcc_multi 9 | elfutils 10 | ]; 11 | } 12 | -------------------------------------------------------------------------------- /config/zellij/code.kdl: -------------------------------------------------------------------------------- 1 | layout { 2 | pane 3 | pane size=1 borderless=true { 4 | // @todo 使用这个插件,应该就可以自动控制 tab 的名称了吧 5 | plugin location="file:///USER_HOME/.zellij/plugins/z-tab-bar.wasm" 6 | } 7 | } 8 | session_name "martins3" 9 | attach_to_session true 10 | -------------------------------------------------------------------------------- /scripts/nix/env/ublksrv.nix: -------------------------------------------------------------------------------- 1 | let 2 | pkgs = import { }; 3 | in 4 | pkgs.mkShell { 5 | buildInputs = with pkgs; [ 6 | autoconf 7 | automake 8 | libtool 9 | pkg-config 10 | liburing 11 | ]; 12 | } 13 | # autoreconf -i 14 | # ./configure 15 | # make -j 16 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: '' 5 | labels: Suggestions 6 | assignees: Martins3 7 | 8 | --- 9 | 10 | - What's your suggestion? 11 | - Why is this better? 12 | - How to implement your ideas? 13 | -------------------------------------------------------------------------------- /config/sh/tmux.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -E -e -u -o pipefail 4 | 5 | tmuxp load -d ~/.dotfiles/config/tmux-note.yaml 6 | tmuxp load -d ~/.dotfiles/config/tmux-code.yaml 7 | 8 | if [[ -n $TMUX ]]; then 9 | # 如果在 tmux 中,先退出 10 | exit 0 11 | else 12 | # 13 | exit 1 14 | fi 15 | -------------------------------------------------------------------------------- /scripts/nix/env/crash.nix: -------------------------------------------------------------------------------- 1 | { pkgs ? import { } }: 2 | 3 | pkgs.stdenv.mkDerivation { 4 | name = "kernel"; 5 | buildInputs = with pkgs; [ 6 | autoconf 7 | automake 8 | libtool 9 | bison 10 | zlib 11 | ncurses 12 | lzo 13 | zstd 14 | ]; 15 | } 16 | -------------------------------------------------------------------------------- /scripts/nix/env/glibc.nix: -------------------------------------------------------------------------------- 1 | let 2 | pkgs = import { }; 3 | in 4 | pkgs.mkShell rec { 5 | buildInputs = with pkgs; [ 6 | bison 7 | ]; 8 | } 9 | 10 | # git clone https://github.com/bminor/glibc 11 | # mkdir -p build && cd build 12 | # ../configure --prefix "$(pwd)/install" 13 | -------------------------------------------------------------------------------- /.lintmdrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "excludeFiles": [], 3 | "rules": { 4 | "no-empty-code": 1, 5 | "no-long-code": [ 6 | 0, 7 | { 8 | "length": 100, 9 | "exclude": [ 10 | "html", 11 | "json", 12 | "yml" 13 | ] 14 | } 15 | ] 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /scripts/backup.ps1: -------------------------------------------------------------------------------- 1 | # 同步 2 | ls "$HOME\AppData\Local\Packages\Microsoft.WindowsTerminal_8wekyb3d8bbwe\LocalState\settings.json" 3 | 4 | cp "$HOME\AppData\Local\Packages\Microsoft.WindowsTerminal_8wekyb3d8bbwe\LocalState\settings.json" "$HOME\.dotfiles\config\windows\terminal.json" 5 | 6 | # VisualStudio 的配置应该是通过 Github 账号登录就可以自动同步了 7 | -------------------------------------------------------------------------------- /scripts/nix/env/edk2.nix: -------------------------------------------------------------------------------- 1 | { pkgs ? import { } }: 2 | 3 | pkgs.stdenv.mkDerivation { 4 | name = "edk2"; 5 | buildInputs = with pkgs; [ 6 | bison 7 | libuuid 8 | nasm 9 | xorg.libX11 10 | xorg.libXext 11 | ]; 12 | hardeningDisable = [ "format" "fortify" ]; 13 | } 14 | -------------------------------------------------------------------------------- /nvim-mini/README.md: -------------------------------------------------------------------------------- 1 | # nvim 的调试 2 | 3 | 利用 https://neovim.io/doc/user/starting.html#%24NVIM_APPNAME 可以很容易的调试 4 | 5 | 1. 部署配置 6 | ```sh 7 | ln -sf $HOME/.dotfiles/nvim-mini/ ~/.config/nvim-mini 8 | ls -la ~/.config/nvim-mini 9 | ``` 10 | 11 | 2. 切换环境变量 12 | ```sh 13 | export NVIM_APPNAME=nvim-mini 14 | ``` 15 | 16 | 3. 执行 nvim ,将会加载新配置 17 | -------------------------------------------------------------------------------- /docs/nvim-bug.md: -------------------------------------------------------------------------------- 1 | ## .h 默认启用的是 cpp ,但是 cpp 中没有 once 2 | 3 | - https://github.com/rafamadriz/friendly-snippets/blob/main/snippets/c/c.json 4 | - https://www.reddit.com/r/neovim/comments/13yw98e/how_can_i_switch_the_local_input_method_in_vim_on/ 5 | 6 | ## [ ] 此外,struct-> 补全的时候,会出现在第一个字母上 7 | 8 | - 是 ccls 的问题吗? 9 | 10 | ## lua 的格式化总是修改大片的代码 11 | -------------------------------------------------------------------------------- /nvim/lsp/ccls.lua: -------------------------------------------------------------------------------- 1 | local opts = { 2 | init_options = { 3 | index = { 4 | threads = 0, 5 | }, 6 | clang = { 7 | excludeArgs = { "-Wall" }, 8 | }, 9 | 10 | highlight = { 11 | lsRanges = true, 12 | }, 13 | 14 | client = { 15 | snippetSupport = true, 16 | }, 17 | }, 18 | } 19 | 20 | return opts 21 | -------------------------------------------------------------------------------- /scripts/nix/env/numactl.nix: -------------------------------------------------------------------------------- 1 | # https://github.com/numactl/numactl 2 | 3 | { pkgs ? import { } }: 4 | 5 | pkgs.stdenv.mkDerivation { 6 | name = "autoconf"; 7 | buildInputs = with pkgs; [ 8 | autoconf 9 | automake 10 | libtool 11 | ]; 12 | } 13 | # ./autogen.sh 14 | # ./configure 15 | # bear -- make -j 16 | # make install 17 | -------------------------------------------------------------------------------- /scripts/nix/env/static.nix: -------------------------------------------------------------------------------- 1 | { pkgs ? import { } }: 2 | 3 | pkgs.stdenv.mkDerivation { 4 | name = "static"; 5 | 6 | nativeBuildInputs = with pkgs.buildPackages; [ 7 | gcc 8 | glibc.static 9 | # 使用的动态库放到这里 10 | ]; 11 | 12 | buildInputs = with pkgs.pkgsStatic; [ 13 | # 如果你依赖更多的静态库 14 | ]; 15 | } 16 | # @todo 运行一个 shell 然后自动使用这个环境 17 | -------------------------------------------------------------------------------- /scripts/nix/env/fio.nix: -------------------------------------------------------------------------------- 1 | let 2 | pkgs = import { }; 3 | in 4 | pkgs.mkShell { 5 | nativeBuildInputs = with pkgs.buildPackages; [ 6 | libaio 7 | python3 zlib liburing 8 | pkg-config 9 | autoconf 10 | gettext 11 | autoconf-archive 12 | automake 13 | libtool 14 | bison 15 | flex 16 | ]; 17 | buildInputs = with pkgs; [ zlib ]; 18 | } 19 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/it-doesn-t-work-for-me.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: It doesn't work for me 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: '' 6 | assignees: Martins3 7 | 8 | --- 9 | 10 | - [ ] **Describe the bug** 11 | A clear and concise description for the bug. 12 | - [ ] **nvim --version** 13 | - [ ] **Operating System** 14 | - [ ] **checkhealth screenshot** 15 | -------------------------------------------------------------------------------- /scripts/nix/env/systemd.nix: -------------------------------------------------------------------------------- 1 | # https://github.com/systemd/systemd 2 | with import { }; 3 | clangStdenv.mkDerivation { 4 | name = "systemd"; 5 | buildInputs = [ 6 | gperf 7 | libxcrypt 8 | libcap 9 | ]; 10 | 11 | nativeBuildInputs = with pkgs; [ 12 | meson 13 | ninja 14 | pkg-config 15 | ]; 16 | } 17 | # meson setup build/ && ninja -C build/ 18 | -------------------------------------------------------------------------------- /config/zellij/solarized-dark.kdl: -------------------------------------------------------------------------------- 1 | themes { 2 | solarized-dark { 3 | fg 253 246 227 4 | bg 0 43 54 5 | black 7 54 66 6 | red 220 50 47 7 | green 133 153 0 8 | yellow 181 137 0 9 | blue 38 139 210 10 | magenta 211 54 130 11 | cyan 42 161 152 12 | white 238 232 213 13 | orange 203 75 22 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /nvim/lua/usr/colorscheme.lua: -------------------------------------------------------------------------------- 1 | require("catppuccin").setup({ 2 | -- flavour = "macchiato", 3 | -- flavour = "latte", 4 | flavour = "frappe", 5 | -- flavour = "mocha", 6 | transparent_background = false, 7 | integrations = {}, 8 | }) 9 | vim.api.nvim_set_hl(0, "LeapBackdrop", { fg = "grey" }) -- leap.nvim 10 | vim.cmd.colorscheme("catppuccin") 11 | 12 | -- vim.cmd.colorscheme "tokyonight" 13 | -------------------------------------------------------------------------------- /scripts/nix/env/dpdk.nix: -------------------------------------------------------------------------------- 1 | # 参考 https://github.com/NixOS/nixpkgs/blob/master/pkgs/os-specific/linux/dpdk/default.nix 重写一下吧 2 | let 3 | pkgs = import { }; 4 | in 5 | pkgs.mkShell rec { 6 | nativeBuildInputs = with pkgs.buildPackages; [ 7 | ninja 8 | meson 9 | numactl 10 | elfutils 11 | python311Packages.pyelftools 12 | ]; 13 | buildInputs = with pkgs; [ zlib ]; 14 | } 15 | -------------------------------------------------------------------------------- /config/tmux-code.yaml: -------------------------------------------------------------------------------- 1 | session_name: code 2 | windows: 3 | - window_name: linux 4 | layout: tiled 5 | shell_command_before: 6 | - cd ~/data/linux 7 | - mkdir -p /tmp/martins3/nvim/ && nvim --listen /tmp/martins3/nvim/$(uuidgen) 8 | # 必须定义两个 window ,否则 tmux status line 存在 no previous window 的警告 9 | - window_name: lab 10 | layout: tiled 11 | shell_command_before: 12 | - cd /tmp 13 | -------------------------------------------------------------------------------- /scripts/nix/env/util-linux.nix: -------------------------------------------------------------------------------- 1 | let 2 | pkgs = import { }; 3 | in 4 | pkgs.mkShell rec { 5 | nativeBuildInputs = with pkgs.buildPackages; [ 6 | pkg-config 7 | po4a 8 | zlib 9 | libxcrypt 10 | pam 11 | libcap_ng 12 | ncurses 13 | systemd 14 | bison 15 | gettext 16 | ninja 17 | ]; 18 | } 19 | # meson build && cd build && ninja -j32 20 | # mv compile_commands.json .. 21 | -------------------------------------------------------------------------------- /nvim/lua/usr/version.lua: -------------------------------------------------------------------------------- 1 | -- 检查 neovim 版本 2 | local actual_ver = vim.version() 3 | local nvim_ver = string.format("%d.%d.%d", actual_ver.major, actual_ver.minor, actual_ver.patch) 4 | 5 | if actual_ver.major == 0 then 6 | if actual_ver.minor < 11 then 7 | local msg = string.format("Please upgrade neovim version : at least %s, but got %s instead!\n", "0.8.0", nvim_ver) 8 | vim.api.nvim_err_writeln(msg) 9 | end 10 | end 11 | -------------------------------------------------------------------------------- /config/tmux-note.yaml: -------------------------------------------------------------------------------- 1 | session_name: note 2 | windows: 3 | - window_name: vn 4 | layout: tiled 5 | shell_command_before: 6 | - cd ~/core/vn 7 | - mkdir -p /tmp/martins3/nvim/ && nvim --listen /tmp/martins3/nvim/$(uuidgen) 8 | - window_name: dotfiles 9 | layout: tiled 10 | shell_command_before: 11 | - cd ~/.dotfiles/ 12 | - mkdir -p /tmp/martins3/nvim/ && nvim --listen /tmp/martins3/nvim/$(uuidgen) 13 | -------------------------------------------------------------------------------- /scripts/nix/env/busybox.nix: -------------------------------------------------------------------------------- 1 | with import { }; 2 | pkgs.stdenv.mkDerivation { 3 | name = "busybox"; 4 | hardeningDisable = [ "all" ]; 5 | buildInputs = with pkgs; [ 6 | getopt 7 | flex 8 | bison 9 | gcc 10 | gnumake 11 | bc 12 | dpkg 13 | pkg-config 14 | binutils 15 | 16 | elfutils 17 | ncurses 18 | openssl 19 | stdenv.cc.libc 20 | stdenv.cc.libc.static 21 | ]; 22 | } 23 | -------------------------------------------------------------------------------- /scripts/nix/env/libiscsi.nix: -------------------------------------------------------------------------------- 1 | let 2 | pkgs = import { }; 3 | in 4 | pkgs.mkShell rec { 5 | nativeBuildInputs = with pkgs.buildPackages; [ 6 | pkg-config 7 | autoconf 8 | gettext 9 | autoconf-archive 10 | autoconf 11 | automake 12 | libtool 13 | bison 14 | flex 15 | ]; 16 | buildInputs = with pkgs; [ zlib ]; 17 | } 18 | 19 | # ./autogen.sh 20 | # ./configure 21 | # make sudo make install 22 | -------------------------------------------------------------------------------- /scripts/nix/env/grub.nix: -------------------------------------------------------------------------------- 1 | let 2 | pkgs = import { }; 3 | in 4 | pkgs.mkShell rec { 5 | nativeBuildInputs = with pkgs.buildPackages; [ 6 | pkg-config 7 | autoconf 8 | gettext 9 | autoconf-archive 10 | autoconf 11 | automake 12 | libtool 13 | bison 14 | flex 15 | ]; 16 | buildInputs = with pkgs; [ zlib ]; 17 | } 18 | 19 | # ./boottrap.sh 20 | # ./configure --prefix=$(pwd)/install --with-platform=efi 21 | -------------------------------------------------------------------------------- /config/tmux-note-private.yaml: -------------------------------------------------------------------------------- 1 | session_name: note 2 | windows: 3 | - window_name: vn 4 | layout: tiled 5 | shell_command_before: 6 | - cd ~/core/vn 7 | - mkdir -p /tmp/martins3/nvim/ && nvim --listen /tmp/martins3/nvim/$(uuidgen) 8 | - window_name: module 9 | layout: tiled 10 | shell_command_before: 11 | - cd ~/core/vn/code/module/ 12 | - mkdir -p /tmp/martins3/nvim/ && nvim --listen /tmp/martins3/nvim/$(uuidgen) 13 | -------------------------------------------------------------------------------- /nixpkgs/home.nix: -------------------------------------------------------------------------------- 1 | { config, pkgs, stdenv, lib, ... }: 2 | 3 | let 4 | 5 | # 用这种方法来使用最新的 neovim ,但是不一定编译成功 6 | # neovim = builtins.getFlake "github:neovim/neovim?dir=contrib"; 7 | opt = import ./opt.nix; 8 | in 9 | { 10 | imports = [ 11 | ./home/cli.nix 12 | ] ++ ( 13 | if opt.isGui then [ 14 | ./home/gui.nix 15 | ] else [ ] 16 | ); 17 | 18 | # nixpkgs.overlays = [ neovim.overlay ]; 19 | programs.home-manager.enable = true; 20 | } 21 | -------------------------------------------------------------------------------- /nvim/lua/usr/bufferline.lua: -------------------------------------------------------------------------------- 1 | require("bufferline").setup({ 2 | options = { 3 | numbers = function(opts) 4 | return string.format("%s", opts.ordinal) 5 | end, 6 | diagnostics = false, 7 | show_buffer_close_icons = false, 8 | show_close_icon = false, 9 | max_name_length = 80, 10 | }, 11 | -- 2025-08-27 : catppuccin doesn't work after update 12 | -- highlights = require("catppuccin.groups.integrations.bufferline").get() 13 | }) 14 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | [*] 2 | insert_final_newline = true 3 | charset = utf-8 4 | indent_style = space 5 | indent_size = 2 6 | 7 | [*.{c,h,c.inc,h.inc}] 8 | indent_style = space 9 | indent_size = 2 10 | emacs_mode = c 11 | 12 | [*.json] 13 | indent_style = space 14 | emacs_mode = python 15 | 16 | [*.yaml] 17 | indent_style = space 18 | 19 | [{Makefile,**.mk}] 20 | # Use tabs for indentation (Makefiles require tabs) 21 | indent_style = tab 22 | 23 | [sh.snippets] 24 | indent_style = tab 25 | -------------------------------------------------------------------------------- /scripts/nix/env/c.nix: -------------------------------------------------------------------------------- 1 | with import { }; 2 | 3 | # 各种 C 环境合集都放这里了 4 | pkgs.llvmPackages.stdenv.mkDerivation { 5 | name = "C test"; 6 | buildInputs = with pkgs; [ 7 | cmake 8 | libpcap 9 | liburing 10 | libtraceevent 11 | glib 12 | pkg-config 13 | fuse3 14 | libaio 15 | numactl 16 | # glibc.static # 可以静态编译 17 | # 2025-05-09 发现添加上这个,编译运行,程序会直接 crash 的。 18 | ]; 19 | LD_LIBRARY_PATH = "${lib.makeLibraryPath [ libaio ]}"; 20 | } 21 | -------------------------------------------------------------------------------- /nvim-mini/init.lua: -------------------------------------------------------------------------------- 1 | local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" 2 | if not vim.loop.fs_stat(lazypath) then 3 | vim.fn.system({ 4 | "git", 5 | "clone", 6 | "--filter=blob:none", 7 | "https://github.com/folke/lazy.nvim.git", 8 | "--branch=stable", -- latest stable release 9 | lazypath, 10 | }) 11 | end 12 | vim.opt.rtp:prepend(lazypath) 13 | 14 | require("lazy").setup({ 15 | "nvim-telescope/telescope.nvim", 16 | "nvim-lua/plenary.nvim", 17 | }, {}) 18 | -------------------------------------------------------------------------------- /scripts/nix/env/llvm.nix: -------------------------------------------------------------------------------- 1 | with import { }; 2 | clangStdenv.mkDerivation { 3 | name = "llvm-dev"; 4 | buildInputs = [ 5 | (python3.withPackages (p: with p; [ 6 | llvmlite 7 | numpy 8 | ])) 9 | 10 | ]; 11 | } 12 | # 1. llvm-propject 应该是不需要使用什么外部依赖的,甚至可以用 gcc 编译 clang 13 | # 2. 编译 cland 的方法 14 | # mkdir -p build && cd build 15 | # cmake ../llvm -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_PROJECTS="clang;clang-tools-extra" 16 | # cmake --build . --target clangd -j31 17 | -------------------------------------------------------------------------------- /scripts/nix/env/rdma.nix: -------------------------------------------------------------------------------- 1 | { 2 | pkgs ? import { }, 3 | }: 4 | 5 | pkgs.llvmPackages.stdenv.mkDerivation { 6 | name = "rdma"; 7 | hardeningDisable = [ "all" ]; 8 | buildInputs = with pkgs; [ 9 | cmake 10 | pkg-config 11 | python3 12 | libnl 13 | ]; 14 | 15 | cmakeFlags = [ 16 | "-DCMAKE_INSTALL_RUNDIR=/run" 17 | "-DCMAKE_INSTALL_SHAREDSTATEDIR=/var/lib" 18 | ]; 19 | } 20 | # 直接执行其中的 ./build.sh 就可以了 21 | # cd build && ninja -t compdb > ../compile_commands.json 22 | -------------------------------------------------------------------------------- /nixpkgs/config.nix: -------------------------------------------------------------------------------- 1 | { 2 | allowUnsupportedSystem = false; 3 | allowUnfree = true; 4 | packageOverrides = pkgs: rec { 5 | # 添加nix user repository (NUR)到nixpkgs里。 6 | nur = import (builtins.fetchTarball "https://github.com/nix-community/NUR/archive/master.tar.gz") { 7 | pkgs = pkgsu; 8 | }; 9 | # 添加非稳定版的nixpkgs到nixpkgs里, 10 | # 比如非稳定版的hello可以通过`pkgs.pkgsu.hello`来访问。 11 | pkgsu = import (builtins.fetchTarball "https://github.com/NixOS/nixpkgs/archive/master.tar.gz") {}; 12 | }; 13 | } 14 | -------------------------------------------------------------------------------- /nvim/snippets/cpp.snippets: -------------------------------------------------------------------------------- 1 | snippet legacy_import 2 | #include 3 | // #include "../dbg.hpp" 4 | using namespace std; 5 | #define REOPEN_READ freopen("/home/maritns3/test/cpp/input.txt", "r", stdin); 6 | int main(int argc, char *argv[]){ 7 | ${0} 8 | return 0; 9 | } 10 | 11 | snippet qpr 12 | std::cout << ${0} << std::endl; 13 | 14 | snippet import 15 | #include 16 | using namespace std; 17 | int main(int argc, char *argv[]){ 18 | ${0} 19 | return 0; 20 | } 21 | -------------------------------------------------------------------------------- /config/sh/wez-opacity.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -E -e -u -o pipefail 4 | 5 | # TODO 扩展为选项吧 6 | function change_wez() { 7 | local file=$HOME/.dotfiles/config/wezterm.lua 8 | 9 | if grep window_background_opacity "$file" | grep -o "1.0"; then 10 | sed -i "s/window_background_opacity = 1.0/window_background_opacity = 0.9/" "$file" 11 | else 12 | sed -i "s/window_background_opacity = 0.9/window_background_opacity = 1.0/" "$file" 13 | fi 14 | } 15 | 16 | function change_kitty() { 17 | local file=config/kitty/kitty.conf 18 | } 19 | -------------------------------------------------------------------------------- /scripts/nix/env/qemu-static.nix: -------------------------------------------------------------------------------- 1 | let 2 | pkgs = import { }; 3 | in 4 | pkgs.stdenv.mkDerivation { 5 | name = "martins3's QEMU"; 6 | buildInputs = with pkgs; [ 7 | zlib 8 | pkg-config 9 | ninja 10 | glib 11 | pixman 12 | xorg.libX11.dev 13 | rdma-core 14 | liburing 15 | libiscsi 16 | libcap_ng 17 | libslirp 18 | gtk3 19 | libaio 20 | libnfs 21 | libseccomp 22 | libssh 23 | libbpf 24 | libusb 25 | zstd 26 | virglrenderer 27 | epoxy 28 | ]; 29 | } 30 | -------------------------------------------------------------------------------- /scripts/nix/env/wayland.nix: -------------------------------------------------------------------------------- 1 | with import {}; 2 | pkgs.llvmPackages.stdenv.mkDerivation { 3 | name = "yyds wayland"; 4 | buildInputs = with pkgs; [ 5 | binutils 6 | cmake 7 | libdrm 8 | libinput 9 | libseat 10 | libxkbcommon 11 | mesa 12 | meson 13 | ninja 14 | pixman 15 | libGL # 提供 EGL/egl.h 16 | pkg-config 17 | wayland 18 | wayland-protocols 19 | xorg.xcbproto 20 | xorg.xcbutil 21 | xwayland 22 | egl-wayland 23 | ]; 24 | } 25 | # 和 vn/code/module/c/wayland 配合使用 26 | -------------------------------------------------------------------------------- /rime/luna_pinyin.my_words.dict.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | name: luna_pinyin.my_words # 词库名称,与文件名一致 3 | version: "1.0" # 版本号,任填 4 | sort: by_weight # 排序依据,by_weight表示按权重(词频)排序 5 | use_preset_vocabulary: true # 是否使用预置发音,一般选true 6 | import_tables: 7 | - luna_pinyin # 预置的朙月拼音词库 8 | - luna_pinyin.martins3 9 | - cn_dicts/8105 # 字表 10 | # - cn_dicts/41448 # 大字表(按需启用) 11 | - cn_dicts/base # 基础词库 12 | - cn_dicts/ext # 扩展词库 13 | - cn_dicts/tencent # 腾讯词向量(大词库,部署时间较长) 14 | - cn_dicts/others # 一些杂项 15 | 16 | ... 17 | -------------------------------------------------------------------------------- /scripts/nix/env/crash.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -E -e -u -o pipefail 4 | # shopt -s inherit_errexit 5 | # PROGNAME=$(basename "$0") 6 | # PROGDIR=$(readlink -m "$(dirname "$0")") 7 | for i in "$@"; do 8 | echo "$i" 9 | done 10 | cd "$(dirname "$0")" 11 | 12 | cd ~/core 13 | if [[ ! -d crash ]]; then 14 | git clone https://github.com/crash-utility/crash 15 | fi 16 | cd crash 17 | ln -sf /home/martins3/.dotfiles/scripts/nix/env/crash.nix default.nix 18 | # nix-shell --command "./configure -x lzo" 19 | nix-shell --command "make -j32" 20 | # 完全理解之后提交给 nixos 社区吧? 21 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .ccls-cache 2 | plugin 3 | .vim-bookmarks 4 | .DS_Store 5 | .stfolder 6 | .syncthing.* 7 | history.txt 8 | 9 | # Kernel Module Compile Results 10 | *.mod* 11 | *.cmd 12 | *.ko 13 | *.o 14 | *.o.d 15 | *.out 16 | .tmp_versions/ 17 | modules.order 18 | Module.symvers 19 | Mkfile.old 20 | dkms.conf 21 | compile_commands.json 22 | 23 | .direnv 24 | .envrc 25 | 26 | .clang-format 27 | kernel/guest/default.nix 28 | .luarc.json 29 | lazy-lock.json 30 | 31 | perf.data 32 | perf.data.old 33 | .bash_history 34 | *.qcow2 35 | __pycache__ 36 | kernel/module/.gdb_history 37 | 38 | .nvim 39 | -------------------------------------------------------------------------------- /scripts/nix/env/xen.nix: -------------------------------------------------------------------------------- 1 | with import { }; 2 | pkgs.llvmPackages.stdenv.mkDerivation { 3 | # hardeningDisable = [ "all" ]; 4 | name = "xen"; 5 | buildInputs = with pkgs; [ 6 | 7 | libuuid 8 | glib 9 | pixman 10 | yajl 11 | fig2dev 12 | pandoc 13 | ncurses 14 | pkg-config 15 | 16 | flex 17 | bison 18 | gcc 19 | gnumake 20 | 21 | # ./configure 22 | # make world 23 | # make install 24 | # 如果在虚拟机中使用,那么需要添加这个 25 | # qemu 26 | xen 27 | python3.pkgs.setuptools 28 | python3.pkgs.distutils 29 | ]; 30 | } 31 | -------------------------------------------------------------------------------- /scripts/nix/env/edk2-cross.nix: -------------------------------------------------------------------------------- 1 | let 2 | pkgs_arm_cross = import { 3 | crossSystem = "aarch64-linux"; 4 | }; 5 | pkgs = import {}; 6 | in 7 | pkgs.mkShell { 8 | buildInputs = with pkgs_arm_cross; [ 9 | # packages for cross compiling, run on local system (x86_64) 10 | stdenv.cc 11 | binutils 12 | # here stdenv.cc is the same with buildPackages.gcc 13 | ] ++ (with pkgs; [ 14 | # packages run on local system (x86_64) 15 | libuuid 16 | ]); 17 | } 18 | 19 | # ➜ source edksetup.sh 20 | # ➜ export GCC5_AARCH64_PREFIX=aarch64-unknown-linux-gnu- # nixos 中 21 | -------------------------------------------------------------------------------- /config/windows/install.ps1: -------------------------------------------------------------------------------- 1 | # 安装 scoop 2 | Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser 3 | Invoke-RestMethod -Uri https://get.scoop.sh | Invoke-Expression 4 | 5 | scoop install git vim neovim 6 | scoop bucket add nerd-fonts 7 | scoop install Hack-NF 8 | 9 | scoop install neovim neovide git lazygit gcc ripgrep fd unzip tree-sitter luarocks yarn yazi lsd llvm fzf 10 | scoop install Sysinternals zoxide make go ripgrep 11 | scoop install ntop python gdu 12 | scoop install ntop python wget 13 | # scoop install https://github.com/JanDeDobbeleer/oh-my-posh/releases/latest/download/oh-my-posh.json 14 | -------------------------------------------------------------------------------- /scripts/nix/env/ipxe.nix: -------------------------------------------------------------------------------- 1 | { pkgs ? import { } }: 2 | 3 | pkgs.stdenv.mkDerivation { 4 | name = "ipxe"; 5 | buildInputs = with pkgs; [ 6 | gnu-efi 7 | mtools 8 | openssl 9 | perl 10 | xorriso 11 | xz 12 | syslinux 13 | ]; 14 | } 15 | 16 | # git clone https://github.com/ipxe/ipxe 17 | # cd ipxe/src 18 | # make 测试失败 19 | # 可以 20 | # make bin/ipxe.lkrn bin-x86_64-efi/ipxe.efi 21 | # ./util/genfsimg -o ipxe.iso bin/ipxe.lkrn bin-x86_64-efi/ipxe.efi 22 | # 23 | # nix-build -E '(import {}).syslinux' --no-out-link 24 | # 参考这里,似乎比想象的复杂 25 | # pkgs/tools/misc/ipxe/default.nix 26 | -------------------------------------------------------------------------------- /config/zellij/the-default.kdl: -------------------------------------------------------------------------------- 1 | layout { 2 | tab name="martins3 yyds" cwd="/home/martins3/core/" { 3 | pane size=1 borderless=true { 4 | plugin location="zellij:tab-bar" 5 | } 6 | pane 7 | } 8 | } 9 | 10 | # tmux alike 11 | layout { 12 | pane size=1 borderless=true { 13 | plugin location="zellij:tab-bar" 14 | } 15 | pane 16 | } 17 | 18 | # 19 | layout { 20 | tab name="my amazing tab" cwd="/home/martins3/core/vn" { 21 | pane command="nvim" 22 | } 23 | } 24 | 25 | layout { 26 | pane size=1 borderless=true { 27 | plugin location="zellij:tab-bar" 28 | } 29 | pane 30 | } 31 | -------------------------------------------------------------------------------- /.pre-commit-config.yaml: -------------------------------------------------------------------------------- 1 | # See https://pre-commit.com for more information 2 | # See https://pre-commit.com/hooks.html for more hooks 3 | repos: 4 | - repo: https://github.com/pre-commit/pre-commit-hooks 5 | rev: v3.2.0 6 | hooks: 7 | - id: trailing-whitespace 8 | - id: end-of-file-fixer 9 | - id: check-yaml 10 | - id: check-added-large-files 11 | - id: check-merge-conflict 12 | 13 | - repo: local 14 | hooks: 15 | 16 | - id: lint-md 17 | name: lint-md 18 | description: check Chinese doc 19 | entry: scripts/lint-md.sh 20 | language: script 21 | require_serial: true 22 | -------------------------------------------------------------------------------- /scripts/nix/env/nettrace.nix: -------------------------------------------------------------------------------- 1 | /* https://discourse.nixos.org/t/how-to-make-mkshell-to-use-clangs-stdenv/9484 */ 2 | with import { }; 3 | (mkShell.override { stdenv = clangStdenv; }) { 4 | hardeningDisable = [ "all" ]; 5 | buildInputs = [ 6 | pkg-config 7 | bpftools 8 | elfutils 9 | libbfd 10 | libbpf 11 | zstd 12 | libcap 13 | llvm 14 | (python3.withPackages ( 15 | p: with p; [ 16 | pyyaml 17 | ] 18 | )) 19 | # TODO 这个是需要的吗? 20 | linuxHeaders 21 | libz 22 | ]; 23 | 24 | # 原来系统中添加了一个 -static ,所以 ld 找不到静态库 25 | LD_LIBRARY_PATH = "${lib.makeLibraryPath [ zstd ]}"; 26 | } 27 | -------------------------------------------------------------------------------- /scripts/nix/env/tlpi.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -E -e -u -o pipefail 4 | for i in "$@"; do 5 | echo "$i" 6 | done 7 | cd "$(dirname "$0")" 8 | 9 | cd ~/core 10 | if [[ -d tlpi-dist ]]; then 11 | echo "already setup" 12 | exit 0 13 | fi 14 | 15 | wget https://man7.org/tlpi/code/download/tlpi-220912-dist.tar.gz 16 | tar -xvf tlpi-220912-dist.tar.gz 17 | rm tlpi-220912-dist.tar.gz 18 | cd tlpi-dist 19 | git init 20 | git add -A 21 | 22 | ln /home/martins3/.dotfiles/scripts/nix/env/tlpi.nix default.nix 23 | echo "use nix" >>.envrc && direnv allow 24 | 25 | cat << _EOF_ > .gitignore 26 | .ccls-cache 27 | .direnv 28 | _EOF_ 29 | 30 | cd lib && make 31 | -------------------------------------------------------------------------------- /nvim/lua/usr/hydra.lua: -------------------------------------------------------------------------------- 1 | local Hydra = require("hydra") 2 | 3 | -- 首先按 c a ,然后就可以使用 hjkl 来调整窗口大小 4 | Hydra({ 5 | name = "Adjust Window Size", 6 | config = { 7 | color = "pink", 8 | invoke_on_body = true, 9 | on_enter = function() 10 | vim.o.virtualedit = "all" 11 | end, 12 | }, 13 | mode = "n", 14 | body = "ca", 15 | heads = { 16 | { "h", "vertical resize +10" }, 17 | { "l", "vertical resize -10" }, 18 | { "", nil, { exit = true } }, 19 | { "", nil, { exit = true } }, 20 | }, 21 | }) 22 | -- 当想要修改一块代码的缩进的时候,使用 < 或者 > ,然后使用 . 来重复,这是 vim 的默认行为。 23 | -------------------------------------------------------------------------------- /scripts/nix/env/tlpi.nix: -------------------------------------------------------------------------------- 1 | with import {}; 2 | pkgs.llvmPackages.stdenv.mkDerivation { 3 | name = "yyds tlpi"; 4 | buildInputs = with pkgs; [ 5 | libcap 6 | acl 7 | glibc 8 | # 参考: https://github.com/NixOS/nixpkgs/issues/198993 9 | # 存在如下的报错: 10 | # gcc -std=c99 -D_XOPEN_SOURCE=600 -D_DEFAULT_SOURCE -g -I../lib -pedantic -Wall -W -Wmissing-prototypes -Wno-sign-compare -Wimplicit-fallthrough -Wno-unused-parameter cap_launcher.c ../libtlpi.a ../libtlpi.a -lcap -lcrypt -o cap_launcher 11 | # /nix/store/22p5nv7fbxhm06mfkwwnibv1nsz06x4b-binutils-2.40/bin/ld: cannot find -lcrypt: No such file or directory 12 | libxcrypt 13 | ]; 14 | } 15 | -------------------------------------------------------------------------------- /scripts/nix/env/install.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -E -e -u -o pipefail 3 | PROGDIR=$(readlink -m "$(dirname "$0")") 4 | items=() 5 | for file in "$PROGDIR"/*.nix; do 6 | items+=("$(basename "$file")") 7 | done 8 | 9 | file=$(printf "%s\n" "${items[@]}" | fzf) 10 | 11 | gum confirm "Continue at [$(pwd)] with [$file]" || exit 0 12 | 13 | if [[ $(basename "$file") == rust-best.nix ]]; then 14 | # 只能用 ln ,不可以用 ln -s 15 | # scripts/nix/env/rust-best.nix 需要加载当前目录中的 ./rust-toolchain.toml 16 | ln "$PROGDIR/$file" default.nix 17 | fi 18 | 19 | if ! ln -sf "$PROGDIR/$file" default.nix; then 20 | cp "$PROGDIR/$file" default.nix 21 | fi 22 | echo "use nix" >>.envrc && direnv allow 23 | -------------------------------------------------------------------------------- /nvim/lua/usr/lualine.lua: -------------------------------------------------------------------------------- 1 | vim.b.rime_enabled = false 2 | local toggle_rime = function(client_id) 3 | vim.lsp.buf_request(0, "workspace/executeCommand", { command = "rime-ls.toggle-rime" }, function(_, result, ctx, _) 4 | if ctx.client_id == client_id then 5 | vim.b.rime_enabled = result 6 | end 7 | end) 8 | end 9 | 10 | -- update lualine 11 | local function rime_status() 12 | if vim.b.rime_enabled then 13 | return "ㄓ" 14 | else 15 | return "" 16 | end 17 | end 18 | 19 | require("lualine").setup({ 20 | extensions = { "nvim-tree", "fugitive" }, 21 | sections = { 22 | lualine_x = { rime_status, "encoding", "fileformat", "filetype" }, 23 | }, 24 | }) 25 | -------------------------------------------------------------------------------- /scripts/nix/env/xdp.nix: -------------------------------------------------------------------------------- 1 | let 2 | pkgs = import { }; 3 | in 4 | pkgs.llvmPackages.stdenv.mkDerivation { 5 | name = "xdp"; 6 | buildInputs = with pkgs; [ 7 | pkg-config 8 | bpftool 9 | libllvm 10 | elfutils 11 | autoconf 12 | automake 13 | libtool 14 | libpcap 15 | glibc_multi 16 | libbpf 17 | 18 | libcap 19 | libbfd 20 | ]; 21 | } 22 | 23 | 24 | # https://github.com/xdp-project/xdp-tutorial 25 | # 似乎因为 clang 的升级,导致编译有报错 26 | # https://maskray.me/blog/2023-08-25-clang-wunused-command-line-argument 27 | # 需要将将其中的 Werror 去掉 28 | # sed -i "s/-Werror//g" lib/Makefile common/common.mk lib/libbpf/src/Makefile 29 | -------------------------------------------------------------------------------- /scripts/nix/env/procmon.nix: -------------------------------------------------------------------------------- 1 | with import { }; 2 | clangStdenv.mkDerivation { 3 | hardeningDisable = [ "all" ]; 4 | 5 | name = "procman-dev"; 6 | buildInputs = [ 7 | libbpf 8 | clang 9 | linuxHeaders 10 | pkg-config 11 | elfutils 12 | zlib 13 | pkg-config 14 | ]; 15 | } 16 | # 不知道咋解决, bpf_helpers.h 17 | # 似乎这个文件是在 tools/lib/bpf/bpf_helpers.h 中的 18 | # 而且 ls -l /nix/store/*-libbpf-*/include/bpf/bpf_helpers.h 19 | # 也是有输出的 20 | 21 | # https://github.com/microsoft/ProcMon-for-Linux/blob/main/BUILD.md 22 | # git clone https://github.com/Sysinternals/ProcMon-for-Linux.git 23 | # cd ProcMon-for-Linux 24 | # mkdir build 25 | # cd build 26 | # cmake .. 27 | # make 28 | -------------------------------------------------------------------------------- /config/sh/test.c: -------------------------------------------------------------------------------- 1 | /* #include */ 2 | #include 3 | 4 | 5 | /* 6 | * 1. 对于这个小文件 ,现在构建都有问题 : clang -target aarch64 test.c 不过报告的问题是 : 7 | * 这个在 centos 上安装 yum install glibc-devel.i686 可以解决掉,但是 nixos 解决不掉 8 | * - 使用 clang -target aarch64 -E test.c 可以看到这个时候是可以正常展开的 9 | 2. 如果 clang -target aarch64-linux-gnu -nostdinc test.c 的时候,那么就会出现和内核一样的问题 10 | * 3. /nix/store/90c4rwfis305q63qw6w6f1lxh7031m0j-clang-14.0.6-lib/lib/clang/14.0.6/include/arm_neon.h 11 | * 12 | * 至此,可以确定,这个操作是 nixos 的技术失误。破案,结束! 13 | * 14 | * wrok around 的方法,在 clang -target aarch64 -E 的时候,获取到这些 header 的位置,然后将其手动拷贝 include 的位置中去, 15 | */ 16 | 17 | int main(int argc, char *argv[]) 18 | { 19 | return 0; 20 | } 21 | -------------------------------------------------------------------------------- /nixpkgs/sys/kernel-419.nix: -------------------------------------------------------------------------------- 1 | { config, pkgs, lib, ... }: 2 | 3 | { 4 | boot = { 5 | # kernelPackages = pkgs.linuxPackages_latest; 6 | kernelPackages = pkgs.linuxPackages_4_19; 7 | }; 8 | 9 | /* 10 | boot.kernelPackages = pkgs.linuxPackagesFor (pkgs.linux_4_19.override { 11 | argsOverride = rec { 12 | src = pkgs.fetchurl { 13 | url = "mirror://kernel/linux/kernel/v4.x/linux-${version}.tar.xz"; 14 | sha256 = "0c9xxqgv2i36hrr06dwz7f3idc04xpv0a5pxg08xdh03cnyf12cx"; 15 | }; 16 | version = "4.19.297"; 17 | modDirVersion = "4.19.297"; 18 | }; 19 | }); 20 | */ 21 | 22 | boot.kernelParams = [ 23 | "mitigations=off" 24 | "iommu=nopt" 25 | ]; 26 | 27 | } 28 | -------------------------------------------------------------------------------- /config/zathurarc: -------------------------------------------------------------------------------- 1 | # https://gist.github.com/michaelmrose/9595075b43f24aa903fa 2 | # Zathura configuration file 3 | # See man `man zathurarc' 4 | 5 | # Open document in fit-width mode by default 6 | set adjust-open "best-fit" 7 | 8 | # One page per row by default 9 | set pages-per-row 1 10 | 11 | #stop at page boundries 12 | set scroll-page-aware "true" 13 | set smooth-scroll "true" 14 | set scroll-full-overlap 0.01 15 | set scroll-step 100 16 | 17 | #zoom settings 18 | set zoom-min 10 19 | set guioptions "" 20 | 21 | set render-loading "false" 22 | set scroll-step 50 23 | 24 | unmap f 25 | map f toggle_fullscreen 26 | map [fullscreen] f toggle_fullscreen 27 | 28 | # 全屏 29 | set window-height 3000 30 | set window-width 3000 31 | -------------------------------------------------------------------------------- /scripts/nix/env/bear.nix: -------------------------------------------------------------------------------- 1 | { pkgs ? import { } }: 2 | 3 | # 参考 nixpkgs pkgs/development/tools/build-managers/bear/default.nix 4 | pkgs.stdenv.mkDerivation { 5 | name = "autoconf"; 6 | 7 | nativeBuildInputs = with pkgs.buildPackages; [ 8 | pkg-config 9 | gcc 10 | glibc.static 11 | ]; 12 | 13 | buildInputs = with pkgs.pkgsStatic; [ 14 | grpc 15 | spdlog 16 | nlohmann_json 17 | /* cmake */ 18 | /* protobuf */ 19 | /* openssl */ 20 | /* gtest */ 21 | /* c-ares */ 22 | /* zlib */ 23 | /* sqlite */ 24 | /* re2 */ 25 | ]; 26 | } 27 | 28 | # mkdir -p build && cd build 29 | # cmake -DENABLE_UNIT_TESTS=OFF -DENABLE_FUNC_TESTS=OFF .. 30 | # make all -j32 31 | # make instal 32 | -------------------------------------------------------------------------------- /scripts/nix/env/rasdaemon.nix: -------------------------------------------------------------------------------- 1 | # https://github.com/mchehab/rasdaemon 2 | 3 | { pkgs ? import { } }: 4 | 5 | pkgs.stdenv.mkDerivation { 6 | name = "kernel"; 7 | buildInputs = with pkgs; [ 8 | autoconf 9 | automake 10 | libtool 11 | sqlite # (if sqlite3 will be used) 12 | perlPackages.DBDSQLite # (if sqlite3 will be used) 13 | 14 | # 将这个作为基础 15 | bison 16 | flex 17 | pkg-config 18 | elfutils 19 | libelf 20 | automake 21 | libtool 22 | nasm 23 | pkgconf 24 | 25 | automake 26 | gcc 27 | git 28 | libelf 29 | zlib 30 | libtool 31 | ]; 32 | } 33 | 34 | # autoreconf -vfi 35 | # ./configure --enable-sqlite3 --enable-aer --enable-mce 36 | # bear -- make -j 37 | -------------------------------------------------------------------------------- /nvim/lsp/lua_ls.lua: -------------------------------------------------------------------------------- 1 | return { 2 | settings = { 3 | Lua = { 4 | runtime = { 5 | -- Tell the language server which version of Lua you're using (most likely LuaJIT in the case of Neovim) 6 | version = "LuaJIT", 7 | }, 8 | diagnostics = { 9 | -- Get the language server to recognize the `vim` global 10 | globals = { "vim" }, 11 | }, 12 | workspace = { 13 | checkThirdParty = false, 14 | -- Make the server aware of Neovim runtime files 15 | library = vim.api.nvim_get_runtime_file("", true), 16 | }, 17 | -- Do not send telemetry data containing a randomized but unique identifier 18 | telemetry = { 19 | enable = false, 20 | }, 21 | }, 22 | }, 23 | } 24 | -------------------------------------------------------------------------------- /scripts/legacy.lua: -------------------------------------------------------------------------------- 1 | local function get_term_in_window() 2 | local terminal_windows = {} 3 | for _, winid in ipairs(vim.api.nvim_list_wins()) do 4 | local bufnr = vim.api.nvim_win_get_buf(winid) 5 | if vim.bo[bufnr].buftype == "terminal" then 6 | table.insert(terminal_windows, winid) 7 | end 8 | end 9 | return terminal_windows 10 | end 11 | 12 | -- 如果当前 window 已经存在 terminal ,那么就选择第一个进入 13 | local term_buffers_in_opened = get_term_in_window() 14 | if #term_buffers_in_opened > 0 then 15 | vim.api.nvim_set_current_win(term_buffers_in_opened[1]) 16 | return 17 | end 18 | 19 | -- TODO 通过 session restore ,无法记录到 last buffer 是什么 20 | -- local buf_name = vim.api.nvim_buf_get_name(last_non_terminal_buf) 21 | -- print("Current buffer: " .. buf_name) 22 | -------------------------------------------------------------------------------- /scripts/nix/env/uboot.nix: -------------------------------------------------------------------------------- 1 | { pkgs ? import { } }: 2 | 3 | pkgs.stdenv.mkDerivation { 4 | name = "hello"; 5 | buildInputs = with pkgs; [ 6 | bison 7 | flex 8 | elfutils 9 | swig 10 | openssl 11 | libuuid 12 | gnutls 13 | libGL 14 | libz 15 | glib.out 16 | # good 完美解决掉问题 17 | (python3.withPackages (p: with p; [ 18 | setuptools 19 | # conda 20 | pip 21 | ])) 22 | ]; 23 | # 原来需要这样包含动态库的 24 | # https://discourse.nixos.org/t/where-can-i-get-libgthread-2-0-so-0/16937/6 25 | # 尝试 nix-index 哦 26 | LD_LIBRARY_PATH = "${pkgs.stdenv.cc.cc.lib}/lib:${pkgs.libGL}/lib:${pkgs.glib.out}/lib:${pkgs.libz}/lib"; 27 | } 28 | -------------------------------------------------------------------------------- /rime/luna_pinyin_simp.custom.yaml: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | patch: 3 | 'speller/algebra': 4 | - erase/^xx$/ # 第一行保留 5 | 6 | - derive/^n/l/ # n => l 7 | - derive/^l/n/ # l => n 8 | 9 | - derive/([ei])n$/$1ng/ # en => eng, in => ing 10 | - derive/([ei])ng$/$1n/ # eng => en, ing => in 11 | 12 | switches: 13 | - name: ascii_mode 14 | reset: 0 15 | states: [ 中文, 英文 ] 16 | - name: full_shape 17 | reset: 0 18 | states: [ 半角, 全角 ] 19 | - name: zh_simp 20 | reset: 1 21 | states: [ 汉字, 漢字] 22 | - name: ascii_punct 23 | reset: 0 24 | states: [ 。,, ., ] 25 | 26 | translator: 27 | dictionary : luna_pinyin.my_words 28 | -------------------------------------------------------------------------------- /config/wtf.yml: -------------------------------------------------------------------------------- 1 | wtf: 2 | colors: 3 | border: 4 | focusable: darkslateblue 5 | focused: orange 6 | normal: gray 7 | grid: 8 | columns: [32, 32, 32, 32, 90] 9 | rows: [10, 10, 10, 4, 4, 90] 10 | refreshInterval: 1 11 | mods: 12 | textfile: 13 | enabled: true 14 | filePath: "~/.config/wtf/config.yml" 15 | format: true 16 | position: 17 | top: 0 18 | left: 0 19 | height: 4 20 | width: 1 21 | refreshInterval: 30 22 | wrapText: false 23 | uptime: 24 | args: [""] 25 | cmd: "uptime" 26 | enabled: true 27 | position: 28 | top: 3 29 | left: 1 30 | height: 1 31 | width: 2 32 | refreshInterval: 30 33 | type: cmdrunner 34 | -------------------------------------------------------------------------------- /scripts/nix/env/rocket.nix: -------------------------------------------------------------------------------- 1 | { pkgs ? import { } }: 2 | 3 | pkgs.llvmPackages.stdenv.mkDerivation { 4 | name = "rocket-chip"; 5 | buildInputs = with pkgs; [ 6 | bison 7 | llvm 8 | verilator 9 | mill 10 | dtc # device-tree-compiler 11 | (python3.withPackages (p: with p; [ 12 | setuptools 13 | ])) 14 | circt 15 | espresso 16 | 17 | # libs 18 | sqlite 19 | zlib 20 | zstd 21 | ]; 22 | shellHook = '' 23 | ''; 24 | } 25 | 26 | # 测试方法: 27 | # git submodule update --init 28 | # make verilog 29 | # 30 | # firtool: Unknown command line argument '-dedup'. Try: 'firtool --help' 31 | # firtool: Did you mean '--no-dedup'? 32 | # 在 build.sc 将 --dedup 去掉即可, 33 | -------------------------------------------------------------------------------- /config/nix.conf: -------------------------------------------------------------------------------- 1 | # TODO 这里的配置和 /etc/nix/nix.conf 优先级是什么 2 | experimental-features = nix-command flakes 3 | # make builtins.fetchurl expire in a long time 4 | # although `man nix.conf` says tarball-ttl default is 4294967295 5 | # `nix show-config` show default is 3600 (1 hour) 6 | # 7 | # 这个配置有两个问题 8 | # 2. 2025-01-05 在 nixos 中会有警告 9 | # 1. 发现在虚拟机 nix-channel --update 会立刻跳过,参考 10 | # https://discourse.nixos.org/t/nix-channel-update-doesnt-update-anything-my-nixpkgs-unstable-channel-is-months-old/44039/5 11 | # 发现是由于有了 cache ,就没有更新,将这个配置注释掉之后,channel 立刻更新 12 | tarball-ttl = 4294967295 # max 32bit integer 13 | 14 | # 似乎没必要安装 15 | # https://nix.dev/manual/nix/2.24/command-ref/conf-file 16 | # build-users-group = nixbld 17 | 18 | substituters = https://mirrors.tuna.tsinghua.edu.cn/nix-channels/store https://cache.nixos.org/ 19 | -------------------------------------------------------------------------------- /config/gnome-terminal.conf: -------------------------------------------------------------------------------- 1 | [/] 2 | background-color='rgb(0,43,54)' 3 | background-transparency-percent=16 4 | bold-is-bright=true 5 | custom-command='/bin/sh -l -c "tmux attach || tmux"' 6 | exit-action='close' 7 | font='Hasklug Nerd Font Bold 11' 8 | foreground-color='rgb(131,148,150)' 9 | login-shell=true 10 | palette=['rgb(7,54,66)', 'rgb(220,50,47)', 'rgb(133,153,0)', 'rgb(181,137,0)', 'rgb(38,139,210)', 'rgb(211,54,130)', 'rgb(42,161,152)', 'rgb(238,232,213)', 'rgb(0,43,54)', 'rgb(203,75,22)', 'rgb(88,110,117)', 'rgb(101,123,131)', 'rgb(131,148,150)', 'rgb(108,113,196)', 'rgb(147,161,161)', 'rgb(253,246,227)'] 11 | preserve-working-directory='always' 12 | use-custom-command=true 13 | use-system-font=false 14 | use-theme-colors=false 15 | use-theme-transparency=false 16 | use-transparent-background=true 17 | visible-name='martins3' 18 | -------------------------------------------------------------------------------- /scripts/nix/env/perftest.nix: -------------------------------------------------------------------------------- 1 | { 2 | pkgs ? import { }, 3 | }: 4 | 5 | pkgs.stdenv.mkDerivation { 6 | name = "perftest"; 7 | # hardeningDisable = [ "all" ]; 8 | buildInputs = with pkgs; [ 9 | cmake 10 | pkg-config 11 | autoconf 12 | pkgconf 13 | automake 14 | libtool 15 | rdma-core 16 | pciutils 17 | ]; 18 | 19 | # 添加上这个,可以让在当前环境中几乎执行任何命令都 segfault 20 | # nix 真的要把人逼疯 21 | # shellHook = '' 22 | # export LD_LIBRARY_PATH=${pkgs.rdma-core}/lib:${pkgs.glibc}/lib 23 | # ''; 24 | } 25 | # 参考 README 中的,不过需要先把 rdma-core 的代码放到正确的位置 26 | # ./autogen.sh 27 | # ./configure 28 | # make 29 | # make install 30 | 31 | # fedora 中需要提前把 rdma-core-devel 配置好 32 | # sudo yum install rdma-core-devel 33 | # 或者参考这个东西来配置本地的库 LT_SYS_LIBRARY_PATH 34 | # 35 | # 但是存在这个东西 : /usr/include/infiniband/verbs.h 36 | # 似乎添加上 rdma-core 就可以了 37 | -------------------------------------------------------------------------------- /config/gdbinit: -------------------------------------------------------------------------------- 1 | # gdb-dashboard init file 2 | 3 | # available layout modules 4 | # stack registers history assembly 5 | # breakpoints expressions memory 6 | # source threads variables 7 | dashboard -layout source 8 | 9 | # https://en.wikipedia.org/wiki/ANSI_escape_code 10 | #dashboard -style prompt 11 | ## fg bold blue 12 | dashboard -style prompt_not_running "\\[\\e[1;34m\\]$\\[\\e[0m\\]" 13 | ## fg bold green 14 | dashboard -style prompt_running "\\[\\e[1;32m\\]$\\[\\e[0m\\]" 15 | 16 | add-auto-load-safe-path /home/martins3/data/qemu/.gdbinit 17 | add-auto-load-safe-path /home/martins3/data/kernel/linux-build/scripts/gdb/vmlinux-gdb.py 18 | 19 | # @todo 有趣 20 | define my-source-profile 21 | dashboard -layout source expression stack variables 22 | dashboard source -style height 20 23 | end 24 | 25 | define my-assembly-profile 26 | dashboard -layout registers assembly memory stack 27 | end 28 | -------------------------------------------------------------------------------- /scripts/nix/env/xiangshang.nix: -------------------------------------------------------------------------------- 1 | { pkgs ? import { } }: 2 | 3 | pkgs.llvmPackages.stdenv.mkDerivation { 4 | name = "xiang"; 5 | buildInputs = with pkgs; [ 6 | bison 7 | llvm 8 | verilator 9 | mill 10 | dtc # device-tree-compiler 11 | (python3.withPackages (p: with p; [ 12 | setuptools 13 | ])) 14 | circt 15 | 16 | ]; 17 | shellHook = '' 18 | export XS_PROJECT_ROOT=$(pwd) 19 | export NEMU_HOME=$(pwd)/NEMU 20 | export AM_HOME=$(pwd)/nexus-am 21 | export NOOP_HOME=$(pwd)/XiangShan 22 | export DRAMSIM3_HOME=$(pwd)/DRAMsim3 23 | ''; 24 | } 25 | 26 | # git submodule update --init --recursive DRAMsim3 NEMU NutShell nexus-am 27 | # git submodule update --init XiangShan && make -C XiangShan init; 28 | # cd XiangShan 29 | # make verilog 30 | # 但是 make 最后会有错误,对比一下 xiby1 的 config 是什么原因吧 31 | -------------------------------------------------------------------------------- /config/zellij/docs.kdl: -------------------------------------------------------------------------------- 1 | layout { 2 | tab name="vn" cwd="/home/martins3/core/vn" { 3 | pane size=1 borderless=true { 4 | plugin location="zellij:tab-bar" 5 | } 6 | pane command="nvim" 7 | } 8 | 9 | // tab name=".dotfiles" cwd="/home/martins3/.dotfiles" { 10 | // pane size=1 borderless=true { 11 | // plugin location="zellij:tab-bar" 12 | // } 13 | // pane command="nvim" 14 | // } 15 | 16 | // tab name="draft" cwd="/home/martins3/core/draft" { 17 | // pane size=1 borderless=true { 18 | // plugin location="zellij:tab-bar" 19 | // } 20 | // pane command="nvim" 21 | // } 22 | 23 | // tab name="orgmode" cwd="/home/martins3/core/org-mode" { 24 | 25 | // pane size=1 borderless=true { 26 | // plugin location="zellij:tab-bar" 27 | // } 28 | // pane command="nvim" 29 | // } 30 | } 31 | session_name "martins3 yyds" 32 | attach_to_session true 33 | -------------------------------------------------------------------------------- /config/gitui/theme.ron: -------------------------------------------------------------------------------- 1 | // https://github.com/catppuccin/gitui/blob/main/themes/catppuccin-macchiato.ron 2 | ( 3 | selected_tab: Some("Reset"), 4 | command_fg: Some("#cad3f5"), 5 | selection_bg: Some("#5b6078"), 6 | selection_fg: Some("#cad3f5"), 7 | cmdbar_bg: Some("#1e2030"), 8 | cmdbar_extra_lines_bg: Some("#1e2030"), 9 | disabled_fg: Some("#8087a2"), 10 | diff_line_add: Some("#a6da95"), 11 | diff_line_delete: Some("#ed8796"), 12 | diff_file_added: Some("#a6da95"), 13 | diff_file_removed: Some("#ee99a0"), 14 | diff_file_moved: Some("#c6a0f6"), 15 | diff_file_modified: Some("#f5a97f"), 16 | commit_hash: Some("#b7bdf8"), 17 | commit_time: Some("#b8c0e0"), 18 | commit_author: Some("#7dc4e4"), 19 | danger_fg: Some("#ed8796"), 20 | push_gauge_bg: Some("#8aadf4"), 21 | push_gauge_fg: Some("#24273a"), 22 | tag_fg: Some("#f4dbd6"), 23 | branch_fg: Some("#8bd5ca") 24 | ) 25 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## Changelog 2 | 3 | ### 2022 4 | 本配置之前一直是基于 [spacevim](https://spacevim.org/) spacevim 的,移除的原因主要是因为: 5 | - spacevim 的配置很多都是 vimscript 写的,我几乎看不懂,出现了问题无法快速独立解决 6 | - spacevim 为了兼容 vim,一些插件的选择和我有冲突,比如包管理器(dein.vim -> packer.nvim) 和文件树(defx -> nvim-tree) 7 | 8 | 将 Fn 相关的快捷键全部去掉了: 9 | - 需要移动手掌,不是很高效 10 | - 有的键盘是没有 Fn 键的,按 Fn 键需要低效的组合键 11 | 12 | ### 2022.8 13 | - 现在仓库的内容不只是 neovim 相关的,还有 nixos 以及其他的各种配置,现在将所有的 vim 配置都放到 nvim 目录下了。 14 | 15 | ### 2022.9 16 | 将 ccls 替换为 clangd,虽然我是 MaskRay 的忠实粉丝,但是: 17 | - ccls 最近更新的比较慢 18 | - clangd 无需额外的插件实现高亮 19 | 20 | ### 2023.2 21 | 将 clangd 换回来 ccls,将相关问题总结到 [2023 年对比一下 ccls 和 clangd](./docs/ccls-vs-clangd.md)。 22 | 23 | ### 2023.7 24 | 将 coc.nvim 切换为 native lsp 了。 25 | 26 | ### 2024.11 27 | - 兼容 nvim 0.10 28 | - 将 terminal 替换为 toggleterm 了 29 | - 将 https://github.com/anuvyklack/hydra.nvim 替换为 30 | https://github.com/nvimtools/hydra.nvim , anuvyklack/hydra.nvim 已经不维护了, 31 | 而且在 nvim 0.10 上有一个非常严重的 bug ,花了 2 天在找到。 32 | -------------------------------------------------------------------------------- /scripts/nix/env/wine.nix: -------------------------------------------------------------------------------- 1 | let 2 | pkgs = import { }; 3 | in 4 | pkgs.mkShell 5 | rec { 6 | buildInputs = with pkgs; [ 7 | bison 8 | flex 9 | fontforge 10 | makeWrapper 11 | pkg-config 12 | 13 | # Required by staging 14 | autoconf 15 | hexdump 16 | perl 17 | 18 | libcap 19 | cups 20 | gettext 21 | dbus 22 | cairo 23 | unixODBC 24 | samba4 25 | ncurses 26 | libva 27 | libpcap 28 | libv4l 29 | sane-backends 30 | libgphoto2 31 | libkrb5 32 | fontconfig 33 | alsa-lib 34 | libpulseaudio 35 | xorg.libXinerama 36 | udev 37 | vulkan-loader 38 | SDL2 39 | libusb1 40 | gtk3 41 | glib 42 | opencl-headers 43 | ocl-icd 44 | openssl 45 | gnutls 46 | libGLU 47 | libGL 48 | mesa.osmesa 49 | libdrm 50 | gnutls 51 | ]; 52 | } 53 | # CFLAGS="-g -O0" ./configure --enable-win64 --without-freetype 54 | # make 55 | -------------------------------------------------------------------------------- /nvim/efm.yaml: -------------------------------------------------------------------------------- 1 | version: 2 2 | root-markers: 3 | - .git/ 4 | lint-debounce: 0s 5 | log-file: /tmp/martins3-nvim-efm.log 6 | log-level: 1 7 | 8 | tools: 9 | rst-lint: &rst-lint 10 | lint-command: 'rst-lint' 11 | lint-formats: 12 | - '%tNFO %f:%l %m' 13 | - '%tARNING %f:%l %m' 14 | - '%tRROR %f:%l %m' 15 | - '%tEVERE %f:%l %m' 16 | 17 | rst-pandoc: &rst-pandoc 18 | format-command: 'pandoc -f rst -t rst -s --columns=79' 19 | 20 | sh-shellcheck: &sh-shellcheck 21 | lint-command: 'shellcheck -f gcc -x' 22 | lint-source: 'shellcheck' 23 | lint-formats: 24 | - '%f:%l:%c: %trror: %m' 25 | - '%f:%l:%c: %tarning: %m' 26 | - '%f:%l:%c: %tote: %m' 27 | 28 | sh-shfmt: &sh-shfmt 29 | format-command: 'shfmt -ci -s -bn' 30 | format-stdin: true 31 | 32 | 33 | languages: 34 | rst: 35 | - <<: *rst-lint 36 | - <<: *rst-pandoc 37 | 38 | sh: 39 | - <<: *sh-shellcheck 40 | - <<: *sh-shfmt 41 | -------------------------------------------------------------------------------- /rime/linux-install.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -E -e -u -o pipefail 4 | 5 | # 路径参考这个: 6 | # https://wiki.archlinux.org/title/Rime 7 | CONFIG_DIR=~/Library/Rime # maos 8 | if [[ $OSTYPE == "linux-gnu"* ]]; then 9 | # CONFIG_DIR=$HOME/.local/share/fcitx5/rime/ 10 | CONFIG_DIR=$HOME/.config/ibus/rime 11 | fi 12 | mkdir -p "$CONFIG_DIR" 13 | 14 | # 安装 plum 15 | cd ~/core/ 16 | if [[ ! -d plum ]]; then 17 | git clone https://github.com/rime/plum 18 | fi 19 | cd plum 20 | # 使用 plum 安装基础组件 21 | rime_dir="$CONFIG_DIR" bash rime-install 22 | 23 | # 从雾凇拼音 中拷贝词库过来 24 | function update_idct_from_ice() { 25 | cd ~/core 26 | if [[ ! -d rime-ice ]]; then 27 | git clone --depth=1 https://github.com/iDvel/rime-ice 28 | fi 29 | cd rime-ice 30 | git pull 31 | cp -r cn_dicts "$CONFIG_DIR" 32 | } 33 | 34 | update_idct_from_ice 35 | 36 | # 部署上我的配置 37 | shopt -s extglob nullglob 38 | cd ~/.dotfiles/rime 39 | for i in *.@(yaml|txt); do 40 | ln -sf "$(pwd)/$i" "$CONFIG_DIR/$i" 41 | done 42 | -------------------------------------------------------------------------------- /scripts/nix/env/libvirt.nix: -------------------------------------------------------------------------------- 1 | # https://github.com/NixOS/nixpkgs/blob/master/pkgs/development/libraries/libvirt/default.nix 2 | let 3 | pkgs = import { }; 4 | in 5 | pkgs.mkShell rec { 6 | buildInputs = with pkgs; [ 7 | # @todo 增加一个 WITH_NUMACTL 8 | bash 9 | bash-completion 10 | curl 11 | dbus 12 | docutils 13 | gettext 14 | glib 15 | gnutls 16 | libgcrypt 17 | libpcap 18 | libtasn1 19 | libtirpc 20 | libxml2 # for xmllint 21 | libxslt # for xsltproc 22 | makeWrapper 23 | meson 24 | numad 25 | perl 26 | perlPackages.XMLXPath 27 | pkg-config 28 | python3 29 | readline 30 | rpcsvc-proto 31 | xhtml1 32 | yajl 33 | ]; 34 | } 35 | # 如果重新配置 meson setup --reconfigure build 36 | # meson setup build -Ddriver_qemu=enabled -Ddriver_libvirtd=enabled -Ddriver_remote=enabled 37 | # cd build && ninja -j30 38 | # ninja -t compdb > compile_commands.json 39 | # cp compile_commands.json .. 40 | -------------------------------------------------------------------------------- /nvim/lua/usr/code_runner.lua: -------------------------------------------------------------------------------- 1 | local function microsoft_edge() 2 | if vim.loop.os_uname().sysname == "Linux" then 3 | return "google-chrome-stable $fileName" 4 | else 5 | return "/Applications/Microsoft\\ Edge.app/Contents/MacOS/Microsoft\\ Edge $file" 6 | end 7 | end 8 | 9 | require("code_runner").setup({ 10 | term = { 11 | position = "belowright", 12 | size = 15, 13 | }, 14 | filetype = { 15 | python = "python3 $file", 16 | c = "cd $dir && gcc -Wall -lpthread -fno-omit-frame-pointer -pg -g " 17 | .. "-lm $fileName -o $fileNameWithoutExt.out && $dir/$fileNameWithoutExt.out", 18 | cpp = "cd $dir && g++ -std=c++20 -lpthread -g $fileName -o" 19 | .. "$fileNameWithoutExt.out && $dir/$fileNameWithoutExt.out", 20 | sh = "bash $file", 21 | html = microsoft_edge(), 22 | r = "Rscript $file", 23 | lua = "lua $file", 24 | nix = "nix eval -f $file", 25 | ps1 = "powershell -ExecutionPolicy Bypass -File $file", 26 | }, 27 | }) 28 | -------------------------------------------------------------------------------- /scripts/nix/env/libbpf.nix: -------------------------------------------------------------------------------- 1 | /* https://discourse.nixos.org/t/how-to-make-mkshell-to-use-clangs-stdenv/9484 */ 2 | with import { }; 3 | 4 | # https://github.com/iovisor/bcc/tree/master/libbpf-tools 5 | # 有点难 6 | # 遇到来两个报错,随便修修,还是不行 7 | # 1. A call to built-in function '__stack_chk_fail' is not supported. 8 | # - 解决方法 : Makefile 中 BPFCFLAGS := -g -O2 -Wall -fno-stack-protector 9 | # 2. clang-11: error: cannot specify -o when generating multiple output files 10 | # - 不知道怎么解决,就算去掉 -o ,生成的 a.out 也有问题 11 | # 感觉 nixos 上使用很难 12 | (mkShell.override { stdenv = clangStdenv; }) { 13 | hardeningDisable = [ "all" ]; 14 | buildInputs = [ 15 | bpftools 16 | elfutils 17 | libbfd 18 | libbpf 19 | libcap 20 | llvm 21 | ]; 22 | } 23 | 24 | # libbfd 和 libcap 是做啥的不知道,但是构建的过程中的确要 25 | # 26 | # ... libbfd: [ OFF ] 27 | # ... clang-bpf-co-re: [ on ] 28 | # ... llvm: [ on ] 29 | # ... libcap: [ OFF ] 30 | -------------------------------------------------------------------------------- /config/pueue.yml: -------------------------------------------------------------------------------- 1 | --- 2 | shared: 3 | pueue_directory: ~/.local/share/pueue 4 | use_unix_socket: true 5 | runtime_directory: null 6 | unix_socket_path: ~/.local/share/pueue/pueue_your_user.socket 7 | host: "localhost" 8 | port: "6924" 9 | daemon_cert: ~/.local/share/pueue/certs/daemon.cert 10 | daemon_key: ~/.local/share/pueue/certs/daemon.key 11 | shared_secret_path: ~/.local/share/pueue/shared_secret 12 | 13 | client: 14 | restart_in_place: false 15 | read_local_logs: true 16 | show_confirmation_questions: false 17 | show_expanded_aliases: false 18 | dark_mode: false 19 | max_status_height: null 20 | status_time_format: "%H:%M:%S" 21 | status_datetime_format: "%Y-%m-%d\n%H:%M:%S" 22 | 23 | daemon: 24 | default_parallel_tasks: 1 25 | pause_group_on_failure: false 26 | pause_all_on_failure: false 27 | callback: "Task {{ id }}\nCommand: {{ command }}\nPath: {{ path }}\nFinished with status '{{ result }}'\"" 28 | callback_log_lines: 10 29 | groups: 30 | default: 1 31 | -------------------------------------------------------------------------------- /scripts/nix/env/qemu.nix: -------------------------------------------------------------------------------- 1 | let 2 | pkgs = import { }; 3 | in 4 | pkgs.stdenv.mkDerivation { 5 | # pkgs.clangStdenv.mkDerivation { 6 | 7 | # 添加上这个才可以添加 --enable-debug 8 | hardeningDisable = [ "all" ]; 9 | name = "martins3's QEMU"; 10 | buildInputs = with pkgs; [ 11 | zlib 12 | pkg-config 13 | ninja 14 | glib 15 | pixman 16 | xorg.libX11.dev 17 | rdma-core 18 | liburing 19 | libiscsi 20 | libcap_ng 21 | libslirp 22 | gtk3 23 | libaio 24 | libnfs 25 | liburing 26 | libseccomp 27 | libssh 28 | libbpf 29 | libusb1 30 | zstd 31 | virglrenderer 32 | libepoxy 33 | numactl 34 | (python3.withPackages (p: with p; [ 35 | sphinx 36 | sphinx-rtd-theme 37 | ])) 38 | flex 39 | bison 40 | rustc 41 | rust-bindgen 42 | rustfmt 43 | clippy 44 | rdma-core 45 | lttng-ust 46 | ]; 47 | 48 | RUST_LIB_SRC = "${pkgs.rust.packages.stable.rustPlatform.rustLibSrc}"; 49 | } 50 | -------------------------------------------------------------------------------- /config/alacritty.toml: -------------------------------------------------------------------------------- 1 | [colors.bright] 2 | black = "0x002b36" 3 | blue = "0x839496" 4 | cyan = "0x93a1a1" 5 | green = "0x586e75" 6 | magenta = "0x6c71c4" 7 | red = "0xcb4b16" 8 | white = "0xfdf6e3" 9 | yellow = "0x657b83" 10 | 11 | [colors.normal] 12 | black = "0x073642" 13 | blue = "0x268bd2" 14 | cyan = "0x2aa198" 15 | green = "0x859900" 16 | magenta = "0xd33682" 17 | red = "0xdc322f" 18 | white = "0xeee8d5" 19 | yellow = "0xb58900" 20 | 21 | [colors.primary] 22 | background = "0x002b36" 23 | foreground = "0x839496" 24 | 25 | [font] 26 | size = 15.0 27 | 28 | [font.normal] 29 | family = "FiraCode Nerd Font" 30 | 31 | [terminal.shell] 32 | program = "zsh" 33 | 34 | [window] 35 | decorations = "none" 36 | opacity = 0.98 37 | startup_mode = "Maximized" 38 | 39 | [[keyboard.bindings]] 40 | key = "Plus" 41 | mods = "Control|Shift" 42 | action = "IncreaseFontSize" 43 | 44 | # 这个为什么配置不失效,而且如何取消掉默认的 control + 和 control 的行为 45 | [[keyboard.bindings]] 46 | key = "Minus" 47 | mods = "Control|Shift" 48 | action = "DecreaseFontSize" 49 | -------------------------------------------------------------------------------- /osc.diff: -------------------------------------------------------------------------------- 1 | diff --git a/nvim/lua/usr/init.lua b/nvim/lua/usr/init.lua 2 | index 56f19e4c4d31..5f6fd895e4b3 100644 3 | --- a/nvim/lua/usr/init.lua 4 | +++ b/nvim/lua/usr/init.lua 5 | @@ -56,14 +56,6 @@ require("bookmarks").setup({ 6 | virt_pattern = { "*.lua", "*.md", "*.c", "*.h", "*.sh", "*.py" }, 7 | }) 8 | 9 | -local function copy() 10 | - if vim.v.event.operator == "y" and vim.v.event.regname == "+" then 11 | - require("osc52").copy_register("+") 12 | - end 13 | -end 14 | - 15 | -vim.api.nvim_create_autocmd("TextYankPost", { callback = copy }) 16 | - 17 | require("persisted").setup({ 18 | autoload = true, 19 | should_save = function() 20 | diff --git a/nvim/lua/usr/lazy.lua b/nvim/lua/usr/lazy.lua 21 | index 91e80316b9c9..412f9f3b8448 100644 22 | --- a/nvim/lua/usr/lazy.lua 23 | +++ b/nvim/lua/usr/lazy.lua 24 | @@ -153,7 +153,6 @@ require("lazy").setup({ 25 | cmd = { "TransferInit", "TransferToggle" }, 26 | opts = {}, 27 | }, 28 | - "ojroques/nvim-osc52", 29 | -- cppman 30 | { 31 | "madskjeldgaard/cppman.nvim", 32 | -------------------------------------------------------------------------------- /config/windows/pwsh.ps1: -------------------------------------------------------------------------------- 1 | #f45873b3-b655-43a6-b217-97c00aa0db58 PowerToys CommandNotFound module 2 | Import-Module -Name Microsoft.WinGet.CommandNotFound 3 | #f45873b3-b655-43a6-b217-97c00aa0db58 4 | function Invoke-SshScript { 5 | param( 6 | [switch]$c 7 | ) 8 | & "C:\Users\97936\data\vn\smartx\ssh.ps1" @PSBoundParameters 9 | } 10 | Set-Alias s Invoke-SshScript 11 | 12 | function gsy(){ 13 | git pull --rebase --autostash 14 | git commit -s -m "double win" 15 | git push 16 | } 17 | 18 | function rmrf(){ 19 | Remove-Item @args -Recurse -Force 20 | } 21 | 22 | function q { exit } 23 | function gg { gitui --watcher } 24 | function fedora { wsl --user martins3 -d FedoraLinux-42 } 25 | Set-Alias ls lsd 26 | function l { lsd -lah @args } 27 | Set-Alias c Clear-Host 28 | Set-Alias v nvim 29 | 30 | # Invoke-Expression (&starship init powershell) 31 | Invoke-Expression (& { (zoxide init powershell | Out-String) }) 32 | # oh-my-posh init pwsh | Invoke-Expression 33 | 34 | Import-Module PSReadline 35 | Set-PSReadLineOption -EditMode Emacs 36 | -------------------------------------------------------------------------------- /docs/zellij.md: -------------------------------------------------------------------------------- 1 | ## zellij 2 | - https://zellij.dev/documentation/introduction.html 3 | - https://news.ycombinator.com/item?id=26902430 4 | - 大家的评价是,技术体系很新 5 | 6 | 启动一个新的布局: 7 | zellij --layout /home/martins3/.dotfiles/config/zellij/docs.kdl 8 | 9 | config/zellij/default.kdl 是默认的启动布局。 10 | 11 | 但是估计从 tmux 到 zellij 迁移难度比较大,需要完成如下工作: 12 | - [ ] 快速切换 session 13 | - [ ] 自动修改 tab 的名称 14 | - [ ] 使用 ctrl+shift+arrow 移动 tab 15 | - [ ] 为什么当一个 layout 含有: 16 | ```txt 17 | pane size=1 borderless=true { 18 | plugin location="zellij:tab-bar" 19 | } 20 | ``` 21 | nvim 的启动首先会卡住一下,是谁的问题 22 | - [x] https://github.com/zellij-org/zellij/issues/1760 这个问题没有解决 23 | - 打开屏幕的一堆横线,但是很快就被解决了 24 | - [ ] 在 nvim 打开的一瞬间,还是存在很多横线 25 | - [ ] 屏幕切换的时候,中文显示有问题。 26 | - 这个问题类似: https://github.com/zellij-org/zellij/issues/2256 27 | - [ ] [无法使用鼠标调整 pane 的大小。](https://github.com/zellij-org/zellij/issues/1262) 28 | - [ ] Alt + hjkl 会直接移动到下一个 tab 中去 29 | 30 | 问题很多,没有时间一个个的修复了,偶尔用用。 31 | 32 | 真的是相当酷炫啊 33 | https://zellij.dev/news/new-plugin-system/ 34 | 35 | 只要这个项目不死掉,完全可以切换过去。 36 | -------------------------------------------------------------------------------- /scripts/nix/env/README.md: -------------------------------------------------------------------------------- 1 | $(shell pkg-config --cflags --libs libaio) 没有 2 | 3 | 4 | ```txt 5 | gcc aio.c -L/nix/store/x4gs2rwxlzncs4xhi7swnkfyx2qy089w-libaio-0.3.113/lib 6 | /nix/store/8qmr9i8i5lgac3jyba331izf8j09ddsa-binutils-2.43.1/bin/ld: /tmp/ccRtXxri.o: in function 7 | `main.cold': 8 | aio.c:(.text.unlikely+0x28): undefined reference to `io_destroy' 9 | /nix/store/8qmr9i8i5lgac3jyba331izf8j09ddsa-binutils-2.43.1/bin/ld: /tmp/ccRtXxri.o: in function 10 | `main': 11 | aio.c:(.text.startup+0x38): undefined reference to `io_setup' 12 | /nix/store/8qmr9i8i5lgac3jyba331izf8j09ddsa-binutils-2.43.1/bin/ld: aio.c:(.text.startup+0x10d): 13 | undefined reference to `io_submit' 14 | /nix/store/8qmr9i8i5lgac3jyba331izf8j09ddsa-binutils-2.43.1/bin/ld: aio.c:(.text.startup+0x174): 15 | undefined reference to `io_destroy' 16 | /nix/store/8qmr9i8i5lgac3jyba331izf8j09ddsa-binutils-2.43.1/bin/ld: aio.c:(.text.startup+0x1d6): 17 | undefined reference to `io_getevents' 18 | collect2: error: ld returned 1 exit status 19 | ``` 20 | 解决办法居然是 -laio 21 | 22 | 23 | ## 总是在一起的 24 | autoconf 25 | automake 26 | -------------------------------------------------------------------------------- /scripts/nix/nix-channel.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -x 4 | if [[ -f /etc/nixos/configuration.nix ]]; then 5 | SUDO=sudo 6 | else 7 | SUDO="" 8 | fi 9 | $SUDO nix-channel --add https://github.com/nix-community/home-manager/archive/release-25.05.tar.gz home-manager 10 | 11 | # $SUDO nix-channel --add https://nixos.org/channels/nixos-24.05 nixos 12 | # $SUDO nix-channel --add https://nixos.org/channels/nixos-24.05 nixpkgs 13 | # $SUDO nix-channel --add https://nixos.org/channels/nixpkgs-unstable/ unstable 14 | # $SUDO nix-channel --add https://nixos.org/channels/nixos-unstable/ nixos-unstable 15 | 16 | if [[ -f /etc/nixos/configuration.nix ]]; then 17 | $SUDO nix-channel --add https://mirror.tuna.tsinghua.edu.cn/nix-channels/nixos-25.05 nixos 18 | $SUDO nix-channel --add https://mirrors.tuna.tsinghua.edu.cn/nix-channels/nixos-unstable/ nixos-unstable 19 | fi 20 | $SUDO nix-channel --add https://mirror.tuna.tsinghua.edu.cn/nix-channels/nixos-25.05 nixpkgs 21 | $SUDO nix-channel --add https://mirrors.tuna.tsinghua.edu.cn/nix-channels/nixpkgs-unstable unstable 22 | 23 | $SUDO nix-channel --update 24 | -------------------------------------------------------------------------------- /nvim/lua/usr/nvim-treesitter.lua: -------------------------------------------------------------------------------- 1 | require 'nvim-treesitter'.setup {} 2 | vim.api.nvim_create_autocmd('FileType', { 3 | pattern = { 'markdown', 'c', 'sh' }, 4 | callback = function() 5 | vim.treesitter.start() 6 | end, 7 | }) 8 | 9 | require 'nvim-treesitter'.install { 10 | "lua", 11 | "java", 12 | "rust", 13 | "nix", 14 | "bash", 15 | "go", 16 | "diff", 17 | "scala", 18 | "awk", 19 | "python", 20 | "markdown", 21 | "markdown_inline", -- 让 markdown 里面的代码段可以高亮 22 | -- 'comment' -- 更好的高亮 TODO XXX NOTE FIXME ,但是其让 url 的高亮过于明显 23 | "rst", 24 | "llvm", 25 | "gitcommit", 26 | "gitignore", 27 | "git_rebase", 28 | "html", 29 | "perl", -- 内核的一些脚本是 perl 30 | "make", 31 | "kconfig", 32 | "toml", 33 | } 34 | 35 | 36 | -- configuration 37 | require("nvim-treesitter-textobjects").setup { 38 | move = { 39 | -- whether to set jumps in the jumplist 40 | set_jumps = true, 41 | }, 42 | } 43 | 44 | vim.keymap.set({ "n", "x", "o" }, "gj", function() 45 | require("nvim-treesitter-textobjects.move").goto_previous_start("@function.outer", "textobjects") 46 | end) 47 | -------------------------------------------------------------------------------- /nvim/lua/usr/mason.lua: -------------------------------------------------------------------------------- 1 | -- Add the same capabilities to ALL server configurations. 2 | -- Refer to :h vim.lsp.config() for more information. 3 | vim.lsp.config("*", { 4 | capabilities = vim.lsp.protocol.make_client_capabilities() 5 | }) 6 | 7 | local servers = { 8 | "bashls", 9 | "cssls", 10 | "efm", 11 | "html", 12 | "jsonls", 13 | "lua_ls", 14 | -- "marksman", 不够稳定,而且 CPU 消耗高 15 | "pyright", 16 | "vimls", 17 | "yamlls", 18 | "perlnavigator", 19 | -- "typos_lsp", 20 | -- "tsserver", 21 | } 22 | 23 | require("mason").setup() 24 | require("mason-lspconfig").setup { 25 | ensure_installed = servers 26 | } 27 | vim.lsp.enable({ 'ccls', 'nixd' }) 28 | -- 虽然打开这个会让 29 | -- 打开这个选项会让 telescope ui 不正常 30 | -- vim.o.winborder = 'rounded' 31 | 32 | vim.diagnostic.config({ 33 | -- virtual_lines 造成了巨大的视觉干扰,还是 virtual_text 好用 34 | -- virtual_lines = { current_line = true, }, 35 | virtual_text = { current_line = true, }, 36 | }) 37 | 38 | local map = vim.keymap.set 39 | map({ "n", "x" }, "lf", function() 40 | require("conform").format { lsp_fallback = true } 41 | end, { desc = "general format file" }) 42 | -------------------------------------------------------------------------------- /scripts/nix/env/rust-simple.nix: -------------------------------------------------------------------------------- 1 | # https://discourse.nixos.org/t/how-can-i-set-up-my-rust-programming-environment/4501/6 2 | with import { }; 3 | pkgs.llvmPackages.stdenv.mkDerivation { 4 | hardeningDisable = [ "all" ]; 5 | name = "simple-rust"; 6 | buildInputs = with pkgs; [ 7 | cargo 8 | rustc 9 | rustfmt 10 | rustup 11 | 12 | # Necessary for the openssl-sys crate 13 | openssl 14 | pkg-config 15 | 16 | rust-analyzer 17 | # wasm-pack 18 | # wasmer 19 | # wasmtime 20 | libclang 21 | cmake 22 | glibc 23 | glibc.dev 24 | 25 | 26 | fuse 27 | 28 | # IronRDP 29 | alsa-lib 30 | libopus 31 | 32 | # alacritty 33 | fontconfig 34 | 35 | # 测试 gRPC 36 | protobuf 37 | ]; 38 | 39 | # See https://discourse.nixos.org/t/rust-src-not-found-and-other-misadventures-of-developing-rust-on-nixos/11570/3?u=samuela. 40 | LIBCLANG_PATH = "${pkgs.llvmPackages.libclang.lib}/lib"; 41 | RUST_SRC_PATH = "${pkgs.rust.packages.stable.rustPlatform.rustLibSrc}"; 42 | BINDGEN_EXTRA_CLANG_ARGS = "-I${pkgs.glibc.dev}/include -I${pkgs.linuxHeaders}/include"; 43 | } 44 | -------------------------------------------------------------------------------- /nvim/lua/usr/orgmode.lua: -------------------------------------------------------------------------------- 1 | require("orgmode").setup({ 2 | org_agenda_files = { "~/core/org-mode/*" }, 3 | org_default_notes_file = "~/core/org-mode/refile.org", 4 | mappings = { 5 | global = { 6 | org_agenda = "oa", 7 | org_capture = "oc", 8 | }, 9 | agenda = { 10 | org_agenda_todo = "t", 11 | }, 12 | org = { 13 | -- 修改 TODO 的状态 14 | org_todo = "t", 15 | -- 打开或者折叠,默认映射为 tab ,但是 tab 用于在 window 直接的移动,所以重新映射为 x 16 | org_cycle = "x", 17 | -- 插入新的代办 18 | org_insert_todo_heading = "a", 19 | }, 20 | }, 21 | org_capture_templates = { 22 | j = { 23 | description = 'Journal', 24 | template = "\n*** %<%Y-%m-%d> %<%A>\n**** %U\n\n%?", 25 | target = "~/core/org-mode/journal.org", 26 | }, 27 | t= "TODO", 28 | tw = { 29 | description = "Work Task", 30 | template = "* TODO %?\n SCHEDULED: %t", 31 | target = "~/core/org-mode/work.org", 32 | }, 33 | ts = { 34 | description = "Study Task", 35 | template = "* TODO %?\n SCHEDULED: %t", 36 | target = "~/core/org-mode/study.org", 37 | }, 38 | }, 39 | }) 40 | -------------------------------------------------------------------------------- /nixpkgs/sys/boot.nix: -------------------------------------------------------------------------------- 1 | { config, pkgs, ... }: 2 | 3 | { 4 | boot = { 5 | crashDump.enable = false; # TODO 这个东西形同虚设,无须浪费表情 6 | crashDump.reservedMemory = "1G"; 7 | # nixos 的 /tmp 不是 tmpfs 的,但是我希望重启之后,/tmp 被清空 8 | tmp.cleanOnBoot = true; 9 | 10 | loader = { 11 | efi = { 12 | canTouchEfiVariables = true; 13 | # assuming /boot is the mount point of the EFI partition in NixOS (as the installation section recommends). 14 | efiSysMountPoint = "/boot"; 15 | }; 16 | 17 | systemd-boot.configurationLimit = 10; 18 | 19 | grub = { 20 | # https://www.reddit.com/r/NixOS/comments/wjskae/how_can_i_change_grub_theme_from_the/ 21 | # theme = pkgs.nixos-grub2-theme; 22 | theme = 23 | pkgs.fetchFromGitHub { 24 | owner = "shvchk"; 25 | repo = "fallout-grub-theme"; 26 | rev = "80734103d0b48d724f0928e8082b6755bd3b2078"; 27 | sha256 = "sha256-7kvLfD6Nz4cEMrmCA9yq4enyqVyqiTkVZV5y4RyUatU="; 28 | }; 29 | devices = [ "nodev" ]; 30 | efiSupport = true; 31 | }; 32 | }; 33 | supportedFilesystems = [ "ntfs" ]; 34 | }; 35 | } 36 | -------------------------------------------------------------------------------- /nixpkgs/patches/dma_ops.patch: -------------------------------------------------------------------------------- 1 | diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c 2 | index ab32a91f287b..5aa5c5113a23 100644 3 | --- a/drivers/pci/pci-sysfs.c 4 | +++ b/drivers/pci/pci-sysfs.c 5 | @@ -29,6 +29,7 @@ 6 | #include 7 | #include 8 | #include 9 | +#include 10 | #include "pci.h" 11 | 12 | static int sysfs_initialized; /* = 0 */ 13 | @@ -373,6 +374,13 @@ static ssize_t dma_mask_bits_show(struct device *dev, 14 | } 15 | static DEVICE_ATTR_RO(dma_mask_bits); 16 | 17 | +static ssize_t dma_ops_show(struct device *dev, 18 | + struct device_attribute *attr, char *buf) 19 | +{ 20 | + return sprintf(buf, "%pF\n", get_dma_ops(dev)); 21 | +} 22 | +static DEVICE_ATTR_RO(dma_ops); 23 | + 24 | static ssize_t consistent_dma_mask_bits_show(struct device *dev, 25 | struct device_attribute *attr, 26 | char *buf) 27 | @@ -608,6 +616,7 @@ static struct attribute *pci_dev_attrs[] = { 28 | #endif 29 | &dev_attr_dma_mask_bits.attr, 30 | &dev_attr_consistent_dma_mask_bits.attr, 31 | + &dev_attr_dma_ops.attr, 32 | &dev_attr_enable.attr, 33 | &dev_attr_broken_parity_status.attr, 34 | &dev_attr_msi_bus.attr, 35 | -------------------------------------------------------------------------------- /scripts/nix/env/rust-best.nix: -------------------------------------------------------------------------------- 1 | { 2 | pkgs ? import { }, 3 | }: 4 | let 5 | overrides = (builtins.fromTOML (builtins.readFile ./rust-toolchain.toml)); 6 | in 7 | pkgs.callPackage ( 8 | { 9 | stdenv, 10 | mkShell, 11 | rustup, 12 | rustPlatform, 13 | 14 | }: 15 | mkShell { 16 | strictDeps = true; 17 | nativeBuildInputs = with pkgs; [ 18 | rustup 19 | rustPlatform.bindgenHook 20 | # firecracker 中 aws-lc 21 | (python3.withPackages ( 22 | p: with p; [ 23 | seccomp 24 | ] 25 | )) 26 | ]; 27 | 28 | # libraries here 29 | buildInputs = with pkgs; [ 30 | libseccomp 31 | rust-analyzer 32 | ]; 33 | RUSTC_VERSION = overrides.toolchain.channel; 34 | # https://github.com/rust-lang/rust-bindgen#environment-variables 35 | shellHook = '' 36 | export PATH="''${CARGO_HOME:-~/.cargo}/bin":"$PATH" 37 | export PATH="''${RUSTUP_HOME:-~/.rustup}/toolchains/$RUSTC_VERSION-${stdenv.hostPlatform.rust.rustcTarget}/bin":"$PATH" 38 | ''; 39 | } 40 | ) { } 41 | # firecracker : 直接 cargo build --features "gdb" 就可以了 42 | # 如果 rust-analyzer 立刻退出,那么试试,基本都是可以解决 43 | # rustup component add rust-analyzer 44 | # 虽然不知道为什么 45 | -------------------------------------------------------------------------------- /config/gitconfig: -------------------------------------------------------------------------------- 1 | [alias] 2 | adog = "log --all --decorate --oneline --graph" 3 | bug = "log -n 1 --pretty=fixes" 4 | kernel = "log -n 1 --pretty=commit" 5 | log-merge = "!f() { git log --oneline --graph --stat \"$1^..$1\"; }; f" 6 | 7 | [core] 8 | abbrev = 12 9 | editor = "nvim" 10 | pager = "delta" 11 | 12 | [credential] 13 | helper = "store" 14 | 15 | [delta] 16 | light = "false" 17 | navigate = "true" 18 | 19 | [diff] 20 | colorMoved = "default" 21 | 22 | [interactive] 23 | diffFilter = "delta --color-only" 24 | 25 | [merge] 26 | conflictstyle = "diff3" 27 | 28 | [pretty] 29 | commit = "commit %h (\"%s\")" 30 | fixes = "Fixes: %h (\"%s\")" 31 | 32 | [sendemail] 33 | smtpencryption = "tls" 34 | smtpserver = "smtp.googlemail.com" 35 | smtpserverport = 587 36 | smtpuser = "xueshi.hu@smartx.com" 37 | 38 | [sendemail "linux"] 39 | cccmd = "/home/martins3/core/linux/scripts/get_maintainer.pl --nogit --nogit-fallback --norolestats --nom" 40 | tocmd = "/home/martins3/core/linux/scripts/get_maintainer.pl --nogit --nogit-fallback --norolestats --nol" 41 | 42 | [user] 43 | email = "xueshi.hu@smartx.com" 44 | name = "Xueshi Hu" 45 | 46 | # 不同的机器有不同的 git proxy 的方法 47 | # 检查方法 48 | # git config --get http.proxy 49 | [include] 50 | path = ~/.gitconfig-local 51 | -------------------------------------------------------------------------------- /scripts/nix/env/spdk.nix: -------------------------------------------------------------------------------- 1 | # 参考: 2 | # https://github.com/NixOS/nixpkgs/blob/master/pkgs/development/libraries/spdk/default.nix 3 | { pkgs ? import { } }: 4 | 5 | pkgs.stdenv.mkDerivation { 6 | pname = "spdk"; 7 | 8 | version = "24.09"; 9 | 10 | nativeBuildInputs = with pkgs; [ 11 | python3 12 | python3.pkgs.pip 13 | python3.pkgs.setuptools 14 | python3.pkgs.wheel 15 | python3.pkgs.wrapPython 16 | python3.pkgs.pyelftools 17 | pkg-config 18 | ensureNewerSourcesForZipFilesHook 19 | ]; 20 | 21 | buildInputs = with pkgs; [ 22 | autoconf 23 | libtool 24 | automake 25 | 26 | elfutils 27 | cunit 28 | dpdk 29 | fuse3 30 | jansson 31 | libaio 32 | libbsd 33 | liburing 34 | elfutils 35 | libuuid 36 | libpcap 37 | libnl 38 | numactl 39 | openssl 40 | ncurses 41 | zlib 42 | zstd 43 | ]; 44 | 45 | propagatedBuildInputs = with pkgs; [ 46 | python3.pkgs.configshell 47 | ]; 48 | 49 | postPatch = '' 50 | patchShebangs . 51 | ''; 52 | 53 | enableParallelBuilding = true; 54 | 55 | env.NIX_CFLAGS_COMPILE = "-mssse3"; # Necessary to compile. 56 | # otherwise does not find strncpy when compiling 57 | env.NIX_LDFLAGS = "-lbsd"; 58 | 59 | } 60 | -------------------------------------------------------------------------------- /config/starship.toml: -------------------------------------------------------------------------------- 1 | add_newline = false 2 | 3 | format = """ 4 | $localip\ 5 | $shlvl\ 6 | $singularity\ 7 | $kubernetes\ 8 | $directory\ 9 | $vcsh\ 10 | $git_branch\ 11 | $git_commit\ 12 | $git_state\ 13 | $git_metrics\ 14 | $git_status\ 15 | $hg_branch\ 16 | $docker_context\ 17 | $package\ 18 | $c\ 19 | $cmake\ 20 | $cobol\ 21 | $daml\ 22 | $dart\ 23 | $deno\ 24 | $dotnet\ 25 | $elixir\ 26 | $elm\ 27 | $erlang\ 28 | $golang\ 29 | $haskell\ 30 | $helm\ 31 | $java\ 32 | $julia\ 33 | $kotlin\ 34 | $lua\ 35 | $nim\ 36 | $nodejs\ 37 | $ocaml\ 38 | $perl\ 39 | $php\ 40 | $pulumi\ 41 | $purescript\ 42 | $python\ 43 | $raku\ 44 | $rlang\ 45 | $red\ 46 | $ruby\ 47 | $rust\ 48 | $scala\ 49 | $swift\ 50 | $terraform\ 51 | $vlang\ 52 | $vagrant\ 53 | $zig\ 54 | $buf\ 55 | $nix_shell\ 56 | $conda\ 57 | $spack\ 58 | $memory_usage\ 59 | $aws\ 60 | $gcloud\ 61 | $openstack\ 62 | $azure\ 63 | $env_var\ 64 | $crystal\ 65 | $custom\ 66 | $sudo\ 67 | $cmd_duration\ 68 | $jobs\ 69 | $line_break\ 70 | $battery\ 71 | $time\ 72 | $status\ 73 | $container\ 74 | $shell\ 75 | $character""" 76 | 77 | [env_var] 78 | variable = "SHELL_ARCH" 79 | style = "bold yellow" 80 | format = "[$env_value]($style) " 81 | 82 | [character] 83 | success_symbol = "[🧀](bold green) " 84 | error_symbol = "[🤒](bold red) " 85 | 86 | [container] 87 | format = '[🦭]($style) ' 88 | -------------------------------------------------------------------------------- /scripts/nixos-install.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -E -e -u -o pipefail 4 | 5 | if [[ ! -d "$HOME"/.config/nixpkgs ]]; then 6 | mkdir -p "$HOME"/.config/nixpkgs 7 | mkdir -p "$HOME"/.config/nix/ 8 | ln -sf "$HOME"/.dotfiles/nixpkgs "$HOME"/.config/home-manager 9 | ln -sf "$HOME"/.dotfiles/nixpkgs/config.nix "$HOME"/.config/nixpkgs/config.nix 10 | ln -sf "$HOME"/.dotfiles/config/nix.conf "$HOME"/.config/nix/nix.conf 11 | fi 12 | 13 | if [[ -f /etc/nixos/configuration.nix ]]; then 14 | line="(import $HOME/.config/home-manager/system.nix { disable_gui = 0; })" 15 | sudo sed -i "/hardware-configuration.nix/a $line" /etc/nixos/configuration.nix 16 | # shellcheck disable=SC2016 17 | hash='$6$Iehu.x9i7eiceV.q$X4INuNrrxGvdK546sxdt3IV9yHr90/Mxo7wuIzdowoN..jFSFjX8gHaXchfBxV4pOYM4h38pPJOeuI1X/5fon/' 18 | line="users.users.root.hashedPassword = \"$hash\";" 19 | echo "$line" >>/etc/nixos/configuration.nix 20 | line="users.users.martins3.hashedPassword = \"$hash\";" 21 | echo "$line" >>/etc/nixos/configuration.nix 22 | 23 | sudo "$HOME"/.dotfiles/scripts/nix/nix-channel.sh 24 | sudo nixos-rebuild switch 25 | else 26 | # 和 nixpkgs/opt.nix 对应,用于仅仅安装 home-manager 27 | cat <<_EOF >"$HOME"/opt-local.nix 28 | { 29 | isGui = false; 30 | } 31 | _EOF 32 | fi 33 | 34 | nix-shell '' -A install 35 | home-manager switch 36 | -------------------------------------------------------------------------------- /config/atuin.toml: -------------------------------------------------------------------------------- 1 | ## where to store your database, default is your system data directory 2 | ## mac: ~/Library/Application Support/com.elliehuxtable.atuin/history.db 3 | ## linux: ~/.local/share/atuin/history.db 4 | # db_path = "~/.history.db" 5 | 6 | ## where to store your encryption key, default is your system data directory 7 | # key_path = "~/.key" 8 | 9 | ## where to store your auth session token, default is your system data directory 10 | # session_path = "~/.key" 11 | 12 | ## date format used, either "us" or "uk" 13 | # dialect = "uk" 14 | 15 | ## enable or disable automatic sync 16 | # auto_sync = true 17 | 18 | ## enable or disable automatic update checks 19 | # update_check = true 20 | 21 | ## how often to sync history. note that this is only triggered when a command 22 | ## is ran, so sync intervals may well be longer 23 | ## set it to 0 to sync after every command 24 | # sync_frequency = "5m" 25 | 26 | ## address of the sync server 27 | # sync_address = "https://api.atuin.sh" 28 | 29 | ## which search mode to use 30 | ## possible values: prefix, fulltext, fuzzy 31 | # search_mode = "prefix" 32 | 33 | ## which style to use 34 | ## possible values: auto, full, compact 35 | style = "compact" 36 | 37 | ## what to do when the escape key is pressed when searching 38 | ## possible values: return-original, return-query 39 | # exit_mode = "return-original" 40 | -------------------------------------------------------------------------------- /barbecue.diff: -------------------------------------------------------------------------------- 1 | diff --git a/nvim/lua/usr/nvim-treesitter.lua b/nvim/lua/usr/nvim-treesitter.lua 2 | index ffc71537274f..fd776b9bff59 100644 3 | --- a/nvim/lua/usr/nvim-treesitter.lua 4 | +++ b/nvim/lua/usr/nvim-treesitter.lua 5 | @@ -78,7 +78,7 @@ require("nvim-treesitter.configs").setup({ 6 | ["xK"] = "@class.outer", 7 | }, 8 | goto_previous_start = { 9 | - ["xh"] = "@function.outer", 10 | + ["gj"] = "@function.outer", 11 | ["xH"] = "@class.outer", 12 | }, 13 | goto_previous_end = { 14 | diff --git a/nvim/lua/usr/which-key.lua b/nvim/lua/usr/which-key.lua 15 | index e6f40e45cab0..6aecf0881c4c 100644 16 | --- a/nvim/lua/usr/which-key.lua 17 | +++ b/nvim/lua/usr/which-key.lua 18 | @@ -119,11 +119,6 @@ wk.add({ 19 | { "gD", "lua vim.lsp.buf.declaration()", desc = "go to declaration" }, 20 | { "gd", "lua vim.lsp.buf.definition()", desc = "go to definition" }, 21 | { "gi", "lua vim.lsp.buf.implementation()", desc = "go to implementation" }, 22 | - { 23 | - "gj", 24 | - "lua require('barbecue.ui').navigate(-1)", 25 | - desc = "go to the head of function / struct", 26 | - }, 27 | { "gr", "lua vim.lsp.buf.references()", desc = "go to reference" }, 28 | { "gw", "Telescope diagnostics", desc = "diagnostics" }, 29 | { "m", group = "bookmarks" }, 30 | -------------------------------------------------------------------------------- /scripts/nix/env/linux.nix: -------------------------------------------------------------------------------- 1 | with import { }; 2 | pkgs.llvmPackages.stdenv.mkDerivation { 3 | hardeningDisable = [ "all" ]; 4 | name = "yyds"; 5 | buildInputs = with pkgs; [ 6 | getopt 7 | flex 8 | bison 9 | gcc 10 | gnumake 11 | bc 12 | rpm 13 | dpkg 14 | pahole # bpf 15 | pkg-config 16 | binutils 17 | 18 | elfutils 19 | ncurses 20 | openssl 21 | zlib 22 | lld 23 | llvm 24 | # selftests 需要依赖的哭 25 | alsa-lib 26 | libcap 27 | libmnl 28 | libcap_ng 29 | liburing 30 | libaio 31 | 32 | # Necessary for the openssl-sys crate: 33 | openssl 34 | pkg-config 35 | graphviz 36 | 37 | (python3.withPackages ( 38 | p: with p; [ 39 | sphinx 40 | # 修改 Documentation/conf.py 中 html_theme = 'sphinx_rtd_theme' 41 | sphinx-rtd-theme 42 | pyyaml 43 | ] 44 | )) 45 | libopcodes 46 | numactl 47 | # numa_num_possible_cpus 48 | # libperl 49 | libunwind 50 | xz 51 | zstd 52 | perl 53 | libtraceevent 54 | libclang 55 | clang 56 | 57 | rustc 58 | rust-bindgen 59 | rustfmt 60 | clippy 61 | 62 | # netlink 用户态测试 63 | libnl 64 | ]; 65 | 66 | RUST_LIB_SRC = "${pkgs.rust.packages.stable.rustPlatform.rustLibSrc}"; 67 | 68 | # See https://discourse.nixos.org/t/rust-src-not-found-and-other-misadventures-of-developing-rust-on-nixos/11570/3?u=samuela. 69 | # RUST_SRC_PATH = "${pkgs.rust.packages.stable.rustPlatform.rustLibSrc}"; 70 | } 71 | -------------------------------------------------------------------------------- /scripts/check-dead-plugin.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -E -e -u -o pipefail 3 | 4 | # 设置目标目录 5 | PLUGIN_DIR="$HOME/.local/share/nvim/lazy" 6 | ONE_YEAR_AGO=$(date -d "2 year ago" +%s) 7 | 8 | echo "Checking plugins in $PLUGIN_DIR for updates older than 1 year..." 9 | echo "---------------------------------------------------------------" 10 | 11 | # 遍历目录下的所有子目录 12 | for repo in "$PLUGIN_DIR"/*; do 13 | if [ -d "$repo/.git" ]; then 14 | # 获取插件名称(目录名) 15 | plugin_name=$(basename "$repo") 16 | 17 | # 进入 Git 仓库目录 18 | pushd "$repo" > /dev/null 19 | 20 | # 获取最后提交的时间戳 21 | last_commit_timestamp=$(git log -1 --format=%ct 2>/dev/null) 22 | 23 | if [ -n "$last_commit_timestamp" ]; then 24 | # 转换为可读日期 25 | last_commit_date=$(date -d "@$last_commit_timestamp" "+%Y-%m-%d") 26 | 27 | # 检查是否超过一年未更新 28 | if [ "$last_commit_timestamp" -lt "$ONE_YEAR_AGO" ]; then 29 | echo "Plugin: $plugin_name" 30 | echo "Last commit: $last_commit_date" 31 | echo "Repository: $(git config --get remote.origin.url)" 32 | echo "---------------------------------------------------------------" 33 | fi 34 | else 35 | echo "Plugin: $plugin_name" 36 | echo "Warning: Could not retrieve commit history" 37 | echo "Repository: $(git config --get remote.origin.url)" 38 | echo "---------------------------------------------------------------" 39 | fi 40 | 41 | # 返回上一级目录 42 | popd > /dev/null 43 | fi 44 | done 45 | 46 | echo "Check complete." 47 | -------------------------------------------------------------------------------- /nvim/init.vim: -------------------------------------------------------------------------------- 1 | set autoread 2 | au FocusGained,BufEnter * :checktime 3 | " 当失去焦点或者离开当前的 buffer 的时候保存 4 | set autowrite 5 | autocmd FocusLost,BufLeave * silent! update 6 | 7 | " 映射 leader 键为 , 8 | let g:mapleader = ',' 9 | " 将 q 映射为 q,因为录制宏的操作比较少,而关掉窗口的操作非常频繁 10 | noremap q q 11 | 12 | " 访问系统剪切板 13 | map y "+y 14 | map p "+p 15 | map d "+d 16 | 17 | " 使用 z a 打开和关闭 fold ,打开大文件(超过 10 万行)的时候可能造成性能问题 18 | " set foldlevelstart=99 19 | " set foldmethod=expr 20 | " set foldexpr=nvim_treesitter#foldexpr() 21 | 22 | " 让光标自动进入到 popup window 中间 23 | " 去掉默认的 gm 快捷键,这个配置需要在 which-key 前面配置才可以生效 24 | let g:git_messenger_always_into_popup = v:true 25 | let g:git_messenger_no_default_mappings = v:true 26 | 27 | " 加载 lua 配置 28 | lua require 'usr' 29 | 30 | " 在 markdown 中间编辑 table 31 | let g:table_mode_corner='|' 32 | 33 | " 使用 gx 在 vim 中间直接打开链接 34 | let g:netrw_nogx = 1 " disable netrw's gx mapping. 35 | nmap gx (openbrowser-smart-search) 36 | vmap gx (openbrowser-smart-search) 37 | 38 | " 自动关闭 vim 如果 window 中只有一个 filetree 39 | " https://github.com/kyazdani42/nvim-tree.lua 40 | 41 | " 关闭特性,开启后会导致nvim 目录时发生闪退 42 | " Disable the feature; enabling it causes Neovim to crash when accessing directories. 43 | 44 | " autocmd BufEnter * ++nested if winnr('$') == 1 && bufname() == 'NvimTree_' . tabpagenr() | quit | endif 45 | 46 | " 定义预先录制的 macro 47 | let @j = 'ysiw`\' " 在一个 word 两侧添加上 `,例如将 abc 变为 `abc` 48 | let @k = 'ysiw"\' 49 | 50 | let g:loaded_perl_provider = 0 51 | 52 | let g:gitblame_delay = 1500 53 | let g:gitblame_ignored_filetypes = ['lua', 'markdown', 'sh'] 54 | -------------------------------------------------------------------------------- /nixpkgs/patches/amd_iommu.patch: -------------------------------------------------------------------------------- 1 | diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c 2 | index af49e24b46a4..6bfe5fbb18ef 100644 3 | --- a/arch/x86/kernel/apic/apic.c 4 | +++ b/arch/x86/kernel/apic/apic.c 5 | @@ -1962,6 +1962,7 @@ void __init enable_IR_x2apic(void) 6 | } 7 | 8 | ir_stat = irq_remapping_prepare(); 9 | + pr_info("[martins3:%s:%d] %x\n", __FUNCTION__, __LINE__, ir_stat); 10 | if (ir_stat < 0 && !x2apic_supported()) 11 | return; 12 | 13 | @@ -1976,8 +1977,10 @@ void __init enable_IR_x2apic(void) 14 | mask_ioapic_entries(); 15 | 16 | /* If irq_remapping_prepare() succeeded, try to enable it */ 17 | - if (ir_stat >= 0) 18 | + if (ir_stat >= 0){ 19 | ir_stat = irq_remapping_enable(); 20 | + pr_info("[martins3:%s:%d] %x\n", __FUNCTION__, __LINE__, ir_stat); 21 | + } 22 | /* ir_stat contains the remap mode or an error code */ 23 | try_to_enable_x2apic(ir_stat); 24 | 25 | diff --git a/drivers/iommu/amd/init.c b/drivers/iommu/amd/init.c 26 | index c2d80a4e5fb0..b474041efd66 100644 27 | --- a/drivers/iommu/amd/init.c 28 | +++ b/drivers/iommu/amd/init.c 29 | @@ -1811,8 +1811,12 @@ static int __init init_iommu_one(struct amd_iommu *iommu, struct ivhd_header *h, 30 | break; 31 | } 32 | 33 | - if (h->efr_reg & BIT(IOMMU_EFR_XTSUP_SHIFT)) 34 | + if (h->efr_reg & BIT(IOMMU_EFR_XTSUP_SHIFT)){ 35 | amd_iommu_xt_mode = IRQ_REMAP_X2APIC_MODE; 36 | + pr_info("[martins3:%s:%d] we have the feature \n", __FUNCTION__, __LINE__); 37 | + } else{ 38 | + pr_info("[martins3:%s:%d] we don't have the feature\n", __FUNCTION__, __LINE__); 39 | + } 40 | 41 | early_iommu_features_init(iommu, h); 42 | -------------------------------------------------------------------------------- /scripts/install.ps1: -------------------------------------------------------------------------------- 1 | # Generated by Qwen 2 | $dotfiles = "$HOME\.dotfiles" 3 | $localappdata = $env:LOCALAPPDATA 4 | $appdata = $env:APPDATA 5 | 6 | $links = @{ 7 | "nvim" = "$appdata\nvim" 8 | "config\gitui" = "$appdata\gitui" 9 | } 10 | 11 | # 构建软链接 12 | foreach ($key in $links.Keys) { 13 | $source = "$dotfiles\$key" 14 | $target = $links[$key] 15 | 16 | if (Test-Path $source) { 17 | if (Test-Path $target) { 18 | Remove-Item -Recurse -Force $target 19 | } 20 | New-Item -ItemType Junction -Path $target -Target $source -Force 21 | Write-Host "✅ Linked $key" 22 | } else { 23 | Write-Warning "⚠️ Source not found: $source" 24 | } 25 | } 26 | 27 | # 复制文件 28 | $files = @( 29 | @{ source = "$dotfiles\.gitconfig"; target = "$HOME\.gitconfig" } 30 | @{ 31 | source = "$dotfiles\config\windows\pwsh.ps1"; 32 | target = "$HOME\Documents\PowerShell\Microsoft.PowerShell_profile.ps1" 33 | } 34 | @{ 35 | source = "$dotfiles\config\windows\pwsh.ps1"; 36 | target = "$HOME\Documents\PowerShell\Microsoft.PowerShell_profile.ps1" 37 | } 38 | @{ 39 | source = "$dotfiles\config\wezterm.lua"; 40 | target = "$HOME\.config\wezterm\wezterm.lua" 41 | } 42 | @{ 43 | source = "$dotfiles\config\tigrc.conf"; 44 | target = "$HOME\.tigrc" 45 | } 46 | ) 47 | 48 | foreach ($file in $files) { 49 | if (Test-Path $file.source) { 50 | Copy-Item -Path $file.source -Destination $file.target -Force 51 | Write-Host "✅ Copied $($file.source)" 52 | } 53 | } 54 | # TODO 为什么这个脚本 执行的这么慢啊 55 | # https://learnxinyminutes.com/powershell/ 56 | -------------------------------------------------------------------------------- /nvim/lua/usr/telescope.lua: -------------------------------------------------------------------------------- 1 | -- You dont need to set any of these options. These are the default ones. Only 2 | -- the loading is important 3 | require("telescope").setup({ 4 | defaults = { 5 | layout_strategy = "vertical", 6 | layout_config = { 7 | vertical = { 8 | height = 0.9, 9 | preview_cutoff = 0, 10 | width = 0.9, 11 | }, 12 | -- other layout configuration here 13 | }, 14 | -- other defaults configuration here 15 | }, 16 | 17 | extensions = { 18 | fzf = { 19 | fuzzy = true, -- false will only do exact matching 20 | override_generic_sorter = true, -- override the generic sorter 21 | override_file_sorter = true, -- override the file sorter 22 | case_mode = "respect_case", -- or "ignore_case" or "respect_case" 23 | -- the default case_mode is "smart_case" 24 | }, 25 | bookmarks = { 26 | -- Available: 'brave', 'buku', 'chrome', 'edge', 'safari', 'firefox' 27 | selected_browser = "edge", 28 | }, 29 | emoji = { 30 | action = function(emoji) 31 | -- insert emoji when picked 32 | vim.api.nvim_put({ emoji.value }, 'c', false, true) 33 | end, 34 | }, 35 | frecency = { 36 | -- auto_validate = false, 37 | }, 38 | }, 39 | }) 40 | 41 | -- To get fzf loaded and working with telescope, you need to call 42 | -- load_extension, somewhere after setup function: 43 | require("telescope").load_extension("fzf") 44 | -- require("telescope").load_extension("neoclip") 45 | require('telescope').load_extension("frecency") 46 | require("telescope").load_extension("bookmarks") 47 | require("telescope").load_extension("emoji") 48 | -------------------------------------------------------------------------------- /nvim/lua/usr/init.lua: -------------------------------------------------------------------------------- 1 | require("usr.options") 2 | require("usr.lazy") 3 | require("usr.mason") 4 | require("usr.cmp") 5 | require("usr.code_runner") 6 | require("usr.hydra") 7 | require("usr.nvim-tree") 8 | require("usr.nvim-treesitter") 9 | require("usr.orgmode") 10 | require("usr.telescope") 11 | require("usr.version") 12 | require("usr.which-key") 13 | require("usr.colorscheme") 14 | require("usr.bufferline") 15 | require("usr.lualine") 16 | require("usr.neovide") 17 | require("usr.util") 18 | require("usr.toggleterm") 19 | require("colorizer").setup({ "css", "javascript", "lua", html = { mode = "foreground" } }) 20 | require("nvim-surround").setup() 21 | require("gitsigns").setup({ signcolumn = false, numhl = true }) 22 | require("leap").add_default_mappings() 23 | require("flit").setup({}) 24 | require("nvim-autopairs").setup() 25 | require("fidget").setup() 26 | require("debugprint").setup() 27 | 28 | -- require("luasnip.loaders.from_lua").lazy_load({ paths = "~/.config/nvim/LuaSnip/" }) 29 | require("luasnip.loaders.from_snipmate").lazy_load({ paths = { "~/.config/nvim/snippets/" } }) 30 | -- require("luasnip.loaders.from_vscode").load({paths = "~/.config/nvim/snippets"}) 31 | 32 | -- 书签 33 | require("bookmarks").setup({ 34 | mappings_enabled = true, 35 | keymap = { 36 | toggle = "mc", 37 | delete = "dd", 38 | }, 39 | virt_pattern = { "*.lua", "*.md", "*.c", "*.h", "*.sh", "*.py" }, 40 | }) 41 | 42 | require("persisted").setup({ 43 | autoload = true, 44 | should_save = function() 45 | -- Do not save if the alpha dashboard is the current filetype 46 | if vim.bo.filetype == "NvimTree" then 47 | return false 48 | end 49 | return true 50 | end, 51 | }) 52 | 53 | require('gitsigns').setup { 54 | current_line_blame = true, 55 | } 56 | -------------------------------------------------------------------------------- /nixpkgs/home/cli.nix: -------------------------------------------------------------------------------- 1 | { 2 | config, 3 | pkgs, 4 | ... 5 | }: 6 | 7 | let 8 | in 9 | { 10 | home.stateVersion = "23.11"; 11 | home.username = "martins3"; 12 | home.homeDirectory = builtins.getEnv "HOME"; 13 | 14 | 15 | home.packages = import ./tools.nix { inherit pkgs; }; 16 | 17 | programs.fish = { 18 | enable = true; 19 | }; 20 | 21 | programs.zsh = { 22 | enable = true; 23 | shellAliases = { }; 24 | initContent = " 25 | source ${config.home.homeDirectory}/.dotfiles/config/zsh 26 | "; 27 | 28 | plugins = [ 29 | { 30 | name = "zsh-autosuggestions"; 31 | file = "zsh-autosuggestions.plugin.zsh"; 32 | src = builtins.fetchGit { 33 | url = "https://github.com/zsh-users/zsh-autosuggestions"; 34 | rev = "a411ef3e0992d4839f0732ebeb9823024afaaaa8"; 35 | }; 36 | } 37 | ]; 38 | 39 | oh-my-zsh = { 40 | enable = true; 41 | plugins = [ "git" ]; 42 | theme = "robbyrussell"; 43 | }; 44 | }; 45 | 46 | home.file.gitconfig = { 47 | source = ../../config/gitconfig; 48 | target = ".gitconfig"; 49 | }; 50 | 51 | home.file.gdbinit = { 52 | source = pkgs.fetchurl { 53 | url = "https://raw.githubusercontent.com/cyrus-and/gdb-dashboard/master/.gdbinit"; 54 | sha256 = "09zfi18yq34gpkwlcd170rxcd0nyn1spxrzh762whaz8vzp4gfkh"; 55 | name = "gdbinit"; 56 | }; 57 | target = ".gdbinit"; 58 | }; 59 | 60 | home.file.gdb_dashboard_init = { 61 | source = ../../config/gdbinit; 62 | target = ".gdbinit.d/init"; 63 | }; 64 | 65 | home.file.npm = { 66 | source = ../../config/npmrc; 67 | target = ".npmrc"; 68 | }; 69 | 70 | programs.direnv.enable = true; 71 | programs.direnv.nix-direnv.enable = true; 72 | } 73 | -------------------------------------------------------------------------------- /scripts/nix/env/rust-complex.nix: -------------------------------------------------------------------------------- 1 | { 2 | pkgs ? import { }, 3 | }: 4 | let 5 | overrides = (builtins.fromTOML (builtins.readFile ./rust-toolchain.toml)); 6 | libPath = 7 | with pkgs; 8 | lib.makeLibraryPath [ 9 | # load external libraries that you need in your rust project here 10 | ]; 11 | in 12 | pkgs.mkShell rec { 13 | buildInputs = with pkgs; [ 14 | clang 15 | # Replace llvmPackages with llvmPackages_X, where X is the latest LLVM version (at the time of writing, 16) 16 | llvmPackages.bintools 17 | rustup 18 | # https://github.com/hyperlight-dev/hyperlight 19 | just 20 | ]; 21 | RUSTC_VERSION = overrides.toolchain.channel; 22 | # https://github.com/rust-lang/rust-bindgen#environment-variables 23 | LIBCLANG_PATH = pkgs.lib.makeLibraryPath [ pkgs.llvmPackages.libclang.lib ]; 24 | shellHook = '' 25 | export PATH=$PATH:/home/martins3/.cargo/bin echo "Hello shell" 26 | export PATH=$PATH:/home/martins3/.rustup/toolchains/$RUSTC_VERSION-x86_64-unknown-linux-gnu/bin/ 27 | ''; 28 | # Add precompiled library to rustc search path 29 | RUSTFLAGS = ( 30 | builtins.map (a: ''-L ${a}/lib'') [ 31 | # add libraries here (e.g. pkgs.libvmi) 32 | ] 33 | ); 34 | LD_LIBRARY_PATH = libPath; 35 | # Add glibc, clang, glib, and other headers to bindgen search path 36 | BINDGEN_EXTRA_CLANG_ARGS = 37 | # Includes normal include path 38 | (builtins.map (a: ''-I"${a}/include"'') [ 39 | # add dev libraries here (e.g. pkgs.libvmi.dev) 40 | pkgs.glibc.dev 41 | ]) 42 | # Includes with special directory paths 43 | ++ [ 44 | ''-I"${pkgs.llvmPackages_latest.libclang.lib}/lib/clang/${pkgs.llvmPackages_latest.libclang.version}/include"'' 45 | ''-I"${pkgs.glib.dev}/include/glib-2.0"'' 46 | ''-I${pkgs.glib.out}/lib/glib-2.0/include/'' 47 | ]; 48 | } 49 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 |

My Linux Configuration

2 |

3 | 4 | License: GNU General Public License v3.0 5 | 6 |

7 | 8 | ## 📚 Document 9 | 10 | - [2024 年 vim 的 C/C++ 配置](./docs/nvim.md) 11 | - [极简 Tmux 配置](./docs/tmux.md) 12 | - [Tabby, Tilix, Gnome Terminal, Alacritty 和 Kitty 使用体验对比](./docs/terminals.md) 13 | - [Rime 输入法配置](./docs/rime.md) 14 | - [tig 基于 vim 模式的快捷键介绍](./docs/tig.md) 15 | - [2023 年对比一下 ccls 和 clangd](./docs/ccls-vs-clangd.md) 16 | - 🚧 [NixOS 初步尝试](./docs/nix.md) 17 | 18 | ## ⚙ Install 19 | 20 | see scripts/install.sh, just a bunch of symbol links execpt neovim configuration is a little of complex: 21 | 22 | - read the [documentation](./docs/nvim.md) 23 | - try [nixos](./docs/nix.md) 24 | 25 | ## 🤝 Contributing 26 | 27 | Contributions, issues and feature requests are welcome!
Feel free to check [issues page](https://github.com/Martins3/My-Linux-config/issues). 28 | 29 | ## 📝 License 30 | 31 | [GNU General Public License v3.0](https://www.gnu.org/licenses/gpl-3.0.en.html) licensed. 32 | 33 | --- 34 | 35 | Created with ❤️ by [**Martins3**](https://martins3.github.io/) 36 | 37 | 51 | 52 | 本站所有文章转发 **CSDN** 将按侵权追究法律责任,其它情况随意。 53 | -------------------------------------------------------------------------------- /docs/nvim-tab.md: -------------------------------------------------------------------------------- 1 | ## tab 和 space 2 | 3 | tab 会被自动修改为 space 吗? 不会,执行 retab 或者 retab! 来转换。 4 | 5 | 就是这个插件让我感到恐惧 6 | "tpope/vim-sleuth" 7 | 8 | - https://tedlogan.com/techblog3.html 9 | - https://gist.github.com/LunarLambda/4c444238fb364509b72cfb891979f1dd 10 | 11 | 1. Expandtab : 是否展开 tab 为 space 12 | 2. Tabstop : 一个 tab 占用多少个格子 13 | 3. Shiftwidth : 当打开自动缩进的时候, 14 | 15 | ```c 16 | int main(int argc, char *argv[]) { // <- 光标在此处,如果 enter ,下一行 17 | return 0; 18 | } 19 | ``` 20 | 21 | https://superuser.com/questions/594583/what-does-shiftwidth-do-in-vim-editor : 4. Softtabstop : Number of spaces that a counts for while performing editing 22 | operations, like inserting a or using . 23 | https://vi.stackexchange.com/questions/4244/what-is-softtabstop-used-for 24 | 25 | 5. smarttab 26 | https://vi.stackexchange.com/questions/34454/how-does-smarttab-actually-works 27 | 28 | 实不相瞒,感觉还是没有太搞清楚. 29 | 30 | - [ ] Softtabstop : 既然是一个 tab 按下去的时候,产生多少个 space 的,那么只有允许 tab expand 的时候才有用吧 31 | - [ ] 让 Softtabstop 和 Shiftwidth 不相等又什么好处吗? 32 | 33 | - https://www.reddit.com/r/neovim/comments/17ak2eq/neovim_is_automatically_removing_trailing/ 34 | 35 | 看后面的转义符,本来是对齐的,现在配置之后,似乎是 tab 装换为 space 了,变的不对齐了 36 | 37 | ```c 38 | #define __WAITQUEUE_INITIALIZER(name, tsk) { \ 39 | .private = tsk, \ 40 | .func = default_wake_function, \ 41 | .entry = { NULL, NULL } } 42 | 43 | #define DECLARE_WAITQUEUE(name, tsk) \ 44 | struct wait_queue_entry name = __WAITQUEUE_INITIALIZER(name, tsk) 45 | ``` 46 | 47 | ## 似乎用途不大了 48 | ```vim 49 | " 将各种命令的执行结果放到 buffer 中,比如 Redir messages 50 | " https://gist.github.com/romainl/eae0a260ab9c135390c30cd370c20cd7 51 | 52 | " 删除 trailing space 和消除 tab space 混用 53 | fun! TrimWhitespace() 54 | let l:save = winsaveview() 55 | keeppatterns %s/\s\+$//e 56 | call winrestview(l:save) 57 | retab 58 | endfun 59 | command! TrimWhitespace call TrimWhitespace() 60 | ``` 61 | -------------------------------------------------------------------------------- /docs/tig.md: -------------------------------------------------------------------------------- 1 | # 基于 tig 的 git workflow 2 | 3 | 经常使用 git ,每一个操作都是类似下面这种全部都敲一遍,会很累,很容易出错,而且记不住这么长的命令。 4 | ```sh 5 | git commit -m "your awesome commit message" 6 | ``` 7 | 所以有各种 git 工具加快经常性事件,比如 8 | - [lazygit](https://github.com/jesseduffield/lazygit) 9 | - [gitk](https://git-scm.com/docs/gitk/) 10 | - [sublime merge](https://www.sublimemerge.com/) 11 | - [forgit](https://github.com/wfxr/forgit) 12 | - [gitui](https://github.com/extrawurst/gitui) : 据说性能很好,但是没有尝试过 13 | 14 | tig 相比这些而言而言,代码开源,功能强大,界面简洁,可以集成到 vim 中使用 15 | 16 | 我的配置基本官方给出来的配置: https://github.com/jonas/tig/blob/master/contrib/vim.tigrc 17 | 18 | ## 自定义命令 19 | ```sh 20 | bind status D ?@rm %(file) 21 | ``` 22 | 表示在 status view 中 D 可以删除一个文件. 23 | - `?` : 表示执行命令前是否咨询一下 24 | - `@` : 表示在 background 中运行 25 | 26 | ## 常见的使用 27 | - 在 diff view 中使用 e 可以让直接编辑对应的文件 28 | - x 来 state 和 unstate 一个文件或者 hunk 29 | - ur 来 discard 一个 hook 30 | - ul 来 discard 一行修改 31 | 32 | 33 | 34 | 35 | 36 | ## 尝试下 gitui 37 | 3. 无法像 tig 一样直接查看一个文件或者一个目录的历史 38 | 3. copy 无法使用 39 | 4. 不可以调整 layout ,而且左侧的框框太大了 40 | 41 | 好处: 42 | 1. 性能 43 | 2. stage 和 unstage 原生支持 44 | 3. 搜索根据强大 45 | 46 | - https://stackoverflow.com/questions/77841799/how-to-search-commit-body-in-gitui 47 | 48 | 62 | 63 | 本站所有文章转发 **CSDN** 将按侵权追究法律责任,其它情况随意。 64 | -------------------------------------------------------------------------------- /nixpkgs/sys/kernel-options.nix: -------------------------------------------------------------------------------- 1 | { config, pkgs, lib, ... }: 2 | 3 | { 4 | 5 | boot.kernelPackages = pkgs.linuxPackages_latest; 6 | # boot.kernelPackages = pkgs.linuxPackages_6_8; 7 | # boot.supportedFilesystems = [ "bcachefs" ]; 8 | 9 | # zfs 需要 stable 的版本才可以 10 | # boot.kernelPackages = config.boot.zfs.package.latestCompatibleLinuxPackages; 11 | # boot.supportedFilesystems = [ "zfs" ]; 12 | # networking.hostId = "9f96ca0b"; 13 | 14 | # @todo 加入的 vfio 参考 https://gist.github.com/CRTified/43b7ce84cd238673f7f24652c85980b3 不过他的感觉也是瞎写的 15 | boot.kernelModules = [ "vfio_pci" "vfio_iommu_type1" 16 | "vmd" "null_blk" "scsi_debug" "vhost_net" "nvmet" "nvmet-tcp" ]; 17 | boot.initrd.kernelModules = []; 18 | boot.blacklistedKernelModules = [ "nouveau" ]; 19 | 20 | boot.extraModprobeConfig = '' 21 | options scsi_debug dev_size_mb=100 22 | ''; 23 | 24 | boot.kernelParams = [ 25 | "transparent_hugepage=never" 26 | "kvm.halt_poll_ns=0" 27 | "mitigations=off" 28 | # 硬件上都直接不支持了 29 | # "tsx=on" 30 | # "tsx_async_abort=off" 31 | 32 | # intel_iommu 需要手动打开 33 | # 不信请看 zcat /proc/config.gz | grep CONFIG_INTEL_IOMMU_DEFAULT_ON 34 | "intel_iommu=on" 35 | # "iommu=pt" 36 | "intremap=on" 37 | "rcutree.sysrq_rcu=1" 38 | # "amd_iommu_intr=vapic" 39 | # "kvm-amd.avic=1" 40 | # "isolcpus=28-31" 41 | # "amd_iommu_intr=legacy" 42 | # 43 | # 打开这个选项之后,iperf3 性能只有之前的 1/5 44 | # "ftrace=function" 45 | # "ftrace_filter=request_firmware" 46 | 47 | # "processor.max_cstate=1" 48 | # "intel_idle.max_cstate=0" 49 | # "amd_iommu=off" 50 | # "amd_iommu=pgtbl_v2" 51 | # "iommu=pt" 52 | # 手动禁用 avx2 53 | # "clearcpuid=156" 54 | 55 | # @todo 不是 systemd 会默认启动 fsck 的吗,这个需要啥 56 | # "fsck.mode=force" 57 | "fsck.repair=yes" 58 | 59 | # 这个会导致 arm 打开所有函数的 trace ,难道是因为 ftrace_filter 设置一个不支持的函数 60 | # 然后机会导致所有的函数都被跟踪 61 | # "ftrace=function" 62 | # "ftrace_filter=dmar_set_interrupt" 63 | ]; 64 | } 65 | -------------------------------------------------------------------------------- /nvim/snippets/markdown.snippets: -------------------------------------------------------------------------------- 1 | priority -50 2 | 3 | snippet code "C snip" 4 | \`\`\`c 5 | ${0} 6 | \`\`\` 7 | 8 | snippet txt "text snip" 9 | \`\`\`txt 10 | ${0} 11 | \`\`\` 12 | 13 | snippet chisel "chisel snip" 14 | \`\`\`scala 15 | ${0} 16 | \`\`\` 17 | 18 | snippet blogMainComment "add blog comment" 19 | 32 | 33 | 本站所有文章转发 **CSDN** 将按侵权追究法律责任,其它情况随意。 34 | 35 | snippet blogConfigComment "add blog comment" 36 | 50 | 51 | 本站所有文章转发 **CSDN** 将按侵权追究法律责任,其它情况随意。 52 | 53 | snippet img "add img" 54 |
click me

55 | 56 | snippet ds "deepseek" 57 | > [!NOTE] 58 | > 参考 Deepseeek ,有待验证 59 | 60 | snippet xh "小鹤双拼" 61 | zh=v, ch=i, sh=u 62 | ai=d, ei=w, ui=v 63 | ao=c, ou=z, iu=q 64 | ie=p, ue/űe=t 65 | an=j, en=f, in=b, un=y 66 | ang=h, eng=g, ing=k, ong=s 67 | ia=x, ian=m, iang=l, iao=n, iong=s 68 | ua=x, uai=k, uan=r, uang=l, uo=o 69 | -------------------------------------------------------------------------------- /config/kitty/kitty.conf: -------------------------------------------------------------------------------- 1 | startup_session ./session.conf 2 | 3 | hide_window_decorations no 4 | # background_opacity 0.8 5 | macos_option_as_alt yes 6 | 7 | font_size 11 8 | 9 | term xterm-256color 10 | # @todo https://sw.kovidgoyal.net/kitty/faq/ 可以浏览一下其中的内容,分析一下 kitty_xterm 到底是否值得 11 | 12 | # solarized dark theme 13 | # https://github.com/dexpota/kitty-themes/blob/master/themes/Solarized_Dark.conf background #001e26 14 | foreground #708183 15 | cursor #708183 16 | selection_background #002731 17 | color0 #002731 18 | color8 #001e26 19 | color1 #d01b24 20 | color9 #bd3612 21 | color2 #728905 22 | color10 #465a61 23 | color3 #a57705 24 | color11 #52676f 25 | color4 #2075c7 26 | color12 #708183 27 | color5 #c61b6e 28 | color13 #5856b9 29 | color6 #259185 30 | color14 #81908f 31 | color7 #e9e2cb 32 | color15 #fcf4dc 33 | selection_foreground #001e26 34 | 35 | tab_bar_edge top 36 | active_tab_title_template "🥝 {title}" 37 | inactive_tab_foreground #d3d7cf 38 | inactive_tab_background #2e3436 39 | active_tab_foreground #2e3436 40 | active_tab_background #62a832 41 | 42 | map ctrl+shift+right no_op 43 | map ctrl+shift+left no_op 44 | 45 | # map ctrl+j previous_tab 46 | map ctrl+k next_tab 47 | 48 | # 使用 alt + fn 切换 tab 49 | # ref : https://github.com/kovidgoyal/kitty/issues/1891 50 | map alt+f1 goto_tab 1 51 | map alt+f2 goto_tab 2 52 | map alt+f3 goto_tab 3 53 | map alt+f4 goto_tab 4 54 | map alt+f5 goto_tab 5 55 | map alt+f6 goto_tab 6 56 | map alt+f7 goto_tab 7 57 | map alt+f8 goto_tab 8 58 | 59 | map ctrl+shift+m launch --title="Mac" --type=tab sh -c "ssh -t martins3@10.0.0.1 \"sh -c -l 'tmux attach || /usr/bin/env tmux'\"" 60 | map ctrl+shift+z launch --title="zellij" --type=tab sh -c "zellij attach || /usr/bin/env zellij" 61 | map ctrl+shift+n launch --title="n100" --type=tab sh -c "ssh -t root@10.0.0.5 \"sh -c -l 'tmux attach || /usr/bin/env tmux'\"" 62 | 63 | hide_window_decorations yes 64 | 65 | # kitty 内置如下两个快捷键 66 | # map ctrl+shift+. move_tab_forward 67 | # map ctrl+shift+, move_tab_backward 68 | 69 | copy_on_select yes 70 | -------------------------------------------------------------------------------- /scripts/install.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -E -e -u -o pipefail 3 | cd ~ || exit 0 4 | if [[ ! -d ~/.dotfiles ]]; then 5 | git clone https://github.com/Martins3/My-Linux-config .dotfiles 6 | fi 7 | mkdir -p ~/.config 8 | mkdir -p ~/.config/wtf 9 | mkdir -p ~/.config/wezterm 10 | mkdir -p ~/.config/zathura 11 | mkdir -p ~/.cargo 12 | mkdir -p ~/.config/atuin/ 13 | mkdir -p ~/.config/pueue 14 | 15 | [[ ! -d ~/.config/nvim ]] && ln -sf ~/.dotfiles/nvim ~/.config/nvim 16 | [[ ! -d ~/.config/kitty ]] && ln -sf ~/.dotfiles/config/kitty ~/.config/kitty 17 | [[ ! -d ~/.config/zellij ]] && ln -sf ~/.dotfiles/config/zellij ~/.config/zellij 18 | [[ ! -d ~/.config/gitui ]] && ln -sf ~/.dotfiles/config/gitui ~/.config/gitui 19 | 20 | ln -sf ~/.dotfiles/config/tmux.conf ~/.tmux.conf 21 | ln -sf ~/.dotfiles/config/tigrc.conf ~/.tigrc 22 | ln -sf ~/.dotfiles/config/alacritty.toml ~/.alacritty.toml 23 | ln -sf ~/.dotfiles/config/wtf.yml ~/.config/wtf/config.yml 24 | ln -sf ~/.dotfiles/config/zathurarc ~/.config/zathura/zathurarc 25 | ln -sf ~/.dotfiles/config/starship.toml ~/.config/starship.toml 26 | ln -sf ~/.dotfiles/config/cargo.toml ~/.cargo/config.toml 27 | ln -sf ~/.dotfiles/config/wezterm.lua ~/.config/wezterm/wezterm.lua 28 | ln -sf ~/.dotfiles/config/atuin.toml ~/.config/atuin/config.toml 29 | ln -sf ~/.dotfiles/config/pueue.yml ~/.config/pueue/pueue.yml 30 | 31 | if [[ ! -L ~/.gitconfig ]]; then 32 | ln -sf ~/.dotfiles/config/gitconfig ~/.gitconfig 33 | fi 34 | 35 | mkdir -p ~/.config/efm-langserver/ 36 | ln -sf ~/.dotfiles/nvim/efm.yaml ~/.config/efm-langserver/config.yaml 37 | 38 | if [[ ! -d ~/.tmux/plugins/tpm ]]; then 39 | git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm 40 | echo "tmux plugin install : prefix + I" 41 | # TODO 真的服了,各种问题 42 | # 1. catppuccin/tmux 这个项目 api 变化太快 43 | # 2. 下载之后自动 checkout 44 | # cd .tmux/plugins/tmux && git checkout 7a284c98e5df4cc84a1a45ad633916 45 | fi 46 | 47 | if systemctl list-units --type target | grep graphical; then 48 | bash "$HOME"/.dotfiles/rime/linux-install.sh 49 | echo "Almost finished,open fcitx 5 Configiration" 50 | fi 51 | -------------------------------------------------------------------------------- /nvim/lua/usr/nvim-tree.lua: -------------------------------------------------------------------------------- 1 | -- https://github.com/nvim-tree/nvim-tree.lua/wiki/Migrating-To-on_attach 2 | local function on_attach(bufnr) 3 | local api = require("nvim-tree.api") 4 | 5 | local function opts(desc) 6 | return { desc = "nvim-tree: " .. desc, buffer = bufnr, noremap = true, silent = true, nowait = true } 7 | end 8 | 9 | vim.keymap.set("n", "", api.node.open.edit, opts("Open")) 10 | vim.keymap.set("n", "o", api.node.open.edit, opts("Open")) 11 | vim.keymap.set("n", "l", api.node.open.edit, opts("Open")) 12 | vim.keymap.set("n", "<2-LeftMouse>", api.node.open.edit, opts("Open")) 13 | vim.keymap.set("n", "h", api.node.navigate.parent_close, opts("Close Directory")) 14 | vim.keymap.set("n", "p", api.node.open.preview, opts("Open Preview")) 15 | vim.keymap.set("n", "", api.tree.reload, opts("Refresh")) 16 | vim.keymap.set("n", "yn", api.fs.copy.filename, opts("Copy Name")) 17 | vim.keymap.set("n", "yp", api.fs.copy.relative_path, opts("Copy Relative Path")) 18 | vim.keymap.set("n", "yy", api.fs.copy.absolute_path, opts("Copy Absolute Path")) 19 | vim.keymap.set("n", "a", api.fs.create, opts("Create")) 20 | vim.keymap.set("n", "d", api.fs.remove, opts("Delete")) 21 | vim.keymap.set("n", "r", api.fs.rename, opts("Rename")) 22 | vim.keymap.set("n", "I", api.tree.toggle_gitignore_filter, opts("Toggle Git Ignore")) 23 | vim.keymap.set("n", "R", api.tree.collapse_all, opts("Collapse")) 24 | vim.keymap.set("n", "?", api.tree.toggle_help, opts("Help")) 25 | end 26 | 27 | require("nvim-tree").setup({ 28 | view = { 29 | side = "right", 30 | }, 31 | on_attach = on_attach, 32 | actions = { 33 | open_file = { 34 | quit_on_open = false, 35 | window_picker = { 36 | enable = false, 37 | }, 38 | }, 39 | }, 40 | }) 41 | 42 | vim.cmd([[ 43 | :hi NvimTreeExecFile gui=bold guifg=#ffa0a0 44 | :hi NvimTreeSymlink gui=bold guifg=#ffff60 45 | :hi NvimTreeSpecialFile gui=bold,underline guifg=#ff80ff 46 | :hi NvimTreeImageFile gui=bold guifg=#ff80ff 47 | ]]) 48 | -------------------------------------------------------------------------------- /nixpkgs/sys/cli.nix: -------------------------------------------------------------------------------- 1 | { config, pkgs, ... }: 2 | 3 | { 4 | 5 | boot.kernel.sysctl = { 6 | # "vm.swappiness" = 200; 7 | "vm.overcommit_memory" = 1; 8 | "kernel.dmesg_restrict" = 0; 9 | }; 10 | 11 | # https://nixos.org/manual/nixos/stable/index.html#ch-file-systems 12 | # 这一个例子如何自动 mount 一个盘,但是配置放到 /etc/nixos/configuration.nix 13 | # 中,参考[1] 但是 options 只有包含一个 14 | # [1]: https://unix.stackexchange.com/questions/533265/how-to-mount-internal-drives-as-a-normal-user-in-nixos 15 | # 16 | # fileSystems."/home/martins3/hack" = { 17 | # device = "/dev/disk/by-uuid/b709d158-aa6a-4b72-8255-513517548111"; 18 | # fsType = "auto"; 19 | # options = [ "user" "exec" "nofail"]; 20 | # }; 21 | 22 | systemd.services.iscsid = { 23 | enable = true; 24 | }; 25 | 26 | # TODO 这个方法好笨 27 | systemd.services.hugepage = { 28 | enable = true; 29 | description = "make user process access hugepage"; 30 | serviceConfig = { 31 | Type = "simple"; 32 | ExecStart = "/run/current-system/sw/bin/chmod o+w /dev/hugepages/"; 33 | Restart = "no"; 34 | }; 35 | wantedBy = [ "multi-user.target" ]; 36 | }; 37 | 38 | systemd.user.services.kernel_doc = { 39 | enable = true; 40 | description = "export kernel doc at 127.0.0.1:3434"; 41 | serviceConfig = { 42 | WorkingDirectory = "/home/martins3/core/linux/Documentation/output"; 43 | Type = "simple"; 44 | ExecStart = "/home/martins3/.nix-profile/bin/python -m http.server 3434"; 45 | Restart = "no"; 46 | }; 47 | wantedBy = [ "timers.target" ]; 48 | }; 49 | 50 | systemd.user.services.pueued = { 51 | enable = true; 52 | unitConfig = { }; 53 | serviceConfig = { 54 | ExecStart = "${pkgs.pueue.outPath}/bin/pueued -vv"; 55 | Restart = "no"; 56 | }; 57 | wantedBy = [ "default.target" ]; 58 | }; 59 | 60 | # virtualisation.vmware.host.enable = true; 61 | virtualisation.docker.enable = true; 62 | virtualisation.multipass.enable = true; 63 | virtualisation.docker.daemon.settings = { 64 | bip = "10.11.0.1/16"; 65 | }; 66 | virtualisation.podman.enable = true; 67 | virtualisation.vswitch.enable = true; 68 | virtualisation.vswitch.package = pkgs.openvswitch; 69 | # services.fstrim.enable = true; 70 | virtualisation.libvirtd.enable = true; 71 | 72 | # zramSwap.enable = true; 73 | 74 | } 75 | -------------------------------------------------------------------------------- /ibus.diff: -------------------------------------------------------------------------------- 1 | diff --git a/nixpkgs/home.nix b/nixpkgs/home.nix 2 | index 8cd5a1cb4a8f..7120b5b877af 100644 3 | --- a/nixpkgs/home.nix 4 | +++ b/nixpkgs/home.nix 5 | @@ -15,15 +15,6 @@ in 6 | ] else [ ] 7 | ); 8 | 9 | - 10 | - # 为了保证任何时候都安装 im-select ,否则无法 11 | - i18n.inputMethod = { 12 | - enabled = "fcitx5"; 13 | - fcitx5.addons = with pkgs; [ 14 | - fcitx5-rime 15 | - ]; 16 | - }; 17 | - 18 | # nixpkgs.overlays = [ neovim.overlay ]; 19 | programs.home-manager.enable = true; 20 | } 21 | diff --git a/nixpkgs/home/app/gnome.nix b/nixpkgs/home/app/gnome.nix 22 | index 48fc862dcbab..08d320b33283 100644 23 | --- a/nixpkgs/home/app/gnome.nix 24 | +++ b/nixpkgs/home/app/gnome.nix 25 | @@ -12,6 +12,8 @@ 26 | bing-wallpaper-changer 27 | gtile 28 | hide-top-bar 29 | + customize-ibus 30 | + 31 | # lightdark-theme-switcher 32 | ]); 33 | 34 | @@ -32,6 +34,7 @@ 35 | "hidetopbar@mathieu.bidon.ca" 36 | "unite@hardpixel.eu" 37 | "theme-switcher@fthx" 38 | + "customize-ibus@hollowman.ml" 39 | ]; 40 | 41 | ## dock icons 42 | @@ -151,5 +154,24 @@ 43 | enable-hot-corners = true; 44 | show-battery-percentage = true; 45 | }; 46 | + 47 | + # input method 48 | + "org/gnome/desktop/input-sources" = { 49 | + sources = with lib.hm.gvariant; mkArray 50 | + "(${lib.concatStrings [type.string type.string]})" [ 51 | + (mkTuple ["xkb" "us"]) 52 | + (mkTuple ["ibus" "rime"]) 53 | + ]; 54 | + }; 55 | + "org/gnome/shell/extensions/customize-ibus" = { 56 | + candidate-orientation = lib.hm.gvariant.mkUint32 1; 57 | + custom-font="Iosevka Nerd Font 10"; 58 | + enable-orientation=true; 59 | + input-indicator-only-on-toggle=false; 60 | + input-indicator-only-use-ascii=false; 61 | + use-custom-font=true; 62 | + use-indicator-show-delay=true; 63 | + }; 64 | + 65 | }; 66 | } 67 | diff --git a/nixpkgs/sys/gui.nix b/nixpkgs/sys/gui.nix 68 | index e9f3ed2587a2..e6a8f3560c92 100644 69 | --- a/nixpkgs/sys/gui.nix 70 | +++ b/nixpkgs/sys/gui.nix 71 | @@ -65,5 +65,10 @@ 72 | # 解决 kitty 和 wezterm 无法使用 fcitx5 输入法的问题 73 | # https://github.com/kovidgoyal/kitty/issues/403 74 | environment.variables.GLFW_IM_MODULE = "ibus"; 75 | + i18n.inputMethod.enabled = "ibus"; 76 | + i18n.inputMethod.ibus.engines = with pkgs.ibus-engines; [ 77 | + rime 78 | + ]; 79 | + 80 | 81 | } 82 | -------------------------------------------------------------------------------- /nvim/lua/usr/toggleterm.lua: -------------------------------------------------------------------------------- 1 | local isWindows = vim.fn.has('win32') == 1 2 | 3 | if isWindows then 4 | local powershell_options = { 5 | shell = vim.fn.executable "pwsh" == 1 and "pwsh" or "powershell", 6 | shellcmdflag = 7 | "-NoLogo -NoProfile -ExecutionPolicy RemoteSigned -Command [Console]::InputEncoding=[Console]::OutputEncoding=[System.Text.Encoding]::UTF8;", 8 | shellredir = "-RedirectStandardOutput %s -NoNewWindow -Wait", 9 | shellpipe = "2>&1 | Out-File -Encoding UTF8 %s; exit $LastExitCode", 10 | shellquote = "", 11 | shellxquote = "", 12 | } 13 | 14 | for option, value in pairs(powershell_options) do 15 | vim.opt[option] = value 16 | end 17 | end 18 | 19 | local Terminal = require("toggleterm.terminal").Terminal 20 | 21 | -- TODO 这些重复的内容显然可以注册成函数 22 | function _lazygit_toggle() 23 | local lazygit = Terminal:new({ 24 | cmd = "tig status", 25 | hidden = true, 26 | direction = "float", 27 | }) 28 | lazygit:toggle() 29 | end 30 | 31 | function _ls_toggle() 32 | local ls = Terminal:new({ cmd = "tig " .. vim.api.nvim_buf_get_name(0), hidden = true, direction = "float" }) 33 | ls:toggle() 34 | end 35 | 36 | function _ipython_toggle() 37 | local ipython = Terminal:new({ cmd = "ipython", hidden = true, direction = "float" }) 38 | ipython:toggle() 39 | end 40 | 41 | require("toggleterm").setup({ 42 | direction = "float", 43 | open_mapping = [[]], 44 | persist_mode = false, -- 总是进入到 insert mode 中 45 | }) 46 | 47 | vim.api.nvim_set_keymap("n", "gs", "lua _lazygit_toggle()", { noremap = true, silent = true }) 48 | vim.api.nvim_set_keymap("n", "gl", "lua _ls_toggle()", { noremap = true, silent = true }) 49 | vim.api.nvim_set_keymap("n", "x", "lua _ipython_toggle()", { noremap = true, silent = true }) 50 | 51 | function _G.set_terminal_keymaps() 52 | local opts = { buffer = 0 } 53 | vim.keymap.set('t', '', [[]], opts) 54 | 55 | vim.keymap.set("t", "", "TermSelect", opts) 56 | end 57 | 58 | -- if you only want these mappings for toggle term use term://*toggleterm#* instead 59 | vim.cmd('autocmd! TermOpen term://* lua set_terminal_keymaps()') 60 | 61 | function get_terminal() 62 | local m = vim.api.nvim_buf_get_name(0) 63 | print(string.match(m, '%d$')) 64 | end 65 | 66 | vim.api.nvim_set_keymap("n", "", "TermSelect", 67 | { noremap = true, silent = true }) 68 | -------------------------------------------------------------------------------- /nvim/lua/usr/options.lua: -------------------------------------------------------------------------------- 1 | local options = { 2 | backup = false, -- creates a backup file 3 | completeopt = { "menuone", "noselect" }, -- mostly just for cmp 4 | conceallevel = 0, -- so that `` is visible in markdown files 5 | fileencoding = "utf-8", -- the encoding written to a file 6 | hlsearch = true, -- highlight all matches on previous search pattern 7 | pumheight = 10, -- pop up menu height 8 | showmode = false, -- we don't need to see things like -- INSERT -- anymore 9 | smartcase = true, -- smart case 10 | splitbelow = true, -- force all horizontal splits to go below current window 11 | splitright = true, -- force all vertical splits to go to the right of current window 12 | swapfile = false, -- creates a swapfile 13 | termguicolors = true, -- set term gui colors (most terminals support this) 14 | timeoutlen = 300, -- time to wait for a mapped sequence to complete (in milliseconds) 15 | undofile = true, -- enable persistent undo 16 | updatetime = 300, -- faster completion (4000ms default) 17 | writebackup = false, -- if a file is being edited by another program (or was written to file while editing with another program), it is not allowed to be edited 18 | cursorline = true, -- highlight the current line 19 | number = true, -- set numbered lines 20 | 21 | signcolumn = "yes", -- always show the sign column, otherwise it would shift the text each time 22 | linebreak = true, -- companion to wrap, don't split words 23 | guifont = "monospace:h17", -- the font used in graphical neovim applications 24 | whichwrap = "bs<>[]hl", -- which "horizontal" keys are allowed to travel to prev/next line 25 | 26 | -- 我设置的部分 27 | wrap = false, -- 不要自动 wrap 28 | laststatus = 3, -- 只有一个全局的 status line,而不是每一个 window 一个 29 | } 30 | 31 | for k, v in pairs(options) do 32 | vim.opt[k] = v 33 | end 34 | 35 | -- vim.opt.shortmess = "ilmnrx" -- flags to shorten vim messages, see :help 'shortmess' 36 | vim.opt.shortmess:append("c") -- don't give |ins-completion-menu| messages 37 | vim.opt.iskeyword:append("-") -- hyphenated words recognized by searches 38 | vim.opt.formatoptions:remove({ "c", "r", "o" }) -- don't insert the current comment leader automatically for auto-wrapping comments using 'textwidth', hitting in insert mode, or hitting 'o' or 'O' in normal mode. 39 | vim.opt.runtimepath:remove("/usr/share/vim/vimfiles") -- separate vim plugins from neovim in case vim still in use 40 | -------------------------------------------------------------------------------- /nixpkgs/sys/kernel-config.nix: -------------------------------------------------------------------------------- 1 | { config, pkgs, lib, ... }: 2 | 3 | { 4 | 5 | # 使用的语法参考: 6 | # https://github.com/NixOS/nixpkgs/blob/master/nixos/modules/system/boot/kernel.nix 7 | # TODO 这里存在让 fio nullblk 性能下降 10% 的选项,有趣啊 8 | boot.kernelPatches = [ 9 | # { 10 | # name = "tracing"; 11 | # patch = null; 12 | # extraStructuredConfig = { 13 | # BOOTTIME_TRACING = lib.kernel.yes; 14 | # OSNOISE_TRACER = lib.kernel.yes; 15 | # FPROBE = lib.kernel.yes; 16 | # TIMERLAT_TRACER = lib.kernel.yes; 17 | # HWLAT_TRACER = lib.kernel.yes; 18 | # # 这三个 fedora 默认没有打开 19 | # IRQSOFF_TRACER = lib.kernel.yes; 20 | # MMIOTRACE = lib.kernel.yes; 21 | # PREEMPT_TRACER = lib.kernel.yes; 22 | # }; 23 | # } 24 | 25 | # { 26 | # name = "lru_gen"; 27 | # patch = null; 28 | # extraStructuredConfig = { 29 | # LRU_GEN_STATS=lib.kernel.yes; 30 | # }; 31 | # } 32 | 33 | # { 34 | # name = "zswap"; 35 | # patch = null; 36 | # extraStructuredConfig = { 37 | # ZSWAP_DEFAULT_ON=lib.kernel.yes; 38 | # }; 39 | # } 40 | 41 | { 42 | name = "irq"; 43 | patch = null; 44 | extraStructuredConfig = { 45 | GENERIC_IRQ_DEBUGFS=lib.kernel.yes; 46 | }; 47 | } 48 | 49 | 50 | # { 51 | # name = "mdev"; 52 | # patch = null; 53 | # extraStructuredConfig = { 54 | # SAMPLES=lib.kernel.yes; 55 | # SAMPLE_VFIO_MDEV_MTTY=lib.kernel.module; 56 | # SAMPLE_VFIO_MDEV_MDPY=lib.kernel.module; 57 | # SAMPLE_VFIO_MDEV_MBOCHS=lib.kernel.module; 58 | # }; 59 | # } 60 | 61 | # { 62 | # name = "iommu"; 63 | # patch = null; 64 | # extraStructuredConfig = { 65 | # IOMMU_DEBUGFS=lib.kernel.yes; 66 | # AMD_IOMMU_DEBUGFS=lib.kernel.yes; 67 | # INTEL_IOMMU_DEBUGFS=lib.kernel.yes; 68 | # }; 69 | # } 70 | 71 | # { 72 | # name = "watchdog"; 73 | # patch = null; 74 | # extraStructuredConfig = { 75 | # LOCKUP_DETECTOR=lib.kernel.yes; 76 | # SOFTLOCKUP_DETECTOR=lib.kernel.yes; 77 | # HARDLOCKUP_DETECTOR_PERF=lib.kernel.yes; 78 | # HARDLOCKUP_CHECK_TIMESTAMP=lib.kernel.yes; 79 | # HARDLOCKUP_DETECTOR=lib.kernel.yes; 80 | # }; 81 | # } 82 | 83 | 84 | # 增加一个 patch 的方法 85 | /* 86 | { 87 | name = "amd-iommu"; 88 | # https://www.reddit.com/r/NixOS/comments/oolk59/how_do_i_apply_local_patches_to_the_kernel/ 89 | # 这里不要携带双引号 90 | patch = /home/martins3/.dotfiles/nixpkgs/patches/amd_iommu.patch; 91 | } 92 | 93 | { 94 | name = "dma-ops"; 95 | patch = /home/martins3/.dotfiles/nixpkgs/patches/dma_ops.patch; 96 | } 97 | */ 98 | ]; 99 | } 100 | -------------------------------------------------------------------------------- /docs/nix-kernel-dev.md: -------------------------------------------------------------------------------- 1 | # 记录下 nixos 下 kernel 开发的问题 2 | 3 | ## fio 无法使用 iouring 的 engine 4 | 5 | ```txt 6 | [sudo] password for martins3: 7 | fio: engine liburing not loadable 8 | fio: failed to load engine 9 | fio: file:ioengines.c:134, func=dlopen, error=liburing: cannot open shared object file: No such file or directory 10 | ``` 11 | 12 | 参考 https://elatov.github.io/2022/01/building-a-nix-package/ 13 | 手动编译 : https://github.com/NixOS/nixpkgs/blob/master/pkgs/tools/system/fio/default.nix 14 | 15 | 检查自己 16 | ```txt 17 | 🤒 ldd fio 18 | linux-vdso.so.1 (0x00007ffdeea6c000) 19 | libz.so.1 => /nix/store/xbm6sj00r5kxvpwf34vysiij5zn3i3mw-zlib-1.2.13/lib/libz.so.1 (0x00007f8fe3ab6000) 20 | libm.so.6 => /nix/store/vnwdak3n1w2jjil119j65k8mw1z23p84-glibc-2.35-224/lib/libm.so.6 (0x00007f8fe39d6000) 21 | libmvec.so.1 => /nix/store/vnwdak3n1w2jjil119j65k8mw1z23p84-glibc-2.35-224/lib/libmvec.so.1 (0x00007f8fe38da000) 22 | libaio.so.1 => /nix/store/qxffmwkzyh3vskafbf96sq4hzrsd2qwz-libaio-0.3.113/lib/libaio.so.1 (0x00007f8fe38d5000) 23 | libpthread.so.0 => /nix/store/vnwdak3n1w2jjil119j65k8mw1z23p84-glibc-2.35-224/lib/libpthread.so.0 (0x00007f8fe38d0000) 24 | libdl.so.2 => /nix/store/vnwdak3n1w2jjil119j65k8mw1z23p84-glibc-2.35-224/lib/libdl.so.2 (0x00007f8fe38c9000) 25 | libc.so.6 => /nix/store/vnwdak3n1w2jjil119j65k8mw1z23p84-glibc-2.35-224/lib/libc.so.6 (0x00007f8fe3600000) 26 | /nix/store/vnwdak3n1w2jjil119j65k8mw1z23p84-glibc-2.35-224/lib/ld-linux-x86-64.so.2 => /nix/store/vnwdak3n1w2jjil119j65k8mw1z23p84-glibc-2.35-224/lib64/ld-linux-x86-64.so.2 (0x00007f8fe3ad 27 | 6000) 28 | ``` 29 | 30 | 修改 dlopen_ioengine 中的代码,让其去 load libaio,结果报错如下 31 | ```txt 32 | fio: file:ioengines.c:135, func=dlopen, error=libaio: cannot open shared object file: No such file or directory 33 | ``` 34 | 看来是搜索机制又问题。 35 | 36 | 参考 https://github.com/Nuitka/Nuitka/issues/1520 37 | 使用这种方法获取到; 38 | ```txt 39 | ldconfig -C out.txt 40 | ldconfig -C out.txt -p 41 | ``` 42 | 43 | 最后为了使用 io_uring,手动编译,尝试使用 t 目录下的这个: 44 | ```sh 45 | sudo ./io_uring /dev/nvme0n1p1 46 | ``` 47 | 48 | 阅读一下 : https://matklad.github.io/2022/03/14/rpath-or-why-lld-doesnt-work-on-nixos.html 49 | 50 | ## perf 51 | 52 | 2. 通过 pkgs.linuxPackages_latest.perf: perf 开始提示缺少 libtraceevent 来支持 tracepoint 了 53 | 1. 6.3 内核无法编译了,之前还是可以手动编译的 54 | 55 | ## linuxHeaders 56 | 不知道这个包是做啥的 57 | 58 | ## 为什么构建模块还需要额外的 kernel.dev 包,这里到底包含了什么 59 | 60 | ```txt 61 | nix-shell '' -A linuxPackages_latest.kernel.dev --command " make -C $(nix-build -E '(import {}).linuxPackages_latest.kernel.dev' --no-out-link)/lib/modules/*/build M=""$(pwd)"" modules" 62 | ``` 63 | 64 | ## 太牛了,这个人几乎将 nix 上构建内核所有问题都解决了? 65 | 66 | - https://github.com/jordanisaacs/kernel-module-flake 67 | -------------------------------------------------------------------------------- /nvim/snippets/c.snippets: -------------------------------------------------------------------------------- 1 | snippet lpr 2 | pr_info("[martins3:%s:%d] ${0}\n", __FUNCTION__, __LINE__); 3 | 4 | snippet qpr 5 | printf("[martins3:%s:%d] ${0}\n", __FUNCTION__, __LINE__); 6 | 7 | snippet seapr 8 | dprintf(1, "[martins3:%s:%d] ${0}\n", __FUNCTION__, __LINE__); 9 | 10 | snippet import "template" 11 | #include // assert 12 | #include // strerror 13 | #include // open 14 | #include // INT_MAX 15 | #include // sqrt 16 | #include // bool false true 17 | #include 18 | #include // malloc sort 19 | #include // strcmp 20 | #include // sleep 21 | 22 | int main(int argc, char *argv[]) { 23 | ${0} 24 | return 0; 25 | } 26 | 27 | snippet sysfs "add monitor into sysfs" 28 | long int foo; 29 | EXPORT_SYMBOL(foo); 30 | static ssize_t foo_show(struct kobject *kobj, struct kobj_attribute *attr, 31 | char *buf) 32 | { 33 | return sysfs_emit(buf, "%ld\n", foo); 34 | } 35 | 36 | static ssize_t foo_store(struct kobject *kobj, struct kobj_attribute *attr, 37 | const char *buf, size_t count) 38 | { 39 | int ret; 40 | 41 | ret = kstrtol(buf, 10, &foo); 42 | if (ret < 0) 43 | return ret; 44 | 45 | return count; 46 | } 47 | 48 | static struct kobj_attribute foo_attribute = 49 | __ATTR(foo, 0664, foo_show, foo_store); 50 | 51 | static struct attribute *attrs[] = { 52 | &foo_attribute.attr, 53 | NULL, 54 | }; 55 | 56 | static struct attribute_group attr_group = { 57 | .attrs = attrs, 58 | }; 59 | 60 | static struct kobject *mymodule; 61 | static DEFINE_MUTEX(test_mutex_hi); 62 | 63 | int greeter_init(void); 64 | int greeter_init(void) 65 | { 66 | int error = 0; 67 | guard(mutex)(&test_mutex_hi); 68 | if (mymodule != NULL) 69 | return 0; 70 | mymodule = kobject_create_and_add("test", kernel_kobj); 71 | if (!mymodule) 72 | return -ENOMEM; 73 | 74 | error = sysfs_create_group(mymodule, &attr_group); 75 | if (error) 76 | kobject_put(mymodule); 77 | 78 | return error; 79 | } 80 | 81 | snippet ktrace "add a new tracepoint" 82 | TRACE_EVENT($1, 83 | 84 | TP_PROTO(u64 count), 85 | 86 | TP_ARGS(count), 87 | 88 | TP_STRUCT__entry(__field(u64, count)), 89 | 90 | TP_fast_assign(__entry->count = count;), 91 | 92 | TP_printk("$1 : %llx ", __entry->count)); 93 | 94 | snippet show_locks "show locks every two seconds" 95 | static unsigned long jiffies_at_begin = 0; 96 | if (time_after(jiffies, jiffies_at_begin + HZ * 2)) { 97 | debug_show_held_locks(current); 98 | jiffies_at_begin = jiffies; 99 | } 100 | -------------------------------------------------------------------------------- /nixpkgs/sys/gui.nix: -------------------------------------------------------------------------------- 1 | { config, pkgs, ... }: 2 | 3 | { 4 | services.xserver = { 5 | enable = true; 6 | xkb.options = "caps:swapescape"; 7 | # 暂时可以使用这个维持生活吧 8 | # gsettings set org.gnome.desktop.input-sources xkb-options "['caps:swapescape']" 9 | # https://nixos.org/manual/nixos/stable/index.html#sec-gnome-gsettings-overrides 10 | }; 11 | 12 | services.xserver.displayManager.gdm.enable = true; 13 | services.xserver.displayManager.gdm.wayland = false; 14 | services.xserver.desktopManager.gnome.enable = true; 15 | 16 | # see xieby1 17 | fonts.packages = ( 18 | with (import (fetchTarball { 19 | url = "https://github.com/NixOS/nixpkgs/archive/d881cf9fd64218a99a64a8bdae1272c3f94daea7.tar.gz"; 20 | sha256 = "1jaghsmsc05lvfzaq4qcy281rhq3jlx75q5x2600984kx1amwaal"; 21 | }) {}); [ 22 | noto-fonts-cjk-sans 23 | noto-fonts-cjk-serif 24 | noto-fonts-emoji]) ++ (with pkgs; [ 25 | (nerdfonts.override { 26 | fonts = [ 27 | "SourceCodePro" 28 | "Iosevka" 29 | "FiraCode" 30 | "FantasqueSansMono" 31 | ]; 32 | }) 33 | # refs to pkgs/data/fonts/roboto-mono/default.nix 34 | (stdenv.mkDerivation { 35 | name = "my_fonts"; 36 | srcs = [(fetchurl { 37 | url = "https://github.com/lxgw/LxgwWenKai/releases/download/v1.315/LXGWWenKaiMono-Bold.ttf"; 38 | sha256 = "129ikb5d9gqcy801rqqsirqjmz24mgshcc6mgj65bq6w6abs3y7y"; 39 | }) (fetchurl { 40 | url = "https://github.com/lxgw/LxgwWenKai/releases/download/v1.315/LXGWWenKai-Regular.ttf"; 41 | sha256 = "1ybzbk50l3lmz0aja9cjh40bxcx9py8349qabxplpispk5jyy76d"; 42 | })]; 43 | sourceRoot = "./"; 44 | unpackCmd = '' 45 | ttfName=$(basename $(stripHash $curSrc)) 46 | cp $curSrc ./$ttfName 47 | ''; 48 | installPhase = '' 49 | mkdir -p $out/share/fonts/truetype 50 | cp -a *.ttf $out/share/fonts/truetype/ 51 | ''; 52 | }) 53 | ]); 54 | 55 | 56 | fonts.fontDir.enable = true; 57 | fonts.fontconfig.defaultFonts = { 58 | monospace = [ 59 | "DejaVu Sans Mono" 60 | "Noto Color Emoji" 61 | "Noto Emoji" 62 | ]; 63 | }; 64 | 65 | # 解决 kitty 和 wezterm 无法使用 fcitx5 输入法的问题 66 | # https://github.com/kovidgoyal/kitty/issues/403 67 | environment.variables.GLFW_IM_MODULE = "ibus"; 68 | i18n.inputMethod.enable = true; 69 | i18n.inputMethod.type = "ibus"; 70 | i18n.inputMethod.ibus.engines = with pkgs.ibus-engines; [ 71 | rime 72 | ]; 73 | 74 | systemd.user.services.clash = { 75 | enable = false; 76 | unitConfig = { }; 77 | serviceConfig = { 78 | Type = "simple"; 79 | ExecStart = "${pkgs.clash-meta.outPath}/bin/clash-meta"; 80 | Restart = "no"; 81 | }; 82 | wantedBy = [ "default.target" ]; 83 | }; 84 | 85 | 86 | } 87 | -------------------------------------------------------------------------------- /config/gitui/key_bindings.ron: -------------------------------------------------------------------------------- 1 | // Note: 2 | // If the default key layout is lower case, 3 | // and you want to use `Shift + q` to trigger the exit event, 4 | // the setting should like this `exit: Some(( code: Char('Q'), modifiers: "SHIFT")),` 5 | // The Char should be upper case, and the modifier should be set to "SHIFT". 6 | // 7 | // Note: 8 | // find `KeysList` type in src/keys/key_list.rs for all possible keys. 9 | // every key not overwritten via the config file will use the default specified there 10 | ( 11 | open_help: Some(( code: F(1), modifiers: "")), 12 | 13 | move_left: Some(( code: Char('h'), modifiers: "")), 14 | move_right: Some(( code: Char('l'), modifiers: "")), 15 | move_up: Some(( code: Char('k'), modifiers: "")), 16 | move_down: Some(( code: Char('j'), modifiers: "")), 17 | 18 | popup_up: Some(( code: Char('p'), modifiers: "CONTROL")), 19 | popup_down: Some(( code: Char('n'), modifiers: "CONTROL")), 20 | page_up: Some(( code: Char('b'), modifiers: "CONTROL")), 21 | page_down: Some(( code: Char('f'), modifiers: "CONTROL")), 22 | home: Some(( code: Char('g'), modifiers: "")), 23 | end: Some(( code: Char('G'), modifiers: "SHIFT")), 24 | shift_up: Some(( code: Char('K'), modifiers: "SHIFT")), 25 | shift_down: Some(( code: Char('J'), modifiers: "SHIFT")), 26 | 27 | edit_file: Some(( code: Char('I'), modifiers: "SHIFT")), 28 | 29 | status_reset_item: Some(( code: Char('U'), modifiers: "SHIFT")), 30 | 31 | diff_reset_lines: Some(( code: Char('u'), modifiers: "")), 32 | diff_stage_lines: Some(( code: Char('s'), modifiers: "")), 33 | 34 | stashing_save: Some(( code: Char('w'), modifiers: "")), 35 | stashing_toggle_index: Some(( code: Char('m'), modifiers: "")), 36 | 37 | stash_open: Some(( code: Char('l'), modifiers: "")), 38 | 39 | abort_merge: Some(( code: Char('M'), modifiers: "SHIFT")), 40 | 41 | // 相较于 lazygit 有两点不太习惯, 42 | // 1. 例如当在 Status 中选中了一个文件,按道理可以通过 h 退出,因为是通过 l 进入 43 | // 但是当前是 exit_popup ,所以需要是 q 44 | // 2. 按道理,当到了主界面,如果继续按 q 就可以退出程序,但是不可以,需要按 K 才可以, 45 | // 因为程序的退出需要是 K ,这有一个好处,就是防止误退出 46 | // 47 | // 默认配置: 48 | // exit: GituiKeyEvent::new(KeyCode::Char('c'), KeyModifiers::CONTROL), 49 | // quit: GituiKeyEvent::new(KeyCode::Char('q'), KeyModifiers::empty()), 50 | // exit_popup: GituiKeyEvent::new(KeyCode::Esc, KeyModifiers::empty()), 51 | 52 | // 不知道咋地,总是一不小心就按了 q ,重新加载 kernel 的 log 就有点慢了 53 | // quit : 退出程序 54 | // exit_popup : 退出搜索和 commit 细节 55 | // 这个就使用默认的,exit 和 quit 有什么区别吗? 56 | quit: Some(( code: Char('K'), modifiers: "SHIFT")), 57 | // exit: Some(( code: Char('c'), modifiers: "CONTROL")), 58 | // exit_popup 最好还是用 esc ,不然搜索工具遇到对应字符就会退出 59 | // exit_popup: Some(( code: Char('q'), modifiers: "")), 60 | 61 | // TODO 62 | // 1. 有办法让 tree 配置为 tig 模式吗? 63 | // 2. 类似使用 tig $hash 的方法? 64 | ) 65 | -------------------------------------------------------------------------------- /config/tigrc.conf: -------------------------------------------------------------------------------- 1 | # https://github.com/jonas/tig/blob/master/contrib/vim.tigrc 2 | # Vim-style keybindings for Tig 3 | # 4 | # To use these keybindings copy the file to your HOME directory and include 5 | # it from your ~/.tigrc file: 6 | # 7 | # $ cp contrib/vim.tigrc ~/.tigrc.vim 8 | # $ echo "source ~/.tigrc.vim" >> ~/.tigrc 9 | 10 | bind generic h scroll-left 11 | bind generic j move-down 12 | bind generic k move-up 13 | bind generic l scroll-right 14 | 15 | bind generic g none 16 | bind generic gg move-first-line 17 | bind generic J next 18 | bind generic K previous 19 | bind generic gp parent 20 | bind generic gP back 21 | bind generic gn view-next 22 | 23 | bind main G move-last-line 24 | bind generic G move-last-line 25 | 26 | bind generic move-page-down 27 | bind generic move-page-up 28 | 29 | bind generic v none 30 | bind generic vm view-main 31 | bind generic vd view-diff 32 | bind generic vl view-log 33 | bind generic vt view-tree 34 | bind generic vb view-blob 35 | bind generic vx view-blame 36 | bind generic vr view-refs 37 | bind generic vs view-status 38 | bind generic vu view-stage 39 | bind generic vy view-stash 40 | bind generic vg view-grep 41 | bind generic vp view-pager 42 | bind generic vh view-help 43 | 44 | bind generic o none 45 | bind generic oo :toggle sort-order 46 | bind generic os :toggle sort-field 47 | bind generic on :toggle line-number 48 | bind generic od :toggle date 49 | bind generic oa :toggle author 50 | bind generic og :toggle line-graphics 51 | bind generic of :toggle file-name 52 | bind generic op :toggle ignore-space 53 | bind generic oi :toggle id 54 | bind generic ot :toggle commit-title-overflow 55 | bind generic oF :toggle file-filter 56 | bind generic or :toggle commit-title-refs 57 | 58 | bind generic @ none 59 | bind generic @j :/^@@ 60 | bind generic @k :?^@@ 61 | bind generic @- :toggle diff-context -1 62 | bind generic @+ :toggle diff-context +1 63 | 64 | bind status u none 65 | bind stage u none 66 | bind generic uu status-update 67 | bind generic ur status-revert 68 | bind generic um status-merge 69 | bind generic ul stage-update-line 70 | bind generic up stage-update-part 71 | bind generic us stage-split-chunk 72 | 73 | bind generic c none 74 | bind generic cc !git commit 75 | bind generic ca !?@git commit --amend --no-edit 76 | 77 | bind generic ? view-help 78 | bind generic view-next 79 | 80 | # --------------------- 我添加的部分 ------------------------------------------- 81 | # https://github.com/jonas/tig/issues/393 82 | # @ does not ask for confirmation. ? does that, but that will execute in foreground. 83 | bind status D @?rm %(file) 84 | bind status X @?sh -c "echo %(file) >> .gitignore" 85 | bind generic x status-update 86 | bind generic refresh 87 | # 拷贝 commit hash 到剪切板 88 | bind generic 7 !tig log %(commit)^..%(commit) 89 | 90 | # To handle linux kernel 91 | # https://github.com/jonas/tig/blob/master/contrib/large-repo.tigrc 92 | # 93 | # Use Git's default (reverse chronological) order, never automatically 94 | # use topo-order for the commit graph 95 | set commit-order = default 96 | 97 | # Limit number of commits loaded by default to 1000 98 | # 1000 正好可以秒开 99 | set main-options = -n 1000 100 | 101 | # Don't show staged and unstaged changes in the main view 102 | # set show-changes = no 103 | -------------------------------------------------------------------------------- /config/zellij/default.swap.kdl.bak: -------------------------------------------------------------------------------- 1 | tab_template name="ui" { 2 | pane size=1 borderless=true { 3 | plugin location="zellij:tab-bar" 4 | } 5 | children 6 | pane size=2 borderless=true { 7 | plugin location="zellij:status-bar" 8 | } 9 | } 10 | 11 | swap_tiled_layout name="vertical" { 12 | ui max_panes=5 { 13 | pane split_direction="vertical" { 14 | pane 15 | pane { children; } 16 | } 17 | } 18 | ui max_panes=8 { 19 | pane split_direction="vertical" { 20 | pane { children; } 21 | pane { pane; pane; pane; pane; } 22 | } 23 | } 24 | ui max_panes=12 { 25 | pane split_direction="vertical" { 26 | pane { children; } 27 | pane { pane; pane; pane; pane; } 28 | pane { pane; pane; pane; pane; } 29 | } 30 | } 31 | } 32 | 33 | swap_tiled_layout name="horizontal" { 34 | ui max_panes=5 { 35 | pane 36 | pane 37 | } 38 | ui max_panes=8 { 39 | pane { 40 | pane split_direction="vertical" { children; } 41 | pane split_direction="vertical" { pane; pane; pane; pane; } 42 | } 43 | } 44 | ui max_panes=12 { 45 | pane { 46 | pane split_direction="vertical" { children; } 47 | pane split_direction="vertical" { pane; pane; pane; pane; } 48 | pane split_direction="vertical" { pane; pane; pane; pane; } 49 | } 50 | } 51 | } 52 | 53 | swap_tiled_layout name="stacked" { 54 | ui min_panes=5 { 55 | pane split_direction="vertical" { 56 | pane 57 | pane stacked=true { children; } 58 | } 59 | } 60 | } 61 | 62 | swap_floating_layout name="staggered" { 63 | floating_panes 64 | } 65 | 66 | swap_floating_layout name="enlarged" { 67 | floating_panes max_panes=10 { 68 | pane { x "5%"; y 1; width "90%"; height "90%"; } 69 | pane { x "5%"; y 2; width "90%"; height "90%"; } 70 | pane { x "5%"; y 3; width "90%"; height "90%"; } 71 | pane { x "5%"; y 4; width "90%"; height "90%"; } 72 | pane { x "5%"; y 5; width "90%"; height "90%"; } 73 | pane { x "5%"; y 6; width "90%"; height "90%"; } 74 | pane { x "5%"; y 7; width "90%"; height "90%"; } 75 | pane { x "5%"; y 8; width "90%"; height "90%"; } 76 | pane { x "5%"; y 9; width "90%"; height "90%"; } 77 | pane focus=true { x 10; y 10; width "90%"; height "90%"; } 78 | } 79 | } 80 | 81 | swap_floating_layout name="spread" { 82 | floating_panes max_panes=1 { 83 | pane {y "50%"; x "50%"; } 84 | } 85 | floating_panes max_panes=2 { 86 | pane { x "1%"; y "25%"; width "45%"; } 87 | pane { x "50%"; y "25%"; width "45%"; } 88 | } 89 | floating_panes max_panes=3 { 90 | pane focus=true { y "55%"; width "45%"; height "45%"; } 91 | pane { x "1%"; y "1%"; width "45%"; } 92 | pane { x "50%"; y "1%"; width "45%"; } 93 | } 94 | floating_panes max_panes=4 { 95 | pane { x "1%"; y "55%"; width "45%"; height "45%"; } 96 | pane focus=true { x "50%"; y "55%"; width "45%"; height "45%"; } 97 | pane { x "1%"; y "1%"; width "45%"; height "45%"; } 98 | pane { x "50%"; y "1%"; width "45%"; height "45%"; } 99 | } 100 | } 101 | -------------------------------------------------------------------------------- /nixpkgs/system.nix: -------------------------------------------------------------------------------- 1 | # add this file to /etc/nixos/configuration.nix: imports 2 | { boot_efi ? 1, disable_gui ? 0}:{ config, pkgs, lib, ... }: 3 | 4 | let 5 | 6 | unstable = import { }; 7 | in 8 | { 9 | imports = [ 10 | ./sys/cli.nix 11 | ./sys/net.nix 12 | ./sys/kernel-options.nix 13 | # ./sys/kernel-config.nix 14 | # ./sys/kernel-419.nix 15 | ] ++ ( 16 | if disable_gui == 0 && builtins.currentSystem == "x86_64-linux" then [ 17 | ./sys/gui.nix 18 | ] else [ ] 19 | ) ++ ( 20 | if boot_efi == 1 then [ 21 | ./sys/boot.nix 22 | ] else [ ] 23 | ); 24 | 25 | services.openssh.enable = true; 26 | 27 | nix.settings.substituters = [ 28 | "https://mirrors.tuna.tsinghua.edu.cn/nix-channels/store" 29 | "https://cache.nixos.org/" 30 | ]; 31 | time.timeZone = "Asia/Shanghai"; 32 | time.hardwareClockInLocalTime = true; 33 | 34 | # nvidia GPU card configuration, for details, 35 | # 注意: 如果你和我一样,用的是老显卡,将 open = true; 注释掉 36 | # see https://nixos.wiki/wiki/Nvidia 37 | 38 | programs.zsh.enable = true; 39 | 40 | 41 | environment.systemPackages = with pkgs; [ 42 | vim 43 | git 44 | wget 45 | zsh 46 | unstable.tailscale 47 | cifs-utils 48 | parted 49 | k3s 50 | ]; 51 | 52 | users.mutableUsers = false; 53 | users.users.martins3 = { 54 | isNormalUser = true; 55 | shell = pkgs.zsh; 56 | # shell = pkgs.nushell; 57 | home = "/home/martins3"; 58 | extraGroups = [ "wheel" "docker" "libvirtd" ]; 59 | }; 60 | 61 | 62 | 63 | # https://nixos.wiki/wiki/Fwupd 64 | # 似乎没啥用,而且还是存在 bug 的 65 | services.fwupd.enable = false; 66 | 67 | services.k3s.enable = false; 68 | services.k3s.role = "server"; 69 | services.k3s.extraFlags = toString [ 70 | # "--kubelet-arg=v=4" # Optionally add additional args to k3s 71 | ]; 72 | 73 | 74 | # GPU passthrough with vfio need memlock 75 | # https://www.reddit.com/r/VFIO/comments/aiwrzr/12_qemu_hardware_error_vfio_dma_mapping_failed/ 76 | security.pam.loginLimits = [ 77 | { domain = "*"; type = "-"; item = "memlock"; value = "infinity"; } 78 | ]; 79 | 80 | # 默认是 cgroup v2 81 | # systemd.enableUnifiedCgroupHierarchy = false; # cgroup v1 82 | 83 | # 组装机器之后,这个需求并不强了 84 | # services.syncthing = { 85 | # enable = true; 86 | # systemService = true; 87 | # # relay.enable = true; 88 | # user = "martins3"; 89 | # dataDir = "/home/martins3"; 90 | # overrideDevices = false; 91 | # overrideFolders = false; 92 | # guiAddress = "0.0.0.0:8384"; 93 | # }; 94 | 95 | documentation.enable = true; 96 | 97 | # sudo systemctl status systemd-oomd.service 98 | # sudo journalctl -u systemd-oomd.service 99 | # @todo services 和 systemd 的差别是什么? 100 | systemd.oomd.enable = true; 101 | services.irqbalance.enable = false; # 将其自动 disable 掉 102 | 103 | # 使用方法 : sudo lldpcli show neighbor 104 | services.lldpd.enable = true; 105 | 106 | # @todo 使用下吧 107 | system.autoUpgrade.enable = false; 108 | 109 | nixpkgs.config.allowUnfree = true; 110 | # programs.steam.enable = true; # steam 安装 111 | 112 | nix.settings.experimental-features = "nix-command flakes"; 113 | # 因为使用的最新内核,打开这个会导致更新过于频繁 114 | } 115 | 116 | 117 | # 做一个开机任务,记录下 SSD 的写入 118 | # 🧀 sudo smartctl -t short -a /dev/nvme2n1 | grep "Data Units Written" 119 | # Data Units Written: 220,743,742 [113 TB] 120 | -------------------------------------------------------------------------------- /config/tmux.conf: -------------------------------------------------------------------------------- 1 | # 使用 Ctrl h 作为 prefix 2 | set -g prefix C-h 3 | 4 | # 这真是一个无解的问题 5 | # 1. 如果 default-terminal 设置为 tmux-256color ,那么 ssh 到服务器,打开 vim ,存在如下报错: 6 | # E437: terminal capability "cm" required 7 | # 2. 如果设置为 xterm-256color, 那么 weechat 和 nvim 的 healthcheck 会报错 8 | # 最后参考这个解决 : https://github.com/alacritty/alacritty/issues/1208 9 | set -g default-terminal "tmux-256color" 10 | set-option -sa terminal-features ',xterm-256color:RGB' 11 | set -s set-clipboard on 12 | 13 | # 让 window 的编号和 pane 的编号从 0 开始,因为 0 这个键实在是太远了 14 | set -g base-index 1 15 | setw -g pane-base-index 1 16 | 17 | # 使用 Alt + num 来选择不同的 window 18 | bind-key -n M-1 select-window -t 1 19 | bind-key -n M-2 select-window -t 2 20 | bind-key -n M-3 select-window -t 3 21 | bind-key -n M-4 select-window -t 4 22 | bind-key -n M-5 select-window -t 5 23 | bind-key -n M-6 select-window -t 6 24 | bind-key -n M-7 select-window -t 7 25 | bind-key -n M-8 select-window -t 8 26 | bind-key -n M-9 select-window -t 9 27 | bind-key -n M-0 select-window -t 10 28 | 29 | # 使用 Alt+hljk 来在不同的 pane 中移动 30 | bind -n M-h select-pane -L 31 | bind -n M-j select-pane -D 32 | bind -n M-k select-pane -U 33 | bind -n M-l select-pane -R 34 | 35 | # 增加状态栏的对比度 36 | setw -g window-status-current-style fg=black,bg=yellow 37 | # 将默认在底部的状态栏移动到上面去 38 | set-option -g status-position top 39 | 40 | # 可以用鼠标直接调整 pane 的大小 41 | set -g mouse on 42 | 43 | # 让 window 的各种操作使用 vim 模式 44 | set-window-option -g mode-keys vi 45 | 46 | # 给当前窗口添加 emoji 表情 47 | # catppuccin_window_current_text 选项已经覆盖了,现在无需设置了 48 | set-option -g window-status-current-format '🧀 #{window_index}:#{b:pane_current_path}' 49 | 50 | # 创建新的 window 51 | bind c new-window -c "#{pane_current_path}" 52 | # 水平创建新的 pane 53 | bind '"' split-window -c "#{pane_current_path}" 54 | # 垂直创建新的 pane 55 | bind % split-window -h -c "#{pane_current_path}" 56 | 57 | # 将 window 的名称自动修改为路径名称,便于区分 58 | set-option -g status-interval 0 59 | set-option -g automatic-rename on 60 | set-option -g automatic-rename-format '#{b:pane_current_path}' 61 | 62 | # prefix v 进入到 copy mode 63 | bind-key -T prefix v copy-mode 64 | 65 | # https://superuser.com/questions/395158/tmux-copy-mode-select-text-block 66 | setw -g mode-keys vi 67 | bind-key -T copy-mode-vi 'v' send -X begin-selection # Begin selection in copy mode. 68 | # bind-key -T copy-mode-vi 'C-v' send -X rectangle-toggle # Begin selection in copy mode. 69 | bind-key -T copy-mode-vi 'y' send -X copy-selection # Yank selection in copy mode. 70 | 71 | # https://superuser.com/questions/343572/how-do-i-reorder-tmux-windows 72 | # 使用 「Ctrl Shift 方向键」调整 window 的位置 73 | bind-key -n C-S-Left swap-window -t -1\; select-window -t -1 74 | bind-key -n C-S-Right swap-window -t +1\; select-window -t +1 75 | 76 | # 使用 prefix f 直接进入到搜索 77 | # https://stackoverflow.com/questions/66430860/on-tmux-2-4-how-to-enter-copy-mode-and-start-a-search-all-in-one-go 78 | bind f copy-mode \; command-prompt -p "(search up)" "send -X search-forward \"%%%\"" 79 | bind -T copy-mode-vi f copy-mode \; command-prompt -p "(search up)" "send -X search-forward \"%%%\"" 80 | 81 | # 我一般会使用两个 session ,使用 Ctrl j 来切换 session 82 | bind-key -n C-j switch-client -n 83 | 84 | # 拷贝之后不要默认自动进入到 normal mode 85 | set -g @yank_action 'copy-pipe' 86 | 87 | # 加载插件 88 | # List of plugins 89 | set -g @plugin 'tmux-plugins/tpm' 90 | set -g @plugin 'tmux-plugins/tmux-sensible' # 默认配置 91 | set -g @plugin 'tmux-plugins/tmux-resurrect' # 关机保存 session 92 | set -g @plugin 'tmux-plugins/tmux-yank' # 方便的拷贝到系统剪切板 93 | run '~/.tmux/plugins/tpm/tpm' 94 | -------------------------------------------------------------------------------- /docs/terminals.md: -------------------------------------------------------------------------------- 1 | # Tabby, Tilix, Gnome Terminal, Alacritty 和 Kitty 使用体验对比 2 | 3 | 目前我使用的是 kitty 。 4 | 5 | 6 | 7 | * [Deepin Terminal: 2016-2018](#deepin-terminal-2016-2018) 8 | * [Tilix: 2019](#tilix-2019) 9 | * [Gnome terminal : 2020](#gnome-terminal-2020) 10 | * [Alacritty : 2020-2022](#alacritty-2020-2022) 11 | * [Kitty : 2022-2023](#kitty-2022-2023) 12 | * [Tabby : 几分钟](#tabby-几分钟) 13 | * [wezterm : 2023-2024](#wezterm-2023-2024) 14 | * [Windows Terminal + wezterm + Kitty : 2025](#windows-terminal-wezterm-kitty-2025) 15 | * [总结](#总结) 16 | 17 | 18 | 19 | 我是 2015 年开始学习计算机的,第一年使用的 Windows,只是使用的 20 | 21 | ## Deepin Terminal: 2016-2018 22 | 23 | 大约使用过 2 年(2016-2018)的 Deepin OS ,发现内置的 terminal 也就是 Deepin Terminal 很好用, 24 | 可以非常容易的切换主题,半透明,容易使用的 tab 和 window 等功能。 25 | 26 | ## Tilix: 2019 27 | 28 | Manjaro 的内置 terminal,大约使用了几个月,之所以切换为 Tilix 是因为在 Manjaro 上无法成功安装 Deepin Terminal, 29 | 而不是因为比 Deepin Terminal 更好。 30 | 31 | ## Gnome terminal : 2020 32 | 33 | Gnome terminal 我也使用过非常长的时间,主要是因为在[龙芯平台上我编不出来 alacritty](https://martins3.github.io/loongarch/neovim.html) 以及有一段时间 alacritty 无法正确的处理 34 | 35 | 原来的 Gnome terminal 的配色我不是很喜欢,以及 36 | 为了让 terminal 一打开就会自动执行 tmux,需要在配置上进行一些[调整](https://github.com/Martins3/My-Linux-Config/blob/master/config/gnome-terminal.dconf) 37 | 38 | 保存和加载配置的方法为(假设将本仓库 clone 到了 ~/.dotfils 上): 39 | ```sh 40 | dconf dump /org/gnome/terminal/legacy/profiles:/:32d12ada-ed49-4c3d-8436-0f64853f7579/ > ~/.dotfiles/scripts/gnome.conf 41 | dconf load /org/gnome/terminal/legacy/profiles:/:32d12ada-ed49-4c3d-8436-0f64853f7579/ < ~/.dotfiles/scripts/gnome.conf 42 | ``` 43 | 44 | gnome terminal d 45 | - Ubuntu 修改默认 terminal emulator 46 | ```sh 47 | sudo update-alternatives --config x-terminal-emulator 48 | ``` 49 | 50 | ## Alacritty : 2020-2022 51 | 52 | Alacritty 目前而言是我使用时间最长的 terminal 了,中间因为输入法的问题换成了 Gnome Terminal,后来解决之后,又切换回来了。 53 | 54 | Alacritty 的优点: 55 | - 对于 UI 可以高度的定制化,只是设置为真正的全屏模式 56 | - 性能很好。 57 | 58 | ## Kitty : 2022-2023 59 | 60 | 切换到 Mac 之后,我发现 alacritty 的两个问题让人很痛苦: 61 | - rime 输入法在输入的过程中无法显示已经输入的字母; 62 | - 需要额外的精力处理 Alt 键; 63 | - 没有 tab 的支持。 64 | 65 | 而且 kitty 支持 session 的概念,配置之后,每次 terminal 可以自动 attach 本地和远程 server 的 tmux 。 66 | 67 | 此外,kitty 的 log 是一只可爱的小猫咪,就凭这一点,我就直接给它打满分。 68 | 69 | ## Tabby : 几分钟 70 | 71 | 非常的酷炫,但是性能不行。 72 | 73 | ## wezterm : 2023-2024 74 | 75 | 我发现我切换到 nixos 之后,kitty 中不能输入中文了,所以就换成了 [wezterm](https://github.com/wez/wezterm) 。 76 | 配置大约花费了半个小时,最后 tab 栏有点丑,其他还好。 77 | 78 | 79 | 80 | ## Windows Terminal + wezterm + Kitty : 2025 81 | 82 | 上班的时候使用 Windows ,用 Window 系统自带的 Windows Terminal。 83 | 84 | 在出租屋的时候使用 macos ,用 wezterm 。 85 | 86 | 不上班的时候使用 Linux 桌面环境,用 Kitty 。 87 | 88 | 对于我来说,这个几个 terminal emulator 其实差不多,在这个环境如果有问题, 89 | 那么就立刻换另外一个。 90 | 91 | ## 总结 92 | 目前,我推荐的 terminal 是: 93 | - kitty 94 | - wezterm 95 | - alacritty 96 | 97 | 虽然 kitty 很大一部分代码是 Python,但是我估计只是用于控制面的,其性能用 [terminal-benchmark](https://github.com/Dica-Developer/terminal-benchmark) 98 | 测试,无明显差距。 99 | 100 | 114 | 115 | 本站所有文章转发 **CSDN** 将按侵权追究法律责任,其它情况随意。 116 | -------------------------------------------------------------------------------- /nvim/lua/usr/cmp.lua: -------------------------------------------------------------------------------- 1 | local cmp_status_ok, cmp = pcall(require, "cmp") 2 | if not cmp_status_ok then 3 | return 4 | end 5 | 6 | local snip_status_ok, luasnip = pcall(require, "luasnip") 7 | if not snip_status_ok then 8 | return 9 | end 10 | 11 | require("luasnip/loaders/from_vscode").lazy_load() 12 | 13 | local check_backspace = function() 14 | local col = vim.fn.col(".") - 1 15 | return col == 0 or vim.fn.getline("."):sub(col, col):match("%s") 16 | end 17 | 18 | local dict = vim.fn.expand("$HOME/.dotfiles/nvim/10k.txt") 19 | 20 | -- `:` cmdline setup. 21 | cmp.setup.cmdline(":", { 22 | mapping = cmp.mapping.preset.cmdline(), 23 | sources = cmp.config.sources({ 24 | { name = "path" }, 25 | }, { 26 | { 27 | name = "cmdline", 28 | option = { 29 | -- ignore_cmds = { "Man", "!" }, 30 | ignore_cmds = {}, 31 | }, 32 | }, 33 | }), 34 | }) 35 | 36 | -- `/` cmdline setup. 37 | cmp.setup.cmdline("/", { 38 | mapping = cmp.mapping.preset.cmdline(), 39 | sources = { 40 | { name = "buffer" }, 41 | }, 42 | }) 43 | 44 | cmp.setup({ 45 | snippet = { 46 | expand = function(args) 47 | luasnip.lsp_expand(args.body) -- For `luasnip` users. 48 | end, 49 | }, 50 | mapping = { 51 | -- 实际上测试,这些键位其实都没用 52 | -- [""] = cmp.mapping.select_prev_item(), 53 | -- [""] = cmp.mapping.select_next_item(), 54 | -- [""] = cmp.mapping(cmp.mapping.scroll_docs(-1), { "i", "c" }), 55 | -- [""] = cmp.mapping(cmp.mapping.scroll_docs(1), { "i", "c" }), 56 | -- [""] = cmp.mapping(cmp.mapping.complete(), { "i", "c" }), 57 | -- [""] = cmp.config.disable, -- Specify `cmp.config.disable` if you want to remove the default `` mapping. 58 | -- [""] = cmp.mapping({ 59 | -- i = cmp.mapping.abort(), 60 | -- c = cmp.mapping.close(), 61 | -- }), 62 | -- Accept currently selected item. If none selected, `select` first item. 63 | -- Set `select` to `false` to only confirm explicitly selected items. 64 | [""] = cmp.mapping.confirm({ select = true }), 65 | [""] = cmp.mapping(function(fallback) 66 | if cmp.visible() then 67 | cmp.select_next_item() 68 | elseif luasnip.expandable() then 69 | luasnip.expand() 70 | elseif luasnip.expand_or_jumpable() then 71 | luasnip.expand_or_jump() 72 | elseif check_backspace() then 73 | fallback() 74 | else 75 | fallback() 76 | end 77 | end, { 78 | "i", 79 | "s", 80 | }), 81 | [""] = cmp.mapping(function(fallback) 82 | if cmp.visible() then 83 | cmp.select_prev_item() 84 | elseif luasnip.jumpable(-1) then 85 | luasnip.jump(-1) 86 | else 87 | fallback() 88 | end 89 | end, { 90 | "i", 91 | "s", 92 | }), 93 | }, 94 | sources = { 95 | { name = "nvim_lsp" }, 96 | { name = "luasnip" }, 97 | { 98 | name = 'buffer', 99 | option = { 100 | get_bufnrs = function() 101 | return vim.api.nvim_list_bufs() 102 | end 103 | } 104 | }, 105 | { name = "path" }, 106 | { name = "emoji" }, 107 | { name = 'orgmode' }, 108 | { 109 | name = "look", 110 | keyword_length = 2, 111 | option = { 112 | convert_case = true, 113 | loud = true, 114 | dict = dict, 115 | }, 116 | }, 117 | }, 118 | confirm_opts = { 119 | behavior = cmp.ConfirmBehavior.Replace, 120 | select = false, 121 | }, 122 | window = { 123 | documentation = { 124 | border = { "╭", "─", "╮", "│", "╯", "─", "╰", "│" }, 125 | }, 126 | }, 127 | experimental = { 128 | ghost_text = false, 129 | }, 130 | }) 131 | -------------------------------------------------------------------------------- /nvim/lua/usr/util.lua: -------------------------------------------------------------------------------- 1 | -- deepseek 协助编写,获取文件名 2 | local function get_file_path() 3 | local file_path = vim.api.nvim_eval("expand('%:p')") 4 | local buf = vim.api.nvim_create_buf(false, true) -- 非列表 buffer,可编辑 5 | 6 | -- 将 buffer 显示在一个新的窗口中 7 | vim.api.nvim_open_win(buf, true, { 8 | relative = "editor", 9 | width = 60, 10 | height = 1, 11 | row = 1, 12 | col = 1, 13 | style = "minimal", 14 | border = "single", 15 | }) 16 | 17 | vim.api.nvim_buf_set_lines(buf, 0, -1, false, { file_path }) 18 | end 19 | 20 | vim.api.nvim_create_user_command("GetFilePath", get_file_path, {}) 21 | 22 | vim.api.nvim_create_user_command("InsertUUID", function() 23 | local function generate_uuid() 24 | local template = "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx" 25 | return string.gsub(template, "[xy]", function(c) 26 | local v = (c == "x") and math.random(0, 15) or math.random(8, 11) 27 | return string.format("%x", v) 28 | end) 29 | end 30 | 31 | math.randomseed(os.time()) -- Seed the random number generator 32 | local uuid = generate_uuid() 33 | local formatted_uuid = "" 34 | vim.api.nvim_put({ formatted_uuid }, "", false, true) 35 | end, { desc = "insert a generated UUID as an HTML comment" }) 36 | 37 | -- generated by Qwen 38 | local function close_hidden_buffers() 39 | local current_buf = vim.api.nvim_get_current_buf() 40 | 41 | local tabpages = vim.api.nvim_list_tabpages() 42 | local visible_buffers = {} 43 | 44 | for _, tab in ipairs(tabpages) do 45 | local wins = vim.api.nvim_tabpage_list_wins(tab) 46 | for _, win in ipairs(wins) do 47 | local buf = vim.api.nvim_win_get_buf(win) 48 | visible_buffers[buf] = true 49 | end 50 | end 51 | 52 | for _, buf in ipairs(vim.api.nvim_list_bufs()) do 53 | if buf == current_buf then 54 | goto skip 55 | end 56 | 57 | if visible_buffers[buf] then 58 | goto skip 59 | end 60 | 61 | if vim.api.nvim_get_option_value("buftype", { buf = buf }) == "terminal" then 62 | vim.notify("Buffer " .. buf .. " is a terminal, not closing", vim.log.levels.INFO) 63 | goto skip 64 | end 65 | 66 | if vim.api.nvim_get_option_value("modified", { buf = buf }) then 67 | vim.notify("Buffer " .. buf .. " is modified, not closing", vim.log.levels.WARN) 68 | goto skip 69 | end 70 | 71 | vim.api.nvim_buf_delete(buf, { force = false }) 72 | 73 | ::skip:: 74 | end 75 | end 76 | 77 | vim.keymap.set( 78 | "n", 79 | "bc", 80 | close_hidden_buffers, 81 | { noremap = true, silent = true, desc = "close all hidden buffers" } 82 | ) 83 | 84 | -- 拷贝, a ,然后粘贴 85 | -- 会调用脚本,将 clipboard 中的 gdb backtrace 简化之后再粘贴出来 86 | function ProcessClipboard() 87 | -- 获取剪贴板内容 88 | local clipboard_content = vim.fn.getreg("+") 89 | -- 检查剪贴板内容是否为空 90 | if clipboard_content == "" then 91 | print("Clipboard is empty!") 92 | return 93 | end 94 | 95 | -- 打开文件并写入剪贴板内容 96 | local tmp = "/tmp/martins3/trim.txt" 97 | local file = io.open(tmp, "w+") 98 | if file then 99 | local success, err = file:write(clipboard_content) 100 | if not success then 101 | print("Failed to write to file: " .. err) 102 | return 103 | end 104 | file:close() 105 | else 106 | print("Failed to open file: " .. tmp) 107 | return 108 | end 109 | 110 | local project = "/home/martins3/data/vn" 111 | local script_path = project .. "/code/qemu/trim.sh" 112 | if vim.fn.filereadable(script_path) == 1 then 113 | vim.fn.system(script_path) 114 | else 115 | print("Script not found: " .. script_path) 116 | end 117 | 118 | file = io.open(tmp, "r") 119 | if file then 120 | local file_content = file:read("*a") -- 读取整个文件内容 121 | -- 将文件内容写入剪贴板 122 | vim.fn.setreg("+", file_content) 123 | print(file_content) 124 | file:close() 125 | else 126 | print("Failed to read file: " .. tmp) 127 | end 128 | print("trim finished !") 129 | end 130 | 131 | -- 映射快捷键 132 | vim.api.nvim_set_keymap("n", "a", ":lua ProcessClipboard()", { noremap = true, silent = true }) 133 | -------------------------------------------------------------------------------- /config/zsh: -------------------------------------------------------------------------------- 1 | if [[ -d $HOME/.nix-profile/bin ]];then 2 | # 如果在 fedora 中安装 nix ,需要首先加载环境变量 3 | if [ -e $HOME/.nix-profile/etc/profile.d/nix.sh ]; then . $HOME/.nix-profile/etc/profile.d/nix.sh; fi # added by Nix installer 4 | 5 | eval "$(direnv hook zsh)" 6 | 7 | function en_direnv() { 8 | echo "use nix" >> .envrc && direnv allow 9 | } 10 | export NIX_CONF_DIR=$HOME/.config/nixpkgs/nix 11 | fi 12 | 13 | 14 | eval "$(zoxide init zsh)" 15 | 16 | export ATUIN_NOBIND="true" 17 | eval "$(atuin init zsh)" 18 | 19 | bindkey '^r' _atuin_search_widget 20 | # eval "$(atuin init zsh --disable-up-arrow)" 21 | # eval "$(mcfly init zsh)" 22 | ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE='fg=5' 23 | export PATH="$HOME/.npm-packages/bin:$PATH" 24 | export PATH="$HOME/.cargo/bin:$PATH" 25 | export PATH="$HOME/.local/bin:$PATH" 26 | export PATH="$HOME/go/bin:$PATH" 27 | 28 | # ocaml 的包管理器是 opam ,为了给他一个依赖环境 29 | [[ ! -r $HOME/.opam/opam-init/init.zsh ]] || source $HOME/.opam/opam-init/init.zsh > /dev/null 2> /dev/null 30 | 31 | # 参考 https://gist.github.com/iansu/1ad9fc5db90aafbf14ce58e99d5940ef 32 | # prompt 中通过不同的 emoji 来标识架构 33 | if [[ -f ~/data/id ]]; then 34 | export SHELL_ARCH=$(cat ~/data/id) 35 | else 36 | 37 | if [[ "$(uname)" == "Darwin" ]]; then 38 | export SHELL_ARCH="🐶" 39 | elif grep "GenuineIntel" /proc/cpuinfo >/dev/null; then 40 | export SHELL_ARCH="🐙" 41 | elif grep "AuthenticAMD" /proc/cpuinfo >/dev/null; then 42 | export SHELL_ARCH="🐉" 43 | else 44 | export SHELL_ARCH="ARM" 45 | fi 46 | fi 47 | eval "$(starship init zsh)" 48 | 49 | 50 | # https://www.reddit.com/r/zellij/comments/10skez0/does_zellij_support_changing_tabs_name_according/ 51 | # rename zellij tab automatically 52 | zellij_tab_name_update() { 53 | if [[ -n $ZELLIJ ]]; then 54 | local current_dir=$PWD 55 | if [[ $current_dir == $HOME ]]; then 56 | current_dir="~" 57 | else 58 | current_dir=${current_dir##*/} 59 | fi 60 | command nohup zellij action rename-tab $current_dir >/dev/null 2>&1 61 | fi 62 | } 63 | 64 | zellij_tab_name_update 65 | chpwd_functions+=(zellij_tab_name_update) 66 | 67 | function zj() { 68 | if [[ -n $ZELLIJ ]]; then 69 | if [[ $# -ne 1 ]]; then 70 | echo "usage: zj name" 71 | exit 1 72 | fi 73 | dirname="/tmp/martins3/$1" 74 | mkdir -p "$dirname" 75 | cd "$dirname" 76 | nohup zellij action rename-tab "$1" >/dev/null 2>&1 77 | fi 78 | } 79 | 80 | alias px="proxychains4 -f $HOME/.dotfiles/config/proxychain.conf" 81 | 82 | 83 | # 自动打开工作区 84 | alias b="$HOME/.dotfiles/config/sh/tmux.sh && exit" 85 | alias c="clear" 86 | alias git_ignore="echo \$(git status --porcelain | grep '^??' | cut -c4-) > .gitignore" 87 | alias gs="tig status" 88 | alias gg="gitui --watcher" 89 | alias kernel_version="git describe --contains" 90 | # https://unix.stackexchange.com/questions/45120/given-a-git-commit-hash-how-to-find-out-which-kernel-release-contains-it 91 | alias ls="eza" 92 | # alias ls="eza --icons" 93 | # 不知道为什么 --icons 会让自动补全消失了 94 | alias l="ls -lah --icons" 95 | alias im="ibus engine rime" 96 | alias q="exit" 97 | alias v=nvim 98 | alias i="ipython" 99 | # alias f="xclip -o >> /home/martins3/core/vn/fun.md && echo '' >> /home/martins3/core/vn/fun.md && cat /home/martins3/core/vn/fun.md" 100 | alias cloc="tokei . -f --sort lines" 101 | alias static="nix-shell -p gcc glibc.static --command zsh" 102 | alias wez=$HOME/.dotfiles/config/sh/wez-opacity.sh 103 | alias ins="$HOME/.dotfiles/scripts/nix/env/install.sh" 104 | alias tm="tmux attach || tmux" 105 | function config_repo(){ 106 | git config user.name martins3 107 | git config user.email hubachelar@gmail.com 108 | } 109 | alias weather="curl wttr.in/beijin" 110 | alias drop_cache="echo 3 | sudo tee /proc/sys/vm/drop_caches" 111 | alias wifi="nmcli dev wifi show-password" 112 | 113 | # TODO 我理解应该可以通过 default.nix 自动实现 source .venv/bin/activate 114 | function p(){ 115 | if [[ ! -d .venv ]]; then 116 | uv venv 117 | fi 118 | source .venv/bin/activate 119 | } 120 | 121 | export NIXPKGS_ALLOW_INSECURE=1 122 | export EDITOR=nvim 123 | export PATH=$PATH:/usr/share/bcc/tools 124 | 125 | if [ -e $HOME/data/vn/code/zsh ]; then 126 | . $HOME/data/vn/code/zsh 127 | fi 128 | -------------------------------------------------------------------------------- /nixpkgs/sys/net.nix: -------------------------------------------------------------------------------- 1 | { config, pkgs, ... }: 2 | 3 | { 4 | services.tailscale.enable = true; 5 | 6 | # http://127.0.0.1:19999/ 7 | # services.netdata.enable = true; 8 | 9 | systemd.services.tailscale-autoconnect = { 10 | description = "Automatic connection to Tailscale"; 11 | 12 | # make sure tailscale is running before trying to connect to tailscale 13 | after = [ 14 | "network-pre.target" 15 | "tailscale.service" 16 | ]; 17 | wants = [ 18 | "network-pre.target" 19 | "tailscale.service" 20 | ]; 21 | wantedBy = [ "multi-user.target" ]; 22 | 23 | # set this service as a oneshot job 24 | serviceConfig.Type = "oneshot"; 25 | 26 | # have the job run this shell script 27 | script = with pkgs; '' 28 | # wait for tailscaled to settle 29 | sleep 2 30 | 31 | # check if we are already authenticated to tailscale 32 | status="$(${tailscale}/bin/tailscale status -json | ${jq}/bin/jq -r .BackendState)" 33 | if [ $status = "Running" ]; then # if so, then do nothing 34 | exit 0 35 | fi 36 | 37 | # otherwise authenticate with tailscale 38 | ${tailscale}/bin/tailscale up -authkey $(cat /home/martins3/.tailscale-credentials) 39 | ''; 40 | }; 41 | 42 | networking.nat = { 43 | enable = false; 44 | internalInterfaces = [ "br-in" ]; 45 | externalInterface = "wlo1"; 46 | internalIPs = [ "10.0.0.0/16" ]; 47 | }; 48 | 49 | networking.firewall.checkReversePath = "loose"; 50 | # networking.hostName = "martins3-host"; 51 | 52 | networking.firewall = { 53 | # enable the firewall 54 | enable = true; 55 | 56 | # always allow traffic from your Tailscale network 57 | trustedInterfaces = [ "tailscale0" ]; 58 | 59 | # allow the Tailscale UDP port through the firewall 60 | allowedUDPPorts = [ 61 | config.services.tailscale.port 62 | 63 | 8472 # k3s, flannel: required if using multi-node for inter-node networking 64 | ]; 65 | 66 | # allow you to SSH in over the public internet 67 | allowedTCPPorts = [ 68 | 22 # ssh 69 | 5201 70 | 5202 71 | 5203 # iperf3 72 | 8889 # clash 73 | 445 # samba 74 | # 8384 # syncthing 75 | # 22000 # syncthing 76 | 2049 # nfs 77 | ]; 78 | 79 | allowedTCPPortRanges = [ 80 | { 81 | from = 50000; 82 | to = 60000; 83 | } 84 | ]; 85 | }; 86 | 87 | # wireless and wired coexist 88 | systemd.network.wait-online.timeout = 1; 89 | 90 | services.samba = { 91 | enable = true; 92 | 93 | # syncPasswordsByPam = true; 94 | 95 | settings = { 96 | # This adds to the [global] section: 97 | global = { 98 | browseable = "yes"; 99 | "smb encrypt" = "required"; 100 | }; 101 | 102 | public = { 103 | path = "/home/martins3/core/winshare"; 104 | browseable = "yes"; 105 | "read only" = "no"; 106 | "guest ok" = "yes"; 107 | # "create mask" = "0644"; 108 | # "directory mask" = "0755"; 109 | # "force user" = "username"; 110 | # "force group" = "groupname"; 111 | }; 112 | 113 | hack = { 114 | path = "/home/martins3/hack"; 115 | browseable = "yes"; 116 | "read only" = "no"; 117 | "guest ok" = "yes"; 118 | }; 119 | 120 | data = { 121 | path = "/home/martins3/data"; 122 | browseable = "yes"; 123 | "read only" = "no"; 124 | "guest ok" = "yes"; 125 | }; 126 | }; 127 | }; 128 | 129 | # networking.proxy.default = "http://127.0.0.1:8889"; 130 | # networking.proxy.noProxy = "127.0.0.1,localhost,internal.domain"; 131 | 132 | # 配合使用 133 | # sudo mount -t nfs4 10.0.0.2:/home/martins3/hack /home/martins3/hack 134 | # 有的 guest os 环境必须用 mount.nfs 135 | # sudo mount.nfs 10.0.0.2:/home/martins3/core/vn /home/martins3/core/vn 136 | # 1. 这个时候居然可以删除掉 nfs ,乌鱼子 137 | # 2. 如果不增加 no_root_squash ,在 fedora 虚拟机中没有 write 权限,但是在 nixos guest 中可以,因为 feodra 默认 root 138 | # - https://serverfault.com/questions/611007/unable-to-write-to-mount-point-nfs-server-getting-permission-denied 139 | # - 但是加上了之后,nixos guest 无法访问了 140 | services.nfs.server.enable = true; 141 | services.nfs.server.exports = '' 142 | /home/martins3/hack 10.0.0.2/16(rw,no_subtree_check) 143 | /home/martins3/data/vn 10.0.0.2/16(rw,no_subtree_check) 144 | ''; 145 | } 146 | -------------------------------------------------------------------------------- /docs/ccls-vs-clangd.md: -------------------------------------------------------------------------------- 1 | # 2023 年对比一下 ccls 和 clangd 2 | 3 | 先说结论,ccls 更好。 4 | 5 | 网上冲浪的时候,感觉有一个普遍的想法,那就是认为 clangd 更好,例如 6 | 1. [最终,我看向了 clangd](https://zhuanlan.zhihu.com/p/364518020) 7 | 8 | 我主要看 QEMU 和 Linux 两个项目,尤其是 Linux ,我之所以认为 ccls 更好是因为 9 | 我特别重视索引的准确程度,ccls 几乎没有出错,但是 clangd 问题很多,而且还出现了 10 | 功能回退的现象。 11 | 12 | 从项目名称上,大家开始的时候会觉得 clangd 才是 LLVM 的官方项目,而 ccls 是一个个人项目,但是实际上, 13 | ccls 的作者 MaskRay 的水平远远高于 clangd 的 maintainer ,他在 LLVM 的累积提交的 commit 14 | 超过 3000 个,他的 blog : https://maskray.me/blog/ 水平很高,如果是编译方向的同学,我建议仔细阅读。 15 | 对于 ccls 的代码质量不需要有任何质疑。 16 | 17 | ## clangd 的问题 18 | 以内核为例: 19 | 20 | ### 无法全局搜索宏 21 | 索引 NULL_COMPOUND_DTOR 找不到 22 | ```c 23 | compound_page_dtor * const compound_page_dtors[NR_COMPOUND_DTORS] = { 24 | [NULL_COMPOUND_DTOR] = NULL, 25 | [COMPOUND_PAGE_DTOR] = free_compound_page, 26 | #ifdef CONFIG_HUGETLB_PAGE 27 | [HUGETLB_PAGE_DTOR] = free_huge_page, 28 | #endif 29 | #ifdef CONFIG_TRANSPARENT_HUGEPAGE 30 | [TRANSHUGE_PAGE_DTOR] = free_transhuge_page, 31 | #endif 32 | }; 33 | ``` 34 | 35 | ### 一些地方颜色渲染不对 36 | 这是 clangd 的结果: 37 | ![](https://user-images.githubusercontent.com/16731244/199185065-4f18db07-e8bb-4bc2-b3e1-316fe9edcba1.png) 38 | 39 | 这是 ccls 的结果: 40 | ![](https://user-images.githubusercontent.com/16731244/219828512-db2bbf9d-3e74-42cb-b7aa-b58a62f331d7.png) 41 | 42 | ### 无法理解和宏重名的结构体成员 43 | 44 | ```c 45 | struct mem_cgroup { 46 | 47 | union { 48 | struct page_counter swap; /* v2 only */ 49 | struct page_counter memsw; /* v1 only */ 50 | }; 51 | ``` 52 | 我发现这里的 swap 总是被理解为: 53 | ```c 54 | /** 55 | * swap - swap values of @a and @b 56 | * @a: first value 57 | * @b: second value 58 | */ 59 | #define swap(a, b) \ 60 | do { typeof(a) __tmp = (a); (a) = (b); (b) = __tmp; } while (0) 61 | ``` 62 | ### clangd 无法理解 gcc 的参数,导致内核项目头上总是存在大量报错 63 | 可以参考 https://stackoverflow.com/questions/70819007/can-not-use-clangd-to-read-linux-kernel-code 解决 64 | 65 | ### 复杂的 macro 无法跳转 66 | 例如: 67 | ```c 68 | static inline unsigned long __raw_spin_lock_irqsave(raw_spinlock_t *lock) 69 | { 70 | unsigned long flags; 71 | 72 | local_irq_save(flags); 73 | preempt_disable(); 74 | spin_acquire(&lock->dep_map, 0, 0, _RET_IP_); 75 | LOCK_CONTENDED(lock, do_raw_spin_trylock, do_raw_spin_lock); 76 | return flags; 77 | } 78 | ``` 79 | `spin_acquire` and `LOCK_CONTENDED` 80 | 81 | 类似的 `ioremap` 这个函数也无法正常跳转。 82 | 83 | ### clangd 在 telescope 中搜索的时候两侧不能有空格 84 | 85 | 必须去掉那些空格,否则搜索内容为空,而 ccls 可以容忍 86 | 87 | ### clangd 无法理解系统中的参数 88 | 例如在内核的代码中创建一个 hello.c ,ccls 可以提供内核的代码要求 89 | ![](https://user-images.githubusercontent.com/16731244/215423433-cc4295a9-fbe3-431e-ac8f-119a8fd28d46.png) 90 | 91 | ### 默认版本 clangd 在 ARM 中不是默认采用 CPU 的数量来索引的 92 | 具体版本 clangd 13 93 | 解决办法: 94 | ```json 95 | "clangd.arguments": ["-j=20"] 96 | ``` 97 | 升级 clangd 98 | ```json 99 | "clangd.path": "/home/martins3/core/LLVM/build/bin/clangd" 100 | ``` 101 | 102 | ### 有的函数搜索不到 103 | 该问题 clangd 13 不存在,升级到 clangd 14 就出现了,之后一直存在。 104 | 105 | 例如 `__populate_section_memmap` 是搜索不到的。 106 | 107 | ### 在 ARM 上展示奇怪的警告 108 | ![](https://user-images.githubusercontent.com/16731244/198576471-d35773af-0ef8-4528-8fb6-59fb5bfd2dd5.png) 109 | 110 | ### clangd 的头文件自动添加不精确 111 | 时不时引入错误的头文件,让编译失败。 112 | 113 | ## ccls 的问题 114 | 当然 ccls 现在我用起来也是有点小问题的: 115 | 116 | 2. ccls 在 nixos 很容易需要重新索引,如果机器性能不行,对于 Linux 之类的项目,一般需要很长时间; 117 | 3. ccls 的高亮依赖额外的插件; 118 | 119 | ![](https://user-images.githubusercontent.com/16731244/215423644-d462a7c8-f691-4137-aac4-875d449608ee.png) 120 | 121 | 122 | ## 都存在的问题 123 | 索引 ARM 如果失败,可以在 compile_commands.json 中将 `-mabi=lp64` 删除。 124 | 125 | ## clangd 做的好的地方 126 | 1. 自动切换 127 | 2. https://clangd.llvm.org/design/remote-index : 看上去不错,但是没有尝试 128 | 129 | ## 更多参考 130 | - https://github.com/MaskRay/ccls/issues/880 131 | 132 | ## 2025/4 的更新 133 | clangd 在 kernel/time/ntp.c 134 | 检查到了这个是不需要的 135 | ```txt 136 | #include "timekeeping_internal.h" 137 | ``` 138 | 139 | 153 | 154 | 本站所有文章转发 **CSDN** 将按侵权追究法律责任,其它情况随意。 155 | -------------------------------------------------------------------------------- /nixpkgs/home/gui.nix: -------------------------------------------------------------------------------- 1 | { config, pkgs, stdenv, lib, ... }: 2 | let 3 | unstable = import { 4 | config.allowUnfree = true; 5 | }; 6 | 7 | in 8 | { 9 | 10 | imports = [ 11 | ./app/gnome.nix 12 | ]; 13 | 14 | fonts.fontconfig.enable = true; 15 | 16 | home.packages = with pkgs; [ 17 | neovide 18 | # shiori # bookmark 管理,但是没搞懂怎么使用 19 | unstable.wpsoffice 20 | # remmina # 远程桌面工具,体验一般 21 | # sublime-merge 22 | # vscode 23 | flameshot # 截图 24 | # unstable.zotero 25 | slack 26 | # drawio 27 | # imagemagick # 压缩照片 28 | # variety # wallpaper 但是 bing wallpaper 已经够好了 29 | kitty 30 | libnotify # 通知小工具 31 | # vmware-workstation 32 | # anki 33 | # foliate # 电子书 34 | wezterm # 2024-08-02 这个版本的 wez 有 bug 35 | # wireshark 36 | alacritty 37 | putty 38 | # warp-terminal 39 | # spacedrive # 一打开就 crash 了,目前没法用 40 | # zoom-us 41 | # spotify 42 | # joplin-desktop # 还有 joplin 43 | # gource 44 | # unstable.firefox 45 | # google-chrome 46 | # pot # 启动之后 segfault 了 47 | # libreoffice 48 | # thunderbird 49 | # feishu 50 | # wechat-uos 51 | # netease-cloud-music-gtk 52 | # yesplaymusic # 似乎这个也不错 53 | # 似乎微信又不可以用了,哈哈 54 | # (nur.repos.xddxdd.wechat-uos.overrideAttrs (old: { 55 | # postInstall = builtins.replaceStrings 56 | # ["--run"] 57 | # [''--set WECHAT_DATA_DIR ${config.home.homeDirectory}/.local/share/wechat-uos/data --run''] 58 | # old.postInstall; 59 | # })) 60 | # nur.repos.linyinfeng.wemeet 61 | microsoft-edge 62 | clash-verge-rev 63 | # 通过 tweaks 调整开机自启动 64 | # gnome-tweaks # @todo 确定是这里设置的,还是只是一个 extension 65 | # clash-nyanpasu 66 | # vlc 67 | # podman-desktop 68 | # tdesktop 69 | # telegram 70 | # gparted # 需要 GTK,使用 disk 也不错 71 | # rofi # @todo rofi 如何使用 72 | # scrcpy # Android 的投屏工具 73 | # xmind 74 | # obsidian 75 | # rustdesk 76 | 77 | # distrobox # 基于容器来提供各种 distribution 78 | # boxbuddy # distrobox 的图形工具 79 | ]; 80 | 81 | xdg.desktopEntries = { 82 | todo = { 83 | name = "Todoist"; 84 | genericName = "ToDo"; 85 | exec = "microsoft-edge https://todoist.com/app/today"; 86 | icon = (pkgs.fetchurl { 87 | url = "https://img.icons8.com/color/512/todoist.png"; 88 | sha256 = "0cas4frxq6rrqbllgdk9wh7a4f8blszxcynsqzcsalc3q7xilkr5"; 89 | }).outPath; 90 | }; 91 | 92 | regex = { 93 | name = "Regex"; 94 | genericName = "regex"; 95 | exec = "microsoft-edge https://regexlearn.com/zh-cn/cheatsheet"; 96 | icon = (pkgs.fetchurl { 97 | url = "https://cdn-icons-png.flaticon.com/512/9804/9804194.png"; 98 | sha256 = "1yh5lnimc0ra5lwmb7vi8yxz58knfwg27rs03xmh7v97324gw1v8"; 99 | }).outPath; 100 | }; 101 | 102 | docker = { 103 | name = "Docker"; 104 | genericName = "docker"; 105 | exec = "microsoft-edge https://dockerlabs.collabnix.com/docker/cheatsheet/"; 106 | icon = (pkgs.fetchurl { 107 | url = "https://img.icons8.com/color/512/docker.png"; 108 | sha256 = "0jbjgh9gbh75q7sli8z6zn7m0nxcawq1v4vp1v4np7k4acp7r1dn"; 109 | }).outPath; 110 | }; 111 | 112 | # @todo 这些玩意儿可以做成模板吗? 113 | bpftrace = { 114 | name = "bpftrace"; 115 | genericName = "bpftrace"; 116 | exec = "microsoft-edge https://github.com/bpftrace/bpftrace/blob/master/man/adoc/bpftrace.adoc"; 117 | icon = (pkgs.fetchurl { 118 | url = "https://img.icons8.com/color/512/docker.png"; 119 | sha256 = "0jbjgh9gbh75q7sli8z6zn7m0nxcawq1v4vp1v4np7k4acp7r1dn"; 120 | }).outPath; 121 | }; 122 | 123 | kernel_cmdline = { 124 | name = "cmdline"; 125 | genericName = "cmdline"; 126 | exec = "microsoft-edge https://www.kernel.org/doc/html/latest/admin-guide/kernel-parameters.html"; 127 | icon = (pkgs.fetchurl { 128 | url = "https://img.icons8.com/color/512/docker.png"; 129 | sha256 = "0jbjgh9gbh75q7sli8z6zn7m0nxcawq1v4vp1v4np7k4acp7r1dn"; 130 | }).outPath; 131 | }; 132 | 133 | crash = { 134 | name = "crash"; 135 | genericName = "crash"; 136 | exec = "microsoft-edge https://crash-utility.github.io/crash_whitepaper.html"; 137 | icon = (pkgs.fetchurl { 138 | url = "https://img.icons8.com/color/512/docker.png"; 139 | sha256 = "0jbjgh9gbh75q7sli8z6zn7m0nxcawq1v4vp1v4np7k4acp7r1dn"; 140 | }).outPath; 141 | }; 142 | }; 143 | # https://icons8.com/icons/ 144 | # 拷贝 url 145 | # nix-prefetch-url https://icons8.com/icon/17842/linux 146 | } 147 | -------------------------------------------------------------------------------- /docs/tmux.md: -------------------------------------------------------------------------------- 1 | # 极简 Tmux 配置 2 | 3 | 其实我很长时间都是不使用 tmux 的,因为很多终端模拟器中已经包含了 Tab 和 Windows 的功能,但是使用了 tmux 之后,发现 tmux 非常灵活,尤其是在远程的 server 中使用。 4 | 5 | ## 先用起来再说 6 | 没有必要阅读 [tmux 之道](https://leanpub.com/the-tao-of-tmux/read) 这种很厚的书,会被直接劝退的。 7 | 其实很多工具,尤其是类似 tmux vim 这种定制化很强的工具,我都是建议先用着再说,遇到问题再 stackoverflow,最后综合的学习一下, 8 | 学习曲线会平缓很多。 9 | 10 | [Oh my tmux](https://github.com/gpakosz/.tmux) 我尝试过几分钟,但是个人默认配置不够简洁,高级功能暂时用不上,所以没有深入分析。 11 | 12 | 最简单的方法就是立刻使用起来,配置可以参考我个人的 [tmux.conf](https://github.com/Martins3/My-Linux-Config/blob/master/scripts/tmux.conf) 配置 13 | 这个脚本超级简单,而且每一个行都是有注释的。 14 | 15 | ## 默认常用操作 16 | - `prefix d` : 等价于 tmux detach 17 | - `prefix &` : kill 当前的 window 18 | - `prefix x` : kill 当前的 pane 19 | - `prefix R` : 重新加载配置 20 | 21 | ## 默认不怎么常用操作 22 | - `prefix l` : 切换到 last window 23 | - `prefix Space` : 切换下一个 pane layout 24 | - `prefix z` : 最大化当前的 pane 25 | - `prefix !` : 将 pane 转换为 window 26 | 27 | ## copy mode 28 | 默认可以编辑的状态 tmux 称为 normal mode,使用 `prefix y` 进入到 copy mode,进入之后,可以使用 vim 的各种移动方式 29 | 30 | > Although tmux copy mode doesn't translate to 100% vim navigation keys - overall they are good enough to feel natural. Some navigation keys that you can use: 31 | > - h / j / k / l to move left/down/up/right 32 | > - w / W / e / E / b / B to move forward to the start / to the end / backward a word or WORD 33 | > - { / } to move backward / forward a paragraph 34 | > - Ctrl + e / d / f to scroll down a line / half screen / whole screen 35 | > - Ctrl + y / u / b to scroll up a line / half screen / whole screen 36 | > - / / ? to search forward / backward 37 | > - n / N to repeat the previous search forward / backward 38 | > etc 39 | > 40 | > https://dev.to/iggredible/the-easy-way-to-copy-text-in-tmux-319g 41 | 42 | - `V` 行选,`v` 字符选,`ctrl-v` 不支持 43 | - [zt/zz/zb 没有支持](https://www.reddit.com/r/tmux/comments/5yoh1q/is_there_a_hack_to_have_vi_ztzzzb_in_copy_mode/) 44 | - 使用 `y` 或者 `enter` 或者鼠标选中,可以复制 45 | - 使用 `ctrl shift v` (MacOS 上 `ctrl-v`) 粘贴,这个和 tmux 无关,一般是 terminal emulator 支持的。 46 | 47 | ## 插件管理 48 | 49 | 安装: 50 | ```sh 51 | git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm 52 | ``` 53 | 54 | - `prefix + I` 55 | - Installs new plugins from GitHub or any other git repository 56 | - Refreshes TMUX environment 57 | - `prefix + U` 58 | - updates plugin(s) 59 | - `prefix + alt + u` 60 | - remove/uninstall plugins not on the plugin list 61 | 62 | ## session 管理 63 | 64 | 通过 tmuxp 创建一个 session 并且自动执行初始化命令: 65 | 66 | 例如,如下命令可以自动创建两个 window 并且分别打开对应的仓库 67 | ```sh 68 | tmuxp load -d ./tmux-session.yaml 69 | ``` 70 | 71 | cat tmux-session.yaml 72 | ```txt 73 | session_name: note 74 | windows: 75 | - window_name: org-mode 76 | layout: tiled 77 | shell_command_before: 78 | - cd ~/core/org-mode 79 | - nvim 80 | - window_name: .dotfiles 81 | layout: tiled 82 | shell_command_before: 83 | - cd ~/core/.dotfiles 84 | - nvim 85 | ``` 86 | ## 配合 bash 使用 87 | 88 | 创建一个 session 并且让 fio 在启动运行: 89 | ```sh 90 | tmux new-session -d -s my_session || true 91 | tmux new-window -d "fio test.fio" 92 | ``` 93 | 94 | ## 一些技巧 95 | 给每一个 tmux pane 设置标题: 96 | ```txt 97 | set -g pane-border-status top 98 | set -g pane-border-format " [ ###P #T ] " 99 | bind T command-prompt -p "Set Pane title:" "select-pane -T '%1'" 100 | ``` 101 | 102 | ## 最近遇到的 tmux 问题 103 | - 有时候,nvim 报告 Clipboard 是 tmux,但是实际上下面的才是正确的 104 | ```txt 105 | ## Clipboard (optional) 106 | - OK: Clipboard tool found: xclip 107 | ``` 108 | - 登录远程终端,在远程终端中使用 clear 或者 vim 的时候遇到 109 | ```txt 110 | 'tmux-256color': unknown terminal type. 111 | ``` 112 | https://unix.stackexchange.com/questions/574669/clearing-tmux-terminal-throws-error-tmux-256color-unknown-terminal-type 113 | 114 | ## 一些试错 115 | 116 | 1. 自动连接远程的 server 的 tmux,这样就可以一次有一次使用 ssh 创建 remote terminal 了 117 | ```sh 118 | ssh -t user@11.22.33.44 "tmux attach || /usr/bin/tmux" 119 | ``` 120 | 当然,可以将这个行为定义为你的 terminal emulator (例如 ketty 或者 wezterm)的一个快捷键。 121 | 122 | 2. tmux list-keys 用于查看已经绑定的快捷键 123 | 124 | 2. tmux 的悬浮窗口 125 | 配置参考: https://gist.github.com/LintaoAmons/22f6184b26bd5b93d8fe9f9276f50f75 126 | ```txt 127 | bind-key -n -N 'Toggle popup window' C-h if-shell -F '#{==:#{session_name},popup}' { 128 | detach-client 129 | } { 130 | display-popup -d "#{pane_current_path}" -xC -yC -w 60% -h 75% -E "tmux attach-session -t popup || tmux new-session -s popup" 131 | } 132 | ``` 133 | 向比 zellij 好处是可以继续多开,但是问题是这会让 switch to next session 命令完全混乱了。 134 | 其实我们希望 popup 的是一个 pane 而不是 session 的。所以最后还是靠 nvim 的悬浮窗来解决问题吧。 135 | 136 | 3. 嵌套 tmux 是一个死亡深渊,没有必要尝试。 137 | - 如果在本地的一个 tmux 中嵌套,tmux 会直接警告你。 138 | - 但是你可以在本地 tmux,然后其中一个 pane 中链接远程,然后在其中开启 tmux,这给我带来了好几个问题。 139 | - 以前是 prefix c 可以创建一个窗口,为了给内层 tmux 创建一个窗口,现在需要按 prefix prefix c,当然也许修改 prefix 也可以。 140 | - 到底是进入的外层还是内层的 tmux 的 vi mode 也是经常搞混的事情。 141 | 142 | ## 扩展 143 | - [tmuxinator](https://github.com/tmuxinator/tmuxinator) 可以实现 kitty 的 session 的管理 144 | - [Tmux-Tutorial](https://leimao.github.io/blog/Tmux-Tutorial/) 145 | - https://news.ycombinator.com/item?id=21055468 146 | - [catppuccin 主题](https://github.com/catppuccin/tmux) 147 | 148 | ## 教程 149 | - https://leimao.github.io/blog/Tmux-Tutorial/ 150 | 151 | 165 | 166 | 本站所有文章转发 **CSDN** 将按侵权追究法律责任,其它情况随意。 167 | -------------------------------------------------------------------------------- /nixpkgs/home/app/gnome.nix: -------------------------------------------------------------------------------- 1 | # from https://github.com/xieby1/nix_config 2 | { config, pkgs, stdenv, lib, ... }: 3 | # gnome extensions and settings 4 | # no need log out to reload extension: +F2 r 5 | { 6 | home.packages = (with pkgs; [ 7 | gnome-sound-recorder 8 | ]) 9 | ++ (with pkgs.gnomeExtensions; [ 10 | unite 11 | clipboard-indicator 12 | bing-wallpaper-changer 13 | gtile 14 | hide-top-bar 15 | customize-ibus 16 | 17 | # lightdark-theme-switcher 18 | ]); 19 | 20 | # Setting: `gsettings set ` 21 | # Getting: `dconf dump /` 22 | dconf.settings = { 23 | "org/gnome/mutter" = { 24 | experimental-features = [ "scale-monitor-framebuffer" ]; 25 | }; 26 | 27 | "org/gnome/shell" = { 28 | ## enabled gnome extensions 29 | disable-user-extensions = false; 30 | enabled-extensions = [ 31 | "BingWallpaper@ineffable-gmail.com" 32 | "clipboard-indicator@tudmotu.com" 33 | "gTile@vibou" 34 | "hidetopbar@mathieu.bidon.ca" 35 | "unite@hardpixel.eu" 36 | "theme-switcher@fthx" 37 | "customize-ibus@hollowman.ml" 38 | ]; 39 | 40 | ## dock icons 41 | favorite-apps = [ 42 | "google-chrome-stable.desktop" 43 | ]; 44 | }; 45 | ## extensions settings 46 | "org/gnome/shell/extensions/system-monitor" = { 47 | compact-display = true; 48 | cpu-show-text = false; 49 | cpu-style = "digit"; 50 | icon-display = false; 51 | memory-show-text = false; 52 | memory-style = "digit"; 53 | net-show-text = false; 54 | net-style = "digit"; 55 | swap-display = false; 56 | swap-style = "digit"; 57 | }; 58 | "org/gnome/shell/extensions/gtile" = { 59 | animation = true; 60 | global-presets = true; 61 | grid-sizes = "6x4,8x6"; 62 | preset-resize-1 = [ "bracketleft" ]; 63 | preset-resize-2 = [ "bracketright" ]; 64 | preset-resize-3 = [ "period" ]; 65 | preset-resize-4 = [ "slash" ]; 66 | preset-resize-5 = [ "apostrophe" ]; 67 | preset-resize-6 = [ "semicolon" ]; 68 | preset-resize-7 = [ "comma" ]; 69 | resize1 = "2x2 1:1 1:1"; 70 | resize2 = "2x2 2:1 2:1"; 71 | resize3 = "2x2 1:2 1:2"; 72 | resize4 = "2x2 2:2 2:2"; 73 | resize5 = "4x8 2:2 3:7"; 74 | resize6 = "1x2 1:1 1:1"; 75 | resize7 = "1x2 1:2 1:2"; 76 | show-icon = false; 77 | }; 78 | 79 | "org/gnome/desktop/session" = { 80 | idle-delay = lib.hm.gvariant.mkUint32 900; # dim the screen after 15 mins 81 | }; 82 | "org/gnome/settings-daemon/plugins/power" = { 83 | ambient-enabled = false; 84 | idle-dim = true; 85 | power-button-action = "suspend"; 86 | # suspend 之后无法 ping 通,即使上一秒还在编译内核,这个完全就是看用户有没 87 | # 交互,而不是看负载的. 88 | sleep-inactive-ac-timeout = 0; # suspend the machine after 1 hour 89 | sleep-inactive-ac-type = "suspend"; 90 | sleep-inactive-battery-type = "suspend"; 91 | }; 92 | "org/gnome/shell/extensions/hidetopbar" = { 93 | mouse-sensitive = true; 94 | enable-active-window = false; 95 | enable-intellihide = true; 96 | }; 97 | "org/gnome/shell/extensions/unite" = { 98 | app-menu-ellipsize-mode = "end"; 99 | extend-left-box = false; 100 | greyscale-tray-icons = false; 101 | hide-app-menu-icon = false; 102 | hide-dropdown-arrows = true; 103 | hide-window-titlebars = "always"; 104 | notifications-position = "center"; 105 | reduce-panel-spacing = true; 106 | show-window-buttons = "always"; 107 | window-buttons-placement = "last"; 108 | window-buttons-theme = "materia"; 109 | restrict-to-primary-screen = false; 110 | }; 111 | "org/gnome/shell/extensions/bingwallpaper" = { 112 | market = "zh-CN"; 113 | delete-previous = false; 114 | }; 115 | 116 | # predefined keyboard shortcuts 117 | "org/gnome/desktop/wm/keybindings" = { 118 | switch-applications = [ ]; 119 | switch-applications-backward = [ ]; 120 | switch-to-application-1 = [ ]; 121 | switch-to-application-2 = [ ]; 122 | switch-to-application-3 = [ ]; 123 | switch-to-application-4 = [ ]; 124 | switch-windows = [ "Tab" ]; 125 | # 似乎默认切换就是按照 workspace 的,这是极好的 126 | # 127 | # TODO 不知道为什么,这个配置没用 128 | switch-windows-directly = [ "l" ]; 129 | switch-to-workspace-1 = [ "1" ]; 130 | switch-to-workspace-2 = [ "2" ]; 131 | switch-to-workspace-3 = [ "3" ]; 132 | switch-to-workspace-4 = [ "4" ]; 133 | switch-windows-backward = [ "Tab" ]; 134 | 135 | move-to-workspace-left = [ "Home" ]; 136 | move-to-workspace-right = [ "End" ]; 137 | }; 138 | 139 | "org/gnome/settings-daemon/plugins/media-keys" = { 140 | custom-keybindings = [ 141 | "/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom0/" 142 | ]; 143 | }; 144 | 145 | "org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom0" = { 146 | binding = "t"; 147 | command = "wezterm"; 148 | /* command = "alacritty"; */ 149 | name = "open-terminal"; 150 | }; 151 | 152 | "org/gnome/shell/extensions/clipboard-indicator" = 153 | { 154 | move-item-first = true; 155 | }; 156 | 157 | # nautilus 158 | "org/gtk/settings/file-chooser" = { 159 | sort-directories-first = true; 160 | }; 161 | 162 | "org/gnome/desktop/interface" = { 163 | enable-hot-corners = true; 164 | show-battery-percentage = true; 165 | }; 166 | 167 | # input method 168 | "org/gnome/desktop/input-sources" = { 169 | sources = with lib.hm.gvariant; mkArray 170 | "(${lib.concatStrings [type.string type.string]})" [ 171 | (mkTuple ["xkb" "us"]) 172 | (mkTuple ["ibus" "rime"]) 173 | ]; 174 | }; 175 | "org/gnome/shell/extensions/customize-ibus" = { 176 | candidate-orientation = lib.hm.gvariant.mkUint32 1; 177 | custom-font="Iosevka Nerd Font 10"; 178 | enable-orientation=true; 179 | input-indicator-only-on-toggle=false; 180 | input-indicator-only-use-ascii=false; 181 | use-custom-font=true; 182 | use-indicator-show-delay=true; 183 | }; 184 | 185 | }; 186 | } 187 | -------------------------------------------------------------------------------- /config/proxychain.conf: -------------------------------------------------------------------------------- 1 | # proxychains.conf VER 4.x 2 | # 3 | # HTTP, SOCKS4a, SOCKS5 tunneling proxifier with DNS. 4 | 5 | 6 | # The option below identifies how the ProxyList is treated. 7 | # only one option should be uncommented at time, 8 | # otherwise the last appearing option will be accepted 9 | # 10 | #dynamic_chain 11 | # 12 | # Dynamic - Each connection will be done via chained proxies 13 | # all proxies chained in the order as they appear in the list 14 | # at least one proxy must be online to play in chain 15 | # (dead proxies are skipped) 16 | # otherwise EINTR is returned to the app 17 | # 18 | strict_chain 19 | # 20 | # Strict - Each connection will be done via chained proxies 21 | # all proxies chained in the order as they appear in the list 22 | # all proxies must be online to play in chain 23 | # otherwise EINTR is returned to the app 24 | # 25 | #round_robin_chain 26 | # 27 | # Round Robin - Each connection will be done via chained proxies 28 | # of chain_len length 29 | # all proxies chained in the order as they appear in the list 30 | # at least one proxy must be online to play in chain 31 | # (dead proxies are skipped). 32 | # the start of the current proxy chain is the proxy after the last 33 | # proxy in the previously invoked proxy chain. 34 | # if the end of the proxy chain is reached while looking for proxies 35 | # start at the beginning again. 36 | # otherwise EINTR is returned to the app 37 | # These semantics are not guaranteed in a multithreaded environment. 38 | # 39 | #random_chain 40 | # 41 | # Random - Each connection will be done via random proxy 42 | # (or proxy chain, see chain_len) from the list. 43 | # this option is good to test your IDS :) 44 | 45 | # Make sense only if random_chain or round_robin_chain 46 | #chain_len = 2 47 | 48 | # Quiet mode (no output from library) 49 | #quiet_mode 50 | 51 | ## Proxy DNS requests - no leak for DNS data 52 | # (disable all of the 3 items below to not proxy your DNS requests) 53 | 54 | # method 1. this uses the proxychains4 style method to do remote dns: 55 | # a thread is spawned that serves DNS requests and hands down an ip 56 | # assigned from an internal list (via remote_dns_subnet). 57 | # this is the easiest (setup-wise) and fastest method, however on 58 | # systems with buggy libcs and very complex software like webbrowsers 59 | # this might not work and/or cause crashes. 60 | proxy_dns 61 | 62 | # method 2. use the old proxyresolv script to proxy DNS requests 63 | # in proxychains 3.1 style. requires `proxyresolv` in $PATH 64 | # plus a dynamically linked `dig` binary. 65 | # this is a lot slower than `proxy_dns`, doesn't support .onion URLs, 66 | # but might be more compatible with complex software like webbrowsers. 67 | #proxy_dns_old 68 | 69 | # method 3. use proxychains4-daemon process to serve remote DNS requests. 70 | # this is similar to the threaded `proxy_dns` method, however it requires 71 | # that proxychains4-daemon is already running on the specified address. 72 | # on the plus side it doesn't do malloc/threads so it should be quite 73 | # compatible with complex, async-unsafe software. 74 | # note that if you don't start proxychains4-daemon before using this, 75 | # the process will simply hang. 76 | #proxy_dns_daemon 127.0.0.1:1053 77 | 78 | # set the class A subnet number to use for the internal remote DNS mapping 79 | # we use the reserved 224.x.x.x range by default, 80 | # if the proxified app does a DNS request, we will return an IP from that range. 81 | # on further accesses to this ip we will send the saved DNS name to the proxy. 82 | # in case some control-freak app checks the returned ip, and denies to 83 | # connect, you can use another subnet, e.g. 10.x.x.x or 127.x.x.x. 84 | # of course you should make sure that the proxified app does not need 85 | # *real* access to this subnet. 86 | # i.e. dont use the same subnet then in the localnet section 87 | #remote_dns_subnet 127 88 | #remote_dns_subnet 10 89 | remote_dns_subnet 224 90 | 91 | # Some timeouts in milliseconds 92 | tcp_read_time_out 15000 93 | tcp_connect_time_out 8000 94 | 95 | ### Examples for localnet exclusion 96 | ## localnet ranges will *not* use a proxy to connect. 97 | ## note that localnet works only when plain IP addresses are passed to the app, 98 | ## the hostname resolves via /etc/hosts, or proxy_dns is disabled or proxy_dns_old used. 99 | 100 | ## Exclude connections to 192.168.1.0/24 with port 80 101 | # localnet 192.168.1.0:80/255.255.255.0 102 | 103 | ## Exclude connections to 192.168.100.0/24 104 | # localnet 192.168.100.0/255.255.255.0 105 | 106 | ## Exclude connections to ANYwhere with port 80 107 | # localnet 0.0.0.0:80/0.0.0.0 108 | # localnet [::]:80/0 109 | 110 | ## RFC6890 Loopback address range 111 | ## if you enable this, you have to make sure remote_dns_subnet is not 127 112 | ## you'll need to enable it if you want to use an application that 113 | ## connects to localhost. 114 | # localnet 127.0.0.0/255.0.0.0 115 | # localnet ::1/128 116 | 117 | ## RFC1918 Private Address Ranges 118 | # localnet 10.0.0.0/255.0.0.0 119 | # localnet 172.16.0.0/255.240.0.0 120 | # localnet 192.168.0.0/255.255.0.0 121 | 122 | ### Examples for dnat 123 | ## Trying to proxy connections to destinations which are dnatted, 124 | ## will result in proxying connections to the new given destinations. 125 | ## Whenever I connect to 1.1.1.1 on port 1234 actually connect to 1.1.1.2 on port 443 126 | # dnat 1.1.1.1:1234 1.1.1.2:443 127 | 128 | ## Whenever I connect to 1.1.1.1 on port 443 actually connect to 1.1.1.2 on port 443 129 | ## (no need to write :443 again) 130 | # dnat 1.1.1.2:443 1.1.1.2 131 | 132 | ## No matter what port I connect to on 1.1.1.1 port actually connect to 1.1.1.2 on port 443 133 | # dnat 1.1.1.1 1.1.1.2:443 134 | 135 | ## Always, instead of connecting to 1.1.1.1, connect to 1.1.1.2 136 | # dnat 1.1.1.1 1.1.1.2 137 | 138 | # ProxyList format 139 | # type ip port [user pass] 140 | # (values separated by 'tab' or 'blank') 141 | # 142 | # only numeric ipv4 addresses are valid 143 | # 144 | # 145 | # Examples: 146 | # 147 | # socks5 192.168.67.78 1080 lamer secret 148 | # http 192.168.89.3 8080 justu hidden 149 | # socks4 192.168.1.49 1080 150 | # http 192.168.39.93 8080 151 | # 152 | # 153 | # proxy types: http, socks4, socks5, raw 154 | # * raw: The traffic is simply forwarded to the proxy without modification. 155 | # ( auth types supported: "basic"-http "user/pass"-socks ) 156 | # 157 | [ProxyList] 158 | # add proxy here ... 159 | # meanwile 160 | # defaults set to "tor" 161 | socks5 127.0.0.1 8889 162 | -------------------------------------------------------------------------------- /docs/rime.md: -------------------------------------------------------------------------------- 1 | # Rime 输入法 2 | 3 | 我使用 Rime 输入法并不是其各种高级功能,我之前一直使用搜狗,但是有一次搜狗崩溃了, 4 | 然后又不知道恢复,在网上参考了各种资料,都无法解决。 5 | 1. https://askubuntu.com/questions/1251749/how-to-install-sogou-input-method-on-ubuntu-20-04 6 | 2. https://leimao.github.io/blog/Ubuntu-Gaming-Chinese-Input/ 7 | 忍无可忍,就换成 Rime 了。但是我发现 Rime 的输入法的门槛很高,这里简单记录下配置过程。 8 | 9 | ## 安装 10 | 11 | 参考 rime/linux-install.sh ,其实也就是: 12 | 13 | 首先在你对应的系统中安装 fcitx-rime,例如: 14 | - fedora : https://fedoraproject.org/wiki/I18N/Fcitx5 15 | ```sh 16 | sudo dnf install -y fcitx5-rime 17 | ``` 18 | 19 | - 安装 : [rime](https://github.com/fcitx/fcitx-rime) 20 | - 安装并且使用: [plum](https://github.com/rime/plum) 21 | - 从 [雾凇拼音](https://github.com/iDvel/rime-ice) 中增加词库,雾凇拼音其他的配置一时无法全部消化吸收,仅仅拷贝其中的 cn_dicts 来扩充自己的词库。 22 | 23 | ## 配置 fcitx5 24 | 在 Fcitx5 Configure 中增加 rime 输入法。 25 | 26 | 在 "Available Input Method" 中搜索 Rime,选中之后,点击中间的那个 "<",让 "Current Input Method" 中增加 Rime 。 27 | 28 | ![image](https://github.com/Martins3/My-Linux-Config/assets/16731244/4c0efdd4-d913-4f03-8cd1-c1a7884b06b1) 29 | 30 | 31 | ## 常用快捷键 32 | 1. `ctrl space` 唤出 rime 输入法 33 | 2. shift 切换的 rime 的中文输入和英文输入。 34 | 3. `ctrl delete` : 删除自造词 35 | 36 | ## 配置简单说明 37 | | 文件 | 说明 | 38 | |--------------------------------|------------------------------| 39 | | linux-install.sh | 简单的安装脚本 | 40 | | default.custom.yaml | 基础配置,例如候选词的个数 | 41 | | luna_pinyin.martins3.dict.yaml | 我自己增加的词汇 | 42 | | luna_pinyin.my_words.dict.yaml | 词库配置,包含雾凇拼音的词库 | 43 | | luna_pinyin_simp.custom.yaml | 输入法的模糊音之类的配置 | 44 | | squirrel.custom.yaml | Mac 的输入法皮肤 | 45 | 46 | ## 皮肤 47 | - 如果你喜欢折腾 48 | - https://github.com/fkxxyz/ssfconv 49 | - 在 mac 中的参考很多,例如: 50 | - [简单安利 Rime 输入法](https://www.manjusaka.blog/posts/2020/01/28/simple-config-for-rime-input/#more) 51 | 52 | 53 | https://github.com/fcitx/fcitx5-rime/issues/15 54 | 55 | ## nixos 的配置 56 | 其他的内容都相同,就是 fcitx 和 rime 的安装和一般的系统不同。 57 | 58 | ```nix 59 | i18n.inputMethod = { 60 | enabled = "fcitx5"; 61 | fcitx5.addons = with pkgs; [ 62 | fcitx5-rime 63 | ]; 64 | }; 65 | ``` 66 | 67 | 参考 [NixOS 中文字体输入法](https://zhuanlan.zhihu.com/p/463403799) 配置。 68 | 69 | ## 2024-05-30 的发现 70 | 如果似乎是需要将 fcitx 的配置中的 Shift-L 取消掉,不然他会覆盖掉 rime 的行为。 71 | 72 | 甚至怀疑是键盘的问题,但是实际上并不是; 73 | https://superuser.com/questions/248517/show-keys-pressed-in-linux 74 | 75 | 似乎自定义的输入法没办法用了。 例如: 76 | rime/luna_pinyin.martins3.dict.yaml 77 | 78 | ## rime-ls 79 | ```sh 80 | git clone https://github.com/wlh320/rime-ls 81 | sudo dnf install librime-devel 82 | cd rime-ls 83 | cargo build --release 84 | cp target/release/rime_ls ~/.cargo/bin 85 | ``` 86 | 在 asahi linux fedora 上尝试的时候,还需要安装如下内容: 87 | 88 | 这是没有图形界面的哦,一样是可以正常使用的 89 | ```sh 90 | /home/martins3/.dotfiles/rime/linux-install.sh 91 | sudo dnf install ibus-rime 92 | ``` 93 | 94 | ### 存在的问题 95 | 1. 自动选择数值 96 | - 没太搞懂,虽然说,https://github.com/liubianshi/cmp-lsp-rimels 已经解决了,但是实际上不好用,但是问题不大,因为 97 | 2. , 的输入应该是自动,谁 miaomiao 的输入中文的忽然携带一个英文都好 98 | 3. 是否可以变为 toggle 的模式 99 | 4. 没办法切换为双拼,但是在 rime-ls 中是可以的 100 | ```txt 101 | schema_trigger_character = "&" -- [since v0.2.0] 当输入此字符串时请求补全会触发 “方案选单” 102 | ``` 103 | 5. 双拼没办法显示当自动匹配的拼音字母 104 | 105 | ## 小鹤双拼的配置 106 | 107 | - https://github.com/brglng/rime-xhup 108 | - https://github.com/ASC8384/myRime 109 | 110 | 配置小鹤双拼还是比较简单的。 111 | 112 | - https://www.zhihu.com/question/20698750 113 | 114 | ![](https://pica.zhimg.com/v2-8d8018a2e277a8b9c2e3ba4baa2a3632_r.jpg?source=1def8aca) 115 | 116 | - [ ] 如何将 emoji 去掉? 117 | 118 | 119 | 不能在赞同了: https://www.zhihu.com/question/383416202/answer/2584564433 120 | 121 | ## 使用 rime-ice 加上 rime-auto-deploy 122 | 123 | https://github.com/iDvel/rime-ice 124 | https://github.com/Mark24Code/rime-auto-deploy 125 | 126 | 直接无敌! 127 | 128 | - [ ] 这个基础上处理下模糊音 129 | - [ ] 默认上屏的操作 130 | - [ ] 不要展示拼音 131 | 132 | 133 | https://github.com/iDvel/rime-ice/issues/133 134 | https://www.mintimate.cc/zh/guide/faQ.html#linux%E8%96%84%E8%8D%B7%E9%85%8D%E7%BD%AE%E6%97%A0%E6%B3%95%E4%BD%BF%E7%94%A8 135 | 136 | 137 | 实在是太复杂了,我靠 : 似乎这里没有插件,所以有问题 138 | https://github.com/NixOS/nixpkgs/blob/nixos-24.05/pkgs/development/libraries/librime/default.nix 139 | 140 | ## 切换 ibus 和 fcitx5 141 | 142 | 似乎 fcitx5 很简单: 143 | 144 | https://github.com/fcitx/fcitx5-rime 145 | https://github.com/rime/ibus-rime/issues : 这个不维护了 146 | 147 | ## rimels 初步尝试 148 | ```diff 149 | diff --git a/nvim/lua/usr/lazy.lua b/nvim/lua/usr/lazy.lua 150 | index f49b0c7ef8a1..d1459b277c94 100644 151 | --- a/nvim/lua/usr/lazy.lua 152 | +++ b/nvim/lua/usr/lazy.lua 153 | @@ -185,63 +185,4 @@ require("lazy").setup({ 154 | config = true, 155 | }, 156 | 'ojroques/nvim-osc52', 157 | - { 158 | - "liubianshi/cmp-lsp-rimels", 159 | - dir = "/home/martins3/core/cmp-lsp-rimels", 160 | - -- 这个插件让正常的补全很卡 161 | - enabled = false, 162 | - config = function() 163 | - local compare = require("cmp.config.compare") 164 | - local cmp = require("cmp") 165 | - cmp.setup({ 166 | - -- 设置排序顺序 167 | - sorting = { 168 | - comparators = { 169 | - compare.sort_text, 170 | - compare.offset, 171 | - compare.exact, 172 | - compare.score, 173 | - compare.recently_used, 174 | - compare.kind, 175 | - compare.length, 176 | - compare.order, 177 | - }, 178 | - }, 179 | - }) 180 | - 181 | - require("rimels").setup({ 182 | - keys = { start = "jk", stop = "jh", esc = ";j", undo = ";u" }, 183 | - cmd = { "/home/martins3/.cargo/bin/rime_ls" }, 184 | - rime_user_dir = "/home/martins3/.local/share/rime-ls", 185 | - shared_data_dir = "/home/martins3/.local/share/fcitx5/rime", 186 | - filetypes = { "NO_DEFAULT_FILETYPES" }, 187 | - single_file_support = true, 188 | - settings = {}, 189 | - docs = { 190 | - description = [[https://www.github.com/wlh320/rime-ls, A language server for librime]], 191 | - }, 192 | - max_candidates = 9, 193 | - trigger_characters = {}, 194 | - schema_trigger_character = "&", -- [since v0.2.0] 当输入此字符串时请求补全会触发 “方案选单” 195 | - probes = { 196 | - ignore = {}, 197 | - using = {}, 198 | - add = {}, 199 | - }, 200 | - detectors = { 201 | - with_treesitter = {}, 202 | - with_syntax = {}, 203 | - }, 204 | - cmp_keymaps = { 205 | - disable = { 206 | - space = false, 207 | - numbers = false, 208 | - enter = false, 209 | - brackets = false, 210 | - backspace = false, 211 | - }, 212 | - }, 213 | - }) 214 | - end, 215 | - }, 216 | }, {}) 217 | ``` 218 | 219 | ## 参考 && TODO 220 | - [双拼練習](https://github.com/BlueSky-07/Shuang) 221 | - [GNU/Linux 输入法折腾笔记 (RIME)](https://mogeko.me/posts/zh-cn/031/) 222 | - [小狼毫 3 分钟入门及进阶指南](https://sspai.com/post/63916) 223 | - [Arch Linux 下给 RIME 中](https://anclark.github.io/2020/11/23/Struggle_with_Linux/%E7%BB%99RIME%E4%B8%AD%E5%B7%9E%E9%9F%B5%E6%B7%BB%E5%8A%A0%E8%AF%8D%E5%BA%93/) 224 | - [Rime 导入搜狗词库](https://www.jianshu.com/p/300bbe1602d4) 225 | - [”深蓝词库转换“ 一款开源免费的输入法词库转换程序](https://github.com/studyzy/imewlconverter) 226 | - [也致第一次安装 Rime 的你](https://gitlab.com/xianghongai/Rime/-/tree/main) 227 | - [ssnhd 的 rime 教程](https://github.com/ssnhd/rime) 228 | 229 | 243 | 244 | 本站所有文章转发 **CSDN** 将按侵权追究法律责任,其它情况随意。 245 | --------------------------------------------------------------------------------