Home

Awesome

Gdoc.vim

Google docs integration for vim/neovim.

Features

Installation

Make sure you have the following

vim-plug

Plug 'aadv1k/gdoc.vim', {'do': './install.py'}
" For the dev branch
Plug 'aadv1k/gdoc.vim', {'do': './install.py', 'branch': 'dev'}

packer.nvim

use {'aadv1k/gdoc.vim', run = './install.py'}
-- For the dev branch
use {'aadv1k/gdoc.vim', run = './install.py', branch = 'dev'}

Initializing the app

For this to work, you need to have a google account, then you need to create a new google cloud project. Creating a google cloud project

Then to use the app, you have to activate drive api (to create documents) and google docs (to edit/write documents) api from Google api dashboard

After this, you need to download credentials, do the steps necessary to setup a consent screen and an oAuth login, then download the credentials and place them anywhere you like. Then put the path of the credentials in the g:path_to_creds.

In the example below, credentials.json is placed in ~/.vim you can use any valid credential file, and put it's path here.

let g:path_to_creds = '/some-path/some-credentials-file.json' " Defaults to '~/.vim/credentials.json'
let g:gdoc_file_path = '/some-directory'                      " Defaults to '~/.vim/'
let g:token_directory = '/some-directory'                     " Defaults to '~/.vim/'

[NOTE]: Directories specified must exist - they will not be created by this plugin.

These paths will be valid both on windows and unix as they are passed through os.path.expanduser() in python.

Usage

This plugin creates a file called .gdoc which is placed in a folder you can specify via g:gdoc_file_path by default it is made in every directory you execute :Gdoc write. .gdoc is used to keep track of the local files and their documents(ids). It does so using the following format {full_file_path} -> {file_id}\n

CommandFunctionDescription
:Gdoc fetch-doc <id>gdoc#FetchDoc(doc_id)Tries to find a document with the specified id, if found then saves it to the current buffer and adds an entry to .gdoc
:Gdoc writegdoc#WriteDoc()Write your current file to a google doc with the same name
:Gdoc syncgdoc#Sync()Upload the changes in your local file to google doc
:Gdoc sync-docgdoc#SyncDoc()Download the changes in google doc to local file
:Gdoc rmgdoc#RmDoc()Delete the google document associated with the local file from google drive.