Skip to content

Commit

Permalink
Merge branch 'tech/typescript'
Browse files Browse the repository at this point in the history
  • Loading branch information
Massolari committed Mar 8, 2024
2 parents 26eb5dd + bf1f54a commit 8a51c91
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 23 deletions.
37 changes: 26 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Forem.nvim

<p align="center">This plugin integrates Neovim with Forem platforms (for example, dev.to)</p>
<p align="center">This plugin integrates Neovim with Forem platforms like [dev.to](https://dev.to)</p>

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

Expand Down Expand Up @@ -38,20 +38,37 @@ https://user-images.githubusercontent.com/12272702/175755866-62be0b6c-31b2-4f45-

## Installation

Using [packer](https://github.com/wbthomason/packer.nvim):
### Using [lazy](https://github.com/folke/lazy.nvim):

```lua
{
"Massolari/forem.nvim",
dependencies = {
"nvim-lua/plenary.nvim",
"nvim-telescope/telescope.nvim",
"rcarriga/nvim-notify"
}
}
```

### Using [packer](https://github.com/wbthomason/packer.nvim):

```lua
use {
"Massolari/forem.nvim",
requires = {
"nvim-lua/plenary.nvim",
"nvim-telescope/telescope.nvim"
"nvim-telescope/telescope.nvim",
"rcarriga/nvim-notify"
}
}
```

## Setup

> [!NOTE]
> These instructions are for the dev.to platform.
First, you need to generate an API key for the DEV platform.

For dev.to, you can do it in [the end of the extension's page](https://dev.to/settings/extensions)
Expand All @@ -62,17 +79,15 @@ With your API key, you just need to set it into the `FOREM_API_KEY` environment

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

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

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

**Note: these functions will only be available after the `setup` call**

## Contributing

Please, don't hesitate in contributing by creating issues and opening pull requests.
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
},
"scripts": {
"build": "make",
"dev": "tstl -p ./src/tsconfig.json --watch"
"dev": "tstl --watch"
},
"keywords": [],
"author": "",
Expand Down
10 changes: 5 additions & 5 deletions tests/minimal_init.lua
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
append = function(option, value)
option.append(option, value)
end
loadModule = function(module, source, directory)
local moduleDir = directory or "/tmp/" .. module
local directoryExists = vim.fn.isdirectory(moduleDir)
if directoryExists == 0 then
vim.fn.system({"git", "clone", source, moduleDir})
end
append(vim.opt.rtp, moduleDir)
return moduleDir
end
plenaryDir = os.getenv("PLENARY_DIR") or "/tmp/plenary.nvim"
loadModule("plenary.nvim", "https://github.com/nvim-lua/plenary.nvim", plenaryDir)
telescopeDir = loadModule("telescope.nvim", "https://github.com/nvim-telescope/telescope.nvim")
append = function(option, value)
option.append(option, value)
end
append(vim.opt.rtp, ".")
append(vim.opt.rtp, plenaryDir)
append(vim.opt.rtp, telescopeDir)
vim.cmd("runtime plugin/plenary.vim")
vim.cmd("runtime plugin/telescope.lua")
require("plenary.busted")
13 changes: 7 additions & 6 deletions tests/minimal_init.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
const append = (option: any, value: any) => {
option.append(option, value);
};

const loadModule = (module: string, source: string, directory?: string) => {
const moduleDir = directory || `/tmp/${module}`;
const directoryExists = vim.fn.isdirectory(moduleDir);
Expand All @@ -6,6 +10,8 @@ const loadModule = (module: string, source: string, directory?: string) => {
vim.fn.system(["git", "clone", source, moduleDir]);
}

append(vim.opt.rtp, moduleDir);

return moduleDir;
};

Expand All @@ -21,12 +27,7 @@ const telescopeDir = loadModule(
"https://github.com/nvim-telescope/telescope.nvim",
);

const append = (option: any, value: any) => {
option.append(option, value);
};

append(vim.opt.rtp, ".");
append(vim.opt.rtp, plenaryDir);
append(vim.opt.rtp, telescopeDir);
vim.cmd("runtime plugin/plenary.vim");
vim.cmd("runtime plugin/telescope.lua");
require("plenary.busted");

0 comments on commit 8a51c91

Please sign in to comment.