Skip to content

Commit

Permalink
fix: documentation for sorter and callback function
Browse files Browse the repository at this point in the history
  • Loading branch information
desdic committed Feb 18, 2024
1 parent d550b93 commit 6bd7ae4
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 20 deletions.
22 changes: 14 additions & 8 deletions doc/marlin.txt
Original file line number Diff line number Diff line change
Expand Up @@ -208,30 +208,36 @@ Usage ~

==============================================================================
------------------------------------------------------------------------------
*M.change_buffer()*
`M.change_buffer`({bufnr}, {_})
Marlin callbacks

------------------------------------------------------------------------------
*callbacks.change_buffer()*
`callbacks.change_buffer`({bufnr}, {_})
Parameters ~
{bufnr} `(number)` buffer id

------------------------------------------------------------------------------
*M.use_split()*
`M.use_split`({bufnr}, {_})
*callbacks.use_split()*
`callbacks.use_split`({bufnr}, {_})
Parameters ~
{bufnr} `(number)` buffer id


==============================================================================
------------------------------------------------------------------------------
*M.by_buffer()*
`M.by_buffer`({filelist})
Marlin sorters

------------------------------------------------------------------------------
*sorters.by_buffer()*
`sorters.by_buffer`({filelist})
Sort indexes by open buffers (Same order like bufferline shows them)

Parameters ~
{filelist} marlin.file[]

------------------------------------------------------------------------------
*M.by_name()*
`M.by_name`({filelist})
*sorters.by_name()*
`sorters.by_name`({filelist})
Sort indexes by path + filename

Parameters ~
Expand Down
8 changes: 4 additions & 4 deletions doc/tags
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
M.by_buffer() marlin.txt /*M.by_buffer()*
M.by_name() marlin.txt /*M.by_name()*
M.change_buffer() marlin.txt /*M.change_buffer()*
M.use_split() marlin.txt /*M.use_split()*
callbacks.change_buffer() marlin.txt /*callbacks.change_buffer()*
callbacks.use_split() marlin.txt /*callbacks.use_split()*
default marlin.txt /*default*
marlin marlin.txt /*marlin*
marlin.add() marlin.txt /*marlin.add()*
Expand All @@ -17,3 +15,5 @@ marlin.remove() marlin.txt /*marlin.remove()*
marlin.remove_all() marlin.txt /*marlin.remove_all()*
marlin.setup() marlin.txt /*marlin.setup()*
marlin.sort() marlin.txt /*marlin.sort()*
sorters.by_buffer() marlin.txt /*sorters.by_buffer()*
sorters.by_name() marlin.txt /*sorters.by_name()*
11 changes: 7 additions & 4 deletions lua/marlin/callbacks.lua
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
local M = {}
--- Marlin callbacks

-- Module definition ==========================================================
local callbacks = {}

---@param bufnr number buffer id
M.change_buffer = function(bufnr, _)
callbacks.change_buffer = function(bufnr, _)
vim.api.nvim_set_current_buf(bufnr)
end

---@param bufnr number buffer id
M.use_split = function(bufnr, _)
callbacks.use_split = function(bufnr, _)
local wins = vim.api.nvim_tabpage_list_wins(0)
for _, win in ipairs(wins) do
local winbufnr = vim.api.nvim_win_get_buf(win)
Expand All @@ -20,4 +23,4 @@ M.use_split = function(bufnr, _)
vim.api.nvim_set_current_buf(bufnr)
end

return M
return callbacks
11 changes: 7 additions & 4 deletions lua/marlin/sorters.lua
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
local M = {}
--- Marlin sorters

-- Module definition ==========================================================
local sorters = {}

local utils = require("marlin.utils")

--- Sort indexes by open buffers (Same order like bufferline shows them)
---
---@param filelist marlin.file[]
M.by_buffer = function(filelist)
sorters.by_buffer = function(filelist)
local index = 1
for _, bufnr in ipairs(vim.api.nvim_list_bufs()) do
if vim.fn.getbufinfo(bufnr)[1].listed == 1 then
Expand All @@ -27,10 +30,10 @@ end
--- Sort indexes by path + filename
---
---@param filelist marlin.file[]
M.by_name = function(filelist)
sorters.by_name = function(filelist)
table.sort(filelist, function(a, b)
return a.filename > b.filename
end)
end

return M
return sorters

0 comments on commit 6bd7ae4

Please sign in to comment.