- Notifications
You must be signed in to change notification settings - Fork2
Google docs integration for vim
License
Aadv1k/gdoc.vim
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Google docs integration for vim/neovim.
- Sync a local file to google docs
- Delete the google doc from google drive
- Download the contents of the document to your local file
- Upload the contents of your local file to it's google doc
- Fetch remote document by their IDs and save them locally
Make sure you have the following
- python >= 3.6 (including pip)
- vim 8+ with python3+
- for neovim users pynvim (
pip install pynvim
)
Plug'aadv1k/gdoc.vim', {'do':'./install.py'}" For the dev branchPlug'aadv1k/gdoc.vim', {'do':'./install.py','branch':'dev'}
use {'aadv1k/gdoc.vim',run='./install.py'}-- For the dev branchuse {'aadv1k/gdoc.vim',run='./install.py',branch='dev'}
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 activatedrive api
(to create documents) andgoogle docs
(to edit/write documents) api fromGoogle api dashboard
After this, you need to download credentials, do the steps necessary to setup a consent screen and anoAuth login, then download the credentials and place them anywhere you like. Then put the path ofthe credentials in theg: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.
letg:path_to_creds='/some-path/some-credentials-file.json'" Defaults to '~/.vim/credentials.json'letg:gdoc_file_path='/some-directory'" Defaults to '~/.vim/'letg: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 throughos.path.expanduser()
in python.
g:token_directory
is where token for your api should live, if you don'twant the oAuth screen to pop-up everytime, you should set a standard directoryto place the token.g:gdoc_file_path
is the directory where the.gdoc
file is placed, this fileis used to map local files to their corresponding document in the drive
This plugin creates a file called
.gdoc
which is placed in a folder you can specify viag: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
Command | Function | Description |
---|---|---|
: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 write | gdoc#WriteDoc() | Write your current file to a google doc with the same name |
:Gdoc sync | gdoc#Sync() | Upload the changes in your local file to google doc |
:Gdoc sync-doc | gdoc#SyncDoc() | Download the changes in google doc to local file |
:Gdoc rm | gdoc#RmDoc() | Delete the google document associated with the local file from google drive. |