한글 입력기 플러그인입니다.
특징:
lazy.nvim:
{
"kiyoon/Korean-IME.nvim",
keys = {
-- lazy load on 한영전환
{
"<f12>",
function()
require("korean_ime").change_mode()
end,
mode = { "i", "n", "x", "s" },
desc = "한/영",
},
},
config = function()
require("korean_ime").setup()
vim.keymap.set("i", "<f9>", function()
require("korean_ime").convert_hanja()
end, { noremap = true, silent = true, desc = "한자" })
end,
},
한/A 표시는 다음과 같이 설정할 수 있습니다.
{
sections = {
-- ...
lualine_z = {
{
function()
if not package.loaded["korean_ime"] then
return ""
end
local mode = require("korean_ime").get_mode()
if mode == "en" then
return "A "
elseif mode == "ko" then
return "한"
end
end,
},
},
}
}
Right Command 키를 nvim일 때 <f12>
로 매핑하고 그 외에는 시스템 입력기를 전환하려면 다음과 같이 설정할 수 있습니다.
wezterm cli get-text --escapes
사용)<f12>
누르기.예를 들어, command 모드 여부는 lualine 양쪽 끝 내용과 색상으로 유추할 수 있습니다.
tmux active pane에 돌아가는 프로그램도 pane-border-format, pane-active-border-style로 유추할 수 있습니다.:
아래 템플릿을 이용해 수정해 사용하시길 바랍니다.
-- Karabiner 이용해 Right Command를 F18로 매핑함.
-- 주의: 단순 예시입니다. string.match 부분을 본인 UI에 맞게 수정해야합니다.
-- tmux 안에서는 동작하지 않으니 마찬가지로 사용자 tmux UI에 맞게 수정해야합니다.
hs.hotkey.bind({}, "f18", function()
local input_source = hs.keycodes.currentSourceID()
local current_app = hs.application.frontmostApplication()
print(current_app:name())
if current_app:name() == "WezTerm" then
-- get current window title
local window_title = current_app:focusedWindow():title()
-- ends with vi/vim/nvim
-- e.g. [1/2] vi
print(window_title)
if
string.match(window_title, " vi$")
or string.match(window_title, " vim$")
or string.match(window_title, " nvim$")
or string.match(window_title, "^vi$")
or string.match(window_title, "^vim$")
or string.match(window_title, "^nvim$")
then
print("vim")
local output, status, type, rc = hs.execute("/opt/homebrew/bin/wezterm cli get-text --escapes")
if
status == true
and type == "exit"
and rc == 0
and output ~= nil
and string.match(output, [[nvim .%[38:2::98:114:164m.%[49m─]])
then
print("not in command mode")
if input_source ~= "com.apple.keylayout.ABC" then
hs.keycodes.currentSourceID("com.apple.keylayout.ABC")
end
hs.eventtap.keyStroke({}, "f12")
return
end
end
end
if input_source == "com.apple.keylayout.ABC" then
hs.keycodes.currentSourceID("com.apple.inputmethod.Korean.2SetKorean")
elseif input_source == "com.apple.inputmethod.Korean.2SetKorean" then
hs.keycodes.currentSourceID("com.apple.keylayout.ABC")
else
hs.keycodes.currentSourceID("com.apple.inputmethod.Korean.2SetKorean")
end
end)