5 Commits
6 changed files with 178 additions and 132 deletions
-2
View File
@@ -5,7 +5,6 @@
"dressing.nvim": { "branch": "master", "commit": "2d7c2db2507fa3c4956142ee607431ddb2828639" }, "dressing.nvim": { "branch": "master", "commit": "2d7c2db2507fa3c4956142ee607431ddb2828639" },
"fidget.nvim": { "branch": "main", "commit": "889e2e96edef4e144965571d46f7a77bcc4d0ddf" }, "fidget.nvim": { "branch": "main", "commit": "889e2e96edef4e144965571d46f7a77bcc4d0ddf" },
"friendly-snippets": { "branch": "main", "commit": "6cd7280adead7f586db6fccbd15d2cac7e2188b9" }, "friendly-snippets": { "branch": "main", "commit": "6cd7280adead7f586db6fccbd15d2cac7e2188b9" },
"fzf-lua": { "branch": "main", "commit": "64590411e6cf3d603d1e1bdad3a3d051f2f5a91a" },
"gitsigns.nvim": { "branch": "main", "commit": "dd3f588bacbeb041be6facf1742e42097f62165d" }, "gitsigns.nvim": { "branch": "main", "commit": "dd3f588bacbeb041be6facf1742e42097f62165d" },
"gruvbox.nvim": { "branch": "main", "commit": "154eb5ff5b96d0641307113fa385eaf0d36d9796" }, "gruvbox.nvim": { "branch": "main", "commit": "154eb5ff5b96d0641307113fa385eaf0d36d9796" },
"harpoon": { "branch": "harpoon2", "commit": "87b1a3506211538f460786c23f98ec63ad9af4e5" }, "harpoon": { "branch": "harpoon2", "commit": "87b1a3506211538f460786c23f98ec63ad9af4e5" },
@@ -28,7 +27,6 @@
"nvim-ufo": { "branch": "main", "commit": "ab3eb124062422d276fae49e0dd63b3ad1062cfc" }, "nvim-ufo": { "branch": "main", "commit": "ab3eb124062422d276fae49e0dd63b3ad1062cfc" },
"nvim-web-devicons": { "branch": "master", "commit": "4fc505ac7bd7692824a142e96e5f529c133862f8" }, "nvim-web-devicons": { "branch": "master", "commit": "4fc505ac7bd7692824a142e96e5f529c133862f8" },
"oil.nvim": { "branch": "master", "commit": "0fcc83805ad11cf714a949c98c605ed717e0b83e" }, "oil.nvim": { "branch": "master", "commit": "0fcc83805ad11cf714a949c98c605ed717e0b83e" },
"parrot.nvim": { "branch": "main", "commit": "5d7e72bdc3efe2638e1bd94ff55028ecc40edd7a" },
"plenary": { "branch": "master", "commit": "74b06c6c75e4eeb3108ec01852001636d85a932b" }, "plenary": { "branch": "master", "commit": "74b06c6c75e4eeb3108ec01852001636d85a932b" },
"plenary.nvim": { "branch": "master", "commit": "74b06c6c75e4eeb3108ec01852001636d85a932b" }, "plenary.nvim": { "branch": "master", "commit": "74b06c6c75e4eeb3108ec01852001636d85a932b" },
"promise-async": { "branch": "main", "commit": "119e8961014c9bfaf1487bf3c2a393d254f337e2" }, "promise-async": { "branch": "main", "commit": "119e8961014c9bfaf1487bf3c2a393d254f337e2" },
+1
View File
@@ -91,6 +91,7 @@ return {
filetypes = { 'yaml', 'yaml.gitlab' }, filetypes = { 'yaml', 'yaml.gitlab' },
settings = { settings = {
yaml = { yaml = {
customTags = { "!reference sequence" },
schemaStore = { enable = false }, schemaStore = { enable = false },
schemas = { schemas = {
['https://gitlab.com/gitlab-org/gitlab-foss/-/raw/master/app/assets/javascripts/editor/schema/ci.json'] = { ['https://gitlab.com/gitlab-org/gitlab-foss/-/raw/master/app/assets/javascripts/editor/schema/ci.json'] = {
-50
View File
@@ -1,50 +0,0 @@
return {
'frankroeder/parrot.nvim',
version = '2.5.1',
dependencies = { 'ibhagwan/fzf-lua', 'nvim-lua/plenary.nvim' },
config = function()
local parrot_opts = {
providers = {
anthropic = {
name = 'anthropic',
endpoint = 'https://api.anthropic.com/v1/messages',
model_endpoint = 'https://api.anthropic.com/v1/models',
api_key = { 'sops', '--config', '/dev/null', '-d', vim.fn.expand('$HOME') .. '/.claude-api' },
headers = function(self)
return {
['Content-Type'] = 'application/json',
['x-api-key'] = self.api_key,
['anthropic-version'] = '2023-06-01',
}
end,
params = {
chat = { max_tokens = 4096 },
command = { max_tokens = 4096 },
},
models = {
'claude-opus-4-6',
'claude-sonet-4-5',
'claude-haiku-4-5',
},
preprocess_payload = function(payload)
for _, message in ipairs(payload.messages) do
message.content = message.content:gsub('^%s*(.-)%s*$', "%1")
end
if payload.messages[1] and payload.messages[1].role == 'system' then
-- remove the first message that serves as the system prompt as anthropic
-- expects the system prompt to be part of the API call body and not the messages
payload.system = payload.messages[1].content
table.remove(payload.messages, 1)
end
return payload
end,
}
},
user_input_ui = 'buffer',
}
local parrot = require('parrot')
parrot.setup(parrot_opts)
end
}
+4
View File
@@ -45,3 +45,7 @@ vim.keymap.set("n", "<C-M-k>", "<cmd>cprev<CR>")
vim.keymap.set("n", "<F12>", "<cmd>PrtChatToggle<CR>") vim.keymap.set("n", "<F12>", "<cmd>PrtChatToggle<CR>")
vim.keymap.set('n', '<leader>cp', function()
vim.fn.setreg('+', vim.fn.expand('%'))
end, { desc = 'Copy file path' })
+93
View File
@@ -0,0 +1,93 @@
local M = {}
--- @class SopsRunner
--- @field config SopsConfig
--- @field run fun(self: SopsRunner, args: table, envs: table): string|nil, string|nil a simple run, accepts a list of arguments
--- @field to_table fun(self: SopsRunner, file: string): table|nil, string|nil convert structured file to lua table
--- @field decrypt fun(self: SopsRunner, file: string, args: table?): string|nil, string|nil decrypt encrypted file
--- @field debug fun(self: SopsRunner): nil
--- @class SopsConfig
--- @field sops_bin? string
--- @field extra_args? table
--- @param opts SopsConfig
--- @return SopsRunner
M.create_runner = function (opts)
opts = opts or {}
opts.sops_bin = opts.sops_bin or 'sops'
opts.extra_args = opts.extra_args or {}
local runner = {
config = {
sops_bin = opts.sops_bin or 'sops',
extra_args = opts.extra_args or {}
} --[[@as SopsConfig]]
}
--- Generic runner
--- @param self SopsRunner
--- @param args table
--- @param envs table|nil
--- @return string|nil, string|nil
function runner:run(args, envs)
envs = envs or {}
local command = {self.config.sops_bin}
vim.list_extend(command, self.config.extra_args)
vim.list_extend(command, args)
local result = vim.system(command, {text = true, env = envs}):wait()
if result.code ~= 0 then
return nil, "Command returned non-zero exit code: " .. result.stderr
end
return result.stdout, nil
end
function runner:decrypt(file, extra_args)
extra_args = extra_args or {}
local run_args = {}
vim.list_extend(run_args, extra_args)
table.insert(run_args, '-d')
table.insert(run_args, file) -- a separate call to ensure that file is always passed the last
return self:run(run_args)
end
function runner:debug()
local edit_script = vim.fn.fnamemodify('scripts/editor.sh', ':p')
vim.print(edit_script)
end
function runner:edit(file, extra_args)
extra_args = extra_args or {}
local edit_script = vim.fn.fnamemodify('scripts/editor.sh', ':p')
vim.print(edit_script)
local edit_args = {}
vim.list_extend(edit_args, extra_args)
table.insert(edit_args, 'edit')
table.insert(edit_args, file)
return self:run(edit_args, {EDITOR="./scripts/editor.sh"})
end
function runner:to_table(file)
local expanded_file = vim.fn.fnamemodify(file, ':p')
local result, err = self:decrypt(expanded_file, {'--output-type', 'json'})
if err then
return nil, 'Failed converting to json: ' .. err
end
return vim.fn.json_decode(result), nil
end
return runner --[[@as SopsRunner]]
end
return M