ime: wrapper helper for fcitx module

This commit is contained in:
js0ny 2025-11-18 08:19:15 +00:00
parent 20a2dc258f
commit 5c189f5c0f
7 changed files with 147 additions and 104 deletions

View file

@ -1,5 +1,6 @@
local mode_arrow = { "n", "v", "s", "x", "o" } local mode_arrow = { "n", "v", "s", "x", "o" }
-- stylua: ignore
local keymaps_basic = { local keymaps_basic = {
-- https://github.com/LazyVim/LazyVim/blob/d1529f650fdd89cb620258bdeca5ed7b558420c7/lua/lazyvim/config/keymaps.lua#L8 -- https://github.com/LazyVim/LazyVim/blob/d1529f650fdd89cb620258bdeca5ed7b558420c7/lua/lazyvim/config/keymaps.lua#L8
{ {
@ -96,7 +97,7 @@ local keymaps_basic = {
opts = { desc = "Down 5 Lines" }, opts = { desc = "Down 5 Lines" },
}, },
{ keys = "<Tab>", cmd = "<C-w><C-w>", opts = { desc = "Focus on other panel" } }, { keys = "<Tab>", cmd = "<C-w><C-w>", opts = { desc = "Focus on other panel" } },
{ keys = "<CR>", cmd = "%" }, -- { keys = "<CR>", cmd = "%" },
{ keys = "Y", cmd = "y$", opts = { desc = "Yank to End of Line" } }, { keys = "Y", cmd = "y$", opts = { desc = "Yank to End of Line" } },
{ mode = mode_arrow, keys = "J", cmd = "5j" }, { mode = mode_arrow, keys = "J", cmd = "5j" },
{ mode = mode_arrow, keys = "K", cmd = "5k" }, { mode = mode_arrow, keys = "K", cmd = "5k" },

View file

@ -15,7 +15,7 @@ return {
openrouter = { openrouter = {
__inherited_from = "openai", __inherited_from = "openai",
endpoint = "https://openrouter.ai/api/v1", endpoint = "https://openrouter.ai/api/v1",
model = "anthropic/claude-sonnet-4.5", model = "openai/gpt-5.1-codex",
api_key_name = "OPENROUTER_API_KEY", api_key_name = "OPENROUTER_API_KEY",
}, },
}, },

View file

@ -52,12 +52,12 @@
"ui_font_size": 16, "ui_font_size": 16,
"buffer_font_size": null, "buffer_font_size": null,
"relative_line_numbers": true, "relative_line_numbers": true,
"buffer_font_family": "Zed Plex Mono", "buffer_font_family": "Maple Mono NF CN",
"remove_trailing_whitespace_on_save": true, "remove_trailing_whitespace_on_save": true,
"agent": { "agent": {
"default_model": { "default_model": {
"provider": "copilot_chat", "provider": "openrouter",
"model": "claude-3-7-sonnet" "model": "openai/gpt-5.1-codex"
} }
}, },
"inlay_hints": { "inlay_hints": {
@ -88,7 +88,11 @@
"metrics": false "metrics": false
}, },
"languages": { "languages": {
"YAML": {
"tab_size": 2
},
"Nix": { "Nix": {
"tab_size": 2,
"formatter": { "formatter": {
"external": { "external": {
"command": "alejandra", "command": "alejandra",
@ -98,6 +102,19 @@
"completions": { "completions": {
"lsp_insert_mode": "replace" "lsp_insert_mode": "replace"
} }
},
"Lua": {
"tab_size": 2,
"formatter": {
"external": {
"command": "stylua"
}
}
} }
},
"auto_install_extensions": {
"catppuccin": true,
"material-icon-theme": true,
"git-firefly": true
} }
} }

View file

@ -77,3 +77,6 @@ nnoremap ]g editor.action.editor.nextChange
" " Use C-w C-w as original C-w " " Use C-w C-w as original C-w
" noremap <C-w><C-w> workbench.action.closeActiveEditor " noremap <C-w><C-w> workbench.action.closeActiveEditor
" noremap <C-w><A-n> workbench.action.togglePanel " noremap <C-w><A-n> workbench.action.togglePanel
" camelCaseMotion
noremap w <leader>w

View file

@ -55,5 +55,7 @@
srm srm
mediainfo mediainfo
exiftool exiftool
ddgr # DuckDuckGo CLI
jujutsu
]; ];
} }

View file

