Only init CopilotChat if installed
dblume

dblume commited on 2025-04-19 16:37:59
Showing 1 changed files, with 7 additions and 2 deletions.


Walk the nvim_list_runtime_paths() and check if
"copilotchat" is in one of them.
... ...
@@ -483,14 +483,19 @@ lua << EOF
483 483
     },
484 484
   }
485 485
 
486
+  for _, str in ipairs(vim.api.nvim_list_runtime_paths()) do
487
+    if str:find("copilotchat") then
486 488
       -- https://github.com/CopilotC-Nvim/CopilotChat.nvim
487 489
       require("CopilotChat").setup({
488
-    question_header = "# 👤 ",
489
-    answer_header = "# 🤖 ",
490
+        question_header = "# ?? ",
491
+        answer_header = "# ?? ",
490 492
       })
491 493
 
492 494
       -- Both Copilot and CopilotChat are installed and both remap "<Tab>". Make <S-Tab> work for CopilotChat.
493 495
       -- https://github.com/CopilotC-Nvim/CopilotChat.nvim/issues/1062
494 496
       vim.keymap.set('i', '<S-Tab>', 'copilot#Accept("\\<S-Tab>")', { expr = true, replace_keycodes = false })
497
+      break
498
+    end
499
+  end
495 500
 
496 501
 EOF
497 502