Skip to content

Commit 602745c

Browse files
authored
feat!: remove sorting/timestamps, add mark reordering, fix deletion bug (#4)
BREAKING CHANGES: - Remove sort_marks config option and all timestamp functionality - Remove validation features from UI and API - Marks now maintain insertion order by default - Add J/K keys for moving marks up/down in UI - Fix deletion not immediately refreshing in marks window - Preserve mark order with new mark_order array in storage Fixes #2 Resolves #3
1 parent 25bb342 commit 602745c

File tree

5 files changed

+165
-200
lines changed

5 files changed

+165
-200
lines changed

README.md

Lines changed: 6 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ Vim's built-in marks are great, but they're global and get messy fast. Marksman
1717
- **Project-scoped marks** - Each project gets its own isolated set of bookmarks
1818
- **Persistent storage** - Your marks survive Neovim restarts with automatic backup
1919
- **Smart naming** - Context-aware auto-generation of mark names based on code structure
20-
- **Quick access** - Jump to your most recent marks with single keys
20+
- **Quick access** - Jump to your marks with single keys
2121
- **Enhanced search** - Find marks by name, file path, or content
22-
- **Validation** - Check and clean up marks pointing to non-existent files
2322
- **Interactive UI** - Browse and manage marks in an enhanced floating window
23+
- **Reordering** - Move marks up and down to organize them as needed
2424
- **Multiple integrations** - Works with Telescope, Snacks.nvim, and more
2525

2626
## Requirements
@@ -55,7 +55,6 @@ Vim's built-in marks are great, but they're global and get messy fast. Marksman
5555
auto_save = true,
5656
max_marks = 100,
5757
search_in_ui = true,
58-
sort_marks = true,
5958
silent = false,
6059
minimal = false,
6160
},
@@ -120,13 +119,13 @@ require("marksman").setup({
120119

121120
1. **Add a mark**: Press `<C-a>` (or your custom key)
122121
2. **See your marks**: Press `<C-e>` to open the marks window
123-
3. **Jump around**: Use `<M-y>`, `<M-u>`, etc. to jump to recent marks
122+
3. **Jump around**: Use `<M-y>`, `<M-u>`, etc. to jump to marks
124123
4. **In the marks window**:
125124
- Press Enter or 1-9 to jump
126125
- `d` to delete
127126
- `r` to rename
128127
- `/` to search
129-
- `v` to validate marks
128+
- `J`/`K` to move marks up/down
130129

131130
### Advanced Features
132131

@@ -157,7 +156,7 @@ The floating window includes:
157156
- **Real-time search** - Press `/` to filter marks instantly
158157
- **Enhanced navigation** - Better keyboard shortcuts and visual feedback
159158
- **File path display** - View relative file paths for better context
160-
- **Validation** - Press `v` to check mark integrity
159+
- **Mark reordering** - Press `J`/`K` to move marks up/down
161160

162161
## Telescope Integration
163162

@@ -193,15 +192,6 @@ local function telescope_marksman()
193192
})
194193
end
195194

