Giter Site home page Giter Site logo

airlatex.vim's Introduction

AirLatex.vim

This is a fork of da-h/AirLatex.vim providing comments, track changes, and some code organization for a vim Websocket Client for Overleaf. As is, this is customized to my workflow- with no added hooks for broader customization. If you'd like to add some, please create a PR- as this is a won't fix for me.

Current State: Use at your own risk.

Warning What's the worst that can happen? Something breaks and automatically clears the buffer. You can easily recover this with the version history in overleaf, but it's still a pain, and might mess up your comment positions. This has only happened to me once when actively developing this plugin, but it's worth noting here.

I have been using this to write my thesis, so it isn't all bad.

First Use

This plugin is a bit paternalistic in its approach, since debugging multiple login methods is not sustainable. See the original AirLatex for a login workflow.

Authenticating

You should not have to reauthenticate once you have authenticated and leave the session. Both of these methods are relatively persistent.

Go H$%^k yourself

To get started, login into your OverLeaf/ShareLatex instance in Firefox. Firefox does not locally encrypt cookies, and AirLatex will Cookie Jack the session cookie to connect to the server. It's a little like hacking yourself, and a nice reminder that any program you run on your machine can do this and more. Here's the relevant code if you are interested.

Once you are logged in, set g:AirLatexCookieDB to the path to the cookie database. If you are lazy, just try:

let g:AirLatexCookieDB="~/.mozilla/firefox/*.default/cookies.sqlite"

For a custom or enterprise solution, you'll have to play with additional settings:

  • g:AirLatexCookieKey
  • g:AirLatexDomain

You will need sqlite for this

Set the cookie yourself

Log into to your instance, and take a look at your cookies. You can explicitly set the Cookie with

let g:AirLatexCookie="cookies:overleaf2_session=justanexamplestring;maybe_morecookies=1"

For details on how to check your cookies look at this issue.

Installing

With Nix

nix run github:dmadisetti/airlatex.vim#

Or add to your flake or what not. If you use nix, you know the drill.

Normal Installation

  1. Install the requirements. (python3)

    pip3 install tornado requests pynvim intervaltree beautifulsoup4
    
  2. Install the Vim Plugin itself Using Vim Plug:

    Plug 'dmadisetti/AirLatex.vim', {'do': ':UpdateRemotePlugins'}
    " Auth and settings mentioned in the documentation.
    

    Using Vundle:

    Plugin 'dmadisetti/AirLatex.vim'
    " Auth and settings mentioned in the documentation.
    

    After installation using :PluginInstall run :UpdateRemotePlugins to register the python plugin.

Launching

Open AirLatex in Vim with :AirLatex Feel free to map AirLatex to a binding of your liking, e.g.:

nmap <leader>a :AirLatex<CR>

Settings

Variable Possible Values Description
g:AirLatexDomain www.overleaf.com (default) Base url of the overleaf instance you would like to connect to.
g:AirLatexShowArchived 0 (default, off), 1 (on) Show/hide archived projects in the project list.
g:AirLatexUseHTTPS 1 (default, on), 0 (off) Choose between http/https.
g:AirLatexLogLevel NOTSET (default), DEBUG_GUI, DEBUG, INFO, WARNING, ERROR, CRITICAL Verbosity of logging.
g:AirLatexLogFile AirLatex.log (default) Log file name. (The file appears in the folder where vim has been started, but only if the log level is greater than NOTSET.)
g:AirLatexWebsocketTimeout 10 (default) Number of seconds to wait before declaring the connection as stale. This may happen if the server does not answer a request by AirLatex. Setting to "none" disables this feature. However, it can be the case that you will not notice when something is wrong with the connection.
g:AirLatexAllowInsecure 0 (default, off), 1 (on) Allow insecure connection. For example, if the server is self hosted and/or the certificate is self-signed
g:AirLatexTrackChanges 0 (default, off), 1 (on) Allow track changes to be sent.

Bindings

The following bindings are scoped to the buffers. If you'd like to customize them, please create a PR.

