惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

D
Docker
I
InfoQ
L
LangChain Blog
阮一峰的网络日志
阮一峰的网络日志
Y
Y Combinator Blog
博客园_首页
Martin Fowler
Martin Fowler
宝玉的分享
宝玉的分享
A
About on SuperTechFans
Apple Machine Learning Research
Apple Machine Learning Research
Vercel News
Vercel News
T
The Blog of Author Tim Ferriss
C
Check Point Blog
B
Blog RSS Feed
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Engineering at Meta
Engineering at Meta
B
Blog
爱范儿
爱范儿
Stack Overflow Blog
Stack Overflow Blog
aimingoo的专栏
aimingoo的专栏
WordPress大学
WordPress大学
F
Fortinet All Blogs
月光博客
月光博客
GbyAI
GbyAI

jdhao's digital space

Conversion between base64 and OpenCV or PIL Image 腾讯云对象存储博客图床开启 CDN 加速(不需要购买额外域名) Search and Replace in Multiple Files in Vim/Neovim Change Table Column Width in LaTeX Image or Table Side by Side in LaTeX LaTeX 并排显示图像或表格 Content inside HTML tags missing in Latest Hugo? Creating Markdown Front Matter with Ultisnips Labelme JSON 标注格式转 voc XML 格式 Nifty Nvim Techniques That Make My Life Easier -- Series 6 macOS 下如何为视频制作字幕 Running Command Asynchronously inside Neovim Resolving Merge Conflict after Git Stash Pop Pylint: command not found? A Hands-on Experience with Neovim's Built-in LSP Support How to Convert PDF to Images with Imagemagick 互联网上常用缩略语集锦 File Backup in Neovim Converting PDF Pages to Images with Poppler Nifty Nvim Techniques That Make My Life Easier -- Series 5 Neovim Configuration for System-wide Use How to sort a list of tuple or list in Python -- lambda or itemgetter? Building A Vim Statusline from Scratch 人类第一颗原子弹爆炸始末 Distributed Training in PyTorch with Horovod Learning Expect Programming Essential Knowledge about SSH Nifty LaTeX Techniques -- Series 1 更改 Adsense 邮寄地址,重新寄送 PIN Mintty Tips and Configurations
Firenvim: Neovim inside Your Browser
2020-01-01 · via jdhao's digital space

Update log

2022-08-15: update firenvim conf; add install setting for packer.nvim

Introduction#

Last year, I have written a post on how to edit texts inside the browser using Vim/Nvim or browser extensions that have Vim emulations. However, none of them is good enough, since they are either not convenient to use or lacking features compared to real Neovim empowered by various plugins.

Firenvim is another project that aims to solve the problem and has done a great job. Thanks to Neovim’s remote UI architecture1, firenvim activate a Neovim instance in the background and acts as a remote UI client for Neovim. Thus, you can use the full power of Neovim and its plugins inside your browser without any compromises.

Install#

To use firenvim, first we need to install it as a Neovim plugin using a plugin manager, for example, with vim-plug:

Plug 'glacambre/firenvim', { 'do': { _ -> firenvim#install(0) } }

If you use packer.nvim, the following works:

use({
  "glacambre/firenvim",
  run = function() fn["firenvim#install"](0) end,
  opt = true,
  setup = [[vim.cmd('packadd firenvim')]],
})

The above setting works for Windows and Linux. For macOS, due to the reason that $PATH variable is changed inside browser, we need to run the following command on the command line:

nvim --headless -c "call firenvim#install(0, 'export PATH=\"$PATH\"')" -c quit

After that, we need to install firenvim extension for Firefox or Chrome.

Now, restart your browser. Click a text area and firenvim should be able to automatically take over the text area and start a neovim instance.

Custom settings#

Firenvim provides the variable g:started_by_firenvim when it starts a neovim instance. So you can use this variable to set conditional options and settings for firenvim. For example, set laststatus to zero, and do not show ruler, since the text area is already very small.

You can also customize the filetype created for each website, as per the doc here.

My custom settings for firenvim are as follows:

if exists('g:started_by_firenvim') && g:started_by_firenvim
  " general config for firenvim
  let g:firenvim_config = {
      \ 'globalSettings': {
          \ 'alt': 'all',
      \  },
      \ 'localSettings': {
          \ '.*': {
              \ 'cmdline': 'neovim',
              \ 'priority': 0,
              \ 'selector': 'textarea',
              \ 'takeover': 'never',
          \ },
      \ }
  \ }

  function! s:setup_firenvim() abort
    set filetype=markdown
    set noruler noshowcmd
    set laststatus=0 showtabline=0
  endfunction

  augroup firenvim
    autocmd!
    autocmd FileType text call s:setup_firenvim()
  augroup END
endif

For more configurations, check the doc on project page.

References#