all repos — dotfiles-base @ 23b5492723397297ac5b1a100c9c37bbd475d02a

base important configs that can safely be used almost anywhere

Initial commit of base dotfiles
x1phosura x1phosura@x1phosura.zone
Tue, 26 Dec 2023 00:23:36 -0800
commit

23b5492723397297ac5b1a100c9c37bbd475d02a

A .bash_profile

@@ -0,0 +1,17 @@

+# +# ~/.bash_profile +# + +[[ -f ~/.bashrc ]] && . ~/.bashrc + +# autostart systemd default session on tty1 +#if [[ "$(tty)" == '/dev/tty1' ]]; then +# exec startx +#fi + +# rust +. "$HOME/.cargo/env" + +# opam configuration +test -r /home/x1phosura/.opam/opam-init/init.sh && . /home/x1phosura/.opam/opam-init/init.sh > /dev/null 2> /dev/null || true +
A .bash_prompt

@@ -0,0 +1,126 @@

+# shellcheck shell=bash + +# Customize bash prompt +# lolcat reference: http://apple.stackexchange.com/a/266112/216733 +# If dynamic can use literal control characters. Otherwise, +# must use PS1 escapes or else line wrap issue. +PROMPT_COMMAND="__prompt_command${PROMPT_COMMAND:+"; $PROMPT_COMMAND"}" +PS1_COLORIZE_COMMAND='__ps1_lolcat' +# shellcheck disable=SC2034 +PS1_DEBUG_COMMAND='__ps1_debug' + +PS1_DEBUG='false' + +__prompt_command() { + # Save last exit code + PS1_exit=$? + + if [[ "$PS1_DEBUG" = 'true' ]]; then + if [[ "$PS1" = "$PS1_DEBUG_DISABLED" ]]; then + PS1=$PS1_DEBUG_ENABLED + fi + else + if [[ "$PS1" = "$PS1_DEBUG_ENABLED" ]]; then + PS1=$PS1_DEBUG_DISABLED + fi + fi +} + +ps1_set_debug_mode() { + if [[ "$PS1_DEBUG" = 'true' ]]; then + PS1=$PS1_DEBUG_ENABLED + else + PS1=$PS1_DEBUG_DISABLED + fi +} + +TERM_DEFAULT=$(tput sgr0) +TERM_BOLD=$(tput bold) # I added this, as of now unused +TERM_RED=$(tput setaf 1) +TERM_GREEN=$(tput setaf 2) +TERM_BLUE=$(tput setaf 4) + +ESC=$'\033' +SOH=$'\001' +STX=$'\002' + +PS1_DEFAULT_LITERAL=$SOH$TERM_DEFAULT$STX +PS1_RED_LITERAL=$SOH$TERM_RED$STX +PS1_GREEN_LITERAL=$SOH$TERM_GREEN$STX +PS1_BLUE_LITERAL=$SOH$TERM_BLUE$STX + +PS1_DEFAULT_ESCAPED='\['$TERM_DEFAULT'\]' + +# Caveat: +# to have a literal '\' or '"' work in both $PS1_DEBUG_DISABLED and +# $PS1_DEBUG_ENABLED, '\' must be represented with '\\\\' and +# '"' must be represented with '\\"' or '\"' to have the proper amount of +# escaping in both modes. PS1 seems to have an initial interpret phase where +# it strips off one level of backslashes, then an echo phase where it strips +# off the second level so '\\\\' =interpret> '\\' =echo> '\' +# '\\"' =interpret> '\"' =echo> '"' +# The following is a bit trickier. Normally, echo would treat the double quote +# as starting a string. PS1 seems to treat it as a literal when echoing. As +# a result, '\\"' is preferred over '\"' as it is easier to understand what is +# happening. +# '\"' =interpret> 'literal(")' =echo> '"' +# In $PS1_DEBUG_ENABLED, the interpret phase is still run by PS1. The echo +# phase is emulated by wrapping $PS1 in double quotes: ...<<<"'PS1'"... +unset PS1 +# vvv - actually change PS1 here - vvv +PS1_COLORLESS=$(sed 's/[[:space:]]*$//' <<<"${PS1:-[\u@\h]:\w \\$}") +PS1_SPACING=' ' +PS1='' + +__ps1_remove_newline() { + tr -d '\n' +} + +__ps1_color_wrap_non_printing() { + local REGEX=$ESC'\[[[:digit:];]*m' + local REPLACE=$SOH'&'$STX + sed "s/$REGEX/$REPLACE/g" +} + +# change lolcat arguments here +__ps1_lolcat() { + lolcat-c -f -h 1.4 | __ps1_remove_newline | __ps1_color_wrap_non_printing +} +PS1+='$(eval "$PS1_COLORIZE_COMMAND" <<<"'$PS1_COLORLESS'")' +PS1+=$PS1_SPACING + +PS1_DEBUG_DISABLED=$PS1 +# long colored prompt text that go over a line have a line wrap issue. +# Problem occurs with literal and PS1 escaped control characters. Tried +# escaping each individual character with perl at +# "$SCRIPTS_DIR"'/ps1_colorize_debug.pl' but still doesn't work. +# can't colorize debug literal text with sed because it does not have the +# following: +# non-greedy quantifiers to do \^B\(.*?\)\^A if running a second sed to +# consume \^B and \^A again. +# lookahead to do \(.*?)\(?=\^A) which wouldn't require a second sed because +# \^A is is looked for but not consumed. +# can use perl regex if want to colorize debug literal text. +# sed also doesn't have non capturing groups so groups are offset. +__ps1_colorize_debug() { + local SOH_REGEX='(\^A)' + local COLOR_CODE_REGEX='((\^\[\(B)?\^\[\[[[:digit:];]*m)' + local STX_REGEX='(\^B)' + local REGEX=$SOH_REGEX$COLOR_CODE_REGEX$STX_REGEX + + local SOH_REPLACE=$PS1_RED_LITERAL'\1'$PS1_DEFAULT_LITERAL + local COLOR_CODE_REPLACE=$PS1_BLUE_LITERAL'\2'$PS1_DEFAULT_LITERAL + local STX_REPLACE=$PS1_GREEN_LITERAL'\4'$PS1_DEFAULT_LITERAL + local REPLACE=$SOH_REPLACE$COLOR_CODE_REPLACE$STX_REPLACE + + sed -E "s/$REGEX/$REPLACE/g" +} +__ps1_debug() { + cat -v | __ps1_colorize_debug +} +__ps1_debug_sed() { + sed -e 's/'$ESC'/[ESC]/g' -e 's/'$SOH'/[SOH]/g' -e 's/'$STX'/[STX]/g' +} +# wrap PS1 for debugging +# shellcheck disable=SC2016 +PS1_DEBUG_ENABLED='$(eval "$PS1_DEBUG_COMMAND" <<<"'$PS1'")'
A .bashrc

@@ -0,0 +1,382 @@

