Aadv1k / gdoc.vim

Google docs integration for vim
GNU General Public License v3.0
78 stars 2 forks source link

No module named google #4

Open ostap-tymchenko opened 9 months ago

ostap-tymchenko commented 9 months ago

Hello! I really like the idea of this plugin but I cant get it to work. The issue im getting seems to be something allot the lines of "No module named google"

image

The security token looks like this, Im not sure if I downloaded the right one, as the instructions in the readme are very vague.

obfuscated

System info:

Operating System: Fedora Linux 39 KDE Plasma Version: 5.27.10 KDE Frameworks Version: 5.111.0 Qt Version: 5.15.11 Kernel Version: 6.6.9-200.fc39.x86_64 (64-bit) Graphics Platform: Wayland Processors: 12 × AMD Ryzen 5 7640U w/ Radeon 760M Graphics Memory: 14.8 GiB of RAM Graphics Processor: AMD Radeon Graphics Manufacturer: Framework Product Name: Laptop 13 (AMD Ryzen 7040Series) System Version: A5

with nvim version:

NVIM v0.9.4 Build type: RelWithDebInfo LuaJIT 2.1.1692716794 Compilation: /usr/bin/gcc -O2 -g -Og -g -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wvla -Wdouble-promotion -Wmissing-noreturn -Wmissing-format-attribute -Wmissing-prototypes -fno-common -Wno-unused-result -Wimplicit-fallthrough -fdiagnostics-color=auto -fstack-protector-strong -DUNIT_TESTING -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -I/usr/include/luajit-2.1 -I/usr/include -I/usr/include/luv -I/builddir/build/BUILD/neovim-0.9.4/redhat-linux-build/src/nvim/auto -I/builddir/build/BUILD/neovim-0.9.4/redhat-linux-build/include -I/builddir/build/BUILD/neovim-0.9.4/redhat-linux-build/cmake.config -I/builddir/build/BUILD/neovim-0.9.4/src -I/usr/include -I/usr/include -I/usr/include -I/usr/include -I/usr/include -I/usr/include -I/usr/include

system vimrc file: "$VIM/sysinit.vim" fall-back for $VIM: "/usr/share/nvim"

Run :checkhealth for more info

Aadv1k commented 9 months ago

So the apparently the version for google-api-python-client and google_auth_oauthlib seemed to be out of date. I simply ran pip3 install --upgrade and froze the changes to the requirements file. Rest everything looks good on your side

I also want to say thank you for showing interest in this little project of mine. I am unable to frequently update it since I have moved onto using emacs, but I will continue to implement any changes features as issues come up.

I apologize if the documentation was a bit confusing, frankly the whole process of creating credentials is confusing and I found this video https://www.youtube.com/watch?v=j1mh0or2CX8 to be very helpful

ostap-tymchenko commented 9 months ago

I GOT IT TO WORK! Oh man, I was not expecting this to work. My school uses a lot of Google Docs, and hopefully being able to use vim makes things easier. Is there any way currently to downloading and editing existing Google Docs?

Aadv1k commented 9 months ago

Hey! glad it worked for you.

Unfortunately no as stated in #2, We are handling the files in a "local-first" manner, eg your local files are associated with their remote counterparts and kept up-to-date. I currently don't see a way to implement this feasably, Some potential options in mind:

If you have any suggestions I will be happy to continue this discussion. thanks, and have a good day. Cheers!

ostap-tymchenko commented 9 months ago

Yeah, those sound feasible, is that difficult to implement? Honestly, I would be happy with either of the Implementations.

Aadv1k commented 9 months ago

Let me see what I can do!

ostap-tymchenko commented 9 months ago

Well, let me know if i can help in any way. Most of my experience is in rust python and lua, so not sure I can help, but If you have anything I can do for you I can submit a PR.

Aadv1k commented 9 months ago

I really appreciate that Ostap! Will keep that in mind (b ^ ^)b

ostap-tymchenko commented 9 months ago

Hi, Just call me Ari. As far as i understand, the most important part of the code looks like this:

query = doc_query(creds_path, token_path, gdoc_path)

