Skip to content

Commit 7105fa9

Browse files
committed
feat: initial poc
1 parent f199b39 commit 7105fa9

File tree

9 files changed

+81
-163
lines changed

9 files changed

+81
-163
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
- name: panvimdoc
2525
uses: kdheepak/panvimdoc@main
2626
with:
27-
vimdoc: nvim-plugin-template
27+
vimdoc: pandoc-this.nvim
2828
treesitter: true
2929
- uses: stefanzweifel/git-auto-commit-action@v4
3030
with:

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2023 nvimdev
3+
Copyright (c) 2023 Shelby Tucker
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 36 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,51 @@
1-
# nvim-plugin-template
1+
# pandoc-this.nvim
22

3-
Neovim plugin template; includes automatic documentation generation from README, integration tests with Busted, and linting with Stylua
3+
**Convert your Neovim buffers to various formats with the power of pandoc!**
44

5-
## Usage
5+
**🚧 Work in Progress! 🚧**
66

7-
1. Click `use this template` button generate a repo on your github.
8-
2. Clone your plugin repo. Open terminal then cd plugin directory.
9-
3. Run `python3 rename.py your-plugin-name`. This will replace all `nvim-plugin-template` to your `plugin-name`.
10-
Then it will prompt you input `y` or `n` to remove example codes in `init.lua` and
11-
`test/plugin_spec.lua`. If you are familiar this repo just input `y`. If you are looking at this template for the first time I suggest you inspect the contents. After this step `rename.py` will also auto-remove.
7+
This plugin is in its early stages of development. It currently provides a basic
8+
proof-of-concept for converting Markdown buffers to docx format. However, we
9+
have big plans for the future!
1210

13-
Now you have a clean plugin environment. Enjoy!
11+
**Planned Features:**
1412

15-
## Format
13+
- **Format Flexibility:**
14+
- Support for various input formats (not just Markdown).
15+
- Automatic input format detection.
16+
- **Output Choice:**
17+
- Easy selection of output formats (docx, html, pdf, epub, etc.).
18+
- Integration with a picker UI (like Telescope) for convenient format
19+
selection.
20+
- **Pandoc Power:**
21+
- Ability to pass custom arguments to pandoc for precise control over
22+
conversion.
23+
- Support for pandoc templates and filters.
24+
- **Seamless Integration:**
25+
- Option for in-place buffer conversion.
26+
- Asynchronous execution to avoid blocking Neovim.
27+
- Customizable keybindings for frequently used conversions.
1628

17-
The CI uses `stylua` to format the code; customize the formatting by editing `.stylua.toml`.
29+
**Current Functionality:**
1830

19-
## Test
31+
- Convert the current buffer (assumed to be Markdown) to a docx file.
32+
- Open the converted docx file in your default application.
2033

21-
Uses [busted](https://lunarmodules.github.io/busted/) for testing. Installs by using `luarocks --lua-version=5.1 install vusted` then runs `vusted ./test`
22-
for your test cases. `vusted` is a wrapper of Busted especially for testing Neovim plugins.
34+
**Installation:**
2335

24-
Create test cases in the `test` folder. Busted expects files in this directory to be named `foo_spec.lua`, with `_spec` as a suffix before the `.lua` file extension. For more usage details please check
25-
[busted usage](https://lunarmodules.github.io/busted/)
36+
- Using [packer.nvim](https://github.com/wbthomason/packer.nvim):
2637

27-
## CI
38+
_(Instructions to be added soon)_
2839

29-
- Auto generates doc from README.
30-
- Runs the Busted/vusted integration tests
31-
- Lints with `stylua`.
40+
**Usage:**
3241

42+
- Currently, there's a basic command to trigger the conversion. This will be
43+
expanded upon in future releases.
3344

34-
## More
45+
**Contributing:**
3546

36-
To see this template in action, take a look at my other plugins.
47+
- Contributions are welcome! Feel free to open issues or submit pull requests.
3748

38-
## License MIT
49+
**License:**
50+
51+
- [MIT License](LICENSE)

doc/nvim-plugin-template.txt

Lines changed: 0 additions & 67 deletions
This file was deleted.
File renamed without changes.

lua/nvim-plugin-template/init.lua

Lines changed: 0 additions & 7 deletions
This file was deleted.

lua/pandoc-this/init.lua

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
local M = {}
2+
3+
local Job = require('plenary.job')
4+
5+
local function remove_frontmatter(text)
6+
return text:gsub([[^---\n.-\n---\n]], '')
7+
end
8+
9+
function M.current_buffer()
10+
local current_buffer = vim.api.nvim_get_current_buf()
11+
local lines = vim.api.nvim_buf_get_lines(current_buffer, 0, -1, false)
12+
local text = table.concat(lines, '\n')
13+
14+
text = remove_frontmatter(text)
15+
16+
local input_tmpfile = os.tmpname()
17+
local output_tmpfile = os.tmpname() .. '.docx'
18+
19+
local file = io.open(input_tmpfile, 'w')
20+
file:write(text)
21+
file:close()
22+
23+
local pandoc = Job:new({
24+
command = 'pandoc',
25+
args = {'-f', 'markdown', '-t', 'docx', '-o', output_tmpfile, input_tmpfile},
26+
on_exit = function(j, exit_code)
27+
os.remove(input_tmpfile) -- Clean up the temporary input file.
28+
29+
if exit_code == 0 or exit_code == nil then
30+
vim.schedule(function()
31+
vim.api.nvim_command('!xdg-open ' .. output_tmpfile)
32+
end)
33+
else
34+
vim.api.nvim_err_writeln('Pandoc conversion failed with exit code: ' .. exit_code)
35+
end
36+
end
37+
38+
})
39+
40+
pandoc:start()
41+
end
42+
43+
return M

rename.py

Lines changed: 0 additions & 56 deletions
This file was deleted.

test/plugin_spec.lua

Lines changed: 0 additions & 8 deletions
This file was deleted.

0 commit comments

Comments
 (0)