Initial commit

This commit is contained in:
Trevor Vallender 2023-11-10 15:44:13 +00:00
commit 976b1a5307
9 changed files with 504 additions and 0 deletions

14
.bash_aliases Normal file
View File

@ -0,0 +1,14 @@
alias weather="curl wttr.in/~Isle+of+Wight"
alias pubip="curl -4 icanhazip.com"
alias less="less -r"
[[ -f ~/.LESS_TERMCAP ]] && . ~/.LESS_TERMCAP
alias checkport="sudo netstat -tnlp | grep"
alias de="devenv"
alias dockerpurge="docker system prune --all --force --volumes"
alias dockerkill="docker stop \`docker ps -a -q\`"
alias vi="nvim"
alias tp="$HOME/bin/tmux_pair.bash"
alias tpdf="termpdf.py"
alias tn="tmux new-window -n"
alias genpdf="pandoc -o migration.pdf -t ms"

107
.bashrc Normal file
View File

@ -0,0 +1,107 @@
PAGER="less -r"
EDITOR="nvim"
VISUAL="nvim"
PATH=$HOME/bin:$HOME/.my_config/bin:$PATH
shopt -s checkwinsize
XDG_STATE_HOME=$HOME/.state
LC_ALL="en_GB.UTF-8"
# Sane defaults for history
HISTFILE=$XDG_STATE_HOME/.bash_history
HISTSIZE=10000
HISTFILESIZE=20000
HISTCONTROL=ignoredups:erasedups # Ubuntu default is ignoreboth
shopt -s histappend # In Ubuntu this is already set by default
PROMPT_COMMAND="${PROMPT_COMMAND:+$PROMPT_COMMAND$'\n'}history -a; history -c; history -r"
shopt -s histappend
# Prompt setup
GIT_PS1_SHOWDIRTYSTATE=1
GIT_PS1_SHOWSTASHSTATE=1
GIT_PS1_SHOWUNTRACKEDFILES=1
GIT_PS1_SHOWUPSTREAM="auto"
source ~/bin/git_prompt.sh
BLUE='\033[0;34m'
CLEAR='\033[0m'
CYAN='\033[0;36m'
GREEN='\033[0;32m'
YELLOW='\033[0;33m'
BOLD='\033[01m'
PS1="\n\n[$GREEN\\]\h$CLEAR\\]] [$BLUE\\]\w$CLEAR\\]]"
PS1+=' $(__git_ps1 [$YELLOW%s$CLEAR]) \n'
PS1+="➮ \[$BOLD\]"
trap 'printf "\033[0m" >&2' DEBUG
if command -v fzf-share >/dev/null; then
source "$(fzf-share)/key-bindings.bash"
source "$(fzf-share)/completion.bash"
fi
# If not running interactively, don't do anything
case $- in
*i*) ;;
*) return;;
esac
# don't put duplicate lines or lines starting with space in the history.
HISTCONTROL=ignoreboth
# append to the history file, don't overwrite it
shopt -s histappend
# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
HISTSIZE=10000
HISTFILESIZE=2000
# check the window size after each command and, if necessary,
# update the values of LINES and COLUMNS.
shopt -s checkwinsize
# make less more friendly for non-text input files, see lesspipe(1)
[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"
# If this is an xterm set the title to user@host:dir
case "$TERM" in
xterm*|rxvt*)
PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
;;
*)
;;
esac
# enable color support of ls and also add handy aliases
if [ -x /usr/bin/dircolors ]; then
test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
alias ls='ls --color=auto'
alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'
fi
# colored GCC warnings and errors
export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01'
# Alias definitions.
# You may want to put all your additions into a separate file like
# ~/.bash_aliases, instead of adding them here directly.
# See /usr/share/doc/bash-doc/examples in the bash-doc package.
if [ -f ~/.bash_aliases ]; then
. ~/.bash_aliases
fi
# enable programmable completion features
if ! shopt -oq posix; then
if [ -f /usr/share/bash-completion/bash_completion ]; then
. /usr/share/bash-completion/bash_completion
elif [ -f /etc/bash_completion ]; then
. /etc/bash_completion
fi
fi
eval "$(/home/tsv/.rbenv/bin/rbenv init - bash)"