+# +# .bashrc +# (Note: this _should_ be _somewhat_ OS-agnostic, at least, enough for me) +# + +# uncomment below to profile bashrc startup in /tmp/bashstart.SEC.NANOSEC +#PS4='+ $(date "+%s.%N")\011 ' +#exec 3>&2 2>/tmp/bashstart.$$.log +#set -x + +# If not running interactively, don't do anything +[[ $- != *i* ]] && return + +# source global bashrc settings (turned off by default, uncomment otherwise) +# [ -f /etc/bashrc ] && source /etc/bashrc + +shopt -s checkwinsize # check window size after cmd, update LINES and COLUMNS +shopt -s globstar # pattern '**' matches all files, >= 0 dir/subdirs +#shopt -s expand_aliases # // + + +HISTSIZE=48000 # history lines stored in memory (while using bash) +HISTFILESIZE=48000 # history lines stored in .bash_history after session +HISTCONTROL=ignoredups # ignore duplicate commands or if start with a space +shopt -s histappend # append to history file instead of overwriting + +case "$(uname -s)" in # for OS-specific configuration + Linux) operating_system='linux' ;; + Darwin) operating_system='macOS' ;; + FreeBSD|OpenBSD|NetBSD) operating_system='BSD' ;; + CYGWIN*|MINGW32*|MSYS*|MINGW*) operating_system='windows' ;; + *) operating_system='other' ;; +esac + +[ -f /etc/hostname ] && hostname="$(cat /etc/hostname)" + +# set PATH to something tolerable +# NOTE: in Arch, everything's already in /usr/bin, /usr/sbin anyway +if [ "$operating_system" = "linux" ]; then + PATH="/usr/bin:/usr/local/bin:/bin:/usr/sbin:/usr/local/sbin:/sbin" # base + PATH="$PATH:/usr/local/games:/usr/games" # base + PATH="$PATH:$HOME/bin" # secret sauce + PATH="$PATH:$HOME/.local/bin" # mostly for pip + PATH="$PATH:$HOME/.emacs.d/bin" # DOOM baby! + PATH="$PATH:$HOME/.cargo/bin" # rust + if [ "$hostname" = "planetx" ]; then + PATH="$PATH:$HOME/opt/riscv/bin" # RISC-V Newlib cross-compiler + elif [ "$hostname" = "shorefall" ]; then + PATH="$PATH:$HOME/bin/jdk-11.0.10+9/bin" # JavaTM + PATH="$PATH:$HOME/bin/android-studio/bin" # Android Studio + #PATH="$PATH:/var/lib/snapd/snap/bin" # snapd + PATH="$PATH:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl" + fi +elif [ "$operating_system" = "macOS" ]; then + PATH="/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin" + PATH="$PATH:/Library/Apple/usr/bin" +fi + +# apply work settings +[ -f "$HOME"/.bash_work_stuff ] && source "$HOME"/.bash_work_stuff + +export PATH + +#export GDK_DPI_SCALE=1.5 # for scaling GTK applications, may sometimes want + +export BROWSER="firefox" + +if [[ "$operating_system" = "macOS" || "$operating_system" = "BSD" ]] ; then + export CLICOLOR=1 +fi + +# use 'nvim' if it exists on system +if [ command -v nvim &> /dev/null ]; then + export EDITOR='vim' +else + export EDITOR='nvim' + alias vim='nvim ' +fi + +# make less more friendly for non-text input files, see lesspipe(1) +[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)" + + +# uncomment for a colored prompt, if the terminal has the capability; turned +# off by default to not distract the user: the focus in a terminal window +# should be on the output of commands, not on the prompt +#force_color_prompt=yes +if [ -n "$force_color_prompt" ]; then + if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then + # We have color support; assume it's compliant with Ecma-48 + # (ISO/IEC-6429). (Lack of such support is extremely rare, and such + # a case would tend to support setf rather than setaf.) + color_prompt=yes + else + color_prompt= + fi +fi + +# PS1 settings +#Old PS1: PS1="[\u@\h]:\w\$ " +if [[ $(id -u) -eq 0 ]]; then # if current user is root + PS1="\[\033[41m\]\[\033[37m\][\u@\h]\[\033[00m\]:\[\033[01;31m\]\w\[\033[00m\]\$ " +elif [[ -f ~/.bash_prompt ]]; then # not root, but ~/.bash_prompt exists + unset color_prompt force_color_prompt + source ~/.bash_prompt +else # if not root, and no prompt config + PS1="\[\033[1;37m\][\u@\h]\[\033[00m\]:\[\033[01;32m\]\w\[\033[00m\]$ " +fi + +# colored GCC warnings and errors +GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01: quote=01' +export GCC_COLORS + + +############################## user functions ############################## + +# find-keyword [directory path] [keyword]: find and list files with keyword in +# the filename +find-keyword() { + if [ "$#" -ne 2 ]; then # if not given 2 arguments + echo "Usage: find-keyword [directory path] [keyword]" + else + find $1 -name "*$2*" -ls + fi +} + +# find-string [string] [directory path]: find and list files containing the +# provided string (and list all occurences/line numbers of the string) +find-string() { + if [ "$#" -ne 2 ]; then # if not given 2 arguments + echo "Usage: find-string [string] [directory path]" + else + grep -nR "$1" "$2" + fi +} + +# img_loop_here: $1 = seconds until next photo displayed +# BUG: currently, after running this function, the user needs to manually run +# 'reset' to unscrew the terminal +img-loop-here() { + if [ "$1" = "" ]; then + echo "Usage: img_loop_here [seconds until next photo displayed]" + else + while true; do + for g in $(ls .); do + timeout "$1" chafa -c full "$g" + done + done + fi +} + +# rainbow-shell: print out a looping rainbow in the shell. Happy pride month! +# For best results, run in full-screened terminal (Mod+f in i3) +rainbow-shell() { + yes "$(seq 231 -1 16)" | while read i; do + printf "\x1b[48;5;${i}m\n" + sleep .02 + done +} + +# colors - print out current color values set in terminal +colors() { + local fgc bgc vals seq0 + + printf "Color escapes are %s\n" '\e[${value};...;${value}m' + printf "Values 30..37 are \e[33mforeground colors\e[m\n" + printf "Values 40..47 are \e[43mbackground colors\e[m\n" + printf "Value 1 gives a \e[1mbold-faced look\e[m\n\n" + + # foreground colors + for fgc in {30..37}; do + # background colors + for bgc in {40..47}; do + fgc=${fgc#37} # white + bgc=${bgc#40} # black + + vals="${fgc:+$fgc;}${bgc}" + vals=${vals%%;} + + seq0="${vals:+\e[${vals}m}" + printf " %-9s" "${seq0:-(default)}" + printf " ${seq0}TEXT\e[m" + printf " \e[${vals:+${vals+$vals;}}1mBOLD\e[m" + done + echo; echo + done +} + +# term-color-vals: print all 256-bit color values in their associated color +term-color-vals() { + for i in {0..255}; do + printf "\x1b[38;5;${i}mcolor%-5i\x1b[0m" $i + if ! (( ($i + 1 ) % 8 )); then + echo + fi + done +} + +# ex - archive extractor +# usage: ex <file> +ex() { + if [ -f $1 ] ; then + case $1 in + *.tar.bz2) tar xjf $1 ;; + *.tar.gz) tar xzf $1 ;; + *.bz2) bunzip2 $1 ;; + *.rar) unrar x $1 ;; + *.gz) gunzip $1 ;; + *.tar) tar xf $1 ;; + *.tbz2) tar xjf $1 ;; + *.tgz) tar xzf $1 ;; + *.zip) unzip $1 ;; + *.Z) uncompress $1 ;; + *.7z) 7z x $1 ;; + *) echo "'$1' cannot be extracted via ex()" ;; + esac + else + echo "'$1' is not a valid file" + fi +} + +# prune_bash_history - remove certain frequently-used/"clutter" command entries +# from .bash_history +prune_bash_history() { +sed 's/^l$//g ; s/^ll$//g ; s/^la$//g ; s/^lla$//g ; s/^cl$//g ; s/^range$//g ; s/^e$//g ; s/^q$//g ; /^$/d ' \ + "$HOME"/.bash_history > \ + "$HOME"/.bash_history-BAK + if [ -f "$HOME"/.bash_history-BAK ]; then + mv "$HOME"/.bash_history-BAK "$HOME"/.bash_history + else + echo "[ERROR] .bash_history-BAK was not created. Aborting..." + fi +} + +# public-ip: fetch current public IP address +public-ip() { + curl 'http://icanhazip.com/' +} + +# scan-for-printers: look for printers on the connected LAN +scan-for-printers() { + sudo lpinfo -v +} + +# wifi-strength: get some WiFi statistics in real time +wifi-strength() { + watch -n 1 cat /proc/net/wireless +} + +sync-src-to-dest() { + if [ ! "$#" = 2 ]; then + echo "A useful rsync helper, semi-unsafe if used thoughtlessly" + echo "usage: $0 [src-dir/] [dest-dir/]" + return 1 + fi + + rsync -avhcz -e ssh --stats --progress --delete --force "$1" "$2" +} + +# STILL has one edge case (if argument contains '..' AND goes through symlink) +mkcd() { + case "$1" in /*) :;; *) set -- "./$1";; esac # for weird directories "-xx/" + mkdir "$1" && cd "$1" +} + +# create executable file containing 'sh' shebang +touch-script() { + if [ "$#" = 0 ]; then + echo "usage: $0 [path(s) to one or more script file(s) to init...] " + return 1 + else + touch "$@" + chmod +x "$@" + for f in "$@"; do + printf '#!/bin/sh\n\n' > "$f" + done + fi +} + +# pick file path with fzf, open in $EDITOR +fzvim() { + file_path="$(fzf)" + if [ -e "$file_path" ]; then + "$EDITOR" "$file_path" + elif [ "$file_path" = "" ]; then # no entries chosen from fzf + : # do nothing + else + echo "$file_path not found." + fi +} + +############################## aliases ############################## + +# Note to self: alias substitution is recursive AS LONG AS each expanded alias +# ends in a space character (allowing for multiple aliases to be used on one +# line). This is a POSIX specification. You do not know how long it took me to +# figure this out. + +# miscellaneous aliases +alias cl='clear ' +alias e='exit ' +alias q='exit ' +alias DIE='shutdown now ' +alias cp='cp -i ' # confirm before overwriting a file +alias df='df -h ' +alias fucking='sudo ' +alias goddammit=' ' +alias bottom='top ' +alias bc='bc -l ' # makes bc use 'scale=20' by default +alias rot13="tr 'A-Za-z' 'N-ZA-Mn-za-m' " +alias iso-date='date --iso-8601=s ' +alias now='date +%s ' +alias gdb='gdb -q ' # muzzle gdb +alias local_webserver='python -m http.server 8001 ' # can change port number +alias hx='/usr/lib/helix/hx ' + +# config editing aliases +alias bashrc="$EDITOR ~/.bashrc" +alias vimrc="$EDITOR ~/.vimrc" +alias init_lua="$EDITOR ~/.config/nvim/init.lua" +alias helix_config="$EDITOR ~/.config/helix/config.toml" +alias nanorc="nano ~/.config/nano/nanorc" # just for fun! +alias i3config="$EDITOR ~/.config/i3/config && i3-msg reload && i3-msg restart" +# TODO: sway config + +not_in_vim="echo -e \"You're not in vim doofus!\"" +alias :wq="$not_in_vim" ; alias :q="$not_in_vim" ; alias :x="$not_in_vim" +alias ZZ="$not_in_vim" + +alias rager='ranger '; alias anger='ranger '; alias range='ranger ' +alias rangre='ranger '; alias rangr='ranger ' # <<<-^^^-: common ranger typos + +[ "$operating_system" = "linux" ] && alias spellcheck='aspell check ' + +case "$operating_system" in + macOS) color_flag='-C ' ;; + BSD) color_flag='--color=auto ' ;; + linux) color_flag='--color=auto ' ;; + *) color_flag='--color=auto ' ;; # assume GNU ls +esac + +alias ls="ls $color_flag " +alias l="ls $color_flag " +alias ll="ls -lh $color_flag " +alias la="ls -A $color_flag " +alias lla="ls -lhA $color_flag " + +if [[ "$operating_system" = linux || "$operating_system" = other ]]; then + alias grep='grep --color=auto ' + alias egrep='egrep --color=auto ' + alias fgrep='fgrep --color=auto ' +fi + + +############################## bash completion ############################## + +# enable programmable completion features (possibly already enabled by +# /etc/bash.bashrc or /etc/profile). +if [ -f /usr/share/bash-completion/bash_completion ]; then + source /usr/share/bash-completion/bash_completion +elif [ -f /etc/bash_completion ]; then + source /etc/bash_completion +fi +if [ "$operating_system" = "macOS" ]; then + if [ -f /usr/local/etc/bash_completion ]; then # for macOS + source /usr/local/etc/bash_completion + elif [ -d /usr/local/etc/bash_completion.d ]; then # also for macOS + for file in /usr/local/etc/bash_completion.d/* ; do + source "$file" + done + fi +fi + +#complete -cf sudo # so sudo actually has tab autocompletion +bind 'set completion-ignore-case on' # case-insensitive tab autocompletion + +. "$HOME/.cargo/env" # should already be in .bash_profile, but just in case + +# uncomment below to profile bashrc startup in /tmp/bashstart.SEC.NANOSEC +#set -x +#exec 2>&3 3>&- +
A .config/nvim/colors/x1ph-off.vim

