feat: Adds leaf autocommand to set the filetype to html for better highlight groups.

This commit is contained in:
2025-01-05 13:14:26 -05:00
parent 15b1aded69
commit 95139d50ba
3 changed files with 31 additions and 14 deletions

View File

@@ -15,11 +15,6 @@
[color]
ui = true
[filter "lfs"]
clean = git-lfs clean -- %f
smudge = git-lfs smudge -- %f
process = git-lfs filter-process
required = true
[credential]
helper = gopass

View File

@@ -33,6 +33,14 @@ createCmd("BufWritePre", {
group = vim.api.nvim_create_augroup("GoFormat", defaultGroupOptions),
})
-- Leaf
createCmd({ "BufRead", "BufNewFile" }, {
pattern = "*.leaf",
callback = function()
vim.opt.filetype = "html"
end,
})
vim.api.nvim_exec2(
[[
autocmd BufNewFile,BufRead /private/**/gopass** setlocal noswapfile nobackup noundofile shada=""

View File

@@ -4,6 +4,7 @@
local api_key="${OPENAI_API_KEY}"
local debug="${DEBUG}"
local outputFile="/tmp/output.json"
function usage() {
cat << EOF
@@ -45,11 +46,18 @@ function makeGptInput {
echo $(jq --null-input \
--arg model "$1" \
--arg question "$2" \
'{ "model": $model, "messages": [{"role": "system", "content": "You are such a helpful assistant!" }, {"role": "user", "content": $question}] }')
'{
"model": $model,
"messages": [
{ "role": "system", "content": "You are such a helpful assistant!" },
{ "role": "developer", "content": "You message data is escaped properly to parse as JSON, including escaping newline characters." },
{ "role": "user", "content": $question }
]
}')
}
function getGptOutput {
echo "$1" | jq '.["choices"][0]["message"]["content"]'
echo "$1" | jq -r '.choices[].message.content'
}
function askGpt {
@@ -99,17 +107,23 @@ debug_print "Input: $input"
# Get the chat-gpt output.
local output="$(askGpt $api_key $input)"
debug_print "Full ouptput: $(echo $output | jq '.[]')"
# TODO: Remove.
echo "$output" > "$outputFile"
debug_print "Full ouptput: $(echo $output | jq '.')"
# If json option is specified, then send full output to stdout and exit.
[ ! -z "$json" ] && echo "$output" | jq '.[]' && exit 0
[ ! -z "$json" ] && (echo "$output" | jq '.') && exit 0
# parse the output message.
local parsedOutput="$(getGptOutput $output)"
echo "$parsedOutput"
# Show the output based on options passed in.
if [ -z "$printOutput" ]; then
echo "# $question\n$parsedOutput" | gum format | gum pager
else
echo "# $question\n$parsedOutput" | gum format
fi
# if [ -z "$printOutput" ]; then
# echo "# $question\n$parsedOutput" | gum format | gum pager
# else
# echo "# $question\n$parsedOutput" | gum format
# fi