Various updates

- change to tmux in lieu of zellij
- disable obsidian nvim plugin
- add vim-ai nvim plugin
- add gitclone.sh script
This commit is contained in:
Jacob Bohanon
2025-03-07 07:12:01 -05:00
parent ad93df5f2f
commit 52c0e15303
9 changed files with 281 additions and 96 deletions

View File

@@ -6,7 +6,7 @@ style = "regular"
save_to_clipboard = true save_to_clipboard = true
[shell] [shell]
args = ["-l", "-c", "zellij attach || zellij"] args = ["-l", "-c", "tmux attach || tmux"]
program = "/usr/bin/zsh" program = "/usr/bin/zsh"
[window] [window]

11
init.sh
View File

@@ -9,7 +9,7 @@ echo "PKGUPD: ${PKGUPD}"
echo "PKGINST: ${PKGINST}" echo "PKGINST: ${PKGINST}"
# Install zsh, neovim, ripgrep, fd # Install zsh, neovim, ripgrep, fd
[[ $PKGINST != '' ]] && $PKGUPD && $PKGINST zsh ripgrep fd-find fzf [[ $PKGINST != '' ]] && $PKGUPD && $PKGINST curl tmux zsh ripgrep fd-find fzf
# Install neovim # Install neovim
pushd /tmp || true pushd /tmp || true
@@ -22,10 +22,10 @@ rm -rf neovim/
popd || true popd || true
# install zellij # install zellij
curl -L -o "$HOME/Downloads/zellij.tar.gz" "https://github.com/zellij-org/zellij/releases/latest/download/zellij-x86_64-unknown-linux-musl.tar.gz" # curl -L -o "$HOME/Downloads/zellij.tar.gz" "https://github.com/zellij-org/zellij/releases/latest/download/zellij-x86_64-unknown-linux-musl.tar.gz"
tar -zxf "$HOME/Downloads/zellij.tar.gz" # tar -zxf "$HOME/Downloads/zellij.tar.gz"
sudo mv zellij /usr/local/bin/zellij # sudo mv zellij /usr/local/bin/zellij
rm "$HOME/Downloads/zellij.tar.gz" # rm "$HOME/Downloads/zellij.tar.gz"
# install vim-plug # install vim-plug
@@ -67,6 +67,7 @@ myzvm install nightly
# Install merge-main.sh # Install merge-main.sh
mkdir -p $HOME/.local/bin mkdir -p $HOME/.local/bin
sudo ln -s $HOME/.dotfiles/zsh/merge-main.sh $HOME/.local/bin/merge-main.sh sudo ln -s $HOME/.dotfiles/zsh/merge-main.sh $HOME/.local/bin/merge-main.sh
sudo ln -s $HOME/.dotfiles/zsh/gitclone.sh $HOME/.local/bin/gitclone.sh
# link gitconfig # link gitconfig
ln -s $HOME/.dotfiles/.gitconfig $HOME/.gitconfig ln -s $HOME/.dotfiles/.gitconfig $HOME/.gitconfig

View File

@@ -0,0 +1,11 @@
[deepthink]
options.model = o1
options.prompt = "You are a deeply capable reasoning being."
[think]
options.model = gpt-4o
options.prompt = "You are a deeply capable reasoning being."
[chat]
options.model = gpt-3.5-turbo
options.prompt = "You are a highly capable being."

184
nvim/lua/plugins/ai.lua Normal file
View File

