diff --git a/bash/.bash_aliases b/bash/.bash_aliases new file mode 100755 index 0000000..946b43b --- /dev/null +++ b/bash/.bash_aliases @@ -0,0 +1,30 @@ +# git +alias gitp="git push" +alias gitpl="git pull" +alias gitplu="git pull upstream" +alias gitom="git push origin master" +alias gitf="git fetch" +alias gits="git status" +alias gitch="git checkout $1" +alias gitd="git diff" +alias gitb="git branch" +alias gitr="git remote" +alias gitfc="gitf && gitch" +alias gita="git add" +alias gitap="git add -p" +alias gitrp="git checkout -p" + +function gitc { + if [ -z "$1" ]; then + git commit + else + git commit -m "$@" + fi +} + +function gitcp { + gitc "$@" && gitp; +} + +alias gitlg="git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr)%Creset by %an' --abbrev-commit --date=relative" + diff --git a/bash/.bashrc b/bash/.bashrc new file mode 100644 index 0000000..160af97 --- /dev/null +++ b/bash/.bashrc @@ -0,0 +1,122 @@ +# ~/.bashrc: executed by bash(1) for non-login shells. +# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc) +# for examples + +# 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. +# See bash(1) for more options +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=1000 +HISTFILESIZE=2000 + +# check the window size after each command and, if necessary, +# update the values of LINES and COLUMNS. +shopt -s checkwinsize + +# If set, the pattern "**" used in a pathname expansion context will +# match all files and zero or more directories and subdirectories. +shopt -s globstar + +# make less more friendly for non-text input files, see lesspipe(1) +[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)" + +# set variable identifying the chroot you work in (used in the prompt below) +if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then + debian_chroot=$(cat /etc/debian_chroot) +fi + +# set a fancy prompt (non-color, unless we know we "want" color) +case "$TERM" in + xterm-color|*-256color) color_prompt=yes;; +esac + +# 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 + +if [ "$color_prompt" = yes ]; then + PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ ' +else + PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ ' +fi +unset color_prompt force_color_prompt + +# 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 dir='dir --color=auto' + #alias vdir='vdir --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' + +# some more ls aliases +alias ll='ls -alF' +alias la='ls -A' +alias l='ls -CF' + +# Add an "alert" alias for long running commands. Use like so: +# sleep 10; alert +alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"' + +# 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 (you don't need to enable +# this, if it's already enabled in /etc/bash.bashrc and /etc/profile +# sources /etc/bash.bashrc). +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 + +export VIM=nvim +export NVM_DIR="$HOME/.nvm" +[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm +[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion diff --git a/clean-env b/clean-env new file mode 100755 index 0000000..c75e300 --- /dev/null +++ b/clean-env @@ -0,0 +1,8 @@ +#!/usr/bin/env zsh +pushd $DOTFILES +for folder in $(echo $STOW_FOLDERS | sed "s/,/ /g") +do + echo "Removing $folder" + stow -D $folder +done +popd diff --git a/install b/install new file mode 100755 index 0000000..616ebae --- /dev/null +++ b/install @@ -0,0 +1,10 @@ +#!/usr/bin/env zsh +pushd $DOTFILES +for folder in $(echo $STOW_FOLDERS | sed "s/,/ /g") +do + echo "stow $folder" + stow -D $folder + stow $folder +done +popd + diff --git a/nvim/.config/nvim/.gitignore b/nvim/.config/nvim/.gitignore new file mode 100644 index 0000000..40b65e3 --- /dev/null +++ b/nvim/.config/nvim/.gitignore @@ -0,0 +1,3 @@ +packer_compiled.lua +undodir/ + diff --git a/nvim/.config/nvim/after/plugin/colors.lua b/nvim/.config/nvim/after/plugin/colors.lua new file mode 100644 index 0000000..f2d1b84 --- /dev/null +++ b/nvim/.config/nvim/after/plugin/colors.lua @@ -0,0 +1,9 @@ +function Colors(color) + color = color or "rose-pine" + vim.cmd.colorscheme(color) + + vim.api.nvim_set_hl(0, "Normal", { bg = "none" }) + vim.api.nvim_set_hl(0, "NormalFloat", { bg = "none" }) +end + +Colors() diff --git a/nvim/.config/nvim/after/plugin/copilot.lua b/nvim/.config/nvim/after/plugin/copilot.lua new file mode 100644 index 0000000..2529819 --- /dev/null +++ b/nvim/.config/nvim/after/plugin/copilot.lua @@ -0,0 +1,6 @@ +require('copilot').setup({ + suggestion = {enabled = false}, + panel = {enabled = false}, +}) + +require('copilot_cmp').setup() diff --git a/nvim/.config/nvim/after/plugin/fugitive.lua b/nvim/.config/nvim/after/plugin/fugitive.lua new file mode 100644 index 0000000..80c9070 --- /dev/null +++ b/nvim/.config/nvim/after/plugin/fugitive.lua @@ -0,0 +1 @@ +vim.keymap.set("n", "gs", vim.cmd.Git) diff --git a/nvim/.config/nvim/after/plugin/harpoon.lua b/nvim/.config/nvim/after/plugin/harpoon.lua new file mode 100644 index 0000000..3b74a82 --- /dev/null +++ b/nvim/.config/nvim/after/plugin/harpoon.lua @@ -0,0 +1,10 @@ +local mark = require("harpoon.mark") +local ui = require("harpoon.ui") + +vim.keymap.set("n", "a", mark.add_file) +vim.keymap.set("n", "", ui.toggle_quick_menu) + +vim.keymap.set("n", "", function() ui.nav_file(1) end) +vim.keymap.set("n", "", function() ui.nav_file(2) end) +vim.keymap.set("n", "", function() ui.nav_file(3) end) +vim.keymap.set("n", "", function() ui.nav_file(4) end) diff --git a/nvim/.config/nvim/after/plugin/lsp.lua b/nvim/.config/nvim/after/plugin/lsp.lua new file mode 100644 index 0000000..dbf05a5 --- /dev/null +++ b/nvim/.config/nvim/after/plugin/lsp.lua @@ -0,0 +1,60 @@ +local lsp = require("lsp-zero") + +lsp.preset("recommended") + +require('mason').setup({}) +require('mason-lspconfig').setup({ + ensure_installed = { + 'tsserver', + 'eslint', + 'rust_analyzer', + 'clangd', + }, + handlers = { + function(server_name) + require('lspconfig')[server_name].setup({}) + end, + }, +}) + +local cmp = require('cmp') +local cmp_select = { behavior = cmp.SelectBehavior.Select } +cmp.setup({ + sources = { + {name = 'nvim_lsp'}, + {name = 'copilot'}, + {name = 'cmp-buffer'}, + {name = 'cmp-path'}, + }, + mapping = cmp.mapping.preset.insert({ + [''] = cmp.mapping.select_prev_item(cmp_select), + [''] = cmp.mapping.select_next_item(cmp_select), + [''] = cmp.mapping.confirm({select = true}), + [''] = cmp.mapping.complete(), + [''] = cmp.mapping.confirm({ + behavior = cmp.ConfirmBehavior.Replace, + select = false, + }) + }) +}) + +lsp.set_preferences({ + sign_icons = {} +}) + +lsp.on_attach(function(client, bufnr) + local opts = { buffer=bufnr, remap=false } + + vim.keymap.set("n", "gd", function() vim.lsp.buf.definition() end, opts) + vim.keymap.set("n", "K", function() vim.lsp.buf.hover() end, opts) + vim.keymap.set("n", "vws", function() vim.lsp.workspace_symbol() end, opts) + vim.keymap.set("n", "vd", function() vim.diagnostic.open_float() end, opts) + vim.keymap.set("n", "[d", function() vim.diagnostic.goto_next() end, opts) + vim.keymap.set("n", "]d", function() vim.diagnosti.goto_prev() end, opts) + vim.keymap.set("n", "vca", function() vim.lsp.buf.code_action() end, opts) + vim.keymap.set("n", "vrr", function() vim.lsp.buf.references() end, opts) + vim.keymap.set("n", "vrn", function() vim.lsp.buf.rename() end, opts) + vim.keymap.set("i", "", function() vim.lsp.buf.signature_help() end, opts) +end) + +lsp.setup() diff --git a/nvim/.config/nvim/after/plugin/telescope.lua b/nvim/.config/nvim/after/plugin/telescope.lua new file mode 100644 index 0000000..737f21b --- /dev/null +++ b/nvim/.config/nvim/after/plugin/telescope.lua @@ -0,0 +1,7 @@ +local builtin = require('telescope.builtin') +vim.keymap.set('n', 'pf', builtin.find_files, {}) +vim.keymap.set('n', '', builtin.git_files, {}) +vim.keymap.set('n', 'pb', builtin.buffers, {}) +vim.keymap.set('n', 'ps', function() + builtin.grep_string({ search = vim.fn.input("Grep > ") }) +end) diff --git a/nvim/.config/nvim/after/plugin/treesitter.lua b/nvim/.config/nvim/after/plugin/treesitter.lua new file mode 100644 index 0000000..a30429e --- /dev/null +++ b/nvim/.config/nvim/after/plugin/treesitter.lua @@ -0,0 +1,16 @@ +require'nvim-treesitter.configs'.setup { + -- A list of parser names, or "all" (the five listed parsers should always be installed) + ensure_installed = { "javascript", "typescript", "go", "rust", "c", "lua", "vim", "vimdoc", "query" }, + + -- Install parsers synchronously (only applied to `ensure_installed`) + sync_install = false, + + -- Automatically install missing parsers when entering buffer + -- Recommendation: set to false if you don't have `tree-sitter` CLI installed locally + auto_install = true, + + highlight = { + enable = true, + additional_vim_regex_highlighting = false, + }, +} diff --git a/nvim/.config/nvim/after/plugin/undotree.lua b/nvim/.config/nvim/after/plugin/undotree.lua new file mode 100644 index 0000000..b6b9276 --- /dev/null +++ b/nvim/.config/nvim/after/plugin/undotree.lua @@ -0,0 +1 @@ +vim.keymap.set("n", "u", vim.cmd.UndotreeToggle) diff --git a/nvim/.config/nvim/init.lua b/nvim/.config/nvim/init.lua new file mode 100644 index 0000000..51b2513 --- /dev/null +++ b/nvim/.config/nvim/init.lua @@ -0,0 +1 @@ +require("zak") diff --git a/nvim/.config/nvim/lua/zak/init.lua b/nvim/.config/nvim/lua/zak/init.lua new file mode 100644 index 0000000..ef9fd6f --- /dev/null +++ b/nvim/.config/nvim/lua/zak/init.lua @@ -0,0 +1,2 @@ +require("zak.remap") +require("zak.set") diff --git a/nvim/.config/nvim/lua/zak/remap.lua b/nvim/.config/nvim/lua/zak/remap.lua new file mode 100644 index 0000000..dc02c9b --- /dev/null +++ b/nvim/.config/nvim/lua/zak/remap.lua @@ -0,0 +1,46 @@ +vim.g.mapleader = " " +vim.keymap.set("n", "pv", vim.cmd.Ex) + +vim.keymap.set("v", "J", ":m '>+1gv=gv") +vim.keymap.set("v", "K", ":m '<-2gv=gv") + +vim.keymap.set("n", "J", "mzJ`z") +vim.keymap.set("n", "", "zz") +vim.keymap.set("n", "", "zz") +vim.keymap.set("n", "n", "nzzzv") +vim.keymap.set("n", "N", "Nzzzv") + +-- greatest remap ever +vim.keymap.set("x", "p", [["_dP]]) + +-- next greatest remap ever : asbjornHaland +vim.keymap.set({"n", "v"}, "y", [["+y]]) +vim.keymap.set("n", "Y", [["+Y]]) + +vim.keymap.set({"n", "v"}, "d", [["_d]]) + +-- This is going to get me cancelled +vim.keymap.set("i", "", "") + +vim.keymap.set("n", "Q", "") +vim.keymap.set("n", "", "silent !tmux neww tmux-sessionizer") +vim.keymap.set("n", "f", vim.lsp.buf.format) + +vim.keymap.set("n", "", "cnextzz") +vim.keymap.set("n", "", "cprevzz") +vim.keymap.set("n", "k", "lnextzz") +vim.keymap.set("n", "j", "lprevzz") + +vim.keymap.set("n", "s", [[:%s/\<\>//gI]]) +vim.keymap.set("n", "x", "!chmod +x %", { silent = true }) + +vim.keymap.set( + "n", + "ee", + "oif err != nil {}Oreturn err" +) + +vim.keymap.set("n", "", function() + vim.cmd("so") +end) + diff --git a/nvim/.config/nvim/lua/zak/set.lua b/nvim/.config/nvim/lua/zak/set.lua new file mode 100644 index 0000000..8527681 --- /dev/null +++ b/nvim/.config/nvim/lua/zak/set.lua @@ -0,0 +1,32 @@ +vim.mouse = "" +vim.opt.guicursor = "" + +vim.opt.nu = true +vim.opt.relativenumber = true + +vim.opt.tabstop = 4 +vim.opt.softtabstop = 4 +vim.opt.shiftwidth = 4 +vim.opt.expandtab = true + +vim.opt.smartindent = true + +vim.opt.wrap = false + +vim.opt.swapfile = false +vim.opt.backup = false +vim.opt.undodir = os.getenv("HOME") .. "/.vim/undodir" +vim.opt.undofile = true + +vim.opt.hlsearch = false +vim.opt.incsearch = true + +vim.opt.termguicolors = true + +vim.opt.scrolloff = 8 +vim.opt.signcolumn = "yes" +vim.opt.isfname:append("@-@") + +vim.opt.updatetime = 50 + +vim.opt.colorcolumn = "80" diff --git a/nvim/.config/nvim/packer.lua b/nvim/.config/nvim/packer.lua new file mode 100644 index 0000000..995e119 --- /dev/null +++ b/nvim/.config/nvim/packer.lua @@ -0,0 +1,54 @@ +-- This file can be loaded by calling `lua require('plugins')` from your init.vim + +-- Only required if you have packer configured as `opt` +vim.cmd [[packadd packer.nvim]] + +return require('packer').startup(function(use) + -- Packer can manage itself + use 'wbthomason/packer.nvim' + + + use { + 'nvim-telescope/telescope.nvim', tag = '0.1.7', + -- or , branch = '0.1.x', + requires = { {'nvim-lua/plenary.nvim'} } + } + + use { + 'rose-pine/neovim', + as = 'rose-pine', + config = function() + vim.cmd('colorscheme rose-pine') + end + } + + use('nvim-treesitter/nvim-treesitter', { run = ':TSUpdate' }) + use('nvim-treesitter/playground') + use { 'nvim-telescope/telescope-fzf-native.nvim', run = 'cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release && cmake --build build --config Release && cmake --install build --prefix build' } + use('theprimeagen/harpoon') + use('mbbill/undotree') + use('tpope/vim-fugitive') + + use { + 'VonHeikemen/lsp-zero.nvim', + branch = 'v3.x', + requires = { + --- Uncomment the two plugins below if you want to manage the language servers from neovim + {'williamboman/mason.nvim'}, + {'williamboman/mason-lspconfig.nvim'}, + + {'neovim/nvim-lspconfig'}, + {'hrsh7th/nvim-cmp'}, + {'hrsh7th/cmp-buffer'}, + {'hrsh7th/cmp-path'}, + {'hrsh7th/cmp-nvim-lsp'}, + {'hrsh7th/cmp-nvim-lua'}, + {'L3MON4D3/LuaSnip'}, + } + } + + use { + 'zbirenbaum/copilot.lua', + 'zbirenbaum/copilot-cmp' + } +end) diff --git a/prep b/prep new file mode 100755 index 0000000..85186f1 --- /dev/null +++ b/prep @@ -0,0 +1,3 @@ +#!/bin/bash + +sudo apt install ripgrep build-essential git cmake fzf stow diff --git a/ubuntu b/ubuntu new file mode 100755 index 0000000..e8a5a93 --- /dev/null +++ b/ubuntu @@ -0,0 +1,11 @@ +#!/usr/bin/env zsh +if [[ -z $STOW_FOLDERS ]]; then + STOW_FOLDERS="nvim,bash" +fi + +if [[ -z $DOTFILES ]]; then + DOTFILES=$HOME/.dotfiles +fi + +STOW_FOLDERS=$STOW_FOLDERS DOTFILES=$DOTFILES $DOTFILES/install +