Skip to content

Commit

Permalink
Merge pull request #177 from neo451/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
neo451 authored Feb 27, 2025
2 parents 99adcae + f57f929 commit a076e92
Show file tree
Hide file tree
Showing 26 changed files with 376 additions and 404 deletions.
16 changes: 4 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
For [rocks.nvim](https://github.com/nvim-neorocks/rocks.nvim):

```vim
Rocks install feed.nvim
:Rocks install feed.nvim
```

For [lazy.nvim](https://github.com/folke/lazy.nvim):
Expand Down Expand Up @@ -106,7 +106,7 @@ Use `:Feed<Enter>`, `:Feed update_feed<Enter>` to open menu and select

## Keymaps

Press `?` in to get keymap hints.
By default, feed.nvim will not set any keymaps for you, press `?` in to see buffer-local keymaps.

### Index buffer

Expand Down Expand Up @@ -290,7 +290,7 @@ requires `rg` and one of the search backends:

```lua
require("feed").setup({
layout = {
ui = {
tags = {
color = "String",
format = function(id, db)
Expand Down Expand Up @@ -323,7 +323,7 @@ require("feed").setup({
end

local tags = vim.tbl_map(get_icon, db:get_tags(id))

table.sort(tags)
return "[" .. table.concat(tags, ", ") .. "]"
end,
},
Expand Down Expand Up @@ -410,10 +410,6 @@ vim.api.nvim_create_autocmd("User", {

:TODO:

## Custom Action

:TODO:

<!-- panvimdoc-ignore-start -->

## ❤️ Related Projects
Expand All @@ -423,7 +419,3 @@ vim.api.nvim_create_autocmd("User", {
- [vnews](https://github.com/danchoi/vnews)
- [lua-feedparser](https://github.com/slact/lua-feedparser)
<!-- panvimdoc-ignore-start -->

```
```
16 changes: 5 additions & 11 deletions doc/feed.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
*feed.txt* For 0.11 Last change: 2025 February 26
*feed.txt* For 0.11 Last change: 2025 February 27

==============================================================================
Table of Contents *feed-table-of-contents*
Expand All @@ -22,7 +22,6 @@ Table of Contents *feed-table-of-contents*
- Grep |feed-search-grep|
5. Recipes |feed-recipes|
6. Lua API |feed-lua-api|
7. Custom Action |feed-custom-action|

==============================================================================
1. Commands *feed-commands*
Expand Down Expand Up @@ -83,7 +82,8 @@ LIST OF COMMANDS *feed-commands-list-of-commands*
==============================================================================
2. Keymaps *feed-keymaps*

Press `?` in to get keymap hints.
By default, feed.nvim will not set any keymaps for you, press `?` in to see
buffer-local keymaps.


INDEX BUFFER *feed-keymaps-index-buffer*
Expand Down Expand Up @@ -289,7 +289,7 @@ Change the highlight of the tags section and use emojis and mini.icons for tags

>lua
require("feed").setup({
layout = {
ui = {
tags = {
color = "String",
format = function(id, db)
Expand Down Expand Up @@ -322,7 +322,7 @@ Change the highlight of the tags section and use emojis and mini.icons for tags
end

local tags = vim.tbl_map(get_icon, db:get_tags(id))

table.sort(tags)
return "[" .. table.concat(tags, ", ") .. "]"
end,
},
Expand Down Expand Up @@ -405,12 +405,6 @@ Custom colorscheme only set when viewing feeds ~

:TODO:


==============================================================================
7. Custom Action *feed-custom-action*

:TODO:

Generated by panvimdoc <https://github.com/kdheepak/panvimdoc>

vim:tw=78:ts=8:noet:ft=help:norl:
9 changes: 3 additions & 6 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ <h1 class="title">feed.nvim</h1>
</ul></li>
<li><a href="#recipes" id="toc-recipes">Recipes</a></li>
<li><a href="#lua-api" id="toc-lua-api">Lua API</a></li>
<li><a href="#custom-action" id="toc-custom-action">Custom Action</a></li>
</ul>
</nav>

Expand Down Expand Up @@ -151,7 +150,7 @@ <h3 id="list-of-commands">List of commands</h3>
</tbody>
</table>
<h2 id="keymaps">Keymaps</h2>
<p>Press <code>?</code> in to get keymap hints.</p>
<p>By default, feed.nvim will not set any keymaps for you, press <code>?</code> in to see buffer-local keymaps.</p>
<h3 id="index-buffer">Index buffer</h3>
<table>
<thead>
Expand Down Expand Up @@ -391,7 +390,7 @@ <h2 id="recipes">Recipes</h2>
Change the highlight of the tags section and use emojis and mini.icons for tags
</summary>
<div class="sourceCode" id="cb3"><pre class="sourceCode lua"><code class="sourceCode lua"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true" tabindex="-1"></a><span class="fu">require</span><span class="op">(</span><span class="st">&quot;feed&quot;</span><span class="op">).</span>setup<span class="op">({</span></span>
<span id="cb3-2"><a href="#cb3-2" aria-hidden="true" tabindex="-1"></a> <span class="va">layout</span> <span class="op">=</span> <span class="op">{</span></span>
<span id="cb3-2"><a href="#cb3-2" aria-hidden="true" tabindex="-1"></a> <span class="va">ui</span> <span class="op">=</span> <span class="op">{</span></span>
<span id="cb3-3"><a href="#cb3-3" aria-hidden="true" tabindex="-1"></a> <span class="va">tags</span> <span class="op">=</span> <span class="op">{</span></span>
<span id="cb3-4"><a href="#cb3-4" aria-hidden="true" tabindex="-1"></a> <span class="va">color</span> <span class="op">=</span> <span class="st">&quot;String&quot;</span><span class="op">,</span></span>
<span id="cb3-5"><a href="#cb3-5" aria-hidden="true" tabindex="-1"></a> <span class="fu">format</span> <span class="op">=</span> <span class="kw">function</span><span class="op">(</span><span class="va">id</span><span class="op">,</span> <span class="va">db</span><span class="op">)</span></span>
Expand Down Expand Up @@ -424,7 +423,7 @@ <h2 id="recipes">Recipes</h2>
<span id="cb3-32"><a href="#cb3-32" aria-hidden="true" tabindex="-1"></a> <span class="kw">end</span></span>
<span id="cb3-33"><a href="#cb3-33" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb3-34"><a href="#cb3-34" aria-hidden="true" tabindex="-1"></a> <span class="kw">local</span> <span class="va">tags</span> <span class="op">=</span> <span class="va">vim</span><span class="op">.</span>tbl_map<span class="op">(</span><span class="va">get_icon</span><span class="op">,</span> <span class="va">db</span><span class="op">:</span>get_tags<span class="op">(</span><span class="va">id</span><span class="op">))</span></span>
<span id="cb3-35"><a href="#cb3-35" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb3-35"><a href="#cb3-35" aria-hidden="true" tabindex="-1"></a> <span class="fu">table.sort</span><span class="op">(</span><span class="va">tags</span><span class="op">)</span></span>
<span id="cb3-36"><a href="#cb3-36" aria-hidden="true" tabindex="-1"></a> <span class="cf">return</span> <span class="st">&quot;[&quot;</span> <span class="op">..</span> <span class="fu">table.concat</span><span class="op">(</span><span class="va">tags</span><span class="op">,</span> <span class="st">&quot;, &quot;</span><span class="op">)</span> <span class="op">..</span> <span class="st">&quot;]&quot;</span></span>
<span id="cb3-37"><a href="#cb3-37" aria-hidden="true" tabindex="-1"></a> <span class="kw">end</span><span class="op">,</span></span>
<span id="cb3-38"><a href="#cb3-38" aria-hidden="true" tabindex="-1"></a> <span class="op">},</span></span>
Expand Down Expand Up @@ -502,8 +501,6 @@ <h2 id="recipes">Recipes</h2>
</details>
<h2 id="lua-api">Lua API</h2>
<p>:TODO:</p>
<h2 id="custom-action">Custom Action</h2>
<p>:TODO:</p>
</main>

<script>
Expand Down
31 changes: 26 additions & 5 deletions lua/feed/commands.lua
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,17 @@ M.update = {
impl = function()
local n = #ut.feedlist(db.feeds, false)
local prog = require("feed.ui.progress").new(n)
vim.system({ "nvim", "--headless", "-c", 'lua require"feed.fetch".update_all()' }, {
local args = vim.v.argv
table.remove(args, 1)
table.remove(args, 1)
local cmds = vim.tbl_flatten({
"nvim",
args,
"--headless",
"-c",
'lua require"feed.fetch".update_all()',
})
vim.system(cmds, {
text = true,
stdout = function(_, data)
if data and vim.trim(data) ~= "" then
Expand Down Expand Up @@ -214,12 +224,24 @@ M.sync = {
end,
}

M.export = {
doc = "use pandoc to convert entry to any format",
impl = function(to, fp)
local entry, id = ui.get_entry()
require("feed.pandoc").convert({ id = id, to = to }, function(res)
ut.save_file(vim.fs.joinpath(fp, entry.title .. "." .. to), res)
end)
end,
}

local entry_cmds = {
"urlview",
"next",
"prev",
"full",
"browser",
"export",
"quit",
}

local index_cmds = {
Expand All @@ -244,15 +266,14 @@ local index_cmds = {

local general_cmds = {
"index",
"search",
"update",
"update_feed",
"sync",
"sync!",
"update_feed",
"list",
"search",
"grep",
"list",
"web",
"browser",
"load_opml",
"export_opml",
"log",
Expand Down
9 changes: 8 additions & 1 deletion lua/feed/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ local default = {
order = { "date", "feed", "tags", "title" },
winbar_right = { "query", "last_updated" },
date = {
width = 10,
width = "#",
color = "FeedDate",
},
feed = {
Expand All @@ -43,6 +43,7 @@ local default = {
color = "FeedTags",
},
title = {
width = "#",
color = "FeedTitle",
},
progress = {
Expand Down Expand Up @@ -71,6 +72,7 @@ local default = {
color = "FeedTags",
},
title = {
width = "#",
color = "FeedTitle",
},
progress = {
Expand Down Expand Up @@ -196,6 +198,11 @@ local default = {
spell = false,
conceallevel = 3,
concealcursor = "nvc",
foldmethod = "expr",
foldlevel = 99,
foldexpr = "v:lua.vim.treesitter.foldexpr()",
foldtext = "",
fillchars = "foldopen:,foldclose:,fold: ,foldsep: ",
},
bo = {
filetype = "markdown",
Expand Down
1 change: 1 addition & 0 deletions lua/feed/curl.lua
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ end
---@param url string
---@param opts { headers: table, data: string | table, etag: string, last_modified: string, timeout: string, cmds: table }
---@param cb? any
---@return vim.SystemCompleted
function M.get(url, opts, cb)
opts = opts or {}
opts.timeout = vim.F.if_nil(opts.timeout, "10")
Expand Down
2 changes: 1 addition & 1 deletion lua/feed/fetch.lua
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ function M.update_all()
local ok = M.update_feed_co(url, { force = false })
local name = ut.url2name(url, feeds)
c = c + 1
io_print(name, ok and "success" or "failed")
io_print(string.format("[%s/%s]", c, n), name, ok and "success" or "failed")
if c == n then
os.exit()
end
Expand Down
51 changes: 51 additions & 0 deletions lua/feed/pandoc.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
local health = require("feed.health")
local ut = require("feed.utils")

---@class pandoc_args
---@field link string
---@field src string
---@field id string
---@field from string
---@field to string

---pandoc wrapper
---@param ctx any
---@param cb fun(str: string)
---@return string?
local function convert(ctx)
local db = require("feed.db")
local link = ctx.link
local src = ctx.src
local fp = ctx.id and tostring(db.dir / "data" / ctx.id) or nil
local from = ctx.from or "html"
local to = ctx.to or vim.api.nvim_get_runtime_file("lua/feed/ui/pandoc_writer.lua", false)[1]
local stdout = ctx.stdout
local on_exit = ctx.on_exit

if not health.check_binary_installed({ name = "pandoc", min_ver = 3 }) then
vim.schedule_wrap(cb)({ "you need pandoc to view feeds https://pandoc.org" })
return
end

local cmd = {
"pandoc",
link and "-r" or "-f",
from,
"-t",
to,
"--wrap=none",
link or fp,
}

vim.system(cmd, {
text = true,
stdin = src,
stdout = function(err, data)
if data then
return vim.schedule_wrap(stdout)(ut.unescape(data))
end
end,
}, vim.schedule_wrap(on_exit))
end

return { convert = convert }
Loading

0 comments on commit a076e92

Please sign in to comment.