~vigoux/azy.nvim-devel

This thread contains a patchset. You're looking at the original emails, but you may wish to use the patch review UI. Review patch
2 2

[PATCH azy.nvim] Add oldfiles source

Details
Message ID
<169715562594.20557.10697035867365383179-0@git.sr.ht>
DKIM signature
missing
Download raw message
Patch: +54 -0
From: Chinmay Dalal <dalal.chinmay.0101@gmail.com>

This commit adds an oldfiles source to quickly recent files
---
 lua/azy/builtins.lua |  8 ++++++++
 lua/azy/sinks.lua    |  6 ++++++
 lua/azy/sources.lua  |  8 ++++++++
 teal/azy/builtins.tl |  8 ++++++++
 teal/azy/sinks.tl    |  6 ++++++
 teal/azy/sources.tl  |  8 ++++++++
 types/types.d.tl     | 10 ++++++++++
 7 files changed, 54 insertions(+)

diff --git a/lua/azy/builtins.lua b/lua/azy/builtins.lua
index b058b64..9b56daf 100644
--- a/lua/azy/builtins.lua
+++ b/lua/azy/builtins.lua
@@ -55,6 +55,8 @@ local Builtins = {SelectOptions = {}, lsp = {}, }








@@ -95,6 +97,12 @@ function Builtins.help()
   end
end

function Builtins.oldfiles()
   return function()
      ui.create(sources.oldfiles(), sinks.oldfiles)
   end
end

function Builtins.buffers()
   return function()
      ui.create(sources.buffers(), sinks.open_file)
diff --git a/lua/azy/sinks.lua b/lua/azy/sinks.lua
index 87043af..4902416 100644
--- a/lua/azy/sinks.lua
+++ b/lua/azy/sinks.lua
@@ -15,6 +15,8 @@ local Sinks = {}





local function open(fname, options)
   if options.vsplit then
      vim.cmd.vsplit(fname)
@@ -39,6 +41,10 @@ function Sinks.help_tag(elem, options)
   end
end

function Sinks.oldfiles(elem, options)
   open(elem.search_text, options)
end

function Sinks.qf_item(elem, options)
   local item = elem.extra
   if item and (item.filename ~= nil or item.bufnr ~= nil) then
diff --git a/lua/azy/sources.lua b/lua/azy/sources.lua
index c8211ca..cbea101 100644
--- a/lua/azy/sources.lua
+++ b/lua/azy/sources.lua
@@ -37,6 +37,8 @@ local Sources = {FilesOptions = {}, }








@@ -228,6 +230,12 @@ function Sources.help()
   return ret
end

function Sources.oldfiles()
   return vim.iter.map(utils.path.shorten, vim.iter.filter(function(filename)
      return vim.fn.filewritable(filename) == 1
   end, vim.v.oldfiles))
end

function Sources.buffers()
   local bufs = vim.api.nvim_list_bufs()
   local ret = {}
diff --git a/teal/azy/builtins.tl b/teal/azy/builtins.tl
index 2f546d9..718b6d8 100644
--- a/teal/azy/builtins.tl
+++ b/teal/azy/builtins.tl
@@ -11,6 +11,8 @@ local record Builtins
  ---@param opts Options
  files: function({string}, sources.FilesOptions): function()

  oldfiles: function(): function()

  ---@desc Search through current buffer's lines
  ---@param opts Options
  curbuf_content: function(sources.FilesOptions): function()
@@ -95,6 +97,12 @@ function Builtins.help(): function()
  end
end

function Builtins.oldfiles(): function()
  return function()
    ui.create(sources.oldfiles(), sinks.oldfiles)
  end
end

function Builtins.buffers(): function()
  return function()
    ui.create(sources.buffers(), sinks.open_file)
