Skip to content

Commit

Permalink
docs and some fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
marioortizmanero committed Apr 27, 2021
1 parent 8624889 commit 0cd3ddd
Show file tree
Hide file tree
Showing 4 changed files with 169 additions and 6 deletions.
42 changes: 42 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Compiled Lua sources
luac.out

# luarocks build files
*.src.rock
*.zip
*.tar.gz

# Object files
*.o
*.os
*.ko
*.obj
*.elf

# Precompiled Headers
*.gch
*.pch

# Libraries
*.lib
*.a
*.la
*.lo
*.def
*.exp

# Shared objects (inc. Windows DLLs)
*.dll
*.so
*.so.*
*.dylib

# Executables
*.exe
*.out
*.app
*.i*86
*.x86_64
*.hex

doc/tags
10 changes: 8 additions & 2 deletions README.adoc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
= adoc-pdf-live.nvim

Very simple live preview plugin for asciidoctor-pdf. HTML live preview is
Very simple live preview plugin for AsciiDoc PDF documents. HTML live preview is
perfect with the
https://asciidoctor.cn/docs/editing-asciidoc-with-live-preview/[browser
plugins], but for PDF documents there's nothing available.
Expand Down Expand Up @@ -38,6 +38,12 @@ Or, to override the default options:
[source, lua]
----
require('adoc_pdf_live').setup {
enabled = options.enabled or false,
viewer = options.viewer or 'zathura',
binary = 'asciidoctor-pdf',
params = options.params or '',
debug = options.debug or false,
style = options.style or '',
style_regex = options.style_regex or 'style\\.ya?ml'
}
----
110 changes: 110 additions & 0 deletions doc/adoc_pdf_live.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
*adoc-pdf-live.txt* simple live preview plugin for AsciiDoc PDF documents

Author: Mario Ortiz Manero <[email protected]>
Homepage: <https://github.com/marioortizmanero/adoc-pdf-live.nvim>
License: GPLv3

==============================================================================
INTRODUCTION *adoc-pdf-live*

Very simple live preview plugin for AsciiDoc PDF documents. HTML live preview
is perfect with the browser plugins [1], but for PDF documents there's nothing
available.

This is a plugin I made for my own use, so I've only tested it on NeoVim
nightly 0.5 [2]. Feel free to open an issue or pull request to fix anything on
your system. This is my first vim plugin ever as well, so there's probably
lots to improve.

[1] https://asciidoctor.cn/docs/editing-asciidoc-with-live-preview/
[2] https://github.com/neovim/neovim

==============================================================================
USAGE *adoc-pdf-live-usage*

For basic setup with all batteries included:
>
require('gitsigns').setup()
<

Configuration can be passed to the setup function. Here is an example with all
the default settings:
>
require('gitsigns').setup {
signs = {
add = {hl = 'DiffAdd' , text = '│', numhl='GitSignsAddNr'},
change = {hl = 'DiffChange', text = '│', numhl='GitSignsChangeNr'},
delete = {hl = 'DiffDelete', text = '_', numhl='GitSignsDeleteNr'},
topdelete = {hl = 'DiffDelete', text = '‾', numhl='GitSignsDeleteNr'},
changedelete = {hl = 'DiffChange', text = '~', numhl='GitSignsChangeNr'},
},
numhl = false,
keymaps = {
-- Default keymap options
noremap = true,
buffer = true,
['n ]c'] = { expr = true, "&diff ? ']c' : '<cmd>lua require\"gitsigns\".next_hunk()<CR>'"},
['n [c'] = { expr = true, "&diff ? '[c' : '<cmd>lua require\"gitsigns\".prev_hunk()<CR>'"},
['n <leader>hs'] = '<cmd>lua require"gitsigns".stage_hunk()<CR>',
['n <leader>hu'] = '<cmd>lua require"gitsigns".undo_stage_hunk()<CR>',
['n <leader>hr'] = '<cmd>lua require"gitsigns".reset_hunk()<CR>',
['n <leader>hp'] = '<cmd>lua require"gitsigns".preview_hunk()<CR>',
['n <leader>hb'] = '<cmd>lua require"gitsigns".blame_line()<CR>',
},
watch_index = {
interval = 1000
},
sign_priority = 6,
status_formatter = nil -- Use default
}
<

==============================================================================
CONFIGURATION *adoc-pdf-live-config*

enabled *adoc-pdf-live-config-enabled*
Type: `boolean`, Default: `false`

True when the plugin is enabled. If this is set in the `setup`
function, this plugin will always be enabled on startup.

viewer *adoc-pdf-live-config-viewer*
Type: `string`, Default: `'zathura'`

The PDF viewer ran when using AdocPdfLiveOpen. The command must take
the filename as its next argument.

binary *adoc-pdf-live-config-binary*
Type: `string`, Default: `'asciidoctor-pdf'`

The binary to be ran to compile the file.

params *adoc-pdf-live-config-params*
Type: `string`, Default: `''`

Extra arguments given to the compiler binary. This is helpful to
enable extensions, like `'-r asciidoctor-mathematical'`

style *adoc-pdf-live-config-style*
Type: `string`, Default: `''`

The style file to forcefully use. If empty, adoc-pdf-live will look
for a style file in the current directory automatically, with the
regex given by `style-regex`.

style-regex *adoc-pdf-live-config-style-regex*
Type: `string`, Default: `'style\\.ya?ml'`

The regex used when looking for which style yaml to use, with a
sed-like format. This plugin will look for a file matching this
regular expression and enable it when compiling the document with
`-a pdf-style=FILE`

debug *adoc-pdf-live-config-debug*
Type: `boolean`, Default: `false`

Print diagnostic messages.

vim:tw=78:ts=2:ft=help:norl:
13 changes: 9 additions & 4 deletions lua/adoc_pdf_live/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ local function log(txt)

local date = vim.fn.trim(vim.fn.system("date"))
txt = string.format("[%s] %s", date, txt)
adoc_pdf_live.out_buf = adoc_pdf_live.out_buf .. "\n" .. txt
adoc_pdf_live.logs = adoc_pdf_live.logs .. "\n" .. txt
end

-- Wrapper to run commands with or without stdout. May be ran in the background
Expand Down Expand Up @@ -57,8 +57,13 @@ end
function adoc_pdf_live.setup(options)
adoc_pdf_live.options = with_defaults(options or {})

-- For logging
adoc_pdf_live.out_buf = ""
-- Initializing logging
adoc_pdf_live.logs = ""

-- Auto start-up
if adoc_pdf_live.options.enabled then
adoc_pdf_live.start()
end
end

function adoc_pdf_live.is_configured()
Expand Down Expand Up @@ -127,7 +132,7 @@ function adoc_pdf_live.set_debug(val)
end

function adoc_pdf_live.show_logs()
print(adoc_pdf_live.out_buf)
print(adoc_pdf_live.logs)
end

return adoc_pdf_live

0 comments on commit 0cd3ddd

Please sign in to comment.