neovim/runtime/plugin/tohtml.lua
Christian Clason 0246f1a897 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`.
2024-02-28 18:34:12 +00:00

13 lines
388 B
Lua

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)
vim.bo.filetype = 'html'
end, { bar = true, nargs = '?' })