diff --git a/teal/azy/sinks.tl b/teal/azy/sinks.tl
index 8b6c3ba..a38d841 100644
--- a/teal/azy/sinks.tl
+++ b/teal/azy/sinks.tl
@@ -13,6 +13,8 @@ local record Sinks
  ---@param el The quickfix item to open
  ---@param opts Options
  qf_item: function(AzyElement<vim.QfItem>, AzyCbModifiers)

  oldfiles: function(AzyElement<nil>, AzyCbModifiers)
end

local function open(fname: string, options: AzyCbModifiers)
@@ -39,6 +41,10 @@ function Sinks.help_tag(elem: AzyElement<nil>, options: AzyCbModifiers)
  end
end

function Sinks.oldfiles(elem: AzyElement<nil>, options: AzyCbModifiers)
  open(elem.search_text, options)
end

function Sinks.qf_item(elem: AzyElement<vim.QfItem>, options: AzyCbModifiers)
  local item = elem.extra
  if item and (item.filename ~= nil or item.bufnr ~= nil) then
diff --git a/teal/azy/sources.tl b/teal/azy/sources.tl
index 6492eb2..9de8ab3 100644
--- a/teal/azy/sources.tl
+++ b/teal/azy/sources.tl
@@ -31,6 +31,8 @@ local record Sources
  ---@desc Help tags source
  help: function(): {AzyElement<nil>}

  oldfiles: function(): {AzyElement<nil>}

  ---@desc Buffers source
  buffers: function(): {AzyElement<nil>}

@@ -228,6 +230,12 @@ function Sources.help(): {AzyElement<nil>}
  return ret
end

function Sources.oldfiles(): {AzyElement<nil>}
  return vim.iter.map(utils.path.shorten, vim.iter.filter(function(filename: string): boolean
    return vim.fn.filewritable(filename) == 1
  end, vim.v.oldfiles))
end

function Sources.buffers(): {AzyElement<nil>}
  local bufs = vim.api.nvim_list_bufs()
  local ret: {AzyElement<nil>} = {}
diff --git a/types/types.d.tl b/types/types.d.tl
index e33f9aa..c4c6283 100644
--- a/types/types.d.tl
+++ b/types/types.d.tl
@@ -66,6 +66,10 @@ global record vim
    eventignore: string
  end

  record v
    oldfiles: {string}
  end

  record wo
    cursorline: boolean
    cursorlineopt: string
@@ -158,6 +162,12 @@ global record vim
    systemlist: function({string}|string): {string}
    system: function({string}|string): string
    taglist: function(string, string|nil): {Tag}
    filewritable: function(string): boolean
  end

  record iter
    filter: function<T>((function(T): boolean), {T}): {T}
    map: function<S, T>((function(S): T), {T}): {AzyElement<nil>}
  end

  record api
-- 
2.38.5

[azy.nvim/patches/.build.yml] build failed

builds.sr.ht <builds@sr.ht>
Details
Message ID
<CW6VH8HU725J.X87E7L2U8Y1U@cirno2>
In-Reply-To
<169715562594.20557.10697035867365383179-0@git.sr.ht> (view parent)
DKIM signature
missing
Download raw message
azy.nvim/patches/.build.yml: FAILED in 53s

[Add oldfiles source][0] from [~p00f][1]

[0]: https://lists.sr.ht/~vigoux/azy.nvim-devel/patches/45639
[1]: dalal.chinmay.0101@gmail.com

✗ #1074423 FAILED azy.nvim/patches/.build.yml https://builds.sr.ht/~vigoux/job/1074423

Re: [azy.nvim/patches/.build.yml] build failed

Details
Message ID
<ypi9cyxjnzrg.fsf@gmail.com>
In-Reply-To
<CW6VH8HU725J.X87E7L2U8Y1U@cirno2> (view parent)
DKIM signature
missing
Download raw message
This had to be a new source instead of just a qwahl-based one for myself because

- it allows preview
- it allows C-v and C-h (a qwahl-based one will take over the current
window)

Thanks,
Chinmay
Reply to thread Export thread (mbox)