diff options
Diffstat (limited to 'main.go')
-rw-r--r-- | main.go | 35 |
1 files changed, 27 insertions, 8 deletions
@@ -11,7 +11,7 @@ import ( "sync" "time" - "git.sr.ht/~rjarry/go-opt" + "git.sr.ht/~rjarry/go-opt/v2" "git.sr.ht/~rjarry/aerc/app" "git.sr.ht/~rjarry/aerc/commands" @@ -21,6 +21,7 @@ import ( "git.sr.ht/~rjarry/aerc/lib/hooks" "git.sr.ht/~rjarry/aerc/lib/ipc" "git.sr.ht/~rjarry/aerc/lib/log" + "git.sr.ht/~rjarry/aerc/lib/pinentry" "git.sr.ht/~rjarry/aerc/lib/templates" "git.sr.ht/~rjarry/aerc/lib/ui" "git.sr.ht/~rjarry/aerc/models" @@ -49,24 +50,38 @@ func execCommand( return err } -func getCompletions(cmdline string) ([]string, string) { +func getCompletions(ctx context.Context, cmdline string) ([]opt.Completion, string) { // complete template terms if options, prefix, ok := commands.GetTemplateCompletion(cmdline); ok { sort.Strings(options) - return options, prefix + completions := make([]opt.Completion, 0, len(options)) + for _, o := range options { + completions = append(completions, opt.Completion{ + Value: o, + Description: "Template", + }) + } + return completions, prefix } args := opt.LexArgs(cmdline) if args.Count() < 2 && args.TrailingSpace() == "" { // complete command names - var completions []string - for _, name := range commands.ActiveCommandNames() { - if strings.HasPrefix(name, cmdline) { - completions = append(completions, name+" ") + var completions []opt.Completion + for _, cmd := range commands.ActiveCommands() { + for _, alias := range cmd.Aliases() { + if strings.HasPrefix(alias, cmdline) { + completions = append(completions, opt.Completion{ + Value: alias + " ", + Description: cmd.Description(), + }) + } } } - sort.Strings(completions) + sort.Slice(completions, func(i, j int) bool { + return completions[i].Value < completions[j].Value + }) return completions, "" } @@ -221,6 +236,10 @@ func main() { } close(deferLoop) + config.EnablePinentry = pinentry.Enable + config.DisablePinentry = pinentry.Disable + config.SetPinentryEnv = pinentry.SetCmdEnv + startup, startupDone := context.WithCancel(context.Background()) if !noIPC { |