Skip to content

feat: add auto terminal provider detection #36

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ See [DEVELOPMENT.md](./DEVELOPMENT.md) for build instructions and development gu
terminal = {
split_side = "right",
split_width_percentage = 0.3,
provider = "snacks", -- or "native"
provider = "auto", -- "auto" (default), "snacks", or "native"
auto_close = true, -- Auto-close terminal after command completion
},

Expand Down
2 changes: 1 addition & 1 deletion lua/claudecode/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ M.state = {
---@alias ClaudeCode.TerminalOpts { \
--- split_side?: "left"|"right", \
--- split_width_percentage?: number, \
--- provider?: "snacks"|"native", \
--- provider?: "auto"|"snacks"|"native", \
--- show_native_term_exit_tip?: boolean }
---
---@alias ClaudeCode.SetupOpts { \
Expand Down
12 changes: 10 additions & 2 deletions lua/claudecode/terminal.lua
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ local claudecode_server_module = require("claudecode.server.init")
local config = {
split_side = "right",
split_width_percentage = 0.30,
provider = "snacks",
provider = "auto",
show_native_term_exit_tip = true,
terminal_cmd = nil,
auto_close = true,
Expand Down Expand Up @@ -48,7 +48,15 @@ end
local function get_provider()
local logger = require("claudecode.logger")

if config.provider == "snacks" then
if config.provider == "auto" then
-- Try snacks first, then fallback to native silently
local snacks_provider = load_provider("snacks")
if snacks_provider and snacks_provider.is_available() then
logger.debug("terminal", "Auto-detected snacks terminal provider")
return snacks_provider
end
-- Fall through to native provider
elseif config.provider == "snacks" then
local snacks_provider = load_provider("snacks")
if snacks_provider and snacks_provider.is_available() then
return snacks_provider
Expand Down