@@ -0,0 +1,184 @@
local map = vim.api.nvim_set_keymap
local noremap = function(ctx, keys, cmd, opts)
opts = opts or {}
opts['noremap'] = true
opts['silent'] = true
map(ctx, keys, cmd, opts)
end
local inoremap = function(keys, cmd)
noremap('i', keys, cmd, nil)
end
local nnoremap = function(keys, cmd)
noremap('n', keys, cmd, nil)
end
local vnoremap = function(keys, cmd)
noremap('v', keys, cmd, nil)
end
nnoremap('<Leader>ai', ':AI<CR>')
nnoremap('<Leader>ch', ':AIChat /right<CR>:set wrap!<CR>i')
nnoremap('<Leader>s', ':AIChat<CR>')
-- " :AI
-- " - prompt: optional prepended prompt
-- " - engine: chat | complete - see how to configure complete engine in the section below
-- " - options: openai config (see https://platform.openai.com/docs/api-reference/completions)
-- " - options.initial_prompt: prompt prepended to every chat request (list of lines or string)
-- " - options.request_timeout: request timeout in seconds
-- " - options.enable_auth: enable authorization using openai key
-- " - options.token_file_path: override global token configuration
-- " - options.selection_boundary: selection prompt wrapper (eliminates empty responses, see #20)
-- " - ui.paste_mode: use paste mode (see more info in the Notes below)
vim.g.vim_ai_complete = {
prompt = "",
engine = "chat",
options = {
model = "gpt-3.5-turbo",
endpoint_url = "https://ai.nonahob.net/proxy/v1/chat/completions",
-- endpoint_url= "http://localhost:9000/v1/chat/completions",
max_tokens = 0,
max_completion_tokens = 0,
temperature = 0.1,
-- this timeout will be limited by an intermediate proxy if one exists.
request_timeout = 60,
stream = 1,
enable_auth = 0,
token_file_path = "",
selection_boundary = "#####",
initial_prompt = "",
},
ui = {
paste_mode = 1,
},
}
-- " :AIEdit
-- " - prompt: optional prepended prompt
-- " - engine: chat | complete - see how to configure complete engine in the section below
-- " - options: openai config (see https://platform.openai.com/docs/api-reference/completions)
-- " - options.initial_prompt: prompt prepended to every chat request (list of lines or string)
-- " - options.request_timeout: request timeout in seconds
-- " - options.enable_auth: enable authorization using openai key
-- " - options.token_file_path: override global token configuration
-- " - options.selection_boundary: selection prompt wrapper (eliminates empty responses, see #20)
-- " - ui.paste_mode: use paste mode (see more info in the Notes below)
vim.g.vim_ai_edit = {
prompt = "",
engine = "chat",
options = {
model = "gpt-4o",
-- endpoint_url= "http://localhost:9000/v1/chat/completions",
endpoint_url= "https://ai.nonahob.net/proxy/v1/chat/completions",
max_tokens = 0,
max_completion_tokens = 0,
temperature = 0.1,
-- this timeout will be limited by an intermediate proxy if one exists.
request_timeout = 60,
stream = 1,
enable_auth = 0,
token_file_path = "",
selection_boundary = "#####",
initial_prompt = "",
},
ui = {
paste_mode = 1,
},
}
-- " This prompt instructs model to work with syntax highlighting
local initial_chat_prompt = [[
>>> system
You are a general assistant. You are knowledgeable about lots of things, but especially about programming.
If and only if you attach a code block with markdown syntax, add syntax type after ``` to enable syntax highlighting. Do not add ``` if you don't attach a code block.
END
]]
-- " :AIChat
-- " - prompt: optional prepended prompt
-- " - options: openai config (see https://platform.openai.com/docs/api-reference/chat)
-- " - options.initial_prompt: prompt prepended to every chat request (list of lines or string)
-- " - options.request_timeout: request timeout in seconds
-- " - options.enable_auth: enable authorization using openai key
-- " - options.token_file_path: override global token configuration
-- " - options.selection_boundary: selection prompt wrapper (eliminates empty responses, see #20)
-- " - ui.open_chat_command: preset (preset_below, preset_tab, preset_right) or a custom command
-- " - ui.populate_options: put [chat-options] to the chat header
-- " - ui.scratch_buffer_keep_open: re-use scratch buffer within the vim session
-- " - ui.force_new_chat: force new chat window (used in chat opening roles e.g. `/tab`)
-- " - ui.paste_mode: use paste mode (see more info in the Notes below)
vim.g.vim_ai_chat = {
-- \ "prompt": "",
options= {
model = "gpt-4o",
endpoint_url= "https://ai.nonahob.net/proxy/v1/chat/completions",
-- endpoint_url= "http://localhost:9000/v1/chat/completions",
max_tokens = 0,
max_completion_tokens = 0,
temperature = 1,
-- this timeout will be limited by an intermediate proxy if one exists.
request_timeout = 60,
stream = 1,
enable_auth = 0,
token_file_path = "",
selection_boundary = "",
initial_prompt = initial_chat_prompt,
},
ui = {
open_chat_command = "preset_below",
scratch_buffer_keep_open = 0,
populate_options = 0,
code_syntax_enabled = 1,
force_new_chat = 0,
paste_mode = 1,
},
}
-- ----------------------------------
-- AIImage is not currently supported
-- ----------------------------------
-- " :AIImage
-- " - prompt: optional prepended prompt
-- " - options: openai config (https://platform.openai.com/docs/api-reference/images/create)
-- " - options.request_timeout: request timeout in seconds
-- " - options.enable_auth: enable authorization using openai key
-- " - options.token_file_path: override global token configuration
-- " - options.download_dir: path to image download directory, `cwd` if not defined
-- vim.g.vim_ai_image = {
-- -- \ "prompt": "",
-- options= {
-- -- \ "model": "dall-e-3",
-- endpoint_url= "https://ai.nonahob.net/proxy/images/generations",
-- -- \ "quality": "standard",
-- -- \ "size": "1024x1024",
-- -- \ "style": "vivid",
-- -- \ "request_timeout": 20,
-- enable_auth= 0,
-- -- \ "token_file_path": "",
-- },
-- -- \ "ui": {
-- -- \ "download_dir": "",
-- -- \ },
-- }
-- custom roles file location
vim.g.vim_ai_roles_config_file = "/home/jacob/.dotfiles/nvim/lua/plugins/ai-roles.ini"
-- " custom token file location
-- let g:vim_ai_token_file_path = "~/.config/openai.token"
-- " debug settings
-- let g:vim_ai_debug = 0
-- let g:vim_ai_debug_log_file = "/tmp/vim_ai_debug.log"
-- " Notes:
-- " ui.paste_mode
-- " - if disabled code indentation will work but AI doesn't always respond with a code block
-- " therefore it could be messed up
-- " - find out more in vim's help `:help paste`
-- " options.max_tokens
-- " - note that prompt + max_tokens must be less than model's token limit, see #42, #46
-- " - setting max tokens to 0 will exclude it from the OpenAI API request parameters, it is
-- " unclear/undocumented what it exactly does, but it seems to resolve issues when the model
-- " hits token limit, which respond with `OpenAI: HTTPError 400`