@@ -0,0 +1,231 @@

+" Name: x1ph-off.vim +" Maintainer: x1phosura +" Original license: The MIT License (MIT) +" +" A mostly-grayscale colorscheme meant to look simple and good. +" Mostly derived from the following: https://github.com/pbrisbin/vim-colors-off +" +" For translating between RGB and console (cterm) colors, see the following: +" https://www.ditig.com/256-colors-cheat-sheet +" +""" +hi clear + +if exists('syntax on') + syntax reset +endif + +let g:colors_name='x1ph-off' +let colors_off_a_little = get(g:, 'colors_off_a_little', 0) +"let colors_off_a_little = 1 + +"let s:black = { "gui": "#212121", "cterm": "0" } " old +"let s:black = { "gui": "#121212", "cterm": "233" } " looks nice too +let s:black = { "gui": "#040404", "cterm": "0" } +let s:medium_gray = { "gui": "#767676", "cterm": "243" } +let s:medium_light_gray = { "gui": "#808080", "cterm": "244" } +let s:white = { "gui": "#F1F1F1", "cterm": "15" } +let s:actual_white = { "gui": "#FFFFFF", "cterm": "231" } +let s:light_black = { "gui": "#424242", "cterm": "8" } +let s:lighter_black = { "gui": "#545454", "cterm": "240" } +let s:subtle_black = { "gui": "#303030", "cterm": "236" } +let s:light_gray = { "gui": "#B2B2B2", "cterm": "249" } +let s:lighter_gray = { "gui": "#C6C6C6", "cterm": "251" } +let s:subtle_gray = { "gui": "#696969", "cterm": "250" } +let s:pink = { "gui": "#fb007a", "cterm": "9" } +let s:dark_red = { "gui": "#C30771", "cterm": "1" } +let s:light_red = { "gui": "#E32791", "cterm": "1" } +let s:orange = { "gui": "#D75F5F", "cterm": "167" } +let s:darker_blue = { "gui": "#005F87", "cterm": "18" } +let s:dark_blue = { "gui": "#008EC4", "cterm": "4" } +let s:blue = { "gui": "#20BBFC", "cterm": "12" } +let s:light_blue = { "gui": "#b6d6fd", "cterm": "153" } +let s:dark_cyan = { "gui": "#20A5BA", "cterm": "6" } +let s:light_cyan = { "gui": "#4FB8CC", "cterm": "14" } +let s:dark_green = { "gui": "#10A778", "cterm": "2" } +let s:light_green = { "gui": "#5FD7A7", "cterm": "10" } +let s:dark_purple = { "gui": "#523C79", "cterm": "5" } +let s:light_purple = { "gui": "#6855DE", "cterm": "13" } +let s:yellow = { "gui": "#F3E430", "cterm": "11" } +let s:dark_yellow = { "gui": "#A89C14", "cterm": "3" } + +if &background == "dark" + let s:bg = s:black + let s:bg_subtle = s:light_black + "let s:bg_subtle_comment = s:subtle_gray + let s:bg_subtle_comment = s:medium_light_gray + let s:bg_very_subtle = s:subtle_black + let s:norm = s:lighter_gray + let s:norm_subtle = s:light_gray + let s:purple = s:light_purple + let s:cyan = s:light_cyan + let s:green = s:light_green + let s:red = s:light_red + let s:visual = s:lighter_black +else + let s:bg = s:actual_white + let s:bg_subtle = s:light_gray + let s:bg_subtle_comment = s:subtle_gray + let s:bg_very_subtle = s:lighter_gray + let s:norm = s:light_black + let s:norm_subtle = s:lighter_black + let s:purple = s:dark_purple + let s:cyan = s:dark_cyan + let s:green = s:dark_green + let s:red = s:dark_red + let s:visual = s:light_blue +endif + +" https://github.com/noahfrederick/vim-hemisu/ +function! s:h(group, style) + execute "highlight" a:group + \ "guifg=" (has_key(a:style, "fg") ? a:style.fg.gui : "NONE") + \ "guibg=" (has_key(a:style, "bg") ? a:style.bg.gui : "NONE") + \ "guisp=" (has_key(a:style, "sp") ? a:style.sp.gui : "NONE") + \ "gui=" (has_key(a:style, "gui") ? a:style.gui : "NONE") + \ "ctermfg=" (has_key(a:style, "fg") ? a:style.fg.cterm : "NONE") + \ "ctermbg=" (has_key(a:style, "bg") ? a:style.bg.cterm : "NONE") + \ "cterm=" (has_key(a:style, "cterm") ? a:style.cterm : "NONE") +endfunction + +call s:h("Normal", {"bg": s:bg, "fg": s:norm}) +call s:h("Cursor", {"bg": s:blue, "fg": s:norm }) +call s:h("Comment", {"fg": s:bg_subtle_comment, "gui": "italic"}) + +call s:h("Constant", {"fg": s:actual_white}) +"hi! link Constant Normal +hi! link Character Constant +hi! link Number Constant +hi! link Boolean Constant +hi! link Float Constant +hi! link String Constant + +"call s:h("Identifier", {"fg": s:dark_blue}) +hi! link Identifier Normal +hi! link Function Identifier + +"call s:h("Statement", {"fg": s:green}) +hi! link Statement Normal +hi! link Conditonal Statement +hi! link Repeat Statement +hi! link Label Statement +hi! link Operator Statement +hi! link Keyword Statement +hi! link Exception Statement + +"call s:h("PreProc", {"fg": s:red}) +hi! link PreProc Normal +hi! link Include PreProc +hi! link Define PreProc +hi! link Macro PreProc +hi! link PreCondit PreProc + +"call s:h("Type", {"fg": s:purple}) +call s:h("Type", {"fg": s:actual_white}) +"hi! link Type Normal +hi! link StorageClass Type +hi! link Structure Type +hi! link Typedef Type + +"call s:h("Special", {"fg": s:pink}) +hi! link Special Normal +hi! link SpecialChar Special +hi! link Tag Special +hi! link Delimiter Special +hi! link SpecialComment Special +hi! link Debug Special + +call s:h("Underlined", {"fg": s:norm, "gui": "underline", "cterm": "underline"}) +call s:h("Ignore", {"fg": s:bg}) +call s:h("Error", {"fg": s:actual_white, "bg": s:red, "cterm": "bold"}) +call s:h("Todo", {"fg": s:actual_white, "bg": s:pink, "gui": "bold", "cterm": "bold"}) +call s:h("SpecialKey", {"fg": s:light_green}) +call s:h("NonText", {"fg": s:medium_gray}) +call s:h("Directory", {"fg": s:dark_blue}) +call s:h("ErrorMsg", {"fg": s:pink}) +call s:h("IncSearch", {"bg": s:yellow, "fg": s:light_black}) +call s:h("Search", {"bg": s:bg_subtle, "fg": s:norm}) +call s:h("MoreMsg", {"fg": s:medium_gray, "cterm": "bold", "gui": "bold"}) +hi! link ModeMsg MoreMsg +call s:h("LineNr", {"fg": s:bg_subtle}) +call s:h("CursorLineNr", {"fg": s:blue, "bg": s:bg_very_subtle}) +call s:h("Question", {"fg": s:red}) +call s:h("StatusLine", {"bg": s:bg_very_subtle}) +call s:h("StatusLineNC", {"bg": s:bg_very_subtle, "fg": s:medium_gray}) +call s:h("VertSplit", {"bg": s:bg_very_subtle, "fg": s:bg_very_subtle}) +call s:h("Title", {"fg": s:dark_blue}) +call s:h("Visual", {"bg": s:visual}) +call s:h("VisualNOS", {"bg": s:bg_subtle}) +call s:h("WarningMsg", {"fg": s:red}) +call s:h("WildMenu", {"fg": s:bg, "bg": s:norm}) +call s:h("Folded", {"fg": s:medium_gray}) +call s:h("FoldColumn", {"fg": s:bg_subtle}) +call s:h("DiffAdd", {"fg": s:green}) +call s:h("DiffDelete", {"fg": s:red}) +call s:h("DiffChange", {"fg": s:dark_yellow}) +call s:h("DiffText", {"fg": s:dark_blue}) +call s:h("SignColumn", {"fg": s:light_green}) + +if has("gui_running") + call s:h("SpellBad", {"gui": "underline", "sp": s:red}) + call s:h("SpellCap", {"gui": "underline", "sp": s:light_green}) + call s:h("SpellRare", {"gui": "underline", "sp": s:pink}) + call s:h("SpellLocal", {"gui": "underline", "sp": s:dark_green}) +else + call s:h("SpellBad", {"cterm": "underline", "fg": s:red}) + call s:h("SpellCap", {"cterm": "underline", "fg": s:light_green}) + call s:h("SpellRare", {"cterm": "underline", "fg": s:pink}) + call s:h("SpellLocal", {"cterm": "underline", "fg": s:dark_green}) +endif + +call s:h("Pmenu", {"fg": s:norm, "bg": s:bg_subtle}) +call s:h("PmenuSel", {"fg": s:norm, "bg": s:blue}) +call s:h("PmenuSbar", {"fg": s:norm, "bg": s:bg_subtle}) +call s:h("PmenuThumb", {"fg": s:norm, "bg": s:bg_subtle}) +call s:h("TabLine", {"fg": s:norm, "bg": s:bg_very_subtle}) +call s:h("TabLineSel", {"fg": s:blue, "bg": s:bg_subtle, "gui": "bold", "cterm": "bold"}) +call s:h("TabLineFill", {"fg": s:norm, "bg": s:bg_very_subtle}) +call s:h("CursorColumn", {"bg": s:bg_very_subtle}) +call s:h("CursorLine", {"fg": s:norm, "bg": s:bg_very_subtle}) +call s:h("ColorColumn", {"bg": s:bg_subtle}) + +call s:h("MatchParen", {"bg": s:bg_subtle, "fg": s:norm}) +call s:h("qfLineNr", {"fg": s:medium_gray}) + +call s:h("htmlH1", {"bg": s:bg, "fg": s:norm}) +call s:h("htmlH2", {"bg": s:bg, "fg": s:norm}) +call s:h("htmlH3", {"bg": s:bg, "fg": s:norm}) +call s:h("htmlH4", {"bg": s:bg, "fg": s:norm}) +call s:h("htmlH5", {"bg": s:bg, "fg": s:norm}) +call s:h("htmlH6", {"bg": s:bg, "fg": s:norm}) + +hi link diffRemoved DiffDelete +hi link diffAdded DiffAdd + +" Signify, git-gutter +hi link SignifySignAdd LineNr +hi link SignifySignDelete LineNr +hi link SignifySignChange LineNr +if colors_off_a_little + hi! GitGutterAdd guifg=#10A778 ctermfg=2 + hi! GitGutterChange guifg=#A89C14 ctermfg=3 + hi! GitGutterDelete guifg=#C30771 ctermfg=1 + hi! GitGutterChangeDelete guifg=#C30771 ctermfg=1 +else + hi link GitGutterAdd LineNr + hi link GitGutterDelete LineNr + hi link GitGutterChange LineNr + hi link GitGutterChangeDelete LineNr +endif + +" Fuzzy Search, Telescope & CtrlP +if colors_off_a_little + hi! CtrlPMatch ctermbg=235 ctermfg=250 guibg=NONE guifg=#5FD7A7 cterm=NONE gui=NONE + hi! TelescopeMatching guifg=#5FD7A7 guibg=#303030 ctermbg=NONE + highlight TelescopeSelection guifg=NONE gui=bold guibg=#303030 +else + hi! CtrlPMatch ctermbg=NONE ctermfg=NONE guibg=NONE guifg=NONE cterm=NONE gui=bold + hi! TelescopeMatching guifg=NONE guibg=NONE ctermbg=NONE + highlight TelescopeSelection guifg=NONE gui=bold guibg=#303030 +endif +
A .config/nvim/init.lua

