From 52c0e15303cc248dfafc719657047c9f8ed6b9e2 Mon Sep 17 00:00:00 2001 From: Jacob Bohanon Date: Fri, 7 Mar 2025 07:12:01 -0500 Subject: [PATCH] Various updates - change to tmux in lieu of zellij - disable obsidian nvim plugin - add vim-ai nvim plugin - add gitclone.sh script --- alacritty/alacritty.toml | 2 +- init.sh | 11 +- nvim/lua/plugins/ai-roles.ini | 11 ++ nvim/lua/plugins/ai.lua | 184 ++++++++++++++++++++++++++++++++++ nvim/lua/plugins/init.lua | 7 +- tmux/tmux.conf | 35 ++++--- zsh/.zshrc | 14 ++- zsh/config.d/solo.zsh | 70 ------------- zsh/gitclone.sh | 43 ++++++++ 9 files changed, 281 insertions(+), 96 deletions(-) create mode 100644 nvim/lua/plugins/ai-roles.ini create mode 100644 nvim/lua/plugins/ai.lua delete mode 100644 zsh/config.d/solo.zsh create mode 100644 zsh/gitclone.sh diff --git a/alacritty/alacritty.toml b/alacritty/alacritty.toml index cc250b2..b6d90d0 100644 --- a/alacritty/alacritty.toml +++ b/alacritty/alacritty.toml @@ -6,7 +6,7 @@ style = "regular" save_to_clipboard = true [shell] -args = ["-l", "-c", "zellij attach || zellij"] +args = ["-l", "-c", "tmux attach || tmux"] program = "/usr/bin/zsh" [window] diff --git a/init.sh b/init.sh index 195d869..f15ee6c 100755 --- a/init.sh +++ b/init.sh @@ -9,7 +9,7 @@ echo "PKGUPD: ${PKGUPD}" echo "PKGINST: ${PKGINST}" # 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 pushd /tmp || true @@ -22,10 +22,10 @@ rm -rf neovim/ popd || true # 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" -tar -zxf "$HOME/Downloads/zellij.tar.gz" -sudo mv zellij /usr/local/bin/zellij -rm "$HOME/Downloads/zellij.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" +# sudo mv zellij /usr/local/bin/zellij +# rm "$HOME/Downloads/zellij.tar.gz" # install vim-plug @@ -67,6 +67,7 @@ myzvm install nightly # Install merge-main.sh 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/gitclone.sh $HOME/.local/bin/gitclone.sh # link gitconfig ln -s $HOME/.dotfiles/.gitconfig $HOME/.gitconfig diff --git a/nvim/lua/plugins/ai-roles.ini b/nvim/lua/plugins/ai-roles.ini new file mode 100644 index 0000000..048ec0a --- /dev/null +++ b/nvim/lua/plugins/ai-roles.ini @@ -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." diff --git a/nvim/lua/plugins/ai.lua b/nvim/lua/plugins/ai.lua new file mode 100644 index 0000000..32e0fd5 --- /dev/null +++ b/nvim/lua/plugins/ai.lua @@ -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('ai', ':AI') +nnoremap('ch', ':AIChat /right:set wrap!i') +nnoremap('s', ':AIChat') +-- " :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` diff --git a/nvim/lua/plugins/init.lua b/nvim/lua/plugins/init.lua index ddbb738..3255aaa 100644 --- a/nvim/lua/plugins/init.lua +++ b/nvim/lua/plugins/init.lua @@ -60,10 +60,12 @@ Plug 'tpope/vim-dispatch' Plug 'jamestthompson3/nvim-remote-containers' -Plug 'epwalsh/obsidian.nvim' +-- Plug 'epwalsh/obsidian.nvim' Plug 'ziglang/zig.vim' +Plug 'madox2/vim-ai' + vim.call('plug#end') require("plugins/airline") @@ -73,4 +75,5 @@ require("plugins/telescope") require("plugins/treesitter") require("plugins/nvim-cmp") require("plugins/vim-go") -require("plugins/obsidian") +-- require("plugins/obsidian") +require("plugins/ai") diff --git a/tmux/tmux.conf b/tmux/tmux.conf index 1aed686..c4760ad 100644 --- a/tmux/tmux.conf +++ b/tmux/tmux.conf @@ -1,28 +1,37 @@ # Set prefix to Ctrl-Space instead of Ctrl-b -unbind C-b -set-option -g prefix C-Space -bind-key C-Space send-prefix +# unbind C-b +# set-option -g prefix C-Space +# 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 % -bind | split-window -h -bind - split-window -v -bind h select-pane -L -bind j select-pane -D -bind k select-pane -U -bind l select-pane -R +bind -n M-\\ split-window -c '#{pane_current_path}' -h +bind -n M-- split-window -c '#{pane_current_path}' -v +bind -n M-m new-window -c '#{pane_current_path}' +bind -n M-n next-window +bind -n M-p previous-window +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 # Set tmux mode to vi (default is emac) set-window-option -g mode-keys vi +set-option -g mouse on + set-option -g renumber-windows on +set -s escape-time 0 + # List of plugins -set -g @plugin 'tmux-plugins/tpm' -set -g @plugin 'tmux-plugins/tmux-sensible' +# set -g @plugin 'tmux-plugins/tpm' +# set -g @plugin 'tmux-plugins/tmux-sensible' # 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' diff --git a/zsh/.zshrc b/zsh/.zshrc index 476fa19..54ab659 100644 --- a/zsh/.zshrc +++ b/zsh/.zshrc @@ -5,7 +5,7 @@ export EDITOR=nvim 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. -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 export PATH=$HOME/.zig/zig:$PATH @@ -29,10 +29,6 @@ else echo "" echo "see https://github.com/settings/tokens for creating a github access token" echo "export GITHUB_TOKEN=" - echo "" - echo "see https://github.com/solo-io/licensing for generating licenses" - echo "export GLOO_LICENSE_KEY=" - echo "export GLOO_MESH_LICENSE_KEY=" fi alias pls='sudo' @@ -66,4 +62,12 @@ export TERM=xterm-256color 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)" diff --git a/zsh/config.d/solo.zsh b/zsh/config.d/solo.zsh deleted file mode 100644 index 956456f..0000000 --- a/zsh/config.d/solo.zsh +++ /dev/null @@ -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' - diff --git a/zsh/gitclone.sh b/zsh/gitclone.sh new file mode 100644 index 0000000..42ffb06 --- /dev/null +++ b/zsh/gitclone.sh @@ -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}"