52
.config/git/config Normal file
View File

@ -0,0 +1,52 @@
[user]
name = Trevor Vallender
email = trevor@tsvallender.co.uk
[includeIf "gitdir:~/foxsoft/"]
path = ~/.config/git/config_foxsoft
[includeIf "gitdir:~/fs/"]
path = ~/.config/git/config_foxsoft
[core]
autocrlf = input
safecrlf = true
excludesfile = $XDG_CONFIG_HOME/git/gitignore
editor = nvim
[alias]
aa = add -A
ap = add --patch
aap = !git add --intent-to-add . && git add --patch
br = branch
cb = clone --bare
co = checkout
cm = commit
cma = commit --amend
g = log --all --grep # Search commit messages
hist = log --pretty=format:\"%h %ad | %s%d [%an]\" --graph --date=short
last = log -1 HEAD
pf = push --force
pmr = push -o merge_request.create -o merge_request.assign="trevor" -o merge_request.remove_source_branch
pmrup = !git push -u origin $(git symbolic-ref --short HEAD) -o merge_request.create -o merge_request.assign="trevor" -o merge_request.remove_source_branch
pmrd = pmr -o merge_request.draft
pmrdup = pmrup -o merge_request.draft
pushup = !git push -u origin $(git symbolic-ref --short HEAD)
rbd = rebase develop
rbi = rebase -i # Useful for squashing commits
st = status
tree = log --oneline --graph --decorate --all
undo-commit = reset --soft HEAD~
wa = worktree add
wr = worktree remove
[init]
defaultBranch = main
[interactive]
diffFilter = delta --color-only
[delta]
features = collared-trogon
navigate = true # use n and N to move between diff sections
side-by-side = true
line-numbers = true
[merge]
conflictstyle = diff3
[diff]
colorMoved = default

View File

@ -0,0 +1,4 @@
[user]
email = trevor@foxsoft.co.uk
[commit]
template = ~/fs/git_template

172
.config/nvim/init.lua Normal file
View File

