Skip to content
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
8 changes: 8 additions & 0 deletions cmd/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,14 @@ var initCmd = &cobra.Command{
return
}

diaryDir := filepath.Join(home, config.AppConfig.General.NotesDir, ".diary")

err = os.MkdirAll(diaryDir, 0o755)
if err != nil {
fmt.Println("Could not create .diary directory", err.Error())
return
}

err = os.MkdirAll(home+"/.config/toney", 0o755)
if err != nil {
fmt.Println("Could not create config directory", err.Error())
Expand Down
4 changes: 3 additions & 1 deletion docs/docs/.vitepress/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default defineConfig({
['link', { rel: 'icon', href: '/favicon.ico' }],
['meta', { name: 'theme-color', content: '#0f172a' }]
],
appearance: false,
appearance: 'force-dark',
base: '/Toney/',
themeConfig: {
outline: 'deep',
Expand Down Expand Up @@ -48,6 +48,8 @@ export default defineConfig({
{ text: 'Global', link: '/config/keybinds/global' },
{ text: 'Home', link: '/config/keybinds/home' },
{ text: 'Daily', link: '/config/keybinds/daily' },
{ text: 'Diary', link: '/config/keybinds/diary' },
{ text: 'Fuzzy Finder', link: '/config/keybinds/fuzz' },
]
}
]
Expand Down
40 changes: 40 additions & 0 deletions docs/docs/config/keybinds/diary.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Diary Keybinds

Denoted by the `[keybinds.diary]` tag in TOML.

## Edit File

can change the keybind for editing the file using the `edit` toml key.

default value is:
```toml
edit = "e"
```

## Finder

can change the keybind for opening the fuzzy finder using the `finder` toml key.

default value is:
```toml
finder = "f"
```

## Scroll Up

can change the keybind for scrolling up using the `scroll_up` toml key.

default value is:
```toml
scroll_up = "up"
```

## Scroll Down

can change the keybind for scrolling down using the `scroll_down` toml key.

default value is:
```toml
scroll_down = "down"
```

40 changes: 40 additions & 0 deletions docs/docs/config/keybinds/fuzz.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Fuzzy Finder Keybinds

Denoted by the `[keybinds.fuzz]` tag in TOML. Usable while in the fuzzy finder menu.

## Start Writing

can change the keybind for writing/searching using the `start_writing` toml key.

default value is:
```toml
start_writing = "/"
```

## Enter

can change the keybind for selecting the item using the `enter` toml key.

default value is:
```toml
enter = "enter"
```

## Up

can change the keybind for moving up using the `up` toml key.

default value is:
```toml
up = "up"
```

## Down

can change the keybind for moving down using the `down` toml key.

default value is:
```toml
down = "down"
```

1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ require (
github.com/go-viper/mapstructure/v2 v2.2.1 // indirect
github.com/gorilla/css v1.0.1 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/lithammer/fuzzysearch v1.1.8 // indirect
github.com/lucasb-eyer/go-colorful v1.2.0 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mattn/go-localereader v0.0.1 // indirect
Expand Down
33 changes: 33 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/lithammer/fuzzysearch v1.1.8 h1:/HIuJnjHuXS8bKaiTMeeDlW2/AyIWk2brx1V8LFgLN4=
github.com/lithammer/fuzzysearch v1.1.8/go.mod h1:IdqeyBClc3FFqSzYq/MXESsS4S0FsZ5ajtkr5xPLts4=
github.com/lucasb-eyer/go-colorful v1.2.0 h1:1nnpGOrhyZZuNyfu1QjKiUICQ74+3FNCN69Aj6K7nkY=
github.com/lucasb-eyer/go-colorful v1.2.0/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0=
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
Expand Down Expand Up @@ -125,6 +127,7 @@ github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8
github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU=
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e h1:JVG44RsyaB9T2KIHavMF/ppJZNG9ZpyihvCd0w101no=
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e/go.mod h1:RbqR21r5mrJuqunuUZ/Dhy/avygyECGrLceyNeo4LiM=
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
github.com/yuin/goldmark v1.7.1/go.mod h1:uzxRWxtg69N339t3louHJ7+O03ezfj6PlliRlaOzY1E=
github.com/yuin/goldmark v1.7.8 h1:iERMLn0/QJeHFhxSt3p6PeN9mGnvIKSpG9YYorDMnic=
github.com/yuin/goldmark v1.7.8/go.mod h1:uzxRWxtg69N339t3louHJ7+O03ezfj6PlliRlaOzY1E=
Expand All @@ -136,20 +139,50 @@ go.uber.org/atomic v1.9.0 h1:ECmE8Bn/WFTYwEW/bpKD3M8VtR/zQVbavAoalC1PYyE=
go.uber.org/atomic v1.9.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
go.uber.org/multierr v1.9.0 h1:7fIwc/ZtS0q++VgcfqFDxSBZVv/Xo49/SYnDFupUwlI=
go.uber.org/multierr v1.9.0/go.mod h1:X2jQV1h+kxSjClGpnseKVIxpmcjrj7MNnI0bnlfKTVQ=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/exp v0.0.0-20220909182711-5c715a9e8561 h1:MDc5xs78ZrZr3HMQugiXOAkSZtfTpbJLDr/lwfgO53E=
golang.org/x/exp v0.0.0-20220909182711-5c715a9e8561/go.mod h1:cyybsKvd6eL0RnXn6p/Grxp8F5bW7iYuBgsNCOHpMYE=
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
golang.org/x/net v0.33.0 h1:74SYHlV8BIgHIFC/LrYkOGIwL19eTYXQ5wc6TBuO36I=
golang.org/x/net v0.33.0/go.mod h1:HXLR5J+9DxmrqMwG9qjGCxZ+zKXxBru04zlTvWlWuN4=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.13.0 h1:AauUjRAJ9OSnvULf/ARrrVywoJDy0YS2AwQ98I37610=
golang.org/x/sync v0.13.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.32.0 h1:s77OFDvIQeibCmezSnk/q6iAfkdiQaJi4VzroCFrN20=
golang.org/x/sys v0.32.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
golang.org/x/term v0.31.0 h1:erwDkOK1Msy6offm1mOgvspSkslFnIGsFnxOKoufg3o=
golang.org/x/term v0.31.0/go.mod h1:R4BeIy7D95HzImkxGkTW1UQTtP54tio2RyHz7PwK0aw=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
golang.org/x/text v0.24.0 h1:dd5Bzh4yt5KYA8f9CJHCP4FB4D51c2c6JvN37xJJkJ0=
golang.org/x/text v0.24.0/go.mod h1:L8rBsPeo2pSS+xqN0d5u2ikmjtmoJbDBT1b7nHvFCdU=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo=
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
Expand Down
12 changes: 12 additions & 0 deletions internal/config/default.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,18 @@ func DefaultConfig() Config {
Up: "up",
Down: "down",
},
Fuzz: FuzzyKeybinds{
Up: "up",
Down: "down",
Enter: "enter",
StartWriting: "/",
},
Diary: DiaryKeybinds{
ScrollUp: "up",
ScrollDown: "down",
Edit: "e",
Finder: "f",
},
Home: HomeKeybinds{
FocusViewer: "V",
FocusExplorer: "F",
Expand Down
16 changes: 16 additions & 0 deletions internal/config/keybinds.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,22 @@ type KeybindsConfig struct {
Global GlobalKeybinds `mapstructure:"global"`
Home HomeKeybinds `mapstructure:"home"`
Daily DailyKeybinds `mapstructure:"daily"`
Fuzz FuzzyKeybinds `mapstructure:"fuzzy"` // TODO: Add to docs
Diary DiaryKeybinds `mapstructure:"diary"` // TODO: Add to docs
}

type FuzzyKeybinds struct {
StartWriting string `mapstructure:"start_writing"`
Up string `mapstructure:"up"`
Down string `mapstructure:"down"`
Enter string `mapstructure:"enter"`
}

type DiaryKeybinds struct {
Edit string `mapstructure:"edit"`
ScrollUp string `mapstructure:"scroll_up"`
ScrollDown string `mapstructure:"scroll_down"`
Finder string `mapstructure:"finder"`
}

type GlobalKeybinds struct {
Expand Down
2 changes: 1 addition & 1 deletion internal/enums/page.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ const (
MenuPage = iota
HomePage
DailyPage
JournalPage
DiaryPage
Quit
)
51 changes: 51 additions & 0 deletions internal/keymap/diaryMap.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package keymap

import (
"reflect"

"github.com/SourcewareLab/Toney/internal/config"
"github.com/charmbracelet/bubbles/key"
)

type DiaryMap struct {
Edit key.Binding
ScrollUp key.Binding
ScrollDown key.Binding
OpenFinder key.Binding
}

func NewDiaryMap() DiaryMap {
cfg := config.AppConfig.Keybinds.Diary
return DiaryMap{
Edit: key.NewBinding(
key.WithKeys(cfg.Edit),
key.WithHelp(cfg.Edit, "edit"),
),
OpenFinder: key.NewBinding(
key.WithKeys(cfg.Finder),
key.WithHelp(cfg.Finder, "find"),
),
ScrollUp: key.NewBinding(
key.WithKeys(cfg.ScrollUp),
key.WithHelp(cfg.ScrollUp, "scroll up"),
),
ScrollDown: key.NewBinding(
key.WithKeys(cfg.ScrollDown),
key.WithHelp(cfg.ScrollDown, "scroll down"),
),
}
}

func (m DiaryMap) Bindings() []key.Binding {
var bindings []key.Binding

v := reflect.ValueOf(m)
for i := 0; i < v.NumField(); i++ {
field := v.Field(i)
if binding, ok := field.Interface().(key.Binding); ok {
bindings = append(bindings, binding)
}
}

return bindings
}
51 changes: 51 additions & 0 deletions internal/keymap/fuzzyMap.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package keymap

import (
"reflect"

"github.com/SourcewareLab/Toney/internal/config"
"github.com/charmbracelet/bubbles/key"
)

type FuzzyMap struct {
StartWriting key.Binding
Up key.Binding
Down key.Binding
Enter key.Binding
}

func NewFuzzyMap() FuzzyMap {
cfg := config.AppConfig.Keybinds.Fuzz
return FuzzyMap{
StartWriting: key.NewBinding(
key.WithKeys(cfg.StartWriting),
key.WithHelp(cfg.StartWriting, "start writing"),
),
Up: key.NewBinding(
key.WithKeys(cfg.Up),
key.WithHelp(cfg.Up, "up"),
),
Down: key.NewBinding(
key.WithKeys(cfg.Down),
key.WithHelp(cfg.Down, "down"),
),
Enter: key.NewBinding(
key.WithKeys(cfg.Enter),
key.WithHelp(cfg.Enter, "enter"),
),
}
}

func (m FuzzyMap) Bindings() []key.Binding {
var bindings []key.Binding

v := reflect.ValueOf(m)
for i := 0; i < v.NumField(); i++ {
field := v.Field(i)
if binding, ok := field.Interface().(key.Binding); ok {
bindings = append(bindings, binding)
}
}

return bindings
}
4 changes: 4 additions & 0 deletions internal/messages/messages.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ import (
)

type (
FzfSelection struct {
Selection string
}

TaskPopupMessage struct {
Type enums.TaskPopup
IsDeleted bool
Expand Down
Loading