-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(nvim): Fix sourcegraph.nvim config
- Loading branch information
1 parent
8096aa7
commit beebe49
Showing
2 changed files
with
18 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
} |