mirror of
https://github.com/js0ny/dotfiles.git
synced 2025-12-21 00:33:00 +00:00
niri: app maps and edit-clipboard shortcuts
This commit is contained in:
parent
bd2a7fcc26
commit
40e3834b7f
5 changed files with 149 additions and 12 deletions
|
|
@ -8,10 +8,21 @@
|
|||
|
||||
-- Entry point of neovim configuration
|
||||
require("config.options")
|
||||
|
||||
local minimal = os.getenv("NVIM_MINIMAL") or os.getenv("EDITOR_POPUP")
|
||||
|
||||
if minimal == "1" then
|
||||
-- require("profiles.minimal")
|
||||
vim.keymap.set("n", "<C-s>", ":wq!<CR>", { noremap = true, silent = true })
|
||||
return
|
||||
end
|
||||
|
||||
local term = os.getenv("TERM") or ""
|
||||
if vim.g.vscode then -- TODO: VSCode Neovim Integration
|
||||
require("profiles.vscode")
|
||||
elseif term == "linux" then -- Under tty
|
||||
-- Under tty
|
||||
-- if under gui, the term will be set to linux as well, additional check required.
|
||||
elseif term == "linux" and not vim.fn.has("gui_running") then
|
||||
require("profiles.tty")
|
||||
vim.cmd("colorscheme vim") -- Use minimal colorscheme
|
||||
else
|
||||
|
|
@ -38,3 +49,43 @@ if vim.g.neovide then
|
|||
vim.g.neovide_light_radius = 5
|
||||
vim.g.neovide_input_macos_option_key_is_meta = "only_left"
|
||||
end
|
||||
|
||||
-- 存储输入法状态的变量
|
||||
vim.g.input_layout = nil
|
||||
|
||||
-- 退出插入模式时:记录当前输入法并切换到英文
|
||||
local function fcitx2en()
|
||||
-- 使用 fcitx5-remote -n 获取当前输入法名称
|
||||
local current_layout = vim.fn.system("fcitx5-remote -n")
|
||||
-- 去除换行符
|
||||
vim.g.input_layout = vim.trim(current_layout)
|
||||
|
||||
-- 切换到英文输入法
|
||||
vim.fn.system("fcitx5-remote -s keyboard-us")
|
||||
end
|
||||
|
||||
-- 进入插入模式时:恢复之前的输入法状态
|
||||
local function fcitx2zh()
|
||||
-- 如果之前记录了输入法状态,则恢复
|
||||
if vim.g.input_layout ~= nil and vim.g.input_layout ~= "" then
|
||||
vim.fn.system("fcitx5-remote -s " .. vim.g.input_layout)
|
||||
end
|
||||
end
|
||||
|
||||
-- 设置 ttimeoutlen
|
||||
vim.opt.ttimeoutlen = 150
|
||||
|
||||
-- 创建自动命令组
|
||||
local fcitx_group = vim.api.nvim_create_augroup("FcitxToggle", { clear = true })
|
||||
|
||||
-- 退出插入模式时切换到英文并记录状态
|
||||
vim.api.nvim_create_autocmd("InsertLeave", {
|
||||
group = fcitx_group,
|
||||
callback = fcitx2en,
|
||||
})
|
||||
|
||||
-- 进入插入模式时恢复之前的输入法
|
||||
vim.api.nvim_create_autocmd("InsertEnter", {
|
||||
group = fcitx_group,
|
||||
callback = fcitx2zh,
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue