Compare commits

...

8 Commits

Author SHA1 Message Date
unkinben b5dee7e0f2 multiple updates
- update swayrc with 4k monitor
- update popterm
- update nvim lsp config
- add helm-ls
- remove yaml/ansible lsps
2025-12-07 20:50:11 +11:00
unkinben 145a25974e Add git autoSetupRemote 2025-11-15 15:39:47 +11:00
unkinben 7e925b2c31 feat: manage tv as external monitor 2025-09-27 15:27:20 +10:00
unkinben ead675c788 chore: update pass repo 2025-09-27 15:27:04 +10:00
unkinben ff3f9e4604 feat: add script to manage worktrees 2025-09-27 15:26:45 +10:00
unkinben 60c67eecee Multiple updates:
add restic to common aliases
update puppet functions/modules
add restic-backup command
2025-08-14 19:35:26 +10:00
unkinben 3b349870d8 feat: add all missing from backlog 2025-06-17 06:01:52 +10:00
unkinben 2fa4e8b410 nvim updates
- add terraform-ls
- add droneci to puppet modules
- added friendly-snippets
2024-09-18 23:22:17 +10:00
13 changed files with 382 additions and 77 deletions
+1
View File
@@ -22,6 +22,7 @@
[push]
default = simple
autoSetupRemote = true
[fetch]
prune = true
+173 -57
View File
@@ -37,59 +37,6 @@ require("nvim-tree").setup({
},
})
-- mason
require("mason").setup()
require("mason-lspconfig").setup()
-- lspconfig
-- require('lspconfig')['gofumpt'].setup{}
-- require('lspconfig')['golines'].setup{}
-- require('lspconfig')['goimports'].setup{}
require('lspconfig')['gopls'].setup{
on_attach = on_attach,
cmd = {"gopls"},
filetypes = {"go", "gomod", "gowork", "dotmpl"},
settings = {
gopls = {
gofumpt = true,
completeUnimported = true,
usePlaceholders = true,
analyses = {
unusedparams = true,
},
},
},
}
require('lspconfig')['pyright'].setup {
on_attach = on_attach,
flags = lsp_flags,
}
require('lspconfig')['powershell_es'].setup{}
require('lspconfig')['clangd'].setup{}
require('lspconfig')['rust_analyzer'].setup{}
require('lspconfig')['ansiblels'].setup{}
require('lspconfig')['bashls'].setup{}
require('lspconfig')['lua_ls'].setup{
settings = {
Lua = {
diagnostics = {
globals = { 'vim', 'on_attach', 'lsp_flags'}
}
}
}
}
require('lspconfig')['yamlls'].setup{
settings = {
yaml = {
customTags = { '!vault'}
}
}
}
require('lspconfig')['intelephense'].setup{}
require('lspconfig')['grammarly'].setup{}
require('lspconfig')['puppet'].setup{}
require('lspconfig')['terraformls'].setup{}
-- Completion Plugin Setup
local cmp = require'cmp'
cmp.setup({
@@ -121,7 +68,7 @@ cmp.setup({
{ name = 'nvim_lsp_signature_help'}, -- display function signatures with current parameter emphasized
{ name = 'nvim_lua', keyword_length = 2}, -- complete neovim's Lua runtime API such vim.lsp.*
{ name = 'buffer', keyword_length = 2 }, -- source current buffer
{ name = 'vsnip', keyword_length = 2 }, -- nvim-cmp source for vim-vsnip
{ name = 'vsnip', keyword_length = 2 }, -- nvim-cmp source for vim-vsnip
{ name = 'calc'}, -- source for math calculation
},
window = {
@@ -143,10 +90,167 @@ cmp.setup({
},
})
-- treesitter
-- LSP configuration using Neovim 0.11+ vim.lsp.config() API
-- Note: Default keybindings and capabilities are automatically set
-- mason (for LSP server management)
require("mason").setup()
require("mason-lspconfig").setup({
automatic_installation = true,
})
-- Go language server configuration
vim.lsp.config('gopls', {
cmd = {"gopls"},
filetypes = {"go", "gomod", "gowork", "gotmpl"},
settings = {
gopls = {
gofumpt = true,
completeUnimported = true,
usePlaceholders = true,
analyses = {
unusedparams = true,
shadow = true,
},
hints = {
assignVariableTypes = true,
compositeLiteralFields = true,
compositeLiteralTypes = true,
constantValues = true,
functionTypeParameters = true,
parameterNames = true,
rangeVariableTypes = true,
},
},
},
})
-- Python language server
vim.lsp.config('pyright', {
settings = {
python = {
analysis = {
typeCheckingMode = "basic",
},
},
},
})
-- PowerShell language server
vim.lsp.config('powershell_es', {})
-- C/C++ language server
vim.lsp.config('clangd', {})
-- Rust language server
vim.lsp.config('rust_analyzer', {
settings = {
["rust-analyzer"] = {
checkOnSave = {
command = "clippy",
},
inlayHints = {
enable = true,
},
},
},
})
-- -- Ansible language server
-- vim.lsp.config('ansiblels', {})
-- Bash language server
vim.lsp.config('bashls', {})
-- Lua language server
vim.lsp.config('lua_ls', {
settings = {
Lua = {
runtime = {
version = 'LuaJIT',
},
diagnostics = {
globals = { 'vim' },
},
workspace = {
library = vim.api.nvim_get_runtime_file("", true),
checkThirdParty = false,
},
telemetry = {
enable = false,
},
hint = {
enable = true,
},
},
},
})
-- vim.lsp.config('helm_ls', {
-- settings = {
-- ['helm-ls'] = {
-- yamlls = {
-- path = "yaml-language-server",
-- }
-- }
-- }
-- })
-- -- YAML language server
-- vim.lsp.config('yamlls', {
-- settings = {
-- yaml = {
-- customTags = { '!vault' },
-- schemas = {
-- kubernetes = "*.yaml",
-- ["http://json.schemastore.org/github-workflow"] = ".github/workflows/*",
-- ["http://json.schemastore.org/ansible-playbook"] = "*play*.{yml,yaml}",
-- ["http://json.schemastore.org/chart"] = "Chart.{yml,yaml}",
-- ["https://json.schemastore.org/gitlab-ci"] = "*gitlab-ci*.{yml,yaml}",
-- ["https://raw.githubusercontent.com/compose-spec/compose-spec/master/schema/compose-spec.json"] = "*docker-compose*.{yml,yaml}",
-- },
-- },
-- },
-- })
-- PHP language server
vim.lsp.config('intelephense', {})
-- Grammar checking
vim.lsp.config('grammarly', {})
-- Puppet language server
vim.lsp.config('puppet', {})
-- Terraform language server
vim.lsp.config('terraformls', {})
-- Enable all configured language servers
vim.lsp.enable('gopls')
vim.lsp.enable('pyright')
vim.lsp.enable('powershell_es')
vim.lsp.enable('clangd')
vim.lsp.enable('rust_analyzer')
-- vim.lsp.enable('ansiblels')
vim.lsp.enable('bashls')
vim.lsp.enable('lua_ls')
-- vim.lsp.enable('yamlls')
-- vim.lsp.enable('helm_ls')
vim.lsp.enable('intelephense')
vim.lsp.enable('grammarly')
vim.lsp.enable('puppet')
vim.lsp.enable('terraformls')
vim.api.nvim_create_autocmd({"BufWritePre"}, {
pattern = {"*.tf", "*.tfvars"},
callback = function()
vim.lsp.buf.format()
end,
})
-- treesitter
require('nvim-treesitter.configs').setup {
--ensure_installed = { "lua", "toml", "python", "bash", "yaml", "go" },
ensure_installed = "all",
ensure_installed = { "lua", "toml", "python", "bash", "yaml", "go" },
--ensure_installed = "all",
auto_install = true,
highlight = {
enable = true,
@@ -226,3 +330,15 @@ require('mini.indentscope').setup()
require('mini.splitjoin').setup()
require('mini.surround').setup()
require('mini.trailspace').setup()
vim.api.nvim_create_autocmd("BufEnter", {
pattern = "*.py",
callback = function()
vim.defer_fn(function()
local venv_path = vim.fn.getcwd() .. "/.venv/bin/python"
if vim.fn.filereadable(venv_path) == 1 then
vim.cmd("PyrightSetPythonPath " .. venv_path)
end
end, 1000) -- 1 second delay (1000ms)
end,
})
+19
View File
@@ -39,3 +39,22 @@ vim.cmd [[
autocmd FileType eruby nnoremap <buffer> <Leader>s :call ToggleERBSyntax()<CR>
augroup END
]]
-- terraform language keybindings
vim.cmd [[
augroup lang_terraform
autocmd!
autocmd BufNewFile,BufRead *.tf set filetype=terraform
augroup END
]]
-- tmpl language keybindings
vim.cmd [[
augroup lang_tmpl
autocmd!
autocmd BufNewFile,BufRead *.yml.tmpl set filetype=yaml
autocmd BufNewFile,BufRead *.yaml.tmpl set filetype=yaml
autocmd BufNewFile,BufRead *.hcl.tmpl set filetype=hcl
augroup END
]]
+73 -14
View File
@@ -1,9 +1,31 @@
-- enter testmode
-- Popterm configuration with named terminals support
vim.cmd([[
" nvim-only config
if has('nvim')
function! OpenCenteredTerminal()
" Global dictionaries to track terminal windows and buffers by name
let g:popterm_windows = {}
let g:popterm_buffers = {}
let g:popterm_current_win = -1
function! ToggleNamedPopterm(name, command)
" Check if this named terminal window exists and is valid
if has_key(g:popterm_windows, a:name) && g:popterm_windows[a:name] != -1 && nvim_win_is_valid(g:popterm_windows[a:name])
" Close the terminal window
call nvim_win_close(g:popterm_windows[a:name], v:false)
let g:popterm_windows[a:name] = -1
let g:popterm_current_win = -1
return
endif
" Close any other open popterm window first
for [term_name, win_id] in items(g:popterm_windows)
if win_id != -1 && nvim_win_is_valid(win_id)
call nvim_win_close(win_id, v:false)
let g:popterm_windows[term_name] = -1
endif
endfor
" Calculate the desired width and height as 80% of the current window size
let height = float2nr((&lines * 0.8) / 1)
let width = float2nr((&columns * 0.8) / 1)
@@ -12,27 +34,64 @@ vim.cmd([[
let top = float2nr((&lines - height) / 2)
let left = float2nr((&columns - width) / 2)
" Define options for the floating window, including its size and position
let opts = {'relative': 'editor', 'row': top, 'col': left, 'width': width, 'height': height, 'style': 'minimal'}
" Define options for the floating window with border
let opts = {
\ 'relative': 'editor',
\ 'row': top,
\ 'col': left,
\ 'width': width,
\ 'height': height,
\ 'style': 'minimal',
\ 'border': 'rounded',
\ 'title': ' ' . a:name . ' ',
\ 'title_pos': 'center'
\ }
" Create a new buffer for the terminal, set it to not listed and with no swapfile
let buf = nvim_create_buf(v:false, v:true)
" Reuse existing buffer for this terminal or create new one
if !has_key(g:popterm_buffers, a:name) || g:popterm_buffers[a:name] == -1 || !nvim_buf_is_valid(g:popterm_buffers[a:name])
let g:popterm_buffers[a:name] = nvim_create_buf(v:false, v:true)
endif
" Open a new window with the terminal buffer, applying the specified options
call nvim_open_win(buf, v:true, opts)
" Open a new window with the terminal buffer
let g:popterm_windows[a:name] = nvim_open_win(g:popterm_buffers[a:name], v:true, opts)
let g:popterm_current_win = g:popterm_windows[a:name]
" Run the default shell in the terminal
call termopen($SHELL)
" Start terminal if buffer is empty or hasn't been initialized
let buffer_lines = nvim_buf_get_lines(g:popterm_buffers[a:name], 0, -1, v:false)
if empty(buffer_lines) || (len(buffer_lines) == 1 && buffer_lines[0] == '')
if a:command != ''
call termopen(a:command, {'buffer': g:popterm_buffers[a:name]})
else
call termopen($SHELL, {'buffer': g:popterm_buffers[a:name]})
endif
endif
" Adjust the focus to the newly opened terminal window
" Set terminal-specific key mappings for this terminal
execute 'tnoremap <buffer> <leader>T <C-\><C-n>:call ToggleNamedPopterm("' . a:name . '", "' . a:command . '")<CR>'
execute 'tnoremap <buffer> <leader>a <C-\><C-n>:call ToggleNamedPopterm("claude", "claude")<CR>'
" Enter insert mode
startinsert
endfunction
" Define the :Popterm command to open the centered terminal
" Wrapper functions for specific terminals
function! TogglePopterm()
call ToggleNamedPopterm('general', '')
endfunction
function! ToggleClaudePopterm()
call ToggleNamedPopterm('claude', 'claude')
endfunction
" Define commands
highlight Terminal guibg=#000000 guifg=none
"autocmd TermOpen * setlocal winhighlight=Normal:Terminal
command! Popterm call OpenCenteredTerminal()
command! Popterm call TogglePopterm()
command! ClaudePopterm call ToggleClaudePopterm()
" Key mappings
nnoremap T :Popterm<CR>
nnoremap <S-t> :Popterm<CR>
nnoremap <leader>a :ClaudePopterm<CR>
endif
]])
+5
View File
@@ -49,7 +49,10 @@ function! OpenPuppetProfileOrRole(layout)
" List modules in puppet-control here
let module_list = []
call add(module_list, 'certbot')
call add(module_list, 'droneci')
call add(module_list, 'frrouting')
call add(module_list, 'glauth')
call add(module_list, 'incus')
call add(module_list, 'jellyfin')
call add(module_list, 'lidarr')
call add(module_list, 'networking')
@@ -59,6 +62,8 @@ function! OpenPuppetProfileOrRole(layout)
call add(module_list, 'readarr')
call add(module_list, 'redisha')
call add(module_list, 'sonarr')
call add(module_list, 'vlcluster')
call add(module_list, 'vmcluster')
" Check if the class name starts with 'profiles::' or 'roles::'
if classname =~ '^profiles::'
+3
View File
@@ -33,6 +33,7 @@ return require('packer').startup(function(use)
use 'hrsh7th/cmp-path'
use 'hrsh7th/cmp-buffer'
use 'hrsh7th/vim-vsnip'
use "rafamadriz/friendly-snippets"
-- telescope
use {
@@ -49,7 +50,9 @@ return require('packer').startup(function(use)
use { 'numToStr/FTerm.nvim' } -- floating terminal
use { 'HampusHauffman/block.nvim' } -- code blocks in different colours
use { 'rodjek/vim-puppet' } -- vim puppet enhancements
use { 'jvirtanen/vim-hcl' } -- hcl syntax highlighting
-- use { 'fatih/vim-go' } -- go-vim
use { 'qvalentin/helm-ls.nvim' }
-- theme
+3 -1
View File
@@ -32,6 +32,8 @@ if command -v nvim >/dev/null 2>&1; then
alias vi='nvim'
fi
alias purevim='vim -u NONE'
alias vimp='xargs nvim -p'
# tmux
if [[ -n $TMUX ]]; then
@@ -70,7 +72,7 @@ alias ypush="yadm push && yadm push origin master"
# fix commands
alias ipcalc='~/.local/bin/ipcalc -n'
alias mpv="mpv -hwdec=vdpau"
alias ifstat="/usr/bin/ifstat"
alias ifstat="/usr/local/bin/ifstat"
alias snapper="sudo /usr/bin/snapper"
alias ap="~/.local/bin/ansible-playbook"
+61 -1
View File
@@ -17,7 +17,8 @@ export ANSIBLE_VAULT_PASSWORD_FILE=$HOME/.local/bin/ansible-vault-pass-client
# VAULT
export VAULT_ADDR=https://vault.service.consul:8200
vaultlogin () {
vault login $(pass show personal/vault/syd1/token)
#vault login $(pass show personal/vault/syd1/token)
export VAULT_TOKEN=$(vault login --field=token --method=ldap username=benvin)
}
# CONSUL: https://developer.hashicorp.com/consul/commands
@@ -26,6 +27,9 @@ export CONSUL_HTTP_TOKEN_FILE=$HOME/.config/consul/token.secret
export CONSUL_HTTP_SSL=true
export CONSUL_HTTP_SSL_VERIFY=true
# NOMAD
export NOMAD_ADDR=https://nomad.service.consul:4646
# set MPD host
export MPD_HOST="$HOME/.config/mpd/socket"
@@ -70,6 +74,10 @@ ncurl() {
curl --netrc-file <(pass show personal/netrc) "$@"
}
export GPG_TTY=$(tty)
export RESTIC_REPOSITORY=s3:https://radosgw.service.consul/restic-personal
export RESTIC_PASSWORD_COMMAND="pass show personal/restic/metabox"
# create function later:
# large image heavy pdf into smaller pdf
# below will:
@@ -80,3 +88,55 @@ ncurl() {
# pdftoppm -jpeg -r 300 input_document.pdf output_image
# jpegoptim --size=100k output_image*.jpg
# img2pdf $(ls -v output_image*.jpg) -o output_document.pdf
# Create a git worktree for the current repo.
# Usage: newtree <branch-name> [<from-ref>]
# - If <from-ref> is omitted, defaults to HEAD.
# - Worktree path: $HOME/src/worktrees/<repo_name>/<branch_name_sanitised>
# (slashes and dashes in the *path component only* are replaced with underscores)
newtree() {
local branch from_ref repo_root repo_name sanitized dest parent
branch="$1"
from_ref="${2:-HEAD}"
if [[ -z "$branch" ]]; then
echo "Usage: newtree <branch-name> [<from-ref>]" >&2
return 2
fi
# Ensure we're inside a git repo
if ! repo_root="$(git rev-parse --show-toplevel 2>/dev/null)"; then
echo "Error: not inside a git repository." >&2
return 1
fi
repo_name="$(basename "$repo_root")"
# Sanitize the branch *for the path only* (keep original branch name for git)
sanitized="${branch//[\/-]/_}"
dest="$HOME/src/worktrees/$repo_name/$sanitized"
parent="$(dirname "$dest")"
# Create parent dir; git will create the final leaf
mkdir -p "$parent" || {
echo "Error: unable to create directory: $parent" >&2
return 1
}
# Optional: prune stale worktrees to avoid false conflicts
git -C "$repo_root" worktree prune >/dev/null 2>&1
# Does the branch already exist?
if git -C "$repo_root" rev-parse --verify --quiet "refs/heads/$branch" >/dev/null; then
echo "Branch '$branch' exists; adding worktree at: $dest"
# --force in case the branch is already checked out elsewhere
git -C "$repo_root" worktree add --force "$dest" "$branch" || return $?
else
echo "Branch '$branch' does not exist; creating from '$from_ref' at: $dest"
git -C "$repo_root" worktree add --force -b "$branch" "$dest" "$from_ref" || return $?
fi
# Jump into the new worktree
cd "$dest" || return $?
echo "✔ Worktree ready at: $dest"
}
+10 -3
View File
@@ -299,13 +299,20 @@ bindsym $mod+r mode "resize"
# monitor-mode settings
# use "swaymsg -t get_outputs" to list outputs
set $laptop eDP-1
set $dell1 'Dell Inc. DELL U2713HM GK0KD357412L'
set $dell1 'Dell Inc. DELL U4320Q D1QV193'
set $dell2 'Dell Inc. DELL U2713HM GK0KD357413L'
set $tv 'Samsung Electric Company SAMSUNG 0x01000E00'
bindswitch --reload --locked lid:on output $laptop disable
bindswitch --reload --locked lid:off output $laptop enable
output $laptop resolution 1920x1080 position 0,0
output $dell1 resolution 2560x1440@59.951Hz position 0,660 transform normal
output $dell2 resolution 2560x1440@59.951Hz position 2560,0 transform 270
output $dell1 resolution 3840x2160@59.997Hz position 0,660 transform normal
output $dell2 resolution 2560x1440@59.951Hz position 3840,530 transform 270
output $tv resolution 1920x1080@59.951Hz position 0,660 transform normal
workspace $ws1 output $dell1
workspace $ws2 output $dell2
workspace $ws3 output $dell1
workspace $ws4 output $dell2
# class border bground text indicator child_border
client.focused #6272A4 #6272A4 #F8F8F2 #6272A4 #6272A4
+6
View File
@@ -32,3 +32,9 @@ sudo dnf install -y firefox chromium gimp libreoffice dia shotwell thunderbird i
tmux udiskie upower vifm virt-manager libvirt jpegoptim poppler-utils qpdf alacritty dunst feh i3 i3blocks \
maim network-manager-applet pavucontrol sway swaylock waybar wl-clipboard grim slurp polybar mpc mpd mpv \
ncmpcpp openvpn
# NPM
npm i opencode-ai@latest
ln -s ~/node_modules/.bin/opencode ~/bin/opencode
+13
View File
@@ -154,3 +154,16 @@ export SSH_AUTH_SOCK
# load shell settings
test -r $XDG_CONFIG_HOME/shell/common && source $XDG_CONFIG_HOME/shell/common
test -r $XDG_CONFIG_HOME/shell/aliases && source $XDG_CONFIG_HOME/shell/aliases
# autocomplete tools
autoload -U +X bashcompinit && bashcompinit
complete -o nospace -C /usr/bin/terraform terraform
complete -o nospace -C /usr/bin/consul consul
complete -o nospace -C /usr/bin/nomad nomad
complete -o nospace -C /usr/bin/vault vault
eval "$(uv generate-shell-completion zsh)"
eval "$(nfpm completion zsh)"
fpath+=~/.zfunc; autoload -Uz compinit; compinit
zstyle ':completion:*' menu select
+14
View File
@@ -0,0 +1,14 @@
#!/usr/bin/bash
export GPG_TTY=$(tty)
export $(pass show personal/radosgw/benvin)
restic backup "$HOME" --exclude-caches --one-file-system \
--exclude '**/.cache' \
--exclude '**/.terraform' \
--exclude '**/.terragrunt-cache' \
--exclude '**/.local/share/containers' \
--exclude '**/go/pkg/mod' \
--exclude '**/Downloads' \
--exclude '**/.thunderbird' \
--exclude '**/backups' \
--exclude '**/Video'