From 3c2de229a44116374cb143889b121c0c92a11ba9 Mon Sep 17 00:00:00 2001 From: Tyler Tracy Date: Tue, 23 Jul 2024 00:18:01 -0700 Subject: [PATCH] X profile and llm nvim --- common/config/.alias | 1 + comps/framework-arch/.Xresources | 50 ++++++++++++++++++++ comps/framework-arch/.shenv | 2 +- comps/framework-arch/.xprofile | 9 ++++ comps/framework-arch/owl-config.json | 8 ++++ setups/nvim/after/plugin/llm.lua | 69 ++++++++++++++++++++++++++++ setups/nvim/lua/tylord/packer.lua | 14 +++--- 7 files changed, 146 insertions(+), 7 deletions(-) create mode 100644 comps/framework-arch/.Xresources create mode 100644 comps/framework-arch/.xprofile create mode 100644 setups/nvim/after/plugin/llm.lua diff --git a/common/config/.alias b/common/config/.alias index 616a1e0..cdec1be 100644 --- a/common/config/.alias +++ b/common/config/.alias @@ -1,4 +1,5 @@ alias ls='ls --color=auto' +alias lg='lazygit' alias dir='dir --color=auto' alias vdir='vdir --color=auto' alias grep='grep --color=auto' diff --git a/comps/framework-arch/.Xresources b/comps/framework-arch/.Xresources new file mode 100644 index 0000000..1116007 --- /dev/null +++ b/comps/framework-arch/.Xresources @@ -0,0 +1,50 @@ +Xcursor.theme: cursor-theme +Xcursor.size: 16 + +! special +*.foreground: #d0d0d0 +*.background: #000000 +*.cursorColor: #d0d0d0 + +! black +*.color0: #000000 +*.color8: #808080 + +! red +*.color1: #ff0000 +*.color9: #ff0000 + +! green +*.color2: #33ff00 +*.color10: #33ff00 + +! yellow +*.color3: #ff0099 +*.color11: #ff0099 + +! blue +*.color4: #0066ff +*.color12: #0066ff + +! magenta +*.color5: #cc00ff +*.color13: #cc00ff + +! cyan +*.color6: #00ffff +*.color14: #00ffff + +! white +*.color7: #d0d0d0 +*.color15: #ffffff + +/* Xft.dpi: 220 */ +/* Xft.autohint: 0 */ +/* Xft.lcdfilter: lcddefault */ +/* Xft.hintstyle: hintfull */ +/* Xft.hinting: 1 */ +/* Xft.antialias: 1 */ + +! Rofi Config +rofi.dpi: 220 + diff --git a/comps/framework-arch/.shenv b/comps/framework-arch/.shenv index 49bade2..d7c8673 100755 --- a/comps/framework-arch/.shenv +++ b/comps/framework-arch/.shenv @@ -20,7 +20,7 @@ export DEV_PATH="/home/tylord/dev" # Programs export EDITOR="nvim" -export BROWSER="brave" +export BROWSER="chromium" export TERMINAL="terminator" export TERMIANL_ROLE="terminator --role" export TERMINAL_EXEC="terminator -e" diff --git a/comps/framework-arch/.xprofile b/comps/framework-arch/.xprofile new file mode 100644 index 0000000..702c0f4 --- /dev/null +++ b/comps/framework-arch/.xprofile @@ -0,0 +1,9 @@ +# Set the cursor speed (wait time, dups per second) +xset r rate 300 35 + +# Set the "theme" +[[ -f ~/.config/X/.Xresources ]] && xrdb -merge -I$HOME ~/.config/X/.Xresources + +setxkbmap -option caps:super + +feh --bg-fill ~/docs/media/backgrounds/joker.jpg diff --git a/comps/framework-arch/owl-config.json b/comps/framework-arch/owl-config.json index 27ebce2..7714eac 100644 --- a/comps/framework-arch/owl-config.json +++ b/comps/framework-arch/owl-config.json @@ -24,6 +24,14 @@ "source": "comps/framework-arch/.alias", "target": "~/.config/alias/main" }, + { + "source": "comps/framework-arch/.xprofile", + "target": "~/.xprofile" + }, + { + "source": "comps/framework-arch/.Xresources", + "target": "~/.config/X/Xresources" + }, { "source": "common/config/.alias", "target": "~/.config/alias/base" diff --git a/setups/nvim/after/plugin/llm.lua b/setups/nvim/after/plugin/llm.lua new file mode 100644 index 0000000..29603cf --- /dev/null +++ b/setups/nvim/after/plugin/llm.lua @@ -0,0 +1,69 @@ +local system_prompt = +'You should replace the code that you are sent, only following the comments. Do not talk at all. Only output valid code. Do not provide any backticks that surround the code. Never ever output backticks like this ```. Any comment that is asking you for something should be removed after you satisfy them. Other comments should left alone. Do not output backticks' +local helpful_prompt = +'You are a helpful assistant. What I have sent are my notes so far. You are very curt, yet helpful.' +require('llm').setup { + timeout_ms = 3000, + services = { + groq = { + url = 'https://api.groq.com/openai/v1/chat/completions', + model = 'llama3-70b-8192', + api_key_name = 'GROQ_API_KEY', + system_prompt = system_prompt, + }, + groq_help = { + url = 'https://api.groq.com/openai/v1/chat/completions', + model = 'llama3-70b-8192', + api_key_name = 'GROQ_API_KEY', + system_prompt = helpful_prompt, + }, + openai = { + url = 'https://api.openai.com/v1/chat/completions', + model = 'gpt-4o', + api_key_name = 'OPENAI_API_KEY', + -- system_prompt = system_prompt, + }, + openai_help = { + url = 'https://api.openai.com/v1/chat/completions', + model = 'gpt-4o', + api_key_name = 'OPENAI_API_KEY', + -- system_prompt = helpful_prompt, + }, + claude = { + url = 'https://api.anthropic.com/v1/messages', + model = 'claude-3-5-sonnet-20240620', + api_key_name = 'ANTHROPIC_API_KEY', + system_prompt = system_prompt, + }, + claude_help = { + url = 'https://api.anthropic.com/v1/messages', + model = 'claude-3-5-sonnet-20240620', + api_key_name = 'ANTHROPIC_API_KEY', + system_prompt = helpful_prompt, + }, + }, +} + +vim.keymap.set('v', 'k', function() + require('llm').prompt { replace = true, service = 'groq' } +end, { desc = 'Prompt with groq (replace = true)' }) + +vim.keymap.set('v', 'K', function() + require('llm').prompt { replace = false, service = 'groq_help' } +end, { desc = 'Prompt with groq (replace = false)' }) + +vim.keymap.set('v', 'L', function() + require('llm').prompt { replace = false, service = 'openai_help' } +end, { desc = 'Prompt with openai (replace = false)' }) + +vim.keymap.set('v', 'l', function() + require('llm').prompt { replace = true, service = 'openai' } +end, { desc = 'Prompt with openai (replace = true)' }) + +vim.keymap.set('n', 'I', function() + require('llm').prompt { replace = false, service = 'anthropic' } +end, { desc = 'Prompt with anthropic (replace = false)' }) + +vim.keymap.set('n', 'i', function() + require('llm').prompt { replace = true, service = 'anthropic_help' } +end, { desc = 'Prompt with anthropic (replace = true)' }) diff --git a/setups/nvim/lua/tylord/packer.lua b/setups/nvim/lua/tylord/packer.lua index 93c60f7..59fa0f7 100644 --- a/setups/nvim/lua/tylord/packer.lua +++ b/setups/nvim/lua/tylord/packer.lua @@ -42,8 +42,7 @@ return require('packer').startup(function(use) requires = { { "nvim-lua/plenary.nvim" } } } - -- Copilot - -- use 'github/copilot.vim' + -- AI use { "zbirenbaum/copilot.lua" } use { "zbirenbaum/copilot-cmp", @@ -52,6 +51,12 @@ return require('packer').startup(function(use) require("copilot_cmp").setup() end } + use { + "melbaldove/llm.nvim", + requires = { "nvim-neotest/nvim-nio" }, + } + -- use { 'huggingface/llm.nvim' } + -- use 'github/copilot.vim' -- LSP use 'neovim/nvim-lspconfig' @@ -62,10 +67,7 @@ return require('packer').startup(function(use) use 'mfussenegger/nvim-lint' -- Formatting - use { - 'stevearc/conform.nvim', - config = function() require('conform').setup() end - } + use { 'stevearc/conform.nvim' } -- Completions use 'hrsh7th/nvim-cmp'