@@ -0,0 +1,8 @@

+-- my init.lua +-- x1phosura + +local vimrc = vim.fn.stdpath("config") .. "/vimrc.vim" -- get path to vimrc +vim.cmd.source(vimrc) + +require('lsp') -- my lsp setup +
A .config/nvim/inspiration/kickstart-init.lua

@@ -0,0 +1,540 @@

+--[[ + +===================================================================== +==================== READ THIS BEFORE CONTINUING ==================== +===================================================================== + +Kickstart.nvim is *not* a distribution. + +Kickstart.nvim is a template for your own configuration. + The goal is that you can read every line of code, top-to-bottom, understand + what your configuration is doing, and modify it to suit your needs. + + Once you've done that, you should start exploring, configuring and tinkering to + explore Neovim! + + If you don't know anything about Lua, I recommend taking some time to read through + a guide. One possible example: + - https://learnxinyminutes.com/docs/lua/ + + + And then you can explore or search through `:help lua-guide` + - https://neovim.io/doc/user/lua-guide.html + + +Kickstart Guide: + +I have left several `:help X` comments throughout the init.lua +You should run that command and read that help section for more information. + +In addition, I have some `NOTE:` items throughout the file. +These are for you, the reader to help understand what is happening. Feel free to delete +them once you know what you're doing, but they should serve as a guide for when you +are first encountering a few different constructs in your nvim config. + +I hope you enjoy your Neovim journey, +- TJ + +P.S. You can delete this when you're done too. It's your config now :) +--]] +-- Set <space> as the leader key +-- See `:help mapleader` +-- NOTE: Must happen before plugins are required (otherwise wrong leader will be used) +vim.g.mapleader = ' ' +vim.g.maplocalleader = ' ' + +-- Install package manager +-- https://github.com/folke/lazy.nvim +-- `:help lazy.nvim.txt` for more info +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) + +-- NOTE: Here is where you install your plugins. +-- You can configure plugins using the `config` key. +-- +-- You can also configure plugins after the setup call, +-- as they will be available in your neovim runtime. +require('lazy').setup({ + -- NOTE: First, some plugins that don't require any configuration + + -- Git related plugins + 'tpope/vim-fugitive', + 'tpope/vim-rhubarb', + + -- Detect tabstop and shiftwidth automatically + 'tpope/vim-sleuth', + + -- NOTE: This is where your plugins related to LSP can be installed. + -- The configuration is done below. Search for lspconfig to find it below. + { + -- LSP Configuration & Plugins + 'neovim/nvim-lspconfig', + dependencies = { + -- Automatically install LSPs to stdpath for neovim + { 'williamboman/mason.nvim', config = true }, + 'williamboman/mason-lspconfig.nvim', + + -- Useful status updates for LSP + -- NOTE: `opts = {}` is the same as calling `require('fidget').setup({})` + { 'j-hui/fidget.nvim', tag = 'legacy', opts = {} }, + + -- Additional lua configuration, makes nvim stuff amazing! + 'folke/neodev.nvim', + }, + }, + + { + -- Autocompletion + 'hrsh7th/nvim-cmp', + dependencies = { + -- Snippet Engine & its associated nvim-cmp source + 'L3MON4D3/LuaSnip', + 'saadparwaiz1/cmp_luasnip', + + -- Adds LSP completion capabilities + 'hrsh7th/cmp-nvim-lsp', + + -- Adds a number of user-friendly snippets + 'rafamadriz/friendly-snippets', + }, + }, + + -- Useful plugin to show you pending keybinds. + { 'folke/which-key.nvim', opts = {} }, + { + -- Adds git related signs to the gutter, as well as utilities for managing changes + 'lewis6991/gitsigns.nvim', + opts = { + -- See `:help gitsigns.txt` + signs = { + add = { text = '+' }, + change = { text = '~' }, + delete = { text = '_' }, + topdelete = { text = '‾' }, + changedelete = { text = '~' }, + }, + on_attach = function(bufnr) + vim.keymap.set('n', '<leader>hp', require('gitsigns').preview_hunk, { buffer = bufnr, desc = 'Preview git hunk' }) + + -- don't override the built-in and fugitive keymaps + local gs = package.loaded.gitsigns + vim.keymap.set({'n', 'v'}, ']c', function() + if vim.wo.diff then return ']c' end + vim.schedule(function() gs.next_hunk() end) + return '<Ignore>' + end, {expr=true, buffer = bufnr, desc = "Jump to next hunk"}) + vim.keymap.set({'n', 'v'}, '[c', function() + if vim.wo.diff then return '[c' end + vim.schedule(function() gs.prev_hunk() end) + return '<Ignore>' + end, {expr=true, buffer = bufnr, desc = "Jump to previous hunk"}) + end, + }, + }, + + { + -- Theme inspired by Atom + 'navarasu/onedark.nvim', + priority = 1000, + config = function() + vim.cmd.colorscheme 'onedark' + end, + }, + + { + -- Set lualine as statusline + 'nvim-lualine/lualine.nvim', + -- See `:help lualine.txt` + opts = { + options = { + icons_enabled = false, + theme = 'onedark', + component_separators = '|', + section_separators = '', + }, + }, + }, + + { + -- Add indentation guides even on blank lines + 'lukas-reineke/indent-blankline.nvim', + -- Enable `lukas-reineke/indent-blankline.nvim` + -- See `:help indent_blankline.txt` + opts = { + char = '┊', + show_trailing_blankline_indent = false, + }, + }, + + -- "gc" to comment visual regions/lines + { 'numToStr/Comment.nvim', opts = {} }, + + -- Fuzzy Finder (files, lsp, etc) + { + 'nvim-telescope/telescope.nvim', + branch = '0.1.x', + dependencies = { + 'nvim-lua/plenary.nvim', + -- Fuzzy Finder Algorithm which requires local dependencies to be built. + -- Only load if `make` is available. Make sure you have the system + -- requirements installed. + { + 'nvim-telescope/telescope-fzf-native.nvim', + -- NOTE: If you are having trouble with this installation, + -- refer to the README for telescope-fzf-native for more instructions. + build = 'make', + cond = function() + return vim.fn.executable 'make' == 1 + end, + }, + }, + }, + + { + -- Highlight, edit, and navigate code + 'nvim-treesitter/nvim-treesitter', + dependencies = { + 'nvim-treesitter/nvim-treesitter-textobjects', + }, + build = ':TSUpdate', + }, + + -- NOTE: Next Step on Your Neovim Journey: Add/Configure additional "plugins" for kickstart + -- These are some example plugins that I've included in the kickstart repository. + -- Uncomment any of the lines below to enable them. + -- require 'kickstart.plugins.autoformat', + -- require 'kickstart.plugins.debug', + + -- NOTE: The import below can automatically add your own plugins, configuration, etc from `lua/custom/plugins/*.lua` + -- You can use this folder to prevent any conflicts with this init.lua if you're interested in keeping + -- up-to-date with whatever is in the kickstart repo. + -- Uncomment the following line and add your plugins to `lua/custom/plugins/*.lua` to get going. + -- + -- For additional information see: https://github.com/folke/lazy.nvim#-structuring-your-plugins + -- { import = 'custom.plugins' }, +}, {}) + +-- [[ Setting options ]] +-- See `:help vim.o` +-- NOTE: You can change these options as you wish! + +-- Set highlight on search +vim.o.hlsearch = false + +-- Make line numbers default +vim.wo.number = true + +-- Enable mouse mode +vim.o.mouse = 'a' + +-- Sync clipboard between OS and Neovim. +-- Remove this option if you want your OS clipboard to remain independent. +-- See `:help 'clipboard'` +vim.o.clipboard = 'unnamedplus' + +-- Enable break indent +vim.o.breakindent = true + +-- Save undo history +vim.o.undofile = true + +-- Case-insensitive searching UNLESS \C or capital in search +vim.o.ignorecase = true +vim.o.smartcase = true + +-- Keep signcolumn on by default +vim.wo.signcolumn = 'yes' + +-- Decrease update time +vim.o.updatetime = 250 +vim.o.timeoutlen = 300 + +-- Set completeopt to have a better completion experience +vim.o.completeopt = 'menuone,noselect' + +-- NOTE: You should make sure your terminal supports this +vim.o.termguicolors = true + +-- [[ Basic Keymaps ]] + +-- Keymaps for better default experience +-- See `:help vim.keymap.set()` +vim.keymap.set({ 'n', 'v' }, '<Space>', '<Nop>', { silent = true }) + +-- Remap for dealing with word wrap +vim.keymap.set('n', 'k', "v:count == 0 ? 'gk' : 'k'", { expr = true, silent = true }) +vim.keymap.set('n', 'j', "v:count == 0 ? 'gj' : 'j'", { expr = true, silent = true }) + +-- [[ Highlight on yank ]] +-- See `:help vim.highlight.on_yank()` +local highlight_group = vim.api.nvim_create_augroup('YankHighlight', { clear = true }) +vim.api.nvim_create_autocmd('TextYankPost', { + callback = function() + vim.highlight.on_yank() + end, + group = highlight_group, + pattern = '*', +}) + +-- [[ Configure Telescope ]] +-- See `:help telescope` and `:help telescope.setup()` +require('telescope').setup { + defaults = { + mappings = { + i = { + ['<C-u>'] = false, + ['<C-d>'] = false, + }, + }, + }, +} + +-- Enable telescope fzf native, if installed +pcall(require('telescope').load_extension, 'fzf') + +-- See `:help telescope.builtin` +vim.keymap.set('n', '<leader>?', require('telescope.builtin').oldfiles, { desc = '[?] Find recently opened files' }) +vim.keymap.set('n', '<leader><space>', require('telescope.builtin').buffers, { desc = '[ ] Find existing buffers' }) +vim.keymap.set('n', '<leader>/', function() + -- You can pass additional configuration to telescope to change theme, layout, etc. + require('telescope.builtin').current_buffer_fuzzy_find(require('telescope.themes').get_dropdown { + winblend = 10, + previewer = false, + }) +end, { desc = '[/] Fuzzily search in current buffer' }) + +vim.keymap.set('n', '<leader>gf', require('telescope.builtin').git_files, { desc = 'Search [G]it [F]iles' }) +vim.keymap.set('n', '<leader>sf', require('telescope.builtin').find_files, { desc = '[S]earch [F]iles' }) +vim.keymap.set('n', '<leader>sh', require('telescope.builtin').help_tags, { desc = '[S]earch [H]elp' }) +vim.keymap.set('n', '<leader>sw', require('telescope.builtin').grep_string, { desc = '[S]earch current [W]ord' }) +vim.keymap.set('n', '<leader>sg', require('telescope.builtin').live_grep, { desc = '[S]earch by [G]rep' }) +vim.keymap.set('n', '<leader>sd', require('telescope.builtin').diagnostics, { desc = '[S]earch [D]iagnostics' }) +vim.keymap.set('n', '<leader>sr', require('telescope.builtin').resume, { desc = '[S]earch [R]esume' }) + +-- [[ Configure Treesitter ]] +-- See `:help nvim-treesitter` +require('nvim-treesitter.configs').setup { + -- Add languages to be installed here that you want installed for treesitter + ensure_installed = { 'c', 'cpp', 'go', 'lua', 'python', 'rust', 'tsx', 'javascript', 'typescript', 'vimdoc', 'vim' }, + + -- Autoinstall languages that are not installed. Defaults to false (but you can change for yourself!) + auto_install = false, + + highlight = { enable = true }, + indent = { enable = true }, + incremental_selection = { + enable = true, + keymaps = { + init_selection = '<c-space>', + node_incremental = '<c-space>', + scope_incremental = '<c-s>', + node_decremental = '<M-space>', + }, + }, + textobjects = { + select = { + enable = true, + lookahead = true, -- Automatically jump forward to textobj, similar to targets.vim + keymaps = { + -- You can use the capture groups defined in textobjects.scm + ['aa'] = '@parameter.outer', + ['ia'] = '@parameter.inner', + ['af'] = '@function.outer', + ['if'] = '@function.inner', + ['ac'] = '@class.outer', + ['ic'] = '@class.inner', + }, + }, + move = { + enable = true, + set_jumps = true, -- whether to set jumps in the jumplist + goto_next_start = { + [']m'] = '@function.outer', + [']]'] = '@class.outer', + }, + goto_next_end = { + [']M'] = '@function.outer', + [']['] = '@class.outer', + }, + goto_previous_start = { + ['[m'] = '@function.outer', + ['[['] = '@class.outer', + }, + goto_previous_end = { + ['[M'] = '@function.outer', + ['[]'] = '@class.outer', + }, + }, + swap = { + enable = true, + swap_next = { + ['<leader>a'] = '@parameter.inner', + }, + swap_previous = { + ['<leader>A'] = '@parameter.inner', + }, + }, + }, +} + +-- Diagnostic keymaps +vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, { desc = 'Go to previous diagnostic message' }) +vim.keymap.set('n', ']d', vim.diagnostic.goto_next, { desc = 'Go to next diagnostic message' }) +vim.keymap.set('n', '<leader>e', vim.diagnostic.open_float, { desc = 'Open floating diagnostic message' }) +vim.keymap.set('n', '<leader>q', vim.diagnostic.setloclist, { desc = 'Open diagnostics list' }) + +-- [[ Configure LSP ]] +-- This function gets run when an LSP connects to a particular buffer. +local on_attach = function(_, bufnr) + -- NOTE: Remember that lua is a real programming language, and as such it is possible + -- to define small helper and utility functions so you don't have to repeat yourself + -- many times. + -- + -- In this case, we create a function that lets us more easily define mappings specific + -- for LSP related items. It sets the mode, buffer and description for us each time. + local nmap = function(keys, func, desc) + if desc then + desc = 'LSP: ' .. desc + end + + vim.keymap.set('n', keys, func, { buffer = bufnr, desc = desc }) + end + + nmap('<leader>rn', vim.lsp.buf.rename, '[R]e[n]ame') + nmap('<leader>ca', vim.lsp.buf.code_action, '[C]ode [A]ction') + + nmap('gd', vim.lsp.buf.definition, '[G]oto [D]efinition') + nmap('gr', require('telescope.builtin').lsp_references, '[G]oto [R]eferences') + nmap('gI', require('telescope.builtin').lsp_implementations, '[G]oto [I]mplementation') + nmap('<leader>D', vim.lsp.buf.type_definition, 'Type [D]efinition') + nmap('<leader>ds', require('telescope.builtin').lsp_document_symbols, '[D]ocument [S]ymbols') + nmap('<leader>ws', require('telescope.builtin').lsp_dynamic_workspace_symbols, '[W]orkspace [S]ymbols') + + -- See `:help K` for why this keymap + nmap('K', vim.lsp.buf.hover, 'Hover Documentation') + nmap('<C-k>', vim.lsp.buf.signature_help, 'Signature Documentation') + + -- Lesser used LSP functionality + nmap('gD', vim.lsp.buf.declaration, '[G]oto [D]eclaration') + nmap('<leader>wa', vim.lsp.buf.add_workspace_folder, '[W]orkspace [A]dd Folder') + nmap('<leader>wr', vim.lsp.buf.remove_workspace_folder, '[W]orkspace [R]emove Folder') + nmap('<leader>wl', function() + print(vim.inspect(vim.lsp.buf.list_workspace_folders())) + end, '[W]orkspace [L]ist Folders') + + -- Create a command `:Format` local to the LSP buffer + vim.api.nvim_buf_create_user_command(bufnr, 'Format', function(_) + vim.lsp.buf.format() + end, { desc = 'Format current buffer with LSP' }) +end + +-- Enable the following language servers +-- Feel free to add/remove any LSPs that you want here. They will automatically be installed. +-- +-- Add any additional override configuration in the following tables. They will be passed to +-- the `settings` field of the server config. You must look up that documentation yourself. +-- +-- If you want to override the default filetypes that your language server will attach to you can +-- define the property 'filetypes' to the map in question. +local servers = { + -- clangd = {}, + -- gopls = {}, + -- pyright = {}, + -- rust_analyzer = {}, + -- tsserver = {}, + -- html = { filetypes = { 'html', 'twig', 'hbs'} }, + + lua_ls = { + Lua = { + workspace = { checkThirdParty = false }, + telemetry = { enable = false }, + }, + }, +} + +-- Setup neovim lua configuration +require('neodev').setup() + +-- nvim-cmp supports additional completion capabilities, so broadcast that to servers +local capabilities = vim.lsp.protocol.make_client_capabilities() +capabilities = require('cmp_nvim_lsp').default_capabilities(capabilities) + +-- Ensure the servers above are installed +local mason_lspconfig = require 'mason-lspconfig' + +mason_lspconfig.setup { + ensure_installed = vim.tbl_keys(servers), +} + +mason_lspconfig.setup_handlers { + function(server_name) + require('lspconfig')[server_name].setup { + capabilities = capabilities, + on_attach = on_attach, + settings = servers[server_name], + filetypes = (servers[server_name] or {}).filetypes, + } + end +} + +-- [[ Configure nvim-cmp ]] +-- See `:help cmp` +local cmp = require 'cmp' +local luasnip = require 'luasnip' +require('luasnip.loaders.from_vscode').lazy_load() +luasnip.config.setup {} + +cmp.setup { + snippet = { + expand = function(args) + luasnip.lsp_expand(args.body) + end, + }, + mapping = cmp.mapping.preset.insert { + ['<C-n>'] = cmp.mapping.select_next_item(), + ['<C-p>'] = cmp.mapping.select_prev_item(), + ['<C-d>'] = cmp.mapping.scroll_docs(-4), + ['<C-f>'] = cmp.mapping.scroll_docs(4), + ['<C-Space>'] = cmp.mapping.complete {}, + ['<CR>'] = cmp.mapping.confirm { + behavior = cmp.ConfirmBehavior.Replace, + select = true, + }, + ['<Tab>'] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_next_item() + elseif luasnip.expand_or_locally_jumpable() then + luasnip.expand_or_jump() + else + fallback() + end + end, { 'i', 's' }), + ['<S-Tab>'] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_prev_item() + elseif luasnip.locally_jumpable(-1) then + luasnip.jump(-1) + else + fallback() + end + end, { 'i', 's' }), + }, + sources = { + { name = 'nvim_lsp' }, + { name = 'luasnip' }, + }, +} + +-- The line beneath this is called `modeline`. See `:help modeline` +-- vim: ts=2 sts=2 sw=2 et +
A .config/nvim/lua/lsp.lua

@@ -0,0 +1,51 @@

+-- Set up language servers. + +-- local lspconfig = require('lspconfig') +local ok, lspconfig = pcall(require, 'lspconfig') +if not ok then + print("error: failed to require 'lspconfig'") +else + lspconfig.pyright.setup{} + lspconfig.lua_ls.setup{} + lspconfig.clangd.setup{} +end + +-- config section from following: +-- https://github.com/neovim/nvim-lspconfig +-- Global mappings. +-- See `:help vim.diagnostic.*` for documentation on any of the below functions +vim.keymap.set('n', '<space>e', vim.diagnostic.open_float) +vim.keymap.set('n', '[d', vim.diagnostic.goto_prev) +vim.keymap.set('n', ']d', vim.diagnostic.goto_next) +vim.keymap.set('n', '<space>q', vim.diagnostic.setloclist) + +-- Use LspAttach autocommand to only map the following keys +-- after the language server attaches to the current buffer +vim.api.nvim_create_autocmd('LspAttach', { + group = vim.api.nvim_create_augroup('UserLspConfig', {}), + callback = function(ev) + -- Enable completion triggered by <c-x><c-o> + vim.bo[ev.buf].omnifunc = 'v:lua.vim.lsp.omnifunc' + + -- Buffer local mappings. + -- See `:help vim.lsp.*` for documentation on any of the below functions + local opts = { buffer = ev.buf } + vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, opts) + vim.keymap.set('n', 'gd', vim.lsp.buf.definition, opts) + vim.keymap.set('n', 'K', vim.lsp.buf.hover, opts) + vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, opts) + vim.keymap.set('n', '<C-k>', vim.lsp.buf.signature_help, opts) + -- vim.keymap.set('n', '<space>wa', vim.lsp.buf.add_workspace_folder, opts) + -- vim.keymap.set('n', '<space>wr', vim.lsp.buf.remove_workspace_folder, opts) + -- vim.keymap.set('n', '<space>wl', function() + -- print(vim.inspect(vim.lsp.buf.list_workspace_folders())) + -- end, opts) + vim.keymap.set('n', '<space>D', vim.lsp.buf.type_definition, opts) + vim.keymap.set('n', '<space>rn', vim.lsp.buf.rename, opts) + vim.keymap.set({ 'n', 'v' }, '<space>ca', vim.lsp.buf.code_action, opts) + vim.keymap.set('n', 'gr', vim.lsp.buf.references, opts) + vim.keymap.set('n', '<space>f', function() + vim.lsp.buf.format { async = true } + end, opts) + end, +})
A .config/nvim/vimrc.vim

@@ -0,0 +1,133 @@

+"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" x1phosura's .vimrc " +" " +" This is my basic .vimrc. I'm not a power user, but I like settings. " +" " +" note to self: vim navigates logical lines. To navigate a long paragraph up " +" and down when the paragraph is all on one line, use gj and gk. " +"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" + +" enable truecolors if available +"if has('nvim') || has('termguicolors') +" set termguicolors +"endif + +" TODO: check _if_ mypeachpuff exists, if not, use peachpuff +set background=dark +"colorscheme peachpuff +colorscheme x1ph-off " TODO: check _if_ x1ph-off exists, if not, use default +"colorscheme default +syntax on + +set guicursor= "force using block cursor (for neovim) +set hlsearch " highlights search targets +set mouse= " disables mouse support, re-enable by 'set mouse=a' +set colorcolumn=80 " creates vertical line at column 80 +set cursorline " underlines currently selected line +" below sets CursorLine colors (233 assumes 256-bit color, more specific black) +hi CursorLine ctermbg=235 +hi ColorColumn ctermbg=235 + +"set number relativenumber " use "hybrid" numbering (both number and relative) +set number " note to self: tun off with 'set nonumber' +set ruler " ??? + +set shortmess+=I " Don't show splash screen + +"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +""" statusline + +set noshowmode " don't show vim mode below statusline +set laststatus=2 " set 'laststatus' bar (neovim default) + +let g:currentmode={ 'n' : 'Normal ', 'no' : 'N-Operator Pending ', + \ 'v' : 'Visual ', 'V' : 'V-Line ', '^V' : 'V-Block ', + \ 's' : 'Select ', 'S': 'S-Line ', '^S' : 'S-Block ', + \ 'i' : 'Insert ', 'R' : 'Replace ', 'Rv' : 'V-Replace ', + \ 'c' : 'Command ', 'cv' : 'Vim Ex ', 'ce' : 'Ex ', + \ 'r' : 'Prompt ', 'rm' : 'More ', 'r?' : 'Confirm ', + \ '!' : 'Shell ', 't' : 'Terminal '} + +" get the current mode for display in vim statusline +function! ModeCurrent() abort + let l:modecurrent = mode() + " use get() -> fails safely, since ^V doesn't seem to register + " 3rd arg is used when return of mode() == 0, which is case with ^V + " thus, ^V fails -> returns 0 -> replaced with 'V Block' + let l:modelist = toupper(get(g:currentmode, l:modecurrent, 'V-Block ')) + let l:current_status_mode = l:modelist + return l:current_status_mode +endfunction + +" black on purple +highlight StatusHighlight term=bold ctermfg=0 ctermbg=13 + +" start building statusline +set statusline=%#StatusHighlight# " change background color to purple +set statusline+=\ %{ModeCurrent()} " put current mode here +set statusline+=%#ColorColumn#\ " change background color to ColorColumn +set statusline+=\ \[%n\] " show which vim buffer +"set statusline+=%* " switch back to normal statusline + +set statusline+=\ %.30f " filename (truncate to 30 chars) +set statusline+=\ %m " modified flag + +set statusline+=%= " format right side of statusline +set statusline+=\ %{&ff}, " unix or dos +set statusline+=%{&fileencoding?&fileencoding:&encoding}\ " File encoding +"set statusline+=\ %y " show filetype +set statusline+=%#StatusHighlight# " highlight purple +set statusline+=\ %l/%L: " current line/Total lines +set statusline+=%c%V " column number(-virtual column number) +"set statusline+=\ (%p%%) " percentage +set statusline+=%* + +"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" + +let g:netrw_liststyle = 3 " change netrw file manager view style + +setlocal ff=unix " Changes file format to unix (changes line endings) + +" Indentation settings according to personal preference, including +" settings for using 4 spaces instead of tabs. +" Do not change 'tabstop' from its default value of 8 with this setup. +set shiftwidth=4 " TODO: explain +set softtabstop=4 " TODO: explain +set expandtab " can re-enable typing tabs with 'set noexpandtab' or 'set noet' +set autoindent " should automatically indent + +set noeol " make vim _not_ automatically append newline to files after exiting + +" makes words not get cut off and split weirdly at end of border +setlocal linebreak + +" autocmd stuff (note: 'au' == 'autocmd') +" includes language/filetype-specific settings +if has("autocmd") + " applies columns rule even when vim is resized (caused by terminal resizing) + "au VimResized * | set columns=84 + + " set markdown notes to "wordwrap" kinda + "au BufRead,BufNewFile *.md setlocal columns=84 + + " turns off tabs-to-spaces conversion for makefiles + au FileType make setlocal shiftwidth=8 softtabstop=8 tabstop=8 noexpandtab + + au FileType c setlocal shiftwidth=8 softtabstop=8 tabstop=8 noexpandtab + au FileType sh setlocal shiftwidth=4 softtabstop=4 tabstop=4 expandtab + + au BufRead,BufNewFile *.rkt,*.rktl set filetype=scheme + au FileType scheme setlocal equalprg=scmindent.rkt " not sure if works +endif + +let c_syntax_for_h=1 " assume header files are going to be C, not C++ + +" maps SHIFT-TAB to insert a real live tab character (in INSERT mode) +:inoremap <S-Tab> <C-V><Tab> + +" double-<Esc> clears search highlights +"nnoremap <silent> <Esc><Esc> <Esc>:nohlsearch<CR><Esc> + +" makes vim scroll fast (unnecesary for neovim) +set ttyfast +
A .gdbinit

@@ -0,0 +1,26 @@

+# my gdbinit file + +# Useful features: +# +### To define a custom "function" of commands to run, use 'define'. ex: +# (gdb) define func_name +# > print varname +# > continue +# > end +# (gdb) +# + +# remove duplicate lines in command history +set history remove-duplicates unlimited + +# makes assembly syntax actually good +set disassembly-flavor intel + +# outputs "next" instruction to execute after each step/next (stop) +set disassemble-next-line on + +# switch to child process if fork/vfork called, default is 'parent' (useful) +#set follow-fork-mode child + +alias e=quit +
A .lynxrc

@@ -0,0 +1,19 @@

+ +# x1phosura's .lynxrc file + +# SHOW_CURSOR controls whether or not the cursor is hidden or appears +# over the current link in documents or the current option in popups. +# Showing the cursor is handy if you are a sighted user with a poor +# terminal that can't do bold and reverse video at the same time or +# at all. It also can be useful to blind users, as an alternative +# or supplement to setting LINKS_AND_FIELDS_ARE_NUMBERED or +# LINKS_ARE_NUMBERED. +# The default defined here or in userdefs.h can be changed via the +# 'o'ptions menu and saved in the RC file, and always can be toggled +# via the -show_cursor command line switch. +show_cursor=true + +# UNDERLINE_LINKS controls whether links are underlined by default, or shown +# in bold. Normally this default is set from the configure script. +underline_links=true +
A .tmux.conf

@@ -0,0 +1,91 @@

+# x1phosura's tmux config +# (there's really not too much interesting here) + +# Notes to future self: +# to apply tmux configs on the fly while it's running, type Ctrl-b, then run +# :source ~/.tmux.conf +# Changes will be applied within the current session (bc they take place on the +# server). +# Also, tmux salved selected text in "buffers." Use: `tmux deleteb` to delete +# the most recently saved buffer + + +####################### Misc. configuration ######################## + +# Refresh status line every 5 sec (good for updating time, playing music, etc) +set -g status-interval 5 + +# Set history scrollback buffer to 5000 lines (default 2000) +set -g history-limit 5000 + +# Refresh status line every 5 sec (good for updating time, playing music, etc) +set -g status-interval 5 + +set-option -g status "on" + +# Use vi-like bindings for stuff +set -g mode-keys vi + +# enables mouse mode (for tmux version > 2.1) +set -g mouse on + +# fixed REALLY DUMB tmux crash in the past (probably unnecessary now) +#set-option -g default-shell /bin/bash + + +####################### Key bindings ######################## +# Note: to output current key bindings, run the following in the shell: +# `tmux list-keys` or `tmux lsk` + +# Hold 'Alt' to access vi-like pane switching +bind -n M-h select-pane -L +bind -n M-j select-pane -D +bind -n M-k select-pane -U +bind -n M-l select-pane -R + +# Use 'Slt-Shift' to access vi-like pane switching +bind -n M-H resize-pane -L 2 +bind -n M-J resize-pane -D 2 +bind -n M-K resize-pane -U 2 +bind -n M-L resize-pane -R 2 + + +####################### Color configuration ######################## + +# variables (personal) +accent1=colour127 +accent2=colour133 + +# variables (work) +#accent1=colour63 +#accent2=colour33 + +lightfg=colour7 +palefg=colour223 +darkfg=colour236 +lessdarkfg=colour239 + +# Fixes color stuff in tmux/vim +set -g default-terminal "screen-256color" + +# Default statusbar color +set-option -g status-style bg=$accent1,fg=$lightfg + +# Active window title colors +set-window-option -g window-status-current-style bg=$accent2,fg=$lightfg + +# Set active pane border color +set-option -g pane-active-border-style fg=$accent1 +# Set inactive pane border color +set-option -g pane-border-style fg=$lessdarkfg + +# Message info +set-option -g message-style bg=$lessdarkfg,fg=$palefg + +# Writing commands inactive +set-option -g message-command-style bg=$lessdarkfg,fg=$lightfg + +# Pane number display +set-option -g display-panes-active-colour $accent1 +set-option -g display-panes-colour $darkfg +
A README.md

@@ -0,0 +1,4 @@

+# x1phosura's dotfiles base + +This is meant to be a "base" or foundational collection of files that I can transfer to most \*nix-type machines with little to no modification and expect them to work. +
A place-dotfiles-base.sh

@@ -0,0 +1,43 @@

+#!/bin/sh + +# place-dotfiles-base.sh: simple script to symlink my core dotfiles +# TODO: currently doesn't work, needs updating +# by x1phosura + +dotfiles_root="$HOME"/73h4x/dotfiles/dotfiles-base # where dotfiles live +#dotfiles_root="$PWD" # alternative (for testing) +dest="$HOME" # usually $HOME + + +die() { + echo "$@"; exit 1 +} + +[ ! -d "$dotfiles_root" ] && \ + die "ERROR: $dotfiles_root doesn't exist. Aborting..." + +# TODO: change '[[' to '[', test... +#[[ "$(realpath $dotfiles_root)" = "$(realpath $dest)" ]] && \ +# die " ERROR: dotfiles_root and dest are the same directory! Aborting..." + +# TODO: maybe, maybe not place .bash_prompt +dotfiles_base_list=".bash_profile \ +.bashrc \ +.gdbinit \ +.lynxrc \ +.tmux.conf \ +.config/nvim" + +# Note: directly symlink items to .config instead of symlinking .config itself +# because I don't want to preserve everything that programs create there +mkdir -p "$dest"/.config + +# link dotfiles in home directory +for file in $dotfiles_base_list ; do + # TODO: only link after checking file's existence in dotfiles_root + ln -svfn "$dotfiles_root"/"$file" "$dest"/"$file" +done + +# handle neovim-to-vimrc symlink +ln -svfn "$dotfiles_root"/.config/nvim/vimrc.vim "$dest"/.vimrc +