Skip to content

Commit

Permalink
fix(nvim): Fix sourcegraph.nvim config
Browse files Browse the repository at this point in the history
  • Loading branch information
mrjones2014 committed Mar 18, 2024
1 parent 8096aa7 commit beebe49
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
1 change: 0 additions & 1 deletion nvim/lua/my/configure/completion.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
return {
'hrsh7th/nvim-cmp',
dependencies = {

{ 'saadparwaiz1/cmp_luasnip' },
{ 'hrsh7th/cmp-buffer' },
{ 'hrsh7th/cmp-path' },
Expand Down
23 changes: 18 additions & 5 deletions nvim/lua/my/configure/sourcegraph.lua
Original file line number Diff line number Diff line change
@@ -1,18 +1,31 @@
return {
'sourcegraph/sg.nvim',
dependencies = { 'mrjones2014/op.nvim' },
keys = {
{
'<leader>co',
function()
-- just load it to get cmp completions from cody
require('sg')
end,
desc = 'Load sourcegraph.nvim plugin',
},
},
config = function()
local output = require('op').get_secret('yz4q4rfnfzsvikdx4ppsze4tti', 'token,endpoint')
if output then
error('Failed to get Sourcegraph token from 1Password')
local secret, stderr = require('op').get_secret('yz4q4rfnfzsvikdx4ppsze4tti', 'token,endpoint')
if not secret then
error(string.format('Failed to get Sourcegraph token from 1Password\n%s', stderr))
end
local secrets = vim.split(output, ',')
local secrets = vim.split(secret, ',')
local token = secrets[1]
local endpoint = secrets[2]
vim.env.SRC_ENDPOINT = endpoint
vim.env.SRC_ACCESS_TOKEN = token
require('sg').setup({
enable_cody = false,
enable_cody = true,
})
local cmp = require('cmp')
local config = cmp.get_config()
table.insert(config.sources, { name = 'cody' })
end,
}

0 comments on commit beebe49

Please sign in to comment.