Skip to content

Commit c73273d

Browse files
committed
refactor: rename the plugin to devto.nvim
We don't support other forem platforms
1 parent d0750f1 commit c73273d

File tree

11 files changed

+68
-68
lines changed

11 files changed

+68
-68
lines changed

README.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# Forem.nvim
1+
# Devto.nvim
22

3-
<p align="center">This plugin integrates Neovim with Forem platforms like [dev.to](https://dev.to)</p>
3+
<p align="center">This plugin integrates Neovim with [dev.to](https://dev.to)</p>
44

55
https://user-images.githubusercontent.com/12272702/175755820-a2b93f4b-fd5c-416b-8b9e-d981335ef75c.mov
66

@@ -35,7 +35,7 @@ You can use the plugin without any dependencies, but if you have any of the foll
3535

3636
```lua
3737
{
38-
"Massolari/forem.nvim",
38+
"Massolari/devto.nvim",
3939
dependencies = {
4040
"nvim-lua/plenary.nvim",
4141
-- Optional
@@ -49,7 +49,7 @@ You can use the plugin without any dependencies, but if you have any of the foll
4949

5050
```lua
5151
use {
52-
"Massolari/forem.nvim",
52+
"Massolari/devto.nvim",
5353
requires = {
5454
"nvim-lua/plenary.nvim",
5555
-- Optional
@@ -68,18 +68,18 @@ First, you need to generate an API key for the DEV platform.
6868

6969
For dev.to, you can do it in [the end of the extension's page](https://dev.to/settings/extensions)
7070

71-
With your API key, you just need to set it into the `FOREM_API_KEY` environment variable.
71+
With your API key, you just need to set it into the `DEVTO_API_KEY` environment variable.
7272

7373
## Usage
7474

75-
The plugin has the following commands and functions available in `forem-nvim` module:
75+
The plugin has the following commands and functions available in `devto-nvim` module:
7676

7777
| function | command | description |
7878
| --------------- | -------------------- | -------------------------------------------------------------------------------------------- |
79-
| `feed()` | `:Forem feed` | Shows fresh articles from the feed, then you can read it in Neovim or open it in the browser |
80-
| `my_articles()` | `:Forem my_articles` | Shows all your articles, then you can pick one to edit |
81-
| `new_article()` | `:Forem new_article` | Asks for a title, then creates an article with the given title and open it to edit |
82-
| `open_by_url()` | `:Forem open_by_url` | Asks for a URL, then opens the article |
79+
| `feed()` | `:Devto feed` | Shows fresh articles from the feed, then you can read it in Neovim or open it in the browser |
80+
| `my_articles()` | `:Devto my_articles` | Shows all your articles, then you can pick one to edit |
81+
| `new_article()` | `:Devto new_article` | Asks for a title, then creates an article with the given title and open it to edit |
82+
| `open_by_url()` | `:Devto open_by_url` | Asks for a URL, then opens the article |
8383

8484
After you save the buffer it'll automatically be saved in the cloud.
8585

lua/forem-nvim/api.lua renamed to lua/devto-nvim/api.lua

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
local M = {}
2-
local notify = require("forem-nvim.notify")
3-
local article = require("forem-nvim.article")
2+
local notify = require("devto-nvim.notify")
3+
local article = require("devto-nvim.article")
44

55
function M.key()
6-
return vim.env.FOREM_API_KEY
6+
return vim.env.devto_API_KEY
77
end
88

99
local BASE_URL = "https://dev.to/api"
@@ -102,7 +102,7 @@ local function request(method, endpoint, options)
102102
headers = {
103103
"api-key: " .. M.key(),
104104
"Content-Type: application/json",
105-
"Accept: application/vnd.forem.api-v1+json"
105+
"Accept: application/vnd.devto.api-v1+json"
106106
}
107107
},
108108
options
File renamed without changes.

lua/forem-nvim/buffer.lua renamed to lua/devto-nvim/buffer.lua

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
local M = {}
2-
local Article = require("forem-nvim.article")
3-
local util = require("forem-nvim.util")
2+
local Article = require("devto-nvim.article")
3+
local util = require("devto-nvim.util")
44
local set_locals = util.set_locals
55

66
M.set_basic_options = function()
@@ -33,7 +33,7 @@ M.get_content = function()
3333
end
3434

3535
M.open_my_article = function(article)
36-
vim.cmd(":edit forem://my-article/" .. tostring(article.id))
36+
vim.cmd(":edit devto://my-article/" .. tostring(article.id))
3737
local buffer = vim.api.nvim_get_current_buf()
3838
M.write(
3939
buffer,
@@ -44,7 +44,7 @@ M.open_my_article = function(article)
4444
end
4545

4646
M.load_article = function(article)
47-
vim.cmd(":edit forem://article/" .. article.title)
47+
vim.cmd(":edit devto://article/" .. article.title)
4848
set_locals({ linebreak = true, textwidth = 80 })
4949
local buffer = vim.api.nvim_get_current_buf()
5050
local body = Article.get_body_lines(article)

lua/forem-nvim/feed.lua renamed to lua/devto-nvim/feed.lua

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
local M = {}
2-
local api = require("forem-nvim.api")
3-
local buffer = require("forem-nvim.buffer")
4-
local notify = require("forem-nvim.notify")
5-
local util = require("forem-nvim.util")
2+
local api = require("devto-nvim.api")
3+
local buffer = require("devto-nvim.buffer")
4+
local notify = require("devto-nvim.notify")
5+
local util = require("devto-nvim.util")
66
local set_locals = util.set_locals
77

88
function M.open()
9-
return vim.cmd("edit forem://articles/feed")
9+
return vim.cmd("edit devto://articles/feed")
1010
end
1111

1212
local function set_basic_options()
@@ -62,7 +62,7 @@ function M.open_article(location)
6262
return
6363
end
6464

65-
local article_data = _G.forem_feed_articles and _G.forem_feed_articles[title]
65+
local article_data = _G.devto_feed_articles and _G.devto_feed_articles[title]
6666
if not article_data then
6767
notify.error("Could not find article data. Please reload the feed.")
6868
return
@@ -91,9 +91,9 @@ local function set_key_maps()
9191
end
9292

9393
local function populate_global_feed_articles(articles)
94-
_G.forem_feed_articles = {}
94+
_G.devto_feed_articles = {}
9595
for _, article in ipairs(articles) do
96-
_G.forem_feed_articles[article.title] = { id = article.id, url = article.url }
96+
_G.devto_feed_articles[article.title] = { id = article.id, url = article.url }
9797
end
9898
end
9999

lua/forem-nvim/init.lua renamed to lua/devto-nvim/init.lua

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
local M = {}
2-
local api = require("forem-nvim.api")
3-
local buffer = require("forem-nvim.buffer")
4-
local feed = require("forem-nvim.feed")
5-
local notify = require("forem-nvim.notify")
6-
local picker = require("forem-nvim.picker")
2+
local api = require("devto-nvim.api")
3+
local buffer = require("devto-nvim.buffer")
4+
local feed = require("devto-nvim.feed")
5+
local notify = require("devto-nvim.notify")
6+
local picker = require("devto-nvim.picker")
77

8-
local NO_API_KEY_ERROR = "forem.nvim: FOREM_API_KEY environment variable is missing"
8+
local NO_API_KEY_ERROR = "devto.nvim: devto_API_KEY environment variable is missing"
99

1010
local function check_api_key(callback)
1111
if api.key() then
@@ -26,7 +26,7 @@ local function save_article()
2626
local id = tonumber(vim.fn.expand("%:t"))
2727

2828
if not id then
29-
notify.error("forem.nvim: Could not find article id")
29+
notify.error("devto.nvim: Could not find article id")
3030
return
3131
end
3232

@@ -79,17 +79,17 @@ local function open_by_url()
7979
api.get_article_by_path(path, buffer.load_article)
8080
end
8181

82-
local forem_au_group = vim.api.nvim_create_augroup("forem_autocmds", {})
82+
local devto_au_group = vim.api.nvim_create_augroup("devto_autocmds", {})
8383

8484
vim.api.nvim_create_autocmd("BufWriteCmd",
85-
{ group = forem_au_group, pattern = "forem://my-article/*", callback = save_article })
85+
{ group = devto_au_group, pattern = "devto://my-article/*", callback = save_article })
8686
vim.api.nvim_create_autocmd("BufEnter",
87-
{ group = forem_au_group, pattern = "forem://articles/feed", callback = feed.load })
87+
{ group = devto_au_group, pattern = "devto://articles/feed", callback = feed.load })
8888
vim.api.nvim_create_autocmd(
8989
"CursorMoved",
9090
{
91-
group = forem_au_group,
92-
pattern = "forem://*/floatmenu",
91+
group = devto_au_group,
92+
pattern = "devto://*/floatmenu",
9393
callback = function()
9494
local bufnum, line, column, off = unpack(vim.fn.getpos("."))
9595
if column <= 1 then
@@ -102,8 +102,8 @@ vim.api.nvim_create_autocmd(
102102
vim.api.nvim_create_autocmd(
103103
"BufEnter",
104104
{
105-
group = forem_au_group,
106-
pattern = "forem://*/floatmenu",
105+
group = devto_au_group,
106+
pattern = "devto://*/floatmenu",
107107
callback = function()
108108
vim.keymap.set(
109109
"n",

lua/forem-nvim/notify.lua renamed to lua/devto-nvim/notify.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
local M = {}
22
local function notify(message, level)
3-
vim.notify(message, vim.log.levels[level], { title = "Forem.nvim" })
3+
vim.notify(message, vim.log.levels[level], { title = "Devto.nvim" })
44
end
55
function M.error(message) return notify(message, "ERROR") end
66

lua/forem-nvim/picker.lua renamed to lua/devto-nvim/picker.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
local M = {}
2-
local buffer = require("forem-nvim.buffer")
3-
local Article = require("forem-nvim.article")
2+
local buffer = require("devto-nvim.buffer")
3+
local Article = require("devto-nvim.article")
44

55
local function my_articles_telescope_picker(articles)
66
local telescope_config = require("telescope.config")

lua/forem-nvim/util.lua renamed to lua/devto-nvim/util.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ function M.open_float_menu(content, options)
6262
true,
6363
content
6464
)
65-
vim.api.nvim_buf_set_name(bufnr, "forem://feed/floatmenu")
65+
vim.api.nvim_buf_set_name(bufnr, "devto://feed/floatmenu")
6666
vim.api.nvim_set_option_value("modifiable", false, { buf = bufnr })
6767
vim.api.nvim_set_option_value("bufhidden", "delete", { buf = bufnr })
6868
vim.api.nvim_set_option_value("cursorline", true, { win = window })

plugin/forem-nvim.lua renamed to plugin/devto-nvim.lua

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
local M = {}
2-
local forem = require("forem-nvim")
3-
local notify = require("forem-nvim.notify")
2+
local devto = require("devto-nvim")
3+
local notify = require("devto-nvim.notify")
44

55
local commands = {
66
feed = "feed",
@@ -10,18 +10,18 @@ local commands = {
1010
}
1111

1212
vim.api.nvim_create_user_command(
13-
"Forem",
13+
"devto",
1414
function(data)
1515
local args = data.args
1616

1717
if args == commands.feed then
18-
return forem.feed()
18+
return devto.feed()
1919
elseif args == commands.my_articles then
20-
return forem.my_articles()
20+
return devto.my_articles()
2121
elseif args == commands.new_article then
22-
return forem.new_article()
22+
return devto.new_article()
2323
elseif args == commands.open_url then
24-
return forem.open_url()
24+
return devto.open_url()
2525
else
2626
notify.error("Unknown command: " .. args)
2727
end

0 commit comments

Comments
 (0)