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
54 changes: 51 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,58 @@ require('tabi').setup({
border = 'rounded',
},
},
keymaps = {
enabled = true, -- Set to false to disable all default keymaps
start = '<Leader>ts',
['end'] = '<Leader>te',
note = '<Leader>tn',
note_delete = '<Leader>td',
retrace = '<Leader>tr',
retrace_end = '<Leader>tq',
sessions = '<Leader>tl',
},
})
```

### Customizing Keymaps

You can override individual keymaps or disable them by setting to `false`:

```lua
require('tabi').setup({
keymaps = {
note = '<Leader>an', -- Custom key for note
next = ']n', -- Custom key for next
prev = '[n', -- Custom key for prev
start = false, -- Disable start keymap
},
})
```

To disable all default keymaps:

```lua
require('tabi').setup({
keymaps = {
enabled = false,
},
})
```

## Default Keymaps

| Key | Mode | Command | Description |
|-----|------|---------|-------------|
| `<Leader>ts` | Normal | `:Tabi start` | Start a new session |
| `<Leader>te` | Normal | `:Tabi end` | End the current session |
| `<Leader>tn` | Normal/Visual | `:Tabi note` | Add/edit note at current line |
| `<Leader>td` | Normal | `:Tabi note delete` | Delete note at current line |
| `<Leader>tr` | Normal | `:Tabi retrace` | Start retrace mode |
| `<Leader>tq` | Normal | `:Tabi retrace end` | Quit retrace mode |
| `<Leader>tl` | Normal | `:Tabi sessions` | List all sessions |

**Note**: In retrace mode, use Neovim's location list commands (`:lnext`, `:lprev`) to navigate between notes.

## Usage

### Basic Workflow
Expand Down Expand Up @@ -87,7 +136,7 @@ require('tabi').setup({
```vim
:Tabi retrace my-reading-session
```
- Navigate through notes with `:Tabi next` and `:Tabi prev`
- Navigate through notes with `:lnext` and `:lprev` (location list commands)
- Exit retrace mode with `:Tabi retrace end`

### Commands
Expand Down Expand Up @@ -115,8 +164,7 @@ require('tabi').setup({
| Command | Description |
|---------|-------------|
| `:Tabi retrace [name]` | Start replaying a session |
| `:Tabi next` | Go to next note in replay |
| `:Tabi prev` | Go to previous note in replay |
| `:lnext` / `:lprev` | Navigate through notes (location list) |
| `:Tabi retrace end` | Exit retrace mode |

### Anonymous Sessions
Expand Down
21 changes: 21 additions & 0 deletions lua/tabi/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,21 @@ local M = {}
---@class TabiOptions
---@field storage TabiStorageConfig
---@field ui TabiUIConfig
---@field keymaps TabiKeymapsConfig

---@class TabiStorageConfig
---@field backend 'local'|'global'

---@class TabiKeymapsConfig
---@field enabled boolean
---@field start string|false
---@field ["end"] string|false
---@field note string|false
---@field note_delete string|false
---@field retrace string|false
---@field retrace_end string|false
---@field sessions string|false

---@class TabiUIConfig
---@field selector 'native'|'telescope'|'float'
---@field note_preview_length number
Expand Down Expand Up @@ -43,6 +54,16 @@ M.defaults = {
layout_config = {},
},
},
keymaps = {
enabled = true,
start = "<Leader>ts",
["end"] = "<Leader>te",
note = "<Leader>tn",
note_delete = "<Leader>td",
retrace = "<Leader>tr",
retrace_end = "<Leader>tq",
sessions = "<Leader>tl",
},
}

--- Current configuration
Expand Down
4 changes: 4 additions & 0 deletions lua/tabi/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ function M.setup(opts)

-- Setup autocommands and highlights
M._setup_highlights()

-- Setup keymaps
local keymaps = require("tabi.keymaps")
keymaps.setup()
end

--- Setup highlight groups
Expand Down
104 changes: 104 additions & 0 deletions lua/tabi/keymaps.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
---@class TabiKeymaps
local M = {}

--- Setup keymaps based on configuration
function M.setup()
local config = require("tabi.config").get()
local keymaps = config.keymaps

if not keymaps.enabled then
return
end

local opts = { silent = true }

-- Session management
if keymaps.start then
vim.keymap.set(
"n",
keymaps.start,
"<Cmd>Tabi start<CR>",
vim.tbl_extend("force", opts, {
desc = "Tabi: Start session",
})
)
end

if keymaps["end"] then
vim.keymap.set(
"n",
keymaps["end"],
"<Cmd>Tabi end<CR>",
vim.tbl_extend("force", opts, {
desc = "Tabi: End session",
})
)
end

if keymaps.sessions then
vim.keymap.set(
"n",
keymaps.sessions,
"<Cmd>Tabi sessions<CR>",
vim.tbl_extend("force", opts, {
desc = "Tabi: List sessions",
})
)
end

-- Note operations
if keymaps.note then
vim.keymap.set(
"n",
keymaps.note,
"<Cmd>Tabi note<CR>",
vim.tbl_extend("force", opts, {
desc = "Tabi: Add/edit note",
})
)
vim.keymap.set(
"v",
keymaps.note,
":Tabi note<CR>",
vim.tbl_extend("force", opts, {
desc = "Tabi: Add note for selection",
})
)
end

if keymaps.note_delete then
vim.keymap.set(
"n",
keymaps.note_delete,
"<Cmd>Tabi note delete<CR>",
vim.tbl_extend("force", opts, {
desc = "Tabi: Delete note",
})
)
end

-- Retrace mode
if keymaps.retrace then
vim.keymap.set(
"n",
keymaps.retrace,
"<Cmd>Tabi retrace<CR>",
vim.tbl_extend("force", opts, {
desc = "Tabi: Start retrace",
})
)
end

if keymaps.retrace_end then
vim.keymap.set(
"n",
keymaps.retrace_end,
"<Cmd>Tabi retrace end<CR>",
vim.tbl_extend("force", opts, {
desc = "Tabi: Quit retrace",
})
)
end
end

return M
6 changes: 3 additions & 3 deletions lua/tabi/retrace.lua
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ function M.start(session)
state.loclist_bufwin = vim.api.nvim_get_current_win()

-- Jump to first note (this will focus the location list)
M.show_current(true) -- silent=true to avoid double notification
M.show_current(true)

vim.notify(string.format("Tabi: Retrace mode started - Note 1/%d", #session.notes), vim.log.levels.INFO)
return true
Expand Down Expand Up @@ -121,7 +121,7 @@ function M.next()
end

state.current_index = state.current_index + 1
M.show_current()
M.show_current(true)
end

--- Go to previous note
Expand All @@ -137,7 +137,7 @@ function M.prev()
end

state.current_index = state.current_index - 1
M.show_current()
M.show_current(true)
end

--- Check if in retrace mode
Expand Down