Buffer Binding Description
sidebar q Close buffer
sidebar enter Enter project/ Toggle folder
sidebar d, D Leave project
document visual gc Mark section for drafting a comment
document visual gt Resolve track changes under visual area
document R Refresh document, or bring back online if connection dropped.
document command :w If project is synced with github, create a new commit.
comments <C-n> Next comment (for stacked comments)
comments <C-p> Prev comment (for stacked comments)
comments ZZ Submit comment in draft
comments ZQ Quit Buffer/ discard draft
comments (insert) Start drafting a response if on thread
comments enter Un/resolve project if over the relevant option.

Recommended Bindings

Additional bindings that are nice to have, but not required for functionality.

" AirLatex Keybinds
if exists("g:AirLatexIsActive") && g:AirLatexIsActive
  nnoremap <space>n :call AirLatex_NextCommentPosition()<CR>
  nnoremap <space>p :call AirLatex_PrevCommentPosition()<CR>
  nnoremap <F2> :call AirLatexToggleTracking()<CR>
  nnoremap <C-x> :call AirLatexToggle()<CR>
  nnoremap X :call AirLatexToggleComments()<CR>
endif

Troubleshooting

If you find a bug. Feel free to open an issue! To make things a bit easier for me, please use AirLatex' debug mode (let g:AirLatexLogLevel='DEBUG').

Credits

This plugin is a complete rework of Vim-ShareLaTeX-Plugin. I took all the good ideas and added even more vim love. โฅ ;)

airlatex.vim's People

Contributors

braun-steven avatar c3r34lk1ll3r avatar da-h avatar dmadisetti avatar moetayuko avatar sbrodehl avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

airlatex.vim's Issues

Find appropo sync rate.

I think the heart beat is too slow for actual collaborative working. We need to figure out a reasonable rate, otherwise it crashes. Need to have someone (@adyotag?) edit a doc at the same time to help find a better rate.

Refresh

Leave doc and rejoin to refresh all comments and buffer in case things get too far out of wack.

Package (nix)

Package so that you can just call airlatex, opposed to having to launch

Need sqlite3 + pip deps

Comment buffer

Thought process:

user                           time
the comment and such and such
-----------------------------------
other user                 time
another reply and such and such
----------------------------------



(intentionally blank space)

Entering insert mode in a section posted by you, allows you to edit
Entering insert mode in the blank section is crafting a response. submission on save
dd resolves the comment
removing all content of a comment deletes the comment

visual mode for comment creation

Update comment intervals on edit

Using interval tree. Currently not updating interval, so highlights will get out of sync with buffer if too much editing occurs.

Github sync

GET https://www.overleaf.com/project/<project>/github-sync/status

reponse: {"enabled":true,"merge_status":"success","repo":"dmadisetti/<repo>","unmerged_branch":null}


GET https://www.overleaf.com/project/<project>/github-sync/commits/unmerged

response: {"diverged":false,"commits":[]}


Not sure if needed?

PUT https://www.overleaf.com/editingSession/<project>

Could skip to just this:

POST https://www.overleaf.com/project/<project>/github-sync/merge

payload: {message: "A commit!"}

Comment refresh issues

resolve and reopen need to refresh
new comments on the thread need to refresh
new comment should show correctly

Also issue if you directly comment on something without opening the comment buffer first, it might be full of junk.
I think this is actually a race condition

Option to Ignore comments

Sometimes I respond to a comment, but don't resolve (for discussion). It'd be nice to have an "ignore" option

Print out current users on page

We show the cursors, but it would be nice to know WHO is on the page. I think we can do this with echo, no need for more buffers

Add some e2e CI

overleaf provides some docker containers. With 5547262 I was able to test that airlatex works with these containers.

TrackChanges works, but comments do not since they require a totally difference service. No clear way of turning this one, but could still do tests for:

interaction:

  • - connect to project
  • - disconnect from project
  • - open up multiple files

Mutation

  • - addition
  • - remove
  • - replace lines
  • - w/ track changes

Deeper Cleanup

  • Buffer Base class
  • Remove nvim from session project handler
  • Doc strings
  • Change format to f strings
  • Use objects instead of dictionary responses
  • project manager requests

Firefox plugin for PDF sync

I mean. May as well use this properly. You can do editor/ PDF split mode, but they use browser channels to communicate. AirLatex -> socket -> FireFox Plugin -> PDF mode will allow this functionality from vim. Have partial prototype

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.