View File

@@ -60,10 +60,12 @@ Plug 'tpope/vim-dispatch'
Plug 'jamestthompson3/nvim-remote-containers' Plug 'jamestthompson3/nvim-remote-containers'
Plug 'epwalsh/obsidian.nvim' -- Plug 'epwalsh/obsidian.nvim'
Plug 'ziglang/zig.vim' Plug 'ziglang/zig.vim'
Plug 'madox2/vim-ai'
vim.call('plug#end') vim.call('plug#end')
require("plugins/airline") require("plugins/airline")
@@ -73,4 +75,5 @@ require("plugins/telescope")
require("plugins/treesitter") require("plugins/treesitter")
require("plugins/nvim-cmp") require("plugins/nvim-cmp")
require("plugins/vim-go") require("plugins/vim-go")
require("plugins/obsidian") -- require("plugins/obsidian")
require("plugins/ai")

View File

@@ -1,28 +1,37 @@
# Set prefix to Ctrl-Space instead of Ctrl-b # Set prefix to Ctrl-Space instead of Ctrl-b
unbind C-b # unbind C-b
set-option -g prefix C-Space # set-option -g prefix C-Space
bind-key C-Space send-prefix # bind-key C-Space send-prefix
# Split windows using | and - # Linux config - ignore prefix with -n and use alt-*
# For mac, remove the -n and don't use alt. e.g.
# bind '\' split-window -c '#{pane_current_path}' -h
unbind '"' unbind '"'
unbind % unbind %
bind | split-window -h bind -n M-\\ split-window -c '#{pane_current_path}' -h
bind - split-window -v bind -n M-- split-window -c '#{pane_current_path}' -v
bind h select-pane -L bind -n M-m new-window -c '#{pane_current_path}'
bind j select-pane -D bind -n M-n next-window
bind k select-pane -U bind -n M-p previous-window
bind l select-pane -R bind -n M-h select-pane -L
bind -n M-j select-pane -D
bind -n M-k select-pane -U
bind -n M-l select-pane -R
# DON'T paste this line in, if you DON'T want vim keybindings # DON'T paste this line in, if you DON'T want vim keybindings
# Set tmux mode to vi (default is emac) # Set tmux mode to vi (default is emac)
set-window-option -g mode-keys vi set-window-option -g mode-keys vi
set-option -g mouse on
set-option -g renumber-windows on set-option -g renumber-windows on
set -s escape-time 0
# List of plugins # List of plugins
set -g @plugin 'tmux-plugins/tpm' # set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-sensible' # set -g @plugin 'tmux-plugins/tmux-sensible'
# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf) # Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf)
run '~/.dotfiles/tmux/plugins/tpm/tpm' # run '~/.dotfiles/tmux/plugins/tpm/tpm'

View File

@@ -5,7 +5,7 @@ export EDITOR=nvim
if [[ -d "/home/linuxbrew" ]]; then eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"; fi if [[ -d "/home/linuxbrew" ]]; then eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"; fi
# If you come from bash you might have to change your $PATH. # If you come from bash you might have to change your $PATH.
export PATH=$HOME/bin:$HOME/.local/bin:/usr/local/bin:/opt/local/bin:$PATH export PATH=$HOME/bin:$HOME/.local/bin:/usr/local/bin:/opt/local/bin:$HOME/.node_modules/bin:$PATH
# Add the zig path used by myzvm # Add the zig path used by myzvm
export PATH=$HOME/.zig/zig:$PATH export PATH=$HOME/.zig/zig:$PATH
@@ -29,10 +29,6 @@ else
echo "" echo ""
echo "see https://github.com/settings/tokens for creating a github access token" echo "see https://github.com/settings/tokens for creating a github access token"
echo "export GITHUB_TOKEN=<token>" echo "export GITHUB_TOKEN=<token>"
echo ""
echo "see https://github.com/solo-io/licensing for generating licenses"
echo "export GLOO_LICENSE_KEY=<gloo edge enterprise license>"
echo "export GLOO_MESH_LICENSE_KEY=<gloo mesh enterprise license>"
fi fi
alias pls='sudo' alias pls='sudo'
@@ -66,4 +62,12 @@ export TERM=xterm-256color
export STARSHIP_CONFIG=~/.config/zsh/starship.toml export STARSHIP_CONFIG=~/.config/zsh/starship.toml
# the gitclone.sh script is designed to be run in a subshell. it executes
# the git clone and then returns a pushd to the caller. With this function, we
# simply `eval` that command so that we effectively git clone a repo from anywhere
# into the correct directory and the move into that directory
function gclone () {
eval $(gitclone.sh $1)
}
eval "$(starship init zsh)" eval "$(starship init zsh)"

