codota / tabnine-nvim

Tabnine Client for Neovim
https://tabnine.com
324 stars 31 forks source link

[FEATURE] Supply auth_cmd #176

Open erichlf opened 2 weeks ago

erichlf commented 2 weeks ago

Is your feature request related to a problem? Please describe. My development environment is in docker containers and so every time I restart a docker container I have to re-authorize tabnine. It would be nice if there could be an automated way to authorize the tabnine plugin.

Describe the solution you'd like Add the ability to supply an auth_cmd where the output of this command is a string containing the authorization token. I tend to store authorization tokens and api keys in gnu pass and so one possible command would be pass show tabnine/auth_token. But this command could be anything that results in a string that is the auth token.

Describe alternatives you've considered I would consider most anything that makes it where I don't have to manually enter the auth token. However, solutions like storing in an environment variable should be avoided.

amirbilu commented 2 weeks ago

@erichlf are you referring to api keys given to old pro users?

erichlf commented 2 weeks ago

Sorry I mean AUTH Token. I have corrected the description.

amirbilu commented 2 weeks ago

The auth token lives for 1 hour so this won't work. What other plugins do?

amirbilu commented 2 weeks ago

A nice workaround could be to mount ~/.config/TabNine. Assuming you're logged-in in the host

erichlf commented 2 weeks ago

That is good to know.

amirbilu commented 1 week ago

Does it work for you?

erichlf commented 1 week ago

I have to figure out why when I bind mount the directory, or use it as a volume it becomes owned by root and I don't have permissions to do anything with it.

erichlf commented 1 week ago

The issue is that ~/.config doesn't already exist in the container and so when ~/.config/TabNine is mounted it will then create the ~/.config directory giving to root ownership, which then breaks all sorts of other things that I have going on that depends on that directory having non-root ownership. What I do as a workaround is that put the following in my dotfiles setup script:

if [[ -d $HOME/.config && ! $(stat -c "%U" $HOME/.config) == "$(whoami)" ]]; then
  sudo chown $UID $HOME/.config 
fi

Once I got the permissions fixed then I was able to get neovim up and running and then I saw that tabnine was working.