set filetype in a pcall to circumvent error (issue #58)

main
bhagwan 3 years ago
parent a2470b81e1
commit a7c093e774

@ -175,8 +175,10 @@ function Previewer:do_syntax(entry)
-- make sure that buffer in preview window must not in normal window
-- greedy match anything after last dot
local ext = entry.path:match("[^.]*$")
if ext then
pcall(api.nvim_buf_set_option, bufnr, 'filetype', ext)
end
api.nvim_buf_call(bufnr, function()
if ext then vim.cmd('set ft=' .. ext) end
vim.cmd('filetype detect')
end)
end

Loading…
Cancel
Save