From 2f85bbe61513d12c746641fed6ad07559bd95719 Mon Sep 17 00:00:00 2001 From: altermo <107814000+altermo@users.noreply.github.com> Date: Mon, 26 Feb 2024 11:42:51 -0800 Subject: feat!: rewrite TOhtml in lua Co-authored-by: wookayin Co-authored-by: clason Co-authored-by: Lewis Russell --- runtime/plugin/tohtml.lua | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 runtime/plugin/tohtml.lua (limited to 'runtime/plugin/tohtml.lua') diff --git a/runtime/plugin/tohtml.lua b/runtime/plugin/tohtml.lua new file mode 100644 index 0000000000..893419ece6 --- /dev/null +++ b/runtime/plugin/tohtml.lua @@ -0,0 +1,11 @@ +if vim.g.loaded_2html_plugin ~= nil then + return +end +vim.g.loaded_2html_plugin = true + +vim.api.nvim_create_user_command('TOhtml', function(args) + local outfile = args.args ~= '' and args.args or vim.fn.tempname() .. '.html' + local html = require('tohtml').tohtml() + vim.fn.writefile(html, outfile) + vim.cmd.split(outfile) +end, { bar = true, nargs = '?' }) -- cgit From 0246f1a897f4c349760cec9aea6db8bdd71bf3c5 Mon Sep 17 00:00:00 2001 From: Christian Clason Date: Wed, 28 Feb 2024 18:01:38 +0100 Subject: fix(tohtml): set filetype of generated HTML to `html` Problem: `:TOhtml` opens the generated HTML code in a split, meaning it inherits the `help` filetype if a help buffer is to be converted. Solution: Explicitly set the filetype to `html`. --- runtime/plugin/tohtml.lua | 1 + 1 file changed, 1 insertion(+) (limited to 'runtime/plugin/tohtml.lua') diff --git a/runtime/plugin/tohtml.lua b/runtime/plugin/tohtml.lua index 893419ece6..79f2794a40 100644 --- a/runtime/plugin/tohtml.lua +++ b/runtime/plugin/tohtml.lua @@ -8,4 +8,5 @@ vim.api.nvim_create_user_command('TOhtml', function(args) local html = require('tohtml').tohtml() vim.fn.writefile(html, outfile) vim.cmd.split(outfile) + vim.bo.filetype = 'html' end, { bar = true, nargs = '?' }) -- cgit