mirror of
https://github.com/aljazceru/opencode.git
synced 2025-12-21 01:34:22 +01:00
wip: vscode extension
This commit is contained in:
@@ -11,6 +11,7 @@ import (
|
||||
"github.com/sst/opencode/internal/commands"
|
||||
"github.com/sst/opencode/internal/styles"
|
||||
"github.com/sst/opencode/internal/theme"
|
||||
"github.com/sst/opencode/internal/util"
|
||||
)
|
||||
|
||||
type CommandsComponent interface {
|
||||
@@ -24,6 +25,7 @@ type commandsComponent struct {
|
||||
width, height int
|
||||
showKeybinds bool
|
||||
showAll bool
|
||||
showVscode bool
|
||||
background *compat.AdaptiveColor
|
||||
limit *int
|
||||
}
|
||||
@@ -73,6 +75,30 @@ func (c *commandsComponent) View() string {
|
||||
commandsToShow = commandsToShow[:*c.limit]
|
||||
}
|
||||
|
||||
if c.showVscode {
|
||||
commandsToShow = append(commandsToShow,
|
||||
// empty line
|
||||
commands.Command{
|
||||
Name: "",
|
||||
Description: "",
|
||||
},
|
||||
commands.Command{
|
||||
Name: commands.CommandName(util.Ide()),
|
||||
Description: "open opencode",
|
||||
Keybindings: []commands.Keybinding{
|
||||
{Key: "cmd+esc", RequiresLeader: false},
|
||||
},
|
||||
},
|
||||
commands.Command{
|
||||
Name: commands.CommandName(util.Ide()),
|
||||
Description: "reference file",
|
||||
Keybindings: []commands.Keybinding{
|
||||
{Key: "cmd+opt+k", RequiresLeader: false},
|
||||
},
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
if len(commandsToShow) == 0 {
|
||||
muted := styles.NewStyle().Foreground(theme.CurrentTheme().TextMuted())
|
||||
if c.showAll {
|
||||
@@ -196,6 +222,12 @@ func WithShowAll(showAll bool) Option {
|
||||
}
|
||||
}
|
||||
|
||||
func WithVscode(showVscode bool) Option {
|
||||
return func(c *commandsComponent) {
|
||||
c.showVscode = showVscode
|
||||
}
|
||||
}
|
||||
|
||||
func New(app *app.App, opts ...Option) CommandsComponent {
|
||||
c := &commandsComponent{
|
||||
app: app,
|
||||
|
||||
Reference in New Issue
Block a user