onivim / oni2

Native, lightweight modal code editor
https://v2.onivim.io
MIT License
7.83k stars 282 forks source link

Markdown preview #3176

Open maxild opened 3 years ago

maxild commented 3 years ago

I just blindly bought a license without even knowing much about the state of onivim2, because I wish to support and use any 'VIM style' editor. My initial plan was to use 'oni2' to edit markdown docs in some of my projects, but I couldn't get 'preview' to work. Is this supported somehow (even through plugins) or is the problem no embedded browser support?

bryphe commented 3 years ago

Hi @maxild ,

I just blindly bought a license without even knowing much about the state of onivim2, because I wish to support and use any 'VIM style' editor.

Thanks for supporting the editor and for logging the issue, appreciate it!

Is this supported somehow (even through plugins) or is the problem no embedded browser support?

We're missing this at the moment - we actually have some limited markdown rendering capabilities (https://github.com/revery-ui/revery/blob/18eb60e6d5b99adebcf5912d05c447e83a0f7e0b/src/UI_Components/Markdown.re) which we use today to render extension details. It isn't the full Github markdown implementation, though - missing some things like tables and images. Synchronizing the scroll position may also be challenging with this implementation.

I anticipate we will need to support embedding some sort of webview eventually - it is required for new capabilities of the vscode extension host (ie, #3128 ), and would be helpful in terms of a fully baked markdown preview experience.

In the meantime - we could look at using our current markdown renderer for preview, and then swapping in the webview to provide more fidelity in the preview once that is available.

MAHDTech commented 3 years ago

@bryphe, just a thought,

What about getting an extension like instant markdown working?

This means the preview portion is run though an external web browser and the editor is just serving the pages.

I just searched open-vsx and doesn't look like it's there at the moment, but it's potentially a smaller hurdle then full integrated markdown preview at this time?

Although i'm not sure what underlying wiring would be required to get the pages served... so could be harder 😁 but interested to get your thoughts.

I find my self currently editing markdown in vscode and Go and Rust in Onivim2 so it's definetly one to consider for the daily driver blocker list 😃

bryphe commented 3 years ago

Thanks for the suggestion @MAHDTech ! I didn't know about that plugin.

I just tested it out (by manually git clone'ing into ~/.config/oni2 and running npm install); seems like it'd be a reasonable stop-gap in the meantime until we have a hosted webview.

The auto-open functionality seems to work; but we're missing the events the extension needs to synchronize and update the markdown (sending visible ranges + selection position) - this extension would actually be a nice test case for these. And lots of other extensions rely on those events (https://github.com/onivim/vscode-exthost/blob/0d6b39803352369daaa97a444ff76352d8452be2/src/vs/workbench/api/common/extHost.protocol.ts#L1083)

abers commented 3 years ago

On a slightly related note, I noticed in the VimConf.live presentation the ability to switch to non-monospaced fonts. How difficult would it be to implement different font sizes for header lines and using two different fonts in the same pane? You could turn oni2 into a fantastic markdown editor with those two features. I'd kill for a vim-powered GUI that let's users have more prose-friendly fonts when working in markdown files, including changing line size for header lines to give a 'lite' preview, but keeping monospaced fonts for code-blocks.