" Opening
query.open_doc_from_file(target_file_path)

And then everything else is basic logic and different methods on query. Honestly, I have 0 experience with vim script, so I'm happy I can tell this much.

So what is your plan for how to implement this? I was thinking the simplest way might be a function to open by id + a function to list the most recent X documents in your gdocs with their ids.

Also, theirs a bug where if you save a new gdoc as an empty file it errors out, but saves it, and if you try to write in it in Neovim and save it then it just doesn't work until you add something to the gdoc from the website, I can make a bug report for it later (and probablty make a pr for it if i can figure out a testing env).

Aadv1k commented 9 months ago

Alright, Done! I added a new command :Gdoc fetch-doc, it can be used like so

:Gdoc fetch-doc 1_mfbkR3FQeAaqEbDuqggk7j1RyS9hHeyeftBRXMCwrA and it will load the document with the id, put it in the current buffer, SAVE the current buffer and then add it to .gdoc hence you will be able to perform all the other actions on it

ostap-tymchenko commented 9 months ago

Oh man that was fast. How do you get the id of a google doc?

Aadv1k commented 9 months ago

image

I got it from the URL bar, it looked like the most straightforward approach, atleast for now

ostap-tymchenko commented 9 months ago

Makes sense. Is it working on your end? For me when I try to download one I get this: image And when I try to do something like write I get this: image

Aadv1k commented 9 months ago

Well, embarassing as it is, I messed up. In my haste I apparently messed up some white-space indentation. You may wanna run PlugUpdate sorry! (if that doesn't work, try re-instaling the plugin completely, I really apologize for the mess-up, hope you understand)

Aadv1k commented 9 months ago

Yeah, that seemed like the only issue. It seems I have gotten a bit rusty in vimscript! I might develop something similar for emacs too 🤔

ostap-tymchenko commented 9 months ago

Hey, Im still getting errors when I try to write: image

Or when fetching: image

I tried a few different docs and the id is defenetly right.

Is it working for you?

Aadv1k commented 9 months ago

well, I don't know what's going on. I assume you have already set

vim.g.path_to_creds = '~/.vim/credentials.json'
vim.g.gdoc_file_path = '~/.vim/' 
vim.g.token_directory = '~/.vim/'

(I am using lua so bit different)

In thase case, I would fully remove the package (comment the line out, clean the directory, re-install) if that doesn't help either then let me know. currently it does work on my end

ostap-tymchenko commented 9 months ago

can i see how you did it with lua? atm i just have it as vim code in a lua file. I have to go deal with other things now but later I can reset it and say how it turns out.

Aadv1k commented 9 months ago

What I mean, is if you are using vim-plug you want to first remove the Plug 'aadv1k/gdoc.vim' line, then run PlugClean, then re-add the line.

I think I miscommunicated, this is my config. I use both vim, and neovim hence slightly differnt configs.

let g:path_to_creds = '~/.vim/credentials.json'
let g:gdoc_file_path = '~/.vim/'
let g:token_directory = '~/.vim/'

rest everything is as-it-is

ostap-tymchenko commented 9 months ago

This is my setup, Does this look right? Im reinstalling the extention now. image

ostap-tymchenko commented 9 months ago

Im still getting issues. Is it possible for you to reinstall the extension and see if it is working? What I tried: "Gdoc fetch-doc ID" in a blank doc. Result: image Gdoc write: image

Aadv1k commented 9 months ago

Well you are right, it does crash. removing the .gdoc fixes the :Gdoc write crash. The issue seems to be in some kind of a mismatch in the ids and the files

Now as for being unable to fetch, make sure the document id you are picking up is created under the same account you gave the OAuth access with, I made this mistake and was stuck.

Again, I am on this issue and will try my best to fix it as soon as I can. Let me know if that works

Aadv1k commented 9 months ago

This is my setup, Does this look right? Im reinstalling the extention now. image

Yes looks good, a side-note if you are using lua, you can simply set variables like vim.g for global variables and vim.opt for options such as vim.opt.numbers = true just a quick tip :D