I cannot get cody commands
wakywayne opened this issue · comments
I was unable to login using the :sourcegraphlogin command so I had to use the sourcegraphlogin! command with a token. I am able to get source graph search to work it seems, but I am unable to get any code completion or Cody commands.
Here is my config:
local status_ok, lsp_installer = pcall(require, "nvim-lsp-installer")
if not status_ok then
return
end
local status_ok_2, sg = pcall(require, "sg")
if not status_ok_2 then
return
end
sg.setup {
on_attatch = require("user.lsp.handlers").on_attach,
enable_cody = true
-- Configuration Options: ~
-- {enable_cody} (boolean?) Enable/disable cody integration
-- {accept_tos} (boolean?) Accept the TOS without being prompted
-- {download_binaries} (boolean?) Default true, download latest release
-- from Github
-- {node_executable} (string?) path to node executable
-- {skip_node_check} (boolean?) Useful if using other js runtime
-- {cody_agent} (string?) path to the cody-agent js bundle
-- {on_attach} (function?) function to run when attaching to
}
I have a similar problem, I also can't get cody autocompletions anymore. It worked for me until a couple of days ago. However in my case the cody chat stuff works, it's only the autocompletions that have stopped working. I use the cmp completion thing, but no matter what file context I try, there are no autocompletions from cody anymore
@wakywayne Do you have Cody set as a completion source in your cmp
setup?
local cmp = require('cmp')
cmp.setup({
-- Sources for autocomplete
sources = cmp.config.sources({
{ name = 'cody' },
-- The rest of your sources
}),
})
@jgero The Cody Pro trial ended on the 21st, so if you were using that and got switched back to the free version, you may have hit your limit.
@jgero no, I didn't. I will have to try that. Thank you. Previously I had passed in my LSP on attach function, but that actually was making it not work at all. So then I stopped doing that and then just invoked the function without passing any on_attached. Is that a mistake on my part?
@jgero are you able to get Cody to understand the context of your project?
@wakywayne Yes Cody understands the context, I can pass in lines, it understands the context and pulls context from even more files
@Kolkhis I know the trial ended, I have bought Pro even before the trial period was over, it worked before for me. I tried debugging a bit and if I trigger the autocompletions manually if I get responses they are emty (no entries in the "items" key in the table). Is the empty items entry a "symptom" of hitting the limit? Should I maybe contact support about my subscription?
@Kolkhis I know the trial ended, I have bought Pro even before the trial period was over, it worked before for me. I tried debugging a bit and if I trigger the autocompletions manually if I get responses they are emty (no entries in the "items" key in the table). Is the empty items entry a "symptom" of hitting the limit? Should I maybe contact support about my subscription?
@jgero I'm not sure what hitting the limit looks like, I'd imagine Cody will just stop suggesting things when the limit is reached.
I'd try running :checkhealth sg
, it should show you the current limits and usage of your account. I'd also recommend logging into your sourcegraph account on their website and checking in the dashboard that your Cody Pro status is enabled.
If everything looks right, I'd definitely contact support.
I don't see any mentions of limits in the checkhealth and on the dashboard it says I'm on the pro subscription plan, so I guess contacting sourcegraph support is my only option
@jgero good luck I have been waiting for a response in there discord for two days
Okay I just logged into my other PC on which I use IntelliJ, and there I get the autosuggestions 🤔 Then I guess it has to be something somewhere in the neovim plugin. How would I go with debugging that?
sg: require("sg.health").check()
sg.nvim report ~
- Machine: x86_64, sysname: Linux
- OK Valid nvim version: table: 0x7ffff44e41e0
- WARNING Unable to find valid cargo executable. Trying to build sg.nvim locally will fail. Instead use `:SourcegraphDownloadBinaries`
- OK Found `sg-nvim-agent`: "/nix/store/m46gr9q825ysa0l1jn1p7kl0q392yvff-vim-pack-dir/pack/myNeovimPackages/start/sg.nvim/target/debug/sg-nvim-agent"
- OK Found `node` (config.node_executable) is executable.
Version: '20.11.1'
- OK Found `cody-agent`: /nix/store/m46gr9q825ysa0l1jn1p7kl0q392yvff-vim-pack-dir/pack/myNeovimPackages/start/sg.nvim/dist/cody-agent.js
- Auth strategy order: { "environment-variables", "nvim", "cody-app" }
- OK Authentication setup correctly ("nvim")
- OK endpoint set to: https://sourcegraph.com
- OK Sourcegraph Connection info: {
access_token_set = true,
endpoint = "https://sourcegraph.com",
sg_nvim_version = "0.2.7",
sourcegraph_version = {
build = "263329_2024-02-27_5.3-87a310bc060c",
product = "263329_2024-02-27_5.3-87a310bc060c"
}
}
- OK Found correct binary versions: "0.2.7" = "0.2.7"
- OK sg.nvim is ready to run
I updated to the newest version of the plugin in nixpkgs, and now I have the same problem as @wakywayne. Sourcegraph search works, but no cody commands or completions:
sg: require("sg.health").check()
sg.nvim report ~
- Machine: x86_64, sysname: Linux
- OK Valid nvim version: table: 0x7f1067d7acf0
- OK Found `cargo` (cargo 1.73.0) is executable
- Use `:SourcegraphDownloadBinaries` to avoid building locally.
- OK Found `sg-nvim-agent`: "/nix/store/2p04ma8rf1jdjs944r356zq6b2lz8d3a-vim-pack-dir/pack/myNeovimPackages/start/sg.nvim/target/debug/sg-nvim-agent"
- OK Found `node` (config.node_executable) is executable.
Version: '21.2.0'
- OK Found `cody-agent`: /nix/store/2p04ma8rf1jdjs944r356zq6b2lz8d3a-vim-pack-dir/pack/myNeovimPackages/start/sg.nvim/dist/cody-agent.js
- OK Authentication setup correctly
- OK endpoint set to: https://sourcegraph.com
- OK Found correct binary versions: "1.0.8" = "1.0.8"
- OK Sourcegraph Connection info: {
access_token_set = true,
endpoint = "https://sourcegraph.com",
sg_nvim_version = "1.0.8",
sourcegraph_version = {
build = "263329_2024-02-27_5.3-87a310bc060c",
product = "263329_2024-02-27_5.3-87a310bc060c"
}
}
- To manage your Cody Account, navigate to: https://sourcegraph.com/cody/manage
- OK Cody Account Information: {
chat_limit = 0,
chat_usage = 27,
code_limit = 0,
code_usage = 355,
cody_pro_enabled = true,
username = "mail-wltvz"
}
- OK sg.nvim is ready to run
I created myself a keybinding to manually trigger the autocompletion and print the result. The callback receives an empty table and if I check :messages
I see
Unable to get token and/or endpoint for sourcegraph. Use
:SourcegraphLogin
or:help sg
for more information
I guess this is some kind of NixOS issue since it seems like the checkhealth command has access to the env variables. How would I go about debugging where they get lost?
Also I will say having to pay for two separate services isn't a permanent solution.
@wakywayne There's no way to switch the model that you're using with the Neovim plugin yet, afaik...
Hm but since it prints a message that it can't get the token and/or endpoint I don't think it's related to the AI behind it. @wakywayne maybe you could also try this keybinding and see if you get the same message about the auth token?
local cody = require("sg.cody.commands")
local map = function(mode, keys, func, desc)
if desc then
desc = "CODY: " .. desc
end
vim.keymap.set(mode, keys, func, { desc = desc })
end
map("n", "<leader>ac", function ()
local request = {}
request.row, request.col = unpack(vim.api.nvim_win_get_cursor(0))
request.filename = vim.api.nvim_buf_get_name(vim.api.nvim_get_current_buf())
cody.autocomplete(request, function (data)
vim.print(data)
end)
end, "[a]sk cody to auto[c]omplete")
Or maybe I'm doing the autocomplete wrong?
@jgero is your problem authenticating or getting Cody to view the scope of your project?
Unclear, since my checkhealth
says the authentication works
I am going to close this issue with the comment I stiil cannot get Cody to work in regards to understanding my projects context, which is their main selling point... I hope that they can start paying more support people and/or at the very least make documentation that describes troubleshooting steps better. Anyways...
Solution to Original Question:
If you are using linux... in your .bashrc file, which can be found with ls -a
and then opened with vim .bashrc
add the following at the bottom(optional)
// SUPER UNSPECIFIC VARIABLE NAMES SHOULD PROBABLLY INCLUDE SOURCEGRAPH IN THE NAME
export SRC_ENDPOINT=https://sourcegraph.com/
export SRC_ACCESS_TOKEN=yourToken