@ -0,0 +1,172 @@
--- Basic stuff
local set = vim.opt
set.autoindent = true
set.tabstop = 2
set.shiftwidth = 2
set.softtabstop = 2
set.expandtab = true
set.number = true
set.relativenumber = true
--- Plugins
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
vim.fn.system({
"git",
"clone",
"--filter=blob:none",
"https://github.com/folke/lazy.nvim.git",
"--branch=stable", -- latest stable release
lazypath,
})
end
vim.opt.rtp:prepend(lazypath)
vim.g.mapleader = " " -- Make sure to set `mapleader` before lazy so your mappings are correct
require("lazy").setup({
"folke/which-key.nvim",
{ "ellisonleao/gruvbox.nvim", priority = 1000 , config = true },
{
'nvim-telescope/telescope.nvim', tag = '0.1.4',
dependencies = { 'nvim-lua/plenary.nvim' }
},
"nvim-tree/nvim-tree.lua",
"nvim-treesitter/nvim-treesitter",
{
"Exafunction/codeium.vim",
config = function ()
-- Change '<C-g>' here to any keycode you like.
vim.keymap.set('i', '<C-g>', function () return vim.fn['codeium#Accept']() end, { expr = true })
vim.keymap.set('i', '<c-;>', function() return vim.fn['codeium#CycleCompletions'](1) end, { expr = true })
vim.keymap.set('i', '<c-,>', function() return vim.fn['codeium#CycleCompletions'](-1) end, { expr = true })
vim.keymap.set('i', '<c-x>', function() return vim.fn['codeium#Clear']() end, { expr = true })
end
},
"hrsh7th/nvim-cmp",
"sar/cmp-lsp.nvim",
"neovim/nvim-lspconfig"
})
require("tsv.remap")
--- Appearance
set.cursorline = true
vim.o.background = "dark"
require("gruvbox").setup({
transparent_mode = true,
})
vim.cmd([[colorscheme gruvbox]])
-- Improve terminal setup
vim.api.nvim_command("autocmd TermOpen * startinsert")
vim.api.nvim_command("autocmd TermOpen * setlocal nonumber norelativenumber")
vim.api.nvim_command("autocmd TermEnter * setlocal signcolumn=no")
vim.keymap.set('t', '<esc>', "<C-\\><C-n>")
-- Git
vim.g.fugitive_gitlab_domains = {'https://git.foxsoft.co.uk'}
-- Strip trailing spaces
vim.api.nvim_create_autocmd({"BufWritePre"}, {
pattern = { "*" },
command = [[%s/\s\+$//e]],
})
-- Nvim-tree
require("nvim-tree").setup({
sort_by = "case_sensitive",
filters = {
dotfiles = true,
},
})
-- Treesitter
require'nvim-treesitter.configs'.setup {
sync_install = false,
auto_install = false,
highlight = {
enable = true,
additional_vim_regex_highlighting = false,
},
}
-- Completion and LSP
local cmp = require'cmp'
cmp.setup {
snippet = {
expand = function(args)
vim.fn["vsnip#anonymous"](args.body)
end,
},
window = {
completion = cmp.config.window.bordered(),
documentation = cmp.config.window.bordered(),
},
mapping = cmp.mapping.preset.insert({
['<C-b>'] = cmp.mapping.scroll_docs(-4),
['<C-f>'] = cmp.mapping.scroll_docs(4),
['<C-Space>'] = cmp.mapping.complete(),
['<C-e>'] = cmp.mapping.abort(),
['<C-y>'] = cmp.mapping.confirm({ select = true }),
}),
sources = cmp.config.sources({
{ name = 'nvim_lsp' },
{ name = 'vsnip' },
{ name = 'path' },
{ name = 'treesitter' },
})
}
local capabilities = require('cmp_nvim_lsp').default_capabilities()
-- textDocument/diagnostic support until 0.10.0 is released
_timers = {}
local function setup_diagnostics(client, buffer)
if require("vim.lsp.diagnostic")._enable then
return
end
local diagnostic_handler = function()
local params = vim.lsp.util.make_text_document_params(buffer)
client.request("textDocument/diagnostic", { textDocument = params }, function(err, result)
if err then
local err_msg = string.format("diagnostics error - %s", vim.inspect(err))
vim.lsp.log.error(err_msg)
end
local diagnostic_items = {}
if result then
diagnostic_items = result.items
end
vim.lsp.diagnostic.on_publish_diagnostics(
nil,
vim.tbl_extend("keep", params, { diagnostics = diagnostic_items }),
{ client_id = client.id }
)
end)
end
diagnostic_handler() -- to request diagnostics on buffer when first attaching
vim.api.nvim_buf_attach(buffer, false, {
on_lines = function()
if _timers[buffer] then
vim.fn.timer_stop(_timers[buffer])
end
_timers[buffer] = vim.fn.timer_start(200, diagnostic_handler)
end,
on_detach = function()
if _timers[buffer] then
vim.fn.timer_stop(_timers[buffer])
end
end,
})
end
require("lspconfig").ruby_ls.setup({
on_attach = function(client, buffer)
setup_diagnostics(client, buffer)
end,
})
-- Vimwiki
vim.cmd([[
let g:vimwiki_list = [{'path': '$HOME/notes/', 'syntax': 'markdown', 'ext': '.md'}]
]])

View File

@ -0,0 +1,13 @@
{
"cmp-lsp.nvim": { "branch": "main", "commit": "60e1e16308c862f678ea02b8430befa20c8fda6c" },
"codeium.vim": { "branch": "main", "commit": "1efe2a2cdf516094bdb211aa8a1d45ef01836207" },
"gruvbox.nvim": { "branch": "main", "commit": "477c62493c82684ed510c4f70eaf83802e398898" },
"lazy.nvim": { "branch": "main", "commit": "96584866b9c5e998cbae300594d0ccfd0c464627" },
"nvim-cmp": { "branch": "main", "commit": "0b751f6beef40fd47375eaf53d3057e0bfa317e4" },
"nvim-lspconfig": { "branch": "master", "commit": "b0852218bc5fa6514a71a9da6d5cfa63a263c83d" },
"nvim-tree.lua": { "branch": "master", "commit": "a2aaf8b430c11af36b869cf1c0ad2f7c8ceeaf2c" },
"nvim-treesitter": { "branch": "master", "commit": "04a9a90c2a60c86aa9451c539586326b337b03e5" },
"plenary.nvim": { "branch": "master", "commit": "50012918b2fc8357b87cff2a7f7f0446e47da174" },
"telescope.nvim": { "branch": "master", "commit": "7011eaae0ac1afe036e30c95cf80200b8dc3f21a" },
"which-key.nvim": { "branch": "main", "commit": "4433e5ec9a507e5097571ed55c02ea9658fb268a" }
}

View File

@ -0,0 +1,70 @@
vim.g.mapleader = " "
vim.keymap.set("n", "<leader>pv", vim.cmd.Ex)
-- Text input
vim.keymap.set('n', '<leader>pt', ":pu!=strftime('%R')<CR>");
vim.keymap.set('n', '<leader>pd', ":pu!=strftime('%F')<CR>");
vim.keymap.set('n', '<leader>pD', ":pu!=strftime('%c')<CR>");
-- Telescope
local builtin = require('telescope.builtin')
local telescope = require('telescope')
vim.keymap.set('n', '<leader>tf', builtin.find_files, {}) -- Open files
vim.keymap.set('n', '<leader>ts', builtin.live_grep, {}) -- Grep files
vim.keymap.set('n', '<leader>tb', builtin.buffers, {}) -- Neovim buffers
vim.keymap.set('n', '<leader>tm', builtin.man_pages, {}) -- man pages
vim.keymap.set('n', '<leader>tp', builtin.registers, {}) -- Paste from registers
vim.keymap.set('n', '<leader>tt', builtin.resume, {}) -- Last open Telescope
vim.keymap.set('n', '<leader>to', builtin.oldfiles, {}) -- Recently opened files
-- Git functionality (tg prefix)
vim.keymap.set('n', '<leader>tgf', builtin.git_files, {})
vim.keymap.set('n', '<leader>tgc', builtin.git_commits, {})
vim.keymap.set('n', '<leader>tgh', builtin.git_bcommits, {}) -- Current buffer's commits
vim.keymap.set('n', '<leader>tgb', builtin.git_branches, {}) -- CR: checkout, C-t: track, C-r: rebase, C-a: create, C-s: switch, C-d: delete, C-y: merge
vim.keymap.set('n', '<leader>tgs', builtin.git_stash, {}) -- List stash, apply with CR
-- LSP functionality (tl prefix)
vim.keymap.set('n', '<leader>tlr', builtin.lsp_references, {})
vim.keymap.set('n', '<leader>tli', builtin.lsp_incoming_calls, {})
vim.keymap.set('n', '<leader>tlo', builtin.lsp_outgoing_calls, {})
vim.keymap.set('n', '<leader>tld', builtin.lsp_definitions, {})
vim.keymap.set('n', '<leader>tlt', builtin.lsp_type_definitions, {})
vim.keymap.set("n", "<leader>tlf", vim.lsp.buf.format) -- Format code
vim.keymap.set('n', '<leader>e', vim.diagnostic.open_float)
-- Custom Telescope commands for Rails
vim.keymap.set('n', '<leader>trj', function()
builtin.find_files({ search_dirs = { "app/javascript", "app/assets/javascripts" } })
end, { desc = "Open Rails Javascripts" } )
vim.keymap.set('n', '<leader>trsj', function()
builtin.live_grep({ search_dirs = { "app/javascript", "app/assets/javascripts" } })
end, { desc = "Grep Rails Javascripts" } )
vim.keymap.set('n', '<leader>trm', function()
builtin.find_files({ search_dirs = { "app/models" } })
end, { desc = "Open Rails Models" } )
vim.keymap.set('n', '<leader>trsm', function()
builtin.live_grep({ search_dirs = { "app/models" } })
end, { desc = "Grep Rails Models" } )
vim.keymap.set('n', '<leader>trc', function()
builtin.find_files({ search_dirs = { "app/controllers" } })
end, { desc = "Open Rails Controllers" } )
vim.keymap.set('n', '<leader>trsc', function()
builtin.live_grep({ search_dirs = { "app/controllers" } })
end, { desc = "Grep Rails Controllers" } )
vim.keymap.set('n', '<leader>trv', function()
builtin.find_files({ search_dirs = { "app/views" } })
end, { desc = "Open Rails Views" } )
vim.keymap.set('n', '<leader>trsv', function()
builtin.live_grep({ search_dirs = { "app/views" } })
end, { desc = "Grep Rails Views" } )
-- Fugitive
vim.keymap.set('n', '<leader>gs', vim.cmd.Git);
vim.keymap.set('n', '<leader>ds', ':Gvdiffsplit!<CR>');
vim.keymap.set('n', '<leader>gl', ':diffget //2<CR>'); -- 'Get left' window
vim.keymap.set('n', '<leader>gr', ':diffget //3<CR>'); -- 'Get right' window
-- Nvim-tree
vim.keymap.set("n", "<leader>nt", vim.cmd.NvimTreeToggle, {})

1
.psqlrc Normal file
View File

@ -0,0 +1 @@
\setenv PAGER 'pspg'

71
.tmux.conf Normal file
View File

@ -0,0 +1,71 @@
set-option -g default-shell $SHELL
# switch to last window like screen
bind-key C-o last-window
# rebind escape key
set-option -g prefix C-o
unbind-key C-b
set -g default-terminal "tmux"
set -as terminal-features ",kitty:RGB"
set -g history-limit 10000
set -g history-file ~/.dotfiles/.tmux_history
set -g window-size smallest
bind-key j select-pane -D
bind-key k select-pane -U
bind-key l select-pane -R
bind-key h select-pane -L
## COLORSCHEME: gruvbox dark (medium)
set-option -g status "on"
# default statusbar color
set-option -g status-style bg=colour237,fg=colour223 # bg=bg1, fg=fg1
# default window title colors
set-window-option -g window-status-style bg=colour214,fg=colour237 # bg=yellow, fg=bg1
# default window with an activity alert
set-window-option -g window-status-activity-style bg=colour237,fg=colour248 # bg=bg1, fg=fg3
# active window title colors
set-window-option -g window-status-current-style bg=red,fg=colour237 # fg=bg1
# pane border
set-option -g pane-active-border-style fg=colour250 #fg2
set-option -g pane-border-style fg=colour237 #bg1
# message infos
set-option -g message-style bg=colour239,fg=colour223 # bg=bg2, fg=fg1
# writing commands inactive
set-option -g message-command-style bg=colour239,fg=colour223 # bg=fg3, fg=bg1
# pane number display
set-option -g display-panes-active-colour colour250 #fg2
set-option -g display-panes-colour colour237 #bg1
# clock
set-window-option -g clock-mode-colour colour109 #blue
# bell
set-window-option -g window-status-bell-style bg=colour167,fg=colour235 # bg=red, fg=bg
## Theme settings mixed with colors (unfortunately, but there is no cleaner way)
set-option -g status-justify "left"
set-option -g status-left-style none
set-option -g status-left-length "80"
set-option -g status-right-style none
set-option -g status-right-length "80"
set-window-option -g window-status-separator ""
set-option -g status-left "#[bg=colour241,fg=colour248] #S #[bg=colour237,fg=colour241,nobold,noitalics,nounderscore]"
set-option -g status-right "#[bg=colour237,fg=colour239 nobold, nounderscore, noitalics]#[bg=colour239,fg=colour246] %Y-%m-%d  %H:%M #[bg=colour239,fg=colour248,nobold,noitalics,nounderscore]#[bg=colour248,fg=colour237] #h "
set-window-option -g window-status-current-format "#[bg=colour214,fg=colour237,nobold,noitalics,nounderscore]#[bg=colour214,fg=colour239] #I #[bg=colour214,fg=colour239,bold] #W#{?window_zoomed_flag,*Z,} #[bg=colour237,fg=colour214,nobold,noitalics,nounderscore]"
set-window-option -g window-status-format "#[bg=colour239,fg=colour237,noitalics]#[bg=colour239,fg=colour223] #I #[bg=colour239,fg=colour223] #W #[bg=colour237,fg=colour239,noitalics]"