https://github.com/kiyoon/Korean-IME.nvim
한글입력기 for NeoVim
https://github.com/kiyoon/Korean-IME.nvim
Last synced: 30 days ago
JSON representation
한글입력기 for NeoVim
- Host: GitHub
- URL: https://github.com/kiyoon/Korean-IME.nvim
- Owner: kiyoon
- Created: 2025-03-08T18:30:29.000Z (about 1 month ago)
- Default Branch: master
- Last Pushed: 2025-03-09T08:34:45.000Z (about 1 month ago)
- Last Synced: 2025-03-09T09:21:00.793Z (about 1 month ago)
- Language: Lua
- Size: 168 KB
- Stars: 5
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-neovim-sorted - kiyoon/Korean-IME.nvim - independent Korean input method that converts English inputs to Korean in-place. | (Language)
- awesome-neovim - kiyoon/Korean-IME.nvim - OS-independent Korean input method that converts English inputs to Korean in-place. (Language / PHP)
README
# Korean-IME.nvim
한글 입력기 플러그인입니다.
**특징:**
- 🔠 영어 입력을 한글로 변환하는 방식입니다.
- 한글 키보드가 없거나 터미널 입력기 버그 등 극한의 상황에서도 한글 입력이 가능합니다.
- 漢字 한자 입력을 지원합니다.
- ♻️ 명령 모드 -> 입력 모드 전환 시 한글 입력 상태를 유지합니다.
- 💤 lazy load를 지원합니다.
- 한영 전환 시에만 플러그인 로드.
- 한자 입력 시에만 한자 DB 로드.## ⚒️ 설치
lazy.nvim:
```lua
{
"kiyoon/Korean-IME.nvim",
keys = {
-- lazy load on 한영전환
{
"",
function()
require("korean_ime").change_mode()
end,
mode = { "i", "n", "x", "s" },
desc = "한/영",
},
},
config = function()
require("korean_ime").setup()vim.keymap.set("i", "", function()
require("korean_ime").convert_hanja()
end, { noremap = true, silent = true, desc = "한자" })
end,
},
```### lualine.nvim
한/A 표시는 다음과 같이 설정할 수 있습니다.
```lua
{
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,
},
},
}
}
```## 💡 Tips
### (macOS) Hammerspoon으로 nvim 감지해 한영 전환하기
Right Command 키를 nvim일 때 ``로 매핑하고 그 외에는 시스템 입력기를 전환하려면 다음과 같이 설정할 수 있습니다.
1. wezterm인지 확인
- window title이 vi인지 확인
- vi이면 command 모드가 아닌지 UI로 확인 (`wezterm cli get-text --escapes` 사용)
- vi이고 command 모드가 아닌 경우 `` 누르기.
2. 그 외에는 시스템 입력기 전환예를 들어, command 모드 여부는 lualine 양쪽 끝 내용과 색상으로 유추할 수 있습니다.
tmux active pane에 돌아가는 프로그램도 pane-border-format, pane-active-border-style로 유추할 수 있습니다.:
아래 템플릿을 이용해 수정해 사용하시길 바랍니다.
```lua
-- 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
endif 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)
```## 📝 Note
- Lua rewrite of [hangeul.vim](https://github.com/lifthrasiir/hangeul.vim)
- 조합 모음이나 자음의 경우 한번 지우면 같이 지워지는 등의 문제가 있습니다.