codex tips

This commit is contained in:
Henrik Bakken
2026-03-10 21:38:08 +01:00
parent e2e5716f80
commit 5310712394
4 changed files with 136 additions and 46 deletions
+117 -27
View File
@@ -137,8 +137,8 @@ map("n", "<C-l>", "<cmd>vertical resize +2<cr>", { desc = "Increase Window Width
-- https://github.com/mhinz/vim-galore#tips-1 -- https://github.com/mhinz/vim-galore#tips-1
-- smarter next/prev in command line -- smarter next/prev in command line
map("n", "<c-n>", "wildmenumode() ? '<c-n>' : '<down>'", { expr = true, desc = "Next" }) map("c", "<c-n>", "wildmenumode() ? '<c-n>' : '<down>'", { expr = true, desc = "Next" })
map("n", "<c-p>", "wildmenumode() ? '<c-p>' : '<up>'", { expr = true, desc = "Prev" }) map("c", "<c-p>", "wildmenumode() ? '<c-p>' : '<up>'", { expr = true, desc = "Prev" })
-- Add undo break-points -- Add undo break-points
map("i", ",", ",<c-g>u") map("i", ",", ",<c-g>u")
@@ -179,11 +179,11 @@ map("n", "<leader>uI", function()
vim.api.nvim_input("I") vim.api.nvim_input("I")
end, { desc = "Inspect Tree" }) end, { desc = "Inspect Tree" })
-- Terminal Mappings -- Terminal Mappings overridden by Snacks.terminal
map("n", "<C-/>", "<cmd>terminal<cr>", { desc = "Show Terminal" }) -- map("n", "<C-/>", "<cmd>terminal<cr>", { desc = "Show Terminal" })
map("t", "<C-/>", "<cmd>close<cr>", { desc = "Hide Terminal" }) -- map("t", "<C-/>", "<cmd>close<cr>", { desc = "Hide Terminal" })
map("n", "<C-_>", "<cmd>terminal<cr>", { desc = "which_key_ignore" }) -- map("n", "<C-_>", "<cmd>terminal<cr>", { desc = "which_key_ignore" })
map("t", "<C-_>", "<cmd>close<cr>", { desc = "which_key_ignore" }) -- map("t", "<C-_>", "<cmd>close<cr>", { desc = "which_key_ignore" })
-- windows -- windows
map("n", "<M-v>", "<cmd>vsplit<cr>", { desc = "Split Window Right", remap = true }) map("n", "<M-v>", "<cmd>vsplit<cr>", { desc = "Split Window Right", remap = true })
@@ -208,7 +208,7 @@ map("n", "<leader><tab>d", "<cmd>tabclose<cr>", { desc = "Close Tab" })
map("n", "<leader><tab>p", "<cmd>tabprevious<cr>", { desc = "Previous Tab" }) map("n", "<leader><tab>p", "<cmd>tabprevious<cr>", { desc = "Previous Tab" })
-- other -- other
map("n", "<leader>cw", [[:cd %:p:h<cr>]], { desc = "Set Workspace To Buffer Path" }) map("n", "<leader>cW", [[:cd %:p:h<cr>]], { desc = "Set Workspace To Buffer Path" })
map("n", "<leader>o", "m`o<Esc>``", { desc = "Insert Newline" }) map("n", "<leader>o", "m`o<Esc>``", { desc = "Insert Newline" })
map( map(
"n", "n",
@@ -293,7 +293,7 @@ vim.api.nvim_create_autocmd("FileType", {
-- wrap and check for spell in text filetypes -- wrap and check for spell in text filetypes
vim.api.nvim_create_autocmd("FileType", { vim.api.nvim_create_autocmd("FileType", {
group = vim.api.nvim_create_augroup("wrap_spell", { clear = true }), group = vim.api.nvim_create_augroup("wrap_spell", { clear = true }),
pattern = { "text", "plaintex", "typst", "gitcommit", "markdown" }, pattern = { "text", "plaintext", "typst", "gitcommit", "markdown" },
callback = function() callback = function()
vim.opt_local.wrap = true vim.opt_local.wrap = true
vim.opt_local.spell = 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, { vim.notify("Unsupported file format: " .. fmt, vim.log.levels.ERROR, {
title = "ConvertEOL", title = "ConvertEOL",
}) })
return
end end
vim.bo.fileformat = fmt vim.bo.fileformat = fmt
vim.cmd([[write]]) vim.cmd([[write]])
@@ -544,7 +545,9 @@ local function makespec_hexokinase()
return { return {
-- coloring of colornames -- coloring of colornames
"rrethy/vim-hexokinase", "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, config = function() vim.g.Hexokinase_highlighters = { "virtual" } end,
} }
end end
@@ -967,6 +970,7 @@ local function makespec_whichkey()
spec = { spec = {
{ {
mode = { "n", "v" }, mode = { "n", "v" },
{ "<leader>a", group = "ai" },
{ "<leader>c", group = "code/content" }, { "<leader>c", group = "code/content" },
{ "<leader>f", group = "file/find" }, { "<leader>f", group = "file/find" },
{ "<leader>g", group = "git" }, { "<leader>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("<leader>uc") Snacks.toggle.option("conceallevel", { off = 0, on = vim.o.conceallevel > 0 and vim.o.conceallevel or 2 }):map("<leader>uc")
Snacks.toggle.diagnostics():map("<leader>ud") Snacks.toggle.diagnostics():map("<leader>ud")
Snacks.toggle.dim():map("<leader>uD") Snacks.toggle.dim():map("<leader>uD")
Snacks.toggle.inlay_hints():map("<leader>ui") -- Snacks.toggle.inlay_hints():map("<leader>ui") -- using vim.show_pos instead
Snacks.toggle.line_number():map("<leader>ul") Snacks.toggle.line_number():map("<leader>ul")
Snacks.toggle.option("relativenumber", { name = "Relative Number" }):map("<leader>uL") Snacks.toggle.option("relativenumber", { name = "Relative Number" }):map("<leader>uL")
Snacks.toggle.option("spell", { name = "Spelling" }):map("<leader>us") Snacks.toggle.option("spell", { name = "Spelling" }):map("<leader>us")
@@ -1349,23 +1353,36 @@ local function makespec_treesitter()
"nvim-treesitter/nvim-treesitter", "nvim-treesitter/nvim-treesitter",
build = ":TSUpdate", build = ":TSUpdate",
opts = { opts = {
{ ensure_installed = {
ensure_installed = { "bash",
"bash", "c",
"c", "cpp",
"cpp", "css",
"git_rebase", "diff",
"gitcommit", "git_rebase",
"lua", "gitcommit",
"python", "gitignore",
"regex", "html",
"vimdoc", "javascript",
}, "json",
auto_install = true, "json5",
highlight = { enable = true }, "lua",
indent = { enable = true, disable = { "python" }, additional_vim_regex_highlighting = { "python" } }, "markdown",
-- incremental_selection done by flash plugin "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, init = function() vim.opt.foldexpr = "nvim_treesitter#foldexpr()" end,
} }
@@ -1463,6 +1480,78 @@ local function makespec_conform()
} }
end 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 = {
{ "<leader>ai", "<cmd>AvanteAsk<cr>", desc = "AI Ask", mode = { "n", "v" } },
{ "<leader>ae", "<cmd>AvanteEdit<cr>", desc = "AI Edit Selection", mode = "v" },
{ "<leader>ar", "<cmd>AvanteRefresh<cr>", desc = "AI Refresh Context" },
},
}
end
local function makespec_noice() local function makespec_noice()
return { return {
"folke/noice.nvim", "folke/noice.nvim",
@@ -1523,6 +1612,7 @@ for _, spec in ipairs({
makespec_autotag(), makespec_autotag(),
makespec_lint(), makespec_lint(),
makespec_mason(), makespec_mason(),
-- makespec_avante(),
-- navigation -- navigation
makespec_atone(), makespec_atone(),
makespec_whichkey(), makespec_whichkey(),
+3 -3
View File
@@ -164,10 +164,10 @@ c.tabs.tabs_are_windows = False
c.tabs.title.format = "{index}.{current_title}" c.tabs.title.format = "{index}.{current_title}"
c.tabs.undo_stack_size = 1000 c.tabs.undo_stack_size = 1000
c.tabs.width = "15%" c.tabs.width = "15%"
c.url.start_pages = "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 = "http://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( 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={}", aw="https://wiki.archlinux.org/?search={}",
ap="https://www.archlinux.org/packages/?q={}", ap="https://www.archlinux.org/packages/?q={}",
gh="https://github.com/search?q={}&type=repositories", gh="https://github.com/search?q={}&type=repositories",
+11 -13
View File
@@ -12,12 +12,11 @@ set -g allow-passthrough
set -g history-limit 100000 set -g history-limit 100000
set -g focus-events on set -g focus-events on
# Set the default terminal terminfo # Advertise tmux correctly to programs running inside it.
set -g default-terminal "foot" set -g default-terminal "tmux-256color"
# True color support (Tc) and undercurl support (Smol) # Tell tmux which features the outer Foot client supports.
set -as terminal-overrides ',foot:Tc' set -as terminal-features ',foot*:RGB,clipboard,focus,title'
set -as terminal-overrides ',foot:Smol'
# Start with index 1 # Start with index 1
set -g base-index 1 set -g base-index 1
@@ -31,11 +30,8 @@ bg_active_window="color252"
bg_highlight="red" bg_highlight="red"
# pane title # 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-status top
setw -g pane-border-format " #{pane_current_path} #{=/-20/…:pane_current_command} ${ps_pid}[${cmd}] #{?alternate_on,<Alt Mode> ,}" setw -g pane-border-format " #{pane_current_path} #{=/-40/…:pane_current_command} #{?alternate_on,<Alt Mode> ,}"
set -g pane-border-style "fg=${fg_inactive_pane}" set -g pane-border-style "fg=${fg_inactive_pane}"
set -g pane-active-border-style "fg=${fg_active_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. # Note : you can press super key by set M.
# (tested with tty only) # (tested with tty only)
set -g prefix M-a set -g prefix M-a
bind M-a send-prefix
# First remove *all* keybindings # First remove *all* keybindings
unbind -a unbind -a
bind M-a send-prefix
# Basic bindings # Basic bindings
bind ? list-keys bind ? list-keys
bind d detach-client bind d detach-client
@@ -90,12 +87,13 @@ bind c copy-mode
# clipboard control # clipboard control
bind p paste-buffer bind p paste-buffer
bind -T copy-mode-vi v send-keys -X begin-selection 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 r send-keys -X rectangle-toggle
bind -T copy-mode-vi Escape send-keys -X cancel 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-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 MouseDragEnd1Pane send-keys -X copy-pipe-and-cancel "wl-copy"
bind -T copy-mode-vi 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 "wl-copy"
# Rename window # Rename window
bind , command-prompt "rename-window %%" bind , command-prompt "rename-window %%"
+5 -3
View File
@@ -14,6 +14,7 @@
# - ... etc # - ... etc
# - sudo enable ufw # - sudo enable ufw
from difflib import unified_diff from difflib import unified_diff
from getpass import getuser
from os.path import lexists from os.path import lexists
from pathlib import Path from pathlib import Path
from shutil import rmtree from shutil import rmtree
@@ -21,14 +22,15 @@ from subprocess import run
from urllib.request import urlretrieve from urllib.request import urlretrieve
HOSTNAME = open("/etc/hostname").read().strip() HOSTNAME = open("/etc/hostname").read().strip()
HOME_TGT = Path("~").expanduser() HOME_TGT = Path.home()
ROOT_TGT = Path("/") ROOT_TGT = Path("/")
DOTFILES = HOME_TGT / "dotfiles" DOTFILES = Path(__file__).resolve().parent
HOME_SRC = DOTFILES / "HOME" HOME_SRC = DOTFILES / "HOME"
ROOT_SRC = DOTFILES / "ROOT" ROOT_SRC = DOTFILES / "ROOT"
CFG_TGT = HOME_TGT / ".config" CFG_TGT = HOME_TGT / ".config"
CFG_SRC = DOTFILES / "CONFIG" CFG_SRC = DOTFILES / "CONFIG"
CUSTOM_SRC = DOTFILES / f"custom-{HOSTNAME}" CUSTOM_SRC = DOTFILES / f"custom-{HOSTNAME}"
USERNAME = getuser()
installmap = dict( installmap = dict(
fonts=( fonts=(
"noto-fonts-emoji", "noto-fonts-emoji",
@@ -430,7 +432,7 @@ def configure_pytools(overwrite: bool) -> None:
def install_virtwin(overwrite: bool, reinstall: bool) -> None: def install_virtwin(overwrite: bool, reinstall: bool) -> None:
helper_install(*installmap["virtwin"], reinstall=reinstall) 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-start default".split())
run("sudo virsh net-autostart default".split()) run("sudo virsh net-autostart default".split())
run("systemctl enable --now libvirtd".split()) run("systemctl enable --now libvirtd".split())