Skip to content

raghur/vim-ghost

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

g:ghost_enable_sync (default: 1)

:GhostToggleSync
:GhostSync

By default, Ghost synchronizes the content of the Vim buffer with the browser's textarea (normal behavior). If ghost_enable_sync is set to 0, Ghost only updates the textarea when the :GhostSync command is issued. While editing, :GhostToggleSync may be used to disable / enable syncing.

The purpose of this modification is to allow the user to control exactly when the textarea should receive an update. This was done specifically for Discourse forums, in which other forum users can see someone is in the process of replying. Discourse does not allow users to disable this. Using vim-ghost with syncing disabled, nobody on a Discourse forum is made aware that a reply is being typed until the very last syncing of the reply's textarea.

Co-authored-by: Pierre Coupard <pierre.coupard@noptel.fi>
115e260

Git stats

Files

Permalink
Failed to load latest commit information.

Vim Ghost

Edit browser textarea content in Vim/Neovim!

demo
  1. Install this firefox addon or this Chrome extension

  2. Add this plugin

    " Vim-plug
    Plug 'raghur/vim-ghost', {'do': ':GhostInstall'}
  3. Ensure you have a vim/neovim instance open. Run :GhostStart to start the server.

  4. On any textarea, click the ghost icon - switch to neovim and edit!. Content is sync’ed real time. Works both ways - edits in the browser window are pushed to neovim as well.

  5. When done, just delete the buffer with :bd! - you’ll be disconnected

Configuring filetype

Whenever a buffer is connected, a User event vim-ghost#connected is raised. Here’s a quick sample of setting filetype to markdown if the textarea was on github or reddit

function! s:SetupGhostBuffer()
    if match(expand("%:a"), '\v/ghost-(github|reddit)\.com-')
        set ft=markdown
    endif
endfunction

augroup vim-ghost
    au!
    au User vim-ghost#connected call s:SetupGhostBuffer()
augroup END

Requirements

additional requirements for vim

" Only enabled for Vim 8 (not for Neovim).
Plug 'roxma/nvim-yarp', v:version >= 800 && !has('nvim') ? {} : { 'on': [], 'for': [] }
Plug 'roxma/vim-hug-neovim-rpc', v:version >= 800 && !has('nvim') ? {} : { 'on': [], 'for': [] }

Auto switching to vim:

Optional, but highly recommended - Switching focus to Neovim
  • Linux: The xdotool command - if available, will be used to focus the nvim window. Works in console, tmux or guis like neovim-qt

    • On Ubuntu, you can install it with sudo apt-get install xdotool

  • macOS: Set the g:ghost_darwin_app variable to the name of your app (see docs).

  • Windows: If pywinauto (https://github.com/pywinauto/pywinauto) is available, it will be used to bring the neovim-qt to foreground.

    # Ensure that you install this module for the version of python
    # that is loaded in neovim
    pip install pywinauto

    Limitations: Currently, on windows, the processname is hardcoded to nvim-qt If you use any of the other GUIs for neovim (OniVim, gonvim etc) then this will not work.

Rationale

With Firefox moving to webextensions, It’s all text is dead. Typing in text areas is a royal PITA and I was looking for a replacement. Came across GhostText - but the vim addon seems dead and uses tcl :ugh:

My vimscript fu is pretty limited - so I thought I’d write a python plugin for neovim.

TODOS

PR’s welcome. Some areas:

  • vim compatibility - DONE

Love it or just find it as useful as I do? Star this repo to let me know

About

Vim/Nvim client for GhostText - Edit browser text areas in Vim/Neovim

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published