From 53107123947e9ee4e756e9d5a586b38f9f96d65c Mon Sep 17 00:00:00 2001 From: Henrik Bakken Date: Tue, 10 Mar 2026 21:38:08 +0100 Subject: [PATCH] codex tips --- CONFIG/nvim/init.lua | 144 ++++++++++++++++++++++++++++------- CONFIG/qutebrowser/config.py | 6 +- CONFIG/tmux/tmux.conf | 24 +++--- endos.py | 8 +- 4 files changed, 136 insertions(+), 46 deletions(-) diff --git a/CONFIG/nvim/init.lua b/CONFIG/nvim/init.lua index 39c1cf3..19be958 100644 --- a/CONFIG/nvim/init.lua +++ b/CONFIG/nvim/init.lua @@ -137,8 +137,8 @@ map("n", "", "vertical resize +2", { desc = "Increase Window Width -- https://github.com/mhinz/vim-galore#tips-1 -- smarter next/prev in command line -map("n", "", "wildmenumode() ? '' : ''", { expr = true, desc = "Next" }) -map("n", "", "wildmenumode() ? '' : ''", { expr = true, desc = "Prev" }) +map("c", "", "wildmenumode() ? '' : ''", { expr = true, desc = "Next" }) +map("c", "", "wildmenumode() ? '' : ''", { expr = true, desc = "Prev" }) -- Add undo break-points map("i", ",", ",u") @@ -179,11 +179,11 @@ map("n", "uI", function() vim.api.nvim_input("I") end, { desc = "Inspect Tree" }) --- Terminal Mappings -map("n", "", "terminal", { desc = "Show Terminal" }) -map("t", "", "close", { desc = "Hide Terminal" }) -map("n", "", "terminal", { desc = "which_key_ignore" }) -map("t", "", "close", { desc = "which_key_ignore" }) +-- Terminal Mappings overridden by Snacks.terminal +-- map("n", "", "terminal", { desc = "Show Terminal" }) +-- map("t", "", "close", { desc = "Hide Terminal" }) +-- map("n", "", "terminal", { desc = "which_key_ignore" }) +-- map("t", "", "close", { desc = "which_key_ignore" }) -- windows map("n", "", "vsplit", { desc = "Split Window Right", remap = true }) @@ -208,7 +208,7 @@ map("n", "d", "tabclose", { desc = "Close Tab" }) map("n", "p", "tabprevious", { desc = "Previous Tab" }) -- other -map("n", "cw", [[:cd %:p:h]], { desc = "Set Workspace To Buffer Path" }) +map("n", "cW", [[:cd %:p:h]], { desc = "Set Workspace To Buffer Path" }) map("n", "o", "m`o``", { desc = "Insert Newline" }) map( "n", @@ -293,7 +293,7 @@ vim.api.nvim_create_autocmd("FileType", { -- wrap and check for spell in text filetypes vim.api.nvim_create_autocmd("FileType", { group = vim.api.nvim_create_augroup("wrap_spell", { clear = true }), - pattern = { "text", "plaintex", "typst", "gitcommit", "markdown" }, + pattern = { "text", "plaintext", "typst", "gitcommit", "markdown" }, callback = function() vim.opt_local.wrap = true vim.opt_local.spell = true @@ -310,6 +310,7 @@ vim.api.nvim_create_user_command("ConvertEOL", function(opts) vim.notify("Unsupported file format: " .. fmt, vim.log.levels.ERROR, { title = "ConvertEOL", }) + return end vim.bo.fileformat = fmt vim.cmd([[write]]) @@ -544,7 +545,9 @@ local function makespec_hexokinase() return { -- coloring of colornames "rrethy/vim-hexokinase", - build = "cd /home/hjalmarlucius/.local/share/nvim/lazy/vim-hexokinase; make hexokinase", + build = function(plugin) + vim.system({ "make", "hexokinase" }, { cwd = plugin.dir }):wait() + end, config = function() vim.g.Hexokinase_highlighters = { "virtual" } end, } end @@ -967,6 +970,7 @@ local function makespec_whichkey() spec = { { mode = { "n", "v" }, + { "a", group = "ai" }, { "c", group = "code/content" }, { "f", group = "file/find" }, { "g", group = "git" }, @@ -1144,7 +1148,7 @@ local function makespec_snacks() Snacks.toggle.option("conceallevel", { off = 0, on = vim.o.conceallevel > 0 and vim.o.conceallevel or 2 }):map("uc") Snacks.toggle.diagnostics():map("ud") Snacks.toggle.dim():map("uD") - Snacks.toggle.inlay_hints():map("ui") + -- Snacks.toggle.inlay_hints():map("ui") -- using vim.show_pos instead Snacks.toggle.line_number():map("ul") Snacks.toggle.option("relativenumber", { name = "Relative Number" }):map("uL") Snacks.toggle.option("spell", { name = "Spelling" }):map("us") @@ -1349,23 +1353,36 @@ local function makespec_treesitter() "nvim-treesitter/nvim-treesitter", build = ":TSUpdate", opts = { - { - ensure_installed = { - "bash", - "c", - "cpp", - "git_rebase", - "gitcommit", - "lua", - "python", - "regex", - "vimdoc", - }, - auto_install = true, - highlight = { enable = true }, - indent = { enable = true, disable = { "python" }, additional_vim_regex_highlighting = { "python" } }, - -- incremental_selection done by flash plugin + ensure_installed = { + "bash", + "c", + "cpp", + "css", + "diff", + "git_rebase", + "gitcommit", + "gitignore", + "html", + "javascript", + "json", + "json5", + "lua", + "markdown", + "markdown_inline", + "python", + "regex", + "toml", + "tsx", + "typescript", + "typst", + "vim", + "vimdoc", + "yaml", }, + auto_install = true, + highlight = { enable = true }, + indent = { enable = true, disable = { "python" } }, + -- incremental_selection done by flash plugin }, init = function() vim.opt.foldexpr = "nvim_treesitter#foldexpr()" end, } @@ -1463,6 +1480,78 @@ local function makespec_conform() } end +local function makespec_avante() + return { + "yetone/avante.nvim", + event = "VeryLazy", + lazy = false, + version = false, + build = "make", + opts = { + provider = "openai", + auto_suggestions_provider = "openai", + providers = { + openai = { + model = "gpt-4.1", + extra_request_body = { + temperature = 0, + }, + max_tokens = 4096, + }, + gemini = { + model = "gemini-2.5-flash", + extra_request_body = { + temperature = 0, + max_tokens = 4096, + }, + }, + }, + ignore_patterns = { + ".git", + "node_modules", + "dist", + "build", + "target", + ".cache", + ".venv", + "venv", + "__pycache__", + ".pytest_cache", + ".mypy_cache", + ".ruff_cache", + ".DS_Store", + "*.lock", + "*.png", + "*.jpg", + "*.jpeg", + "*.gif", + "*.webp", + "*.pdf", + "*.svg", + "*.zip", + "*.tar", + "*.gz", + "*.min.js", + "*.map", + "*.secret", + "*.whl", + "*.data", + }, + }, + dependencies = { + "nvim-lua/plenary.nvim", + "MunifTanjim/nui.nvim", + "echasnovski/mini.icons", + "nvim-treesitter/nvim-treesitter", + }, + keys = { + { "ai", "AvanteAsk", desc = "AI Ask", mode = { "n", "v" } }, + { "ae", "AvanteEdit", desc = "AI Edit Selection", mode = "v" }, + { "ar", "AvanteRefresh", desc = "AI Refresh Context" }, + }, + } +end + local function makespec_noice() return { "folke/noice.nvim", @@ -1523,6 +1612,7 @@ for _, spec in ipairs({ makespec_autotag(), makespec_lint(), makespec_mason(), + -- makespec_avante(), -- navigation makespec_atone(), makespec_whichkey(), diff --git a/CONFIG/qutebrowser/config.py b/CONFIG/qutebrowser/config.py index ad2372c..b6b42a3 100644 --- a/CONFIG/qutebrowser/config.py +++ b/CONFIG/qutebrowser/config.py @@ -164,10 +164,10 @@ c.tabs.tabs_are_windows = False c.tabs.title.format = "{index}.{current_title}" c.tabs.undo_stack_size = 1000 c.tabs.width = "15%" -c.url.start_pages = "http://www.google.com/search?hl=en&source=hp" -c.url.default_page = "http://www.google.com/search?hl=en&source=hp" +c.url.start_pages = "https://www.google.com/search?hl=en&source=hp" +c.url.default_page = "https://www.google.com/search?hl=en&source=hp" c.url.searchengines = dict( - DEFAULT="http://www.google.com/search?hl=en&source=hp&q={}", + DEFAULT="https://www.google.com/search?hl=en&source=hp&q={}", aw="https://wiki.archlinux.org/?search={}", ap="https://www.archlinux.org/packages/?q={}", gh="https://github.com/search?q={}&type=repositories", diff --git a/CONFIG/tmux/tmux.conf b/CONFIG/tmux/tmux.conf index 6de3d80..0385049 100644 --- a/CONFIG/tmux/tmux.conf +++ b/CONFIG/tmux/tmux.conf @@ -12,12 +12,11 @@ set -g allow-passthrough set -g history-limit 100000 set -g focus-events on -# Set the default terminal terminfo -set -g default-terminal "foot" +# Advertise tmux correctly to programs running inside it. +set -g default-terminal "tmux-256color" -# True color support (Tc) and undercurl support (Smol) -set -as terminal-overrides ',foot:Tc' -set -as terminal-overrides ',foot:Smol' +# Tell tmux which features the outer Foot client supports. +set -as terminal-features ',foot*:RGB,clipboard,focus,title' # Start with index 1 set -g base-index 1 @@ -31,11 +30,8 @@ bg_active_window="color252" bg_highlight="red" # pane title -ps_pid='#(pgrep -P "#{pane_pid}" | tr "\n" " ")' -cmd='#(ps --no-headers -o args $(pgrep -P "#{pane_pid}"))' -# cmd='#(ps --no-headers -t #{pane_tty} -o args -O-c | tr "\n" " ")' setw -g pane-border-status top -setw -g pane-border-format " #{pane_current_path} #{=/-20/…:pane_current_command} ${ps_pid}[${cmd}] #{?alternate_on, ,}" +setw -g pane-border-format " #{pane_current_path} #{=/-40/…:pane_current_command} #{?alternate_on, ,}" set -g pane-border-style "fg=${fg_inactive_pane}" set -g pane-active-border-style "fg=${fg_active_pane}" @@ -68,11 +64,12 @@ set -g set-titles on # Note : you can press super key by set M. # (tested with tty only) set -g prefix M-a -bind M-a send-prefix # First remove *all* keybindings unbind -a +bind M-a send-prefix + # Basic bindings bind ? list-keys bind d detach-client @@ -90,12 +87,13 @@ bind c copy-mode # clipboard control bind p paste-buffer bind -T copy-mode-vi v send-keys -X begin-selection -bind -T copy-mode-vi y send-keys -X copy-pipe-and-cancel "xclip -i -f -selection primary | xclip -i -selection clipboard" +bind -T copy-mode-vi y send-keys -X copy-pipe-and-cancel "wl-copy" +bind -T copy-mode-vi Enter send-keys -X copy-selection-and-cancel bind -T copy-mode-vi r send-keys -X rectangle-toggle bind -T copy-mode-vi Escape send-keys -X cancel bind -T copy-mode-vi q send-keys -X clear-selection -bind -T copy-mode MouseDragEnd1Pane send-keys -X copy-pipe-and-cancel "xclip -selection primary -filter | xclip -selection clipboard" -bind -T copy-mode-vi MouseDragEnd1Pane send-keys -X copy-pipe-and-cancel "xclip -selection primary -filter | xclip -selection clipboard" +bind -T copy-mode MouseDragEnd1Pane send-keys -X copy-pipe-and-cancel "wl-copy" +bind -T copy-mode-vi MouseDragEnd1Pane send-keys -X copy-pipe-and-cancel "wl-copy" # Rename window bind , command-prompt "rename-window %%" diff --git a/endos.py b/endos.py index eafdb81..3f1cae7 100755 --- a/endos.py +++ b/endos.py @@ -14,6 +14,7 @@ # - ... etc # - sudo enable ufw from difflib import unified_diff +from getpass import getuser from os.path import lexists from pathlib import Path from shutil import rmtree @@ -21,14 +22,15 @@ from subprocess import run from urllib.request import urlretrieve HOSTNAME = open("/etc/hostname").read().strip() -HOME_TGT = Path("~").expanduser() +HOME_TGT = Path.home() ROOT_TGT = Path("/") -DOTFILES = HOME_TGT / "dotfiles" +DOTFILES = Path(__file__).resolve().parent HOME_SRC = DOTFILES / "HOME" ROOT_SRC = DOTFILES / "ROOT" CFG_TGT = HOME_TGT / ".config" CFG_SRC = DOTFILES / "CONFIG" CUSTOM_SRC = DOTFILES / f"custom-{HOSTNAME}" +USERNAME = getuser() installmap = dict( fonts=( "noto-fonts-emoji", @@ -430,7 +432,7 @@ def configure_pytools(overwrite: bool) -> None: def install_virtwin(overwrite: bool, reinstall: bool) -> None: helper_install(*installmap["virtwin"], reinstall=reinstall) - run("sudo usermod -aG libvirt $USER".split()) + run(["sudo", "usermod", "-aG", "libvirt", USERNAME]) run("sudo virsh net-start default".split()) run("sudo virsh net-autostart default".split()) run("systemctl enable --now libvirtd".split())