Skip to content

Commit

Permalink
fix: Added event for better updates
Browse files Browse the repository at this point in the history
- Also added an example for telescope if anyone should need it
  • Loading branch information
desdic committed Feb 26, 2024
1 parent 8afdb1b commit d6bbd54
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 4 deletions.
46 changes: 46 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,52 @@ But they can also be change if you want to write your own sorter.

Choice is yours

### But there is no UI

Correct. I'm not planning on creating a UI but if you really want one you can easily create it.

Example using telescope

```lua
vim.keymap.set("n", "<Leader>fx", function()
local conf = require("telescope.config").values
local action_state = require("telescope.actions.state")
local results = require("marlin").get_indexes()

local index = 0
require("telescope.pickers")
.new({}, {
prompt_title = "Marlin",
finder = require("telescope.finders").new_table({
results = results,
entry_maker = function(entry)
index = index + 1
return {
value = entry,
ordinal = index ..":" .. entry.filename,
lnum = entry.row,
col = entry.col + 1,
filename = entry.filename,
display = index .. ":" .. entry.filename .. ":" .. entry.row .. ":" .. entry.col,
}
end,
}),
previewer = conf.grep_previewer({}),
sorter = conf.generic_sorter({}),
attach_mappings = function(_, map)
map("i", "d", function(bufnr)
local current_picker = action_state.get_current_picker(bufnr)
current_picker:delete_selection(function(selection)
require("marlin").remove(selection.filename)
end)
end)
return true
end,
})
:find()
end, { desc = "Telescope marlin" })
```

### Why yet another ..

When I first saw harpoon I was immediately hooked but I missed a few key features.
Expand Down
2 changes: 0 additions & 2 deletions TODO.md
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
# TODO

- Currently no GUI and there might not be one
4 changes: 2 additions & 2 deletions lua/marlin/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ local default = {

local get_cursor = function()
local cursor = vim.api.nvim_win_get_cursor(0)
return cursor[1] or 1, cursor[2] or 0
return cursor[1], cursor[2]
end

local save = function(m)
Expand Down Expand Up @@ -327,7 +327,7 @@ marlin.setup = function(opts)
end

local augroup = vim.api.nvim_create_augroup("marlin", {})
vim.api.nvim_create_autocmd({ "BufLeave", "VimLeavePre" }, {
vim.api.nvim_create_autocmd({ "CursorMoved", "BufLeave", "VimLeavePre" }, {
group = augroup,
pattern = "*",
callback = function(_)
Expand Down

0 comments on commit d6bbd54

Please sign in to comment.