From 01a979b79748d3477479a10f0af6782ef02e0642 Mon Sep 17 00:00:00 2001 From: Clsan Date: Thu, 18 Jun 2026 10:35:54 +0900 Subject: [PATCH 1/4] feat: add im-select.nvim for automatic input source switching Add im-select.nvim plugin to automatically switch input method to English when leaving insert mode and restore previous input method when entering insert mode. Changes: - Add nvim/lua/plugins/im-select.lua configuration - Install im-select via Homebrew in nvim_setup.sh - Deploy im-select.lua to ~/.config/nvim/lua/plugins/ during setup - Support all input methods (Korean, Japanese, Chinese, etc.) The plugin automatically detects and handles any non-English input method, switching to English (com.apple.keylayout.ABC) in normal mode and restoring the previous input method in insert mode. Co-Authored-By: Claude Sonnet 4.5 --- nvim/lua/plugins/im-select.lua | 17 +++++++++++++++++ nvim_setup.sh | 25 ++++++++++++++++++++++--- 2 files changed, 39 insertions(+), 3 deletions(-) create mode 100644 nvim/lua/plugins/im-select.lua diff --git a/nvim/lua/plugins/im-select.lua b/nvim/lua/plugins/im-select.lua new file mode 100644 index 0000000..ee34e1f --- /dev/null +++ b/nvim/lua/plugins/im-select.lua @@ -0,0 +1,17 @@ +-- im-select.nvim — 자동 입력 소스 전환 (insert mode ↔ normal mode) +-- normal mode 진입 시 자동으로 영문 입력으로 전환하고, +-- insert mode 재진입 시 이전 입력 소스로 복원. +-- 한글, 일본어, 중국어 등 모든 입력 소스를 자동 감지하여 처리. +return { + "keaising/im-select.nvim", + event = "VeryLazy", + opts = { + -- macOS 기본 영문 입력 소스 (normal mode 에서 사용할 기본값) + default_im_select = "com.apple.keylayout.ABC", + -- im-select 바이너리 경로 (Homebrew 로 설치) + default_command = "/opt/homebrew/bin/im-select", + -- 모드 전환 시 자동으로 입력 소스 전환 활성화 + set_default_events = { "VimEnter", "FocusGained", "InsertLeave", "CmdlineLeave" }, + set_previous_events = { "InsertEnter" }, + }, +} diff --git a/nvim_setup.sh b/nvim_setup.sh index 61e03a6..9999e79 100644 --- a/nvim_setup.sh +++ b/nvim_setup.sh @@ -17,6 +17,7 @@ brew_install neovim brew_install ripgrep # Telescope live-grep brew_install fd # Telescope find files brew_install lazygit # LazyVim git UI 통합 +brew_install im-select # 입력 소스 자동 전환 (im-select.nvim) brew_install_cask font-jetbrains-mono-nerd-font # 아이콘 글리프 # ============================================ @@ -34,17 +35,19 @@ else fi # ============================================ -# avante.nvim plugin spec 배치 +# plugin spec 배치 (avante.nvim, im-select.nvim) # - git 체크아웃이면 저장소 파일 사용, 다운로드 모드면 raw GitHub 에서 curl # (PR CI 에서 아직 master 에 없는 파일을 404 로 받는 문제 방지) # ============================================ +mkdir -p "$NVIM_CONFIG/lua/plugins" + +# avante.nvim AVANTE_DEST="$NVIM_CONFIG/lua/plugins/avante.lua" AVANTE_SRC="$NVIM_SCRIPT_DIR/nvim/lua/plugins/avante.lua" if [[ -f "$AVANTE_DEST" ]]; then # 로컬에서 프로바이더(예: 사내 게이트웨이)를 직접 설정해 둘 수 있으므로 덮어쓰지 않음 echo " ↳ avante.lua 이미 존재 — 배치 스킵 (로컬 설정 보존)" else - mkdir -p "$(dirname "$AVANTE_DEST")" if [[ -f "$AVANTE_SRC" ]]; then cp "$AVANTE_SRC" "$AVANTE_DEST" echo " ↳ avante.lua 배치 (로컬)" @@ -54,6 +57,22 @@ else fi fi -echo "✅ Neovim + LazyVim + avante ready" +# im-select.nvim +IMSELECT_DEST="$NVIM_CONFIG/lua/plugins/im-select.lua" +IMSELECT_SRC="$NVIM_SCRIPT_DIR/nvim/lua/plugins/im-select.lua" +if [[ -f "$IMSELECT_DEST" ]]; then + echo " ↳ im-select.lua 이미 존재 — 배치 스킵 (로컬 설정 보존)" +else + if [[ -f "$IMSELECT_SRC" ]]; then + cp "$IMSELECT_SRC" "$IMSELECT_DEST" + echo " ↳ im-select.lua 배치 (로컬)" + else + curl -fsSL https://raw.githubusercontent.com/Clsan/setup/master/nvim/lua/plugins/im-select.lua -o "$IMSELECT_DEST" + echo " ↳ im-select.lua 배치 (curl)" + fi +fi + +echo "✅ Neovim + LazyVim + avante + im-select ready" echo " ↳ 첫 nvim 실행 시 LazyVim 이 플러그인을 자동 설치합니다 (avante 빌드 포함)" echo " ↳ avante 프로바이더/API 키는 미설정 — $AVANTE_DEST 참고" +echo " ↳ im-select: normal mode 진입 시 자동으로 영문 입력으로 전환" From d89db6cb0434db240ff2540c41134a0785594c32 Mon Sep 17 00:00:00 2001 From: Clsan Date: Thu, 18 Jun 2026 10:41:26 +0900 Subject: [PATCH 2/4] fix: use custom tap for im-select installation im-select is not available in the main Homebrew repository. It requires tapping daipeihust/tap first. Changes: - Replace direct brew_install with explicit tap + trust + install sequence - Add idempotency check with command -v im-select - Handle trust requirement for third-party tap Verified idempotent: running the script multiple times shows "im-select already installed" without attempting reinstallation. Co-Authored-By: Claude Sonnet 4.5 --- nvim_setup.sh | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/nvim_setup.sh b/nvim_setup.sh index 9999e79..0aca7cc 100644 --- a/nvim_setup.sh +++ b/nvim_setup.sh @@ -17,9 +17,18 @@ brew_install neovim brew_install ripgrep # Telescope live-grep brew_install fd # Telescope find files brew_install lazygit # LazyVim git UI 통합 -brew_install im-select # 입력 소스 자동 전환 (im-select.nvim) brew_install_cask font-jetbrains-mono-nerd-font # 아이콘 글리프 +# im-select (입력 소스 자동 전환) +if ! command -v im-select &>/dev/null; then + echo " ↳ Installing im-select..." + brew tap daipeihust/tap + brew trust daipeihust/tap 2>/dev/null || true + brew install im-select +else + echo " ↳ im-select already installed" +fi + # ============================================ # LazyVim 부트스트랩 # - ~/.config/nvim 이 비어있을 때만 starter 클론 (기존 설정 보존) From b37a272341a24786ed6a9444deeb80c3cea3e78f Mon Sep 17 00:00:00 2001 From: Clsan Date: Thu, 18 Jun 2026 10:45:01 +0900 Subject: [PATCH 3/4] refactor: add brew_tap_and_install helper function Extract the tap + trust + install pattern into a reusable helper function in common.sh, similar to brew_install and brew_install_cask. Changes: - Add brew_tap_and_install(tap, formula) helper to common.sh - Simplify nvim_setup.sh to use one-line brew_tap_and_install call - Maintain idempotency with command -v check inside the helper This makes it easier to install formulae from third-party taps in the future. Co-Authored-By: Claude Sonnet 4.5 --- common.sh | 15 +++++++++++++++ nvim_setup.sh | 11 +---------- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/common.sh b/common.sh index 16ea256..38bf8fa 100644 --- a/common.sh +++ b/common.sh @@ -69,6 +69,21 @@ brew_install_cask() { } } +brew_tap_and_install() { + local tap="$1" + local formula="$2" + + if command -v "$formula" &>/dev/null; then + echo " ↳ $formula already installed" + return 0 + fi + + echo " ↳ Installing $formula from $tap..." + brew tap "$tap" + brew trust "$tap" 2>/dev/null || true + brew install "$formula" +} + # 다운받아 실행한 .sh 파일들을 끝나면 정리 # git 체크아웃에서 돌릴 때는 작업 트리를 건드리면 안 되므로 스킵 cleanup_downloads() { diff --git a/nvim_setup.sh b/nvim_setup.sh index 0aca7cc..cf23711 100644 --- a/nvim_setup.sh +++ b/nvim_setup.sh @@ -17,18 +17,9 @@ brew_install neovim brew_install ripgrep # Telescope live-grep brew_install fd # Telescope find files brew_install lazygit # LazyVim git UI 통합 +brew_tap_and_install daipeihust/tap im-select # 입력 소스 자동 전환 (im-select.nvim) brew_install_cask font-jetbrains-mono-nerd-font # 아이콘 글리프 -# im-select (입력 소스 자동 전환) -if ! command -v im-select &>/dev/null; then - echo " ↳ Installing im-select..." - brew tap daipeihust/tap - brew trust daipeihust/tap 2>/dev/null || true - brew install im-select -else - echo " ↳ im-select already installed" -fi - # ============================================ # LazyVim 부트스트랩 # - ~/.config/nvim 이 비어있을 때만 starter 클론 (기존 설정 보존) From c7baed4eb658919333cb3031cc51d7e0dfb1cbc8 Mon Sep 17 00:00:00 2001 From: Clsan Date: Thu, 18 Jun 2026 11:47:42 +0900 Subject: [PATCH 4/4] fix: fix im-select terminal compatibility and add double-Esc keymap MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Simplify im-select events: remove FocusGained/VimEnter (caused timing issues with snacks terminal double-Esc), remove set_previous_events - Add TermLeave to set_default_events so IM switches to ABC when leaving any terminal buffer (raw :terminal or snacks terminal) - Add idempotent keymaps.lua setup in nvim_setup.sh: appends double-Esc → keymap for raw :terminal buffers via append_line_if_missing Co-Authored-By: Claude Sonnet 4.6 --- nvim/lua/plugins/im-select.lua | 12 +++--------- nvim_setup.sh | 5 +++++ 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/nvim/lua/plugins/im-select.lua b/nvim/lua/plugins/im-select.lua index ee34e1f..97ce546 100644 --- a/nvim/lua/plugins/im-select.lua +++ b/nvim/lua/plugins/im-select.lua @@ -1,17 +1,11 @@ --- im-select.nvim — 자동 입력 소스 전환 (insert mode ↔ normal mode) --- normal mode 진입 시 자동으로 영문 입력으로 전환하고, --- insert mode 재진입 시 이전 입력 소스로 복원. --- 한글, 일본어, 중국어 등 모든 입력 소스를 자동 감지하여 처리. +-- im-select.nvim — normal mode 진입 시 자동으로 영문 입력으로 전환 return { "keaising/im-select.nvim", event = "VeryLazy", opts = { - -- macOS 기본 영문 입력 소스 (normal mode 에서 사용할 기본값) default_im_select = "com.apple.keylayout.ABC", - -- im-select 바이너리 경로 (Homebrew 로 설치) default_command = "/opt/homebrew/bin/im-select", - -- 모드 전환 시 자동으로 입력 소스 전환 활성화 - set_default_events = { "VimEnter", "FocusGained", "InsertLeave", "CmdlineLeave" }, - set_previous_events = { "InsertEnter" }, + set_default_events = { "InsertLeave", "CmdlineLeave", "TermLeave" }, + set_previous_events = {}, }, } diff --git a/nvim_setup.sh b/nvim_setup.sh index cf23711..ff7f067 100644 --- a/nvim_setup.sh +++ b/nvim_setup.sh @@ -72,6 +72,11 @@ else fi fi +# keymaps.lua — terminal mode 에서 Esc Esc 로 normal 모드로 이동 +KEYMAPS_DEST="$NVIM_CONFIG/lua/config/keymaps.lua" +append_line_if_missing "$KEYMAPS_DEST" 'vim.keymap.set("t", "", "", { desc = "Exit terminal mode" })' +echo " ↳ keymaps.lua terminal keymap 확인/추가" + echo "✅ Neovim + LazyVim + avante + im-select ready" echo " ↳ 첫 nvim 실행 시 LazyVim 이 플러그인을 자동 설치합니다 (avante 빌드 포함)" echo " ↳ avante 프로바이더/API 키는 미설정 — $AVANTE_DEST 참고"