196-
-- Sort by access time
197-
table.sort(entries, function(a, b)
198-
local mark_a = marks[a.value]
199-
local mark_b = marks[b.value]
200-
local time_a = mark_a.accessed_at or mark_a.created_at or 0
201-
local time_b = mark_b.accessed_at or mark_b.created_at or 0
202-
return time_a > time_b
203-
end)
204-
205195
pickers.new({}, {
206196
prompt_title = "Project Marks",
207197
finder = finders.new_table({
@@ -260,15 +250,6 @@ function M.snacks_marksman()
260250
table.insert(results, entry)
261251
end
262252

263-
-- Sort by access time
264-
table.sort(results, function(a, b)
265-
local mark_a = marks[a.mark_name]
266-
local mark_b = marks[b.mark_name]
267-
local time_a = mark_a.accessed_at or mark_a.created_at or 0
268-
local time_b = mark_b.accessed_at or mark_b.created_at or 0
269-
return time_a > time_b
270-
end)
271-
272253
return results
273254
end
274255
```
@@ -303,7 +284,6 @@ marksman.import_marks()
303284
```lua
304285
local storage = require("marksman.storage")
305286

306-
storage.validate_marks() -- Check mark integrity
307287
storage.get_project_name() -- Get current project name
308288
```
309289

@@ -315,30 +295,10 @@ storage.get_project_name() -- Get current project name
315295
| `auto_save` | boolean | `true` | Automatically save marks |
316296
| `max_marks` | number | `100` | Maximum marks per project |
317297
| `search_in_ui` | boolean | `true` | Enable search in UI |
318-
| `sort_marks` | boolean | `true` | Sort marks by access time (false = insertion order) |
319298
| `minimal` | boolean | `false` | Set to true for clean UI (only order and filepath)|
320299
| `silent` | boolean | `false` | Set to true to supress notifications|
321300
| `highlights` | table | `{...}` | Custom highlight groups |
322301

323-
### Sorting Behavior
324-
By default (`sort_marks = true`), marks are sorted by:
325-
1. **Access time** (when you last jumped to the mark)
326-
2. **Creation time** (when the mark was created)
327-
328-
This means recently used marks appear first, making them easier to access.
329-
330-
When `sort_marks = false`:
331-
- Marks maintain their **insertion order** (oldest marks first)
332-
- Quick access keys (`goto_1`, `goto_2`, etc.) will jump to marks in the order they were created
333-
- Useful if you prefer predictable, stable ordering
334-
335-
```lua
336-
-- Example: Disable sorting to keep insertion order
337-
require("marksman").setup({
338-
sort_marks = false, -- Marks stay in creation order
339-
})
340-
```
341-
342302
## How it works
343303

344304
### Storage
@@ -366,7 +326,7 @@ The search function looks through:
366326
- Code context (the line content)
367327

368328
### File Path Display
369-
The UI now shows relative file paths instead of just filenames, making it easier to distinguish between files with the same name in different directories.
329+
The UI shows relative file paths instead of just filenames, making it easier to distinguish between files with the same name in different directories.
370330

371331
## Performance
372332

lua/marksman/init.lua

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,8 @@ local default_config = {
3030
auto_save = true,
3131
max_marks = 100,
3232
search_in_ui = true,
33-
sort_marks = true,
3433
silent = false,
35-
minimal = false, -- Set to true for clean UI (only order and filename)
34+
minimal = false,
3635
}
3736

3837
local config = {}
@@ -96,8 +95,6 @@ function M.add_mark(name, description)
9695
line = line,
9796
col = col,
9897
text = vim.fn.getline("."):sub(1, 80),
99-
created_at = os.time(),
100-
accessed_at = os.time(),
10198
}
10299

103100
local success = storage_module.add_mark(name, mark)
@@ -118,7 +115,7 @@ function M.goto_mark(name_or_index)
118115
local mark_name = name_or_index
119116

120117
if type(name_or_index) == "number" then
121-
local mark_names = storage_module.get_sorted_mark_names()
118+
local mark_names = storage_module.get_mark_names()
122119
if name_or_index > 0 and name_or_index <= #mark_names then
123120
mark_name = mark_names[name_or_index]
124121
mark = marks[mark_name]
@@ -133,9 +130,6 @@ function M.goto_mark(name_or_index)
133130
return false
134131
end
135132

136-
-- Update access time
137-
storage_module.update_mark_access(mark_name)
138-
139133
vim.cmd("edit " .. vim.fn.fnameescape(mark.file))
140134
vim.fn.cursor(mark.line, mark.col)
141135
vim.cmd("normal! zz") -- Center the line
@@ -173,6 +167,19 @@ function M.rename_mark(old_name, new_name)
173167
end
174168
end
175169

170+
function M.move_mark(name, direction)
171+
local storage_module = get_storage()
172+
local success = storage_module.move_mark(name, direction)
173+
174+
if success then
175+
notify("󰃀 Mark moved " .. direction, vim.log.levels.INFO)
176+
return true
177+
else
178+
notify("Cannot move mark " .. direction, vim.log.levels.WARN)
179+
return false
180+
end
181+
end
182+
176183
function M.show_marks()
177184
local storage_module = get_storage()
178185
local ui_module = get_ui()

0 commit comments

Comments
 (0)