@ -1,66 +1,88 @@
{pkgs, ...}: { {
home.packages = with pkgs; [ pkgs,
# Terminal Emulator lib,
ghostty # default ...
kitty }: let
alacritty mkFcitxIM = builtins.map (
warp-terminal p:
lib.hiPrio (
pkgs.runCommand "${p.name}-wrapped" {nativeBuildInputs = with pkgs; [makeWrapper];} ''
mkdir -p $out/bin
makeWrapper \
${p}/bin/${p.meta.mainProgram or p.pname} \
$out/bin/${p.meta.mainProgram or p.pname} \
--set GTK_IM_MODULE fcitx \
--set QT_IM_MODULE fcitx
''
)
);
in {
home.packages = with pkgs;
[
# Terminal Emulator
ghostty # default
kitty
alacritty
warp-terminal
# PDF Viewer # PDF Viewer
kdePackages.okular # default kdePackages.okular # default
sioyek sioyek
# Image Viewer # Image Viewer
loupe # SUPER FAST 有催人跑的感觉 w/ GPU Accel. loupe # SUPER FAST 有催人跑的感觉 w/ GPU Accel.
kdePackages.elisa kdePackages.elisa
mpv mpv
haruna haruna
# Email # Email
protonmail-bridge protonmail-bridge
thunderbird thunderbird
birdtray birdtray
# Theming # Theming
papirus-icon-theme papirus-icon-theme
rose-pine-cursor rose-pine-cursor
pcloud pcloud
materialgram materialgram
steam steam
signal-desktop signal-desktop
# Use Wayland for Jetbrains # Use Wayland for Jetbrains
(jetbrains.idea-ultimate.override { (jetbrains.idea-ultimate.override {
vmopts = ''-Dawt.toolkit.name=WLToolkit''; vmopts = ''-Dawt.toolkit.name=WLToolkit'';
}) })
(jetbrains.rider.override { (jetbrains.rider.override {
vmopts = ''-Dawt.toolkit.name=WLToolkit''; vmopts = ''-Dawt.toolkit.name=WLToolkit'';
}) })
localsend localsend
cherry-studio cherry-studio
kdePackages.kdeconnect-kde kdePackages.kdeconnect-kde
picard picard
qutebrowser qutebrowser
ryubing ryubing
qbittorrent qbittorrent
protonvpn-gui protonvpn-gui
proton-pass proton-pass
neovim-qt goldendict-ng
goldendict-ng kdePackages.kdenlive
kdePackages.kdenlive gimp
gimp steam-run
steam-run bottles
bottles lutris
lutris vivaldi
vivaldi rustdesk
rustdesk kdePackages.krdc
kdePackages.krdc kdePackages.breeze
kdePackages.breeze zotero
zotero anki-bin
anki-bin feishin
feishin ]
]; ++ (mkFcitxIM [
pkgs.neovim-qt
pkgs.anki
]);
home.sessionVariables = { home.sessionVariables = {
ANKI_WAYLAND = 1; ANKI_WAYLAND = 1;
@ -68,37 +90,6 @@
NIXOS_OZONE_WL = 1; NIXOS_OZONE_WL = 1;
}; };
xdg.desktopEntries = {
"anki" = {
name = "Anki";
genericName = "Flashcards";
comment = "An intelligent spaced-repetition memory training program";
icon = "anki";
type = "Application";
terminal = false;
categories = [
"Education"
"Languages"
"KDE"
"Qt"
];
mimeType = [
"application/x-apkg"
"application/x-anki"
"application/x-ankiaddon"
];
# Should specify wayland and IME used
exec = "env ANKI_WAYLAND=1 QT_IM_MODULE=fcitx anki %f";
settings = {
"TryExec" = "anki";
"Version" = "1.0";
"X-GNOME-SingleWindow" = "true";
"SingleMainWindow" = "true";
"StartupWMClass" = "anki";
};
};
};
# TODO: This is a dependency of `feishin` (EOL) # TODO: This is a dependency of `feishin` (EOL)
# Once the new version is published, delete this # Once the new version is published, delete this
nixpkgs.config.permittedInsecurePackages = [ nixpkgs.config.permittedInsecurePackages = [

View file

@ -105,17 +105,46 @@ in {
source = rimeConfigFiltered; source = rimeConfigFiltered;
recursive = true; recursive = true;
}; };
home.file."${rimePath}/default.custom.yaml" = { # yaml 最后留出一行
text = '' home.file = {
patch: "${rimePath}/default.custom.yaml" = {
schema_list: text = ''
- schema: wanxiang_pro patch:
- schema: latex # 方案列表
- schema: jyut6ping3 schema_list:
- schema: dioion - schema: wanxiang_pro
- schema: gekion - schema: latex
- schema: jyut6ping3
- schema: dioion
- schema: gekion
# 切换中英:
# 不同的选项表示:打字打到一半时按下了 CapsLock、Shift、Control 后:
# commit_code 上屏原始的编码,然后切换到英文
# commit_text 上屏拼出的词句,然后切换到英文
# clear 清除未上屏内容,然后切换到英文
# inline_ascii 切换到临时英文模式,按回车上屏后回到中文状态
# noop 屏蔽快捷键,不切换中英,但不要屏蔽 CapsLock
ascii_composer/switch_key:
Shift_L: noop
Shift_R: commit_code
key_binder/bindings:
# emacs editing:
- { when: composing, accept: Control+p, send: Up }
- { when: composing, accept: Control+n, send: Down }
- { when: composing, accept: Control+b, send: Left }
- { when: composing, accept: Control+f, send: Right }
''; '';
enable = true; enable = true;
};
"${rimePath}/wanxiang_pro.custom.yaml" = {
text = ''
patch:
key_binder/sequence:
pin: "Alt+p" # 使用 Alt-p 而不是 Ctrl-p 置顶候选项(见 ./default.custom.yaml 中 emacs editing
'';
enable = true;
};
}; };
} }