glacambre / firenvim

Embed Neovim in Chrome, Firefox & others.
GNU General Public License v3.0
4.69k stars 145 forks source link

Neovim instance in dedicated tab #1012

Closed luetage closed 3 years ago

luetage commented 3 years ago

This is a feature request. I’m enjoying firenvim so far, it works great in textboxes. But what I immediately wanted to do was fire up an nvim instance for simple coding tasks / web development. This got me thinking… why not provide a dedicated extension page, which automatically loads nvim?

My current workaround is using this site ☛ https://textarea.online

glacambre commented 3 years ago

Hi, thanks for the feature request :).

I immediately wanted to do was fire up an nvim instance for simple coding tasks / web development

I am curious, why use Firenvim for that, rather than your usual terminal/neovim GUI? I don't find Firenvim particularly good at being a regular neovim UI and I see the fact that it lives in the browser as a serious disadvantage compared to the terminal/other neovim GUIs when it comes to regular development.

luetage commented 3 years ago

I'm using Vivaldi and mod the user interface of the browser with CSS/Javascript. Sometimes I don’t want to fire up the terminal in another workspace just to quickly review someones code, or help out. Previously I did this from the DevTools, which is awkward. My markdown preview viewer for nvim also fires up in the browser. I noticed it’s a nice setup to tile both firenvim and the viewer in a single browser window. Anyway, I tried two things so far:

glacambre commented 3 years ago

I see, I think I am beginning to understand your workflow.

In the case of reviewing code/helping out, the nicest workflow would be to be able to just click on an element and have it turn into a Firenvim instance I think.

For regular markdown writing, I'm still not sure I see the advantage of using Firenvim, but this is probably because Firefox doesn't do tiling and so I rely on my window manager to do that for me instead.

So I guess this feature indeed makes sense and I'll accept PRs to implement it. I might not be able to work on that myself for a while though, so if you want to implement it yourself and require help/guidance to do it, feel free to ask, I'll be more than happy to answer all your questions :).

Loading a bare webpage with textarea from the file system, which fails because extensions have no access.

That's weird, using firenvim on file:///tmp/index.html works both in Firefox and Chrome for me. data:text/html;charset=utf-8,<html><body><textarea></textarea></body></html> works in Firefox but not in Chrome, does that work in Vivaldi?

luetage commented 3 years ago

Using a bookmarklet is nifty, didn’t think about that ^^. But yeah, neither seems to work on Vivaldi. When clicking within the textarea nothing happens. Using the shortcut to turn the focused element into an iframe, I can see this warning in the background page: “Could not establish connection. Receiving end does not exist.”

luetage commented 3 years ago

I installed Firefox stable to test this, both the bookmarklet and the webpage from file system load Firenvim indeed. I did this just to ensure I don’t mess up anything obvious. I took a look at the code and I noticed Firenvim checks for the kind of browser in use. I’m running Vivaldi snapshot (the beta version of the browser), which is not declared. Could this be an issue?

glacambre commented 3 years ago

No, I don't think so. There are two kinds of browser checks performed:

By the way, if you want to implement this, here's what I think the process might look like:

luetage commented 3 years ago

Thank you for your thorough explanation, I will try it. Independently of that I will probably issue a report to the Vivaldi bugtracker anyway. If anything, we should have more functionality than Chrome.

glacambre commented 3 years ago

@luetage told me on Matrix that Firenvim can work on file:// pages, you just need to enable file access in the browser. Since working on a local page works, adding a dedicated feature to open a local page in Firenvim does not seem very worthwile to me so I'll close this issue. Thanks a lot for looking into this @luetage! :)

luetage commented 3 years ago

For anyone wanting to load a tab with text area from the file system and stumbling upon this request, I created a simple HTML page with favicon for this purpose.

<!DOCTYPE html>
<html>
  <head>
    <title>Firenvim</title>
    <link rel="icon" type="image/png" href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAACXBIWXMAAAsTAAALEwEAmpwYAAAC7klEQVQ4y1WTW2hUVxiF1zmTmThJRnPpEI1oqpKWxBZK0Yc8+OANIUQwKU3yUCRxsvekhOqDCD4IGggKIkIURY0XVBKDmhiktd7aatAXwceWXqBQaKjaCA2Y0ZmYvVx7TCwOLP5zDvN//1r/2QfjphL/mnKMm4VgGqB5Xw6qN2PglYKA3wVg5nOwvzjguQXgoRhwLP0NfkyvC7gDeUDWRL9WY5lvnjFqqNLzW7GANwsFirTw56oKdzYOnk8E7A2B/q4uYAdR2D6BrI0ecAZUcw9t3kGEwwh5SdcDWM8bITlWuZ31KGdcz/ZFNKEFgYS2jjP7MyZGNTpBZqRVTOlPuwX5IQ/4idcFv19BN1Cyh5crwKGiAiBNlKQzH6OTPLot5QHZaRPxLh65g4IfUnMfEryACTcCxwdF5C9LRjnVA06eChCYGcTNizpYvipJTfCPVLWHTCu/r3vYLUCPAOfwF6/KwR3p10W/k2tld7VWbAkY1kbsdFaVzanBJ5qee21DOoscu/AZewXpx4B2QX4rPf5gkmwvJb+aBVhXB+MyoX1N3Z8X4PiMDZhfqMVDHhbgJOoVgxyRHpRN8vnmUk40wE+XnI+QURzqflBNRYrwtxx4gNdO7hLkNO7nXdxN/El2z3Mv294Bar0DQRg12dFh24ScKfhi1oFXjmuQVIzdPOtjFH9Pf8DIuQj8RDEygsiBu+qh/hwIcJFzkA4M6Y3s5Akt93rioOKAZxD66d5FtTQliI9w2UP9SZSLpJr/yQMMXrI7/h/7ojnei9VyTCdzOB766cHbGPzSvwVBRqM2i9t2QzT/PXQGbTri5Naolp50PFLQyL5isHd+yLFlszv4H2LnImwxI/itdVXI1vlw7dFrbEo+Z8PyleysVLyqkPtUb1S+W+JbiPVx3IeqkYSdxJPmuoANi8ENy5dyU/VHbFwC15mMEPXw++NgMAfg+060g6R9imctNdDkgGtr4DYuA7csjnDFpyCUaa++Jv3eAOF53ELgeA1CAAAAAElFTkSuQmCC">
    <style>
      body, textarea {
        background: #1c1c1c;
        color: #d0d0d0;
      }
      body {
        margin: 0;
        overflow: hidden;
      }
      textarea {
        width: 100%;
        height: 100vh;
        padding: 0;
        border: none;
        resize: none;
        cursor: default;
        caret-color: transparent;
        font: 1rem monospace;
      }
      textarea:focus {
        outline: none;
      }
    </style>
  </head>
  <body>
    <textarea spellcheck="false"></textarea>
  </body>
  <script> window.onload = () => document.querySelector('textarea').focus()</script>
</html>