View File

@@ -1,70 +0,0 @@
SOLO_DIR="$HOME/src/github.com/solo-io"
SOLO_GITHUB="https://github.com/solo-io"
mkdir -p $SOLO_DIR
REPOS=(
"gloo"
"gloo-fed"
"solo-projects"
"solo-apis"
"solo-kit"
"dev-portal"
"gloo-mesh"
"gloo-mesh-ui"
"gloo-mesh-enterprise"
"ext-auth-service"
"rate-limiter"
"caching-service"
"envoy-gloo"
"envoy-gloo-ee"
)
for repo in "${REPOS[@]}"
do
repo_addr="${SOLO_GITHUB}/${repo}"
repo_dir="${SOLO_DIR}/${repo}"
if [[ ! -d $repo_dir ]]; then
pushd $SOLO_DIR
git clone $repo_addr
popd
fi
done
function nvim_readme() {
nvim ./README.md
}
# Aliases to reach different repos
alias cdsi='cd $SOLO_DIR'
alias cdg='cd $SOLO_DIR/gloo'
alias nvg='cdg && nvim_readme'
alias cdgf='cd $SOLO_DIR/gloo-fed'
alias nvgf='cdgf && nvim_readme'
alias cdsp='cd $SOLO_DIR/solo-projects'
alias nvsp='cdsp && nvim_readme'
alias cdsa='cd $SOLO_DIR/solo-apis'
alias nvsa='cdsa && nvim_readme'
alias cdsk='cd $SOLO_DIR/solo-kit'
alias nvsk='cdsk && nvim_readme'
alias cddp='cd $SOLO_DIR/dev-portal'
alias nvdp='cddp && nvim_readme'
alias cdgm='cd $SOLO_DIR/gloo-mesh'
alias nvgm='cdgm && nvim_readme'
alias cdgmui='cd $SOLO_DIR/gloo-mesh-ui'
alias nvgmui='cdgmui && nvim_readme'
alias cdgme='cd $SOLO_DIR/gloo-mesh-enterprise'
alias nvgme='cdgme && nvim_readme'
alias cdea='cd $SOLO_DIR/ext-auth-service'
alias nvea='cdea && nvim_readme'
alias cdrl='cd $SOLO_DIR/rate-limiter'
alias nvrl='cdrl && nvim_readme'
alias cdcs='cd $SOLO_DIR/caching-service'
alias nvcs='cdcs && nvim_readme'
alias cdeg='cd $SOLO_DIR/envoy-gloo'
alias nveg='cdeg && nvim_readme'
alias cdee='cd $SOLO_DIR/envoy-gloo-ee'
alias nvee='cdee && nvim_readme'
alias cde='cd $SOLO_DIR/../envoyproxy/envoy'
alias nve='cde && nvim_readme'

43
zsh/gitclone.sh Normal file
View File

@@ -0,0 +1,43 @@
#!/bin/bash
url=$1
# make sure we have a valid git url. only works with http/s
regex='^https?://[^/]+/[^/]+/[^/]+(\.git)?$'
if [[ ! $"url" =~ $regex ]]; then
echo "echo \"$url does not match regex\""
exit 1
fi
# turn our url into a repo path
repo="${url#"http://"}"
repo="${repo#"https://"}"
repo="${repo%".git"}"
# get the location where we will clone this repo
repodir="$HOME/src/${repo}"
# get th directory we will need to be in to call the git clone
dir="${repodir%/*}"
# check for existence of git command
if [[ -z $(which git) ]]; then
echo "echo 'git executable not found'"
exit 1
fi
mkdir -p "$dir"
pushd $dir > /dev/null
# perform the git clone and check output
output="$(git clone $url)"
if [[ $? > 0 ]]; then
popd > /dev/null
(rmdir $repodir && rmdir $dir) || true
echo "echo 'git clone operation failed'"
exit 1
fi
# return our pushd command to the calling shell
echo "pushd ${repodir}"