commit da119d8b517ef09106a419c2e9de3fc64718c970 Author: Hadeed Ahmad Date: Mon Aug 21 14:56:16 2023 +0500 Initial commit diff --git a/bin/stow.py b/bin/stow.py new file mode 100755 index 0000000..9572fc1 --- /dev/null +++ b/bin/stow.py @@ -0,0 +1,55 @@ +#! /usr/bin/env python3 + +import os +import re +import shutil +import sys + +DOTS = os.getenv("DOTS", os.getcwd()) + +def stow(pkg, stow_dir): + pkg_path = os.path.join(DOTS, pkg) + + for root, dirs, files in os.walk(pkg_path): + files = [f for f in files if not f.startswith(".")] + dirs[:] = [d for d in dirs if not d.startswith(".")] + + symlink_dir = root.replace(pkg_path, stow_dir) + if not os.path.exists(symlink_dir): + os.makedirs(symlink_dir) + + for file in files: + source = os.path.join(root, file) + target = os.path.join(symlink_dir, re.sub("^dot-", ".", file)) + + if os.path.exists(target): + os.remove(target) + + os.symlink(source, target) + +def get_pkgs(): + pkgs = [] + + if len(sys.argv) > 1: + for pkg in sys.argv[1:]: + if os.path.isdir(os.path.join(DOTS, pkg)): + pkgs.append(pkg) + else: + print(f"The package {pkg} is not a valid package.", file=sys.stderr) + else: + pkgs = [d for d in os.listdir(DOTS) if not d.startswith(".")] + + return pkgs + +def get_stow_dir(pkg): + return os.path.expanduser({ + "home" : "~", + "bin" : "~/bin", + "config" : "~/.config" + }.get(pkg, f"~/.config/{pkg}")) + +if __name__ == "__main__": + for pkg in get_pkgs(): + if pkg in ["docs"]: continue + + stow(pkg, get_stow_dir(pkg)) diff --git a/config/starship.toml b/config/starship.toml new file mode 100644 index 0000000..6823032 --- /dev/null +++ b/config/starship.toml @@ -0,0 +1,5 @@ +[python] +symbol=" " + +[lua] +symbol=" " diff --git a/config/user-dirs.dirs b/config/user-dirs.dirs new file mode 100644 index 0000000..00fa1ae --- /dev/null +++ b/config/user-dirs.dirs @@ -0,0 +1,15 @@ +# This file is written by xdg-user-dirs-update +# If you want to change or add directories, just edit the line you're +# interested in. All local changes will be retained on the next run. +# Format is XDG_xxx_DIR="$HOME/yyy", where yyy is a shell-escaped +# homedir-relative path, or XDG_xxx_DIR="/yyy", where /yyy is an +# absolute path. No other format is supported. + +XDG_DESKTOP_DIR="$HOME" +XDG_DOWNLOAD_DIR="$HOME/dl" +XDG_TEMPLATES_DIR="$HOME" +XDG_PUBLICSHARE_DIR="$HOME" +XDG_DOCUMENTS_DIR="$HOME/docs" +XDG_MUSIC_DIR="$HOME" +XDG_PICTURES_DIR="$HOME/pics" +XDG_VIDEOS_DIR="$HOME" diff --git a/docs/pacman_pkgs.txt b/docs/pacman_pkgs.txt new file mode 100644 index 0000000..ff6ffc0 --- /dev/null +++ b/docs/pacman_pkgs.txt @@ -0,0 +1,11 @@ +bat +exa +fd +kitty +neovim +qmk +ripgrep +starship +unclutter +xclip +zsh diff --git a/git/config b/git/config new file mode 100644 index 0000000..cadfd35 --- /dev/null +++ b/git/config @@ -0,0 +1,23 @@ +[init] + defaultBranch = main + +[user] + email = hadeedji@gmail.com + name = Hadeed Ahmad + +[alias] + s = status -u + a = add + aa = add -A + c = commit + ca = commit --amend --no-edit + p = push + pf = push -f + ac = !git aa && git c + aca = !git aa && git ca + acp = !git ac && git p + acap = !git aca && git pf + l = log --all --decorate --oneline --graph -n 20 + cfc = !git clone $(xclip -out -sel clip) + +# vim: filetype=gitconfig diff --git a/home/dot-zshenv b/home/dot-zshenv new file mode 100644 index 0000000..e5dfd59 --- /dev/null +++ b/home/dot-zshenv @@ -0,0 +1,5 @@ +export ZDOTDIR="$HOME/.config/zsh" + +[ -e "$ZDOTDIR/.zshenv" ] && . "$ZDOTDIR/.zshenv" + +# vim: filetype=zsh diff --git a/kitty/keys.conf b/kitty/keys.conf new file mode 100644 index 0000000..7f2bf75 --- /dev/null +++ b/kitty/keys.conf @@ -0,0 +1,26 @@ +clear_all_shortcuts yes +kitty_mod ctrl+shift + +map kitty_mod+c copy_to_clipboard +map kitty_mod+v paste_from_clipboard + +map kitty_mod+p scroll_line_up +map kitty_mod+n scroll_line_down +map kitty_mod+u scroll_page_up +map kitty_mod+d scroll_page_down +map kitty_mod+g show_last_command_output + +map kitty_mod+equal change_font_size all +1.0 +map kitty_mod+minus change_font_size all -1.0 +map kitty_mod+backspace change_font_size all 0 + +map kitty_mod+enter new_window +map kitty_mod+k next_window +map kitty_mod+j previous_window +map kitty_mod+w close_window + +map kitty_mod+t new_tab +map kitty_mod+l next_tab +map kitty_mod+h previous_tab +map kitty_mod+o select_tab +map kitty_mod+q close_tab diff --git a/kitty/kitty.conf b/kitty/kitty.conf new file mode 100644 index 0000000..442ebe0 --- /dev/null +++ b/kitty/kitty.conf @@ -0,0 +1,14 @@ +font_family JetBrains Mono +font_size 12.0 + +enable_audio_bell no +disable_ligatures cursor + +scrollback_lines 4096 + +enabled_layouts tall +tab_bar_style hidden +hide_window_decorations yes + +include keys.conf +include themes/gruvbox.conf diff --git a/kitty/ssh.conf b/kitty/ssh.conf new file mode 100644 index 0000000..48d358b --- /dev/null +++ b/kitty/ssh.conf @@ -0,0 +1,5 @@ +env ZDOTDIR=$HOME/.config/zsh +env REMOTE_HOST=1 +copy --dest .config/zsh --exclude 'dot-' $DOTS/zsh +copy --dest .config/zsh/.zshenv $DOTS/zsh/dot-zshenv +copy --dest .config/zsh/.zshrc $DOTS/zsh/dot-zshrc diff --git a/kitty/themes/gruvbox.conf b/kitty/themes/gruvbox.conf new file mode 100644 index 0000000..6245a86 --- /dev/null +++ b/kitty/themes/gruvbox.conf @@ -0,0 +1,29 @@ +foreground #ebdbb2 +background #272727 +selection_foreground #655b53 +selection_background #ebdbb2 +url_color #d65c0d + +color0 #272727 +color8 #928373 + +color1 #cc231c +color9 #fb4833 + +color2 #989719 +color10 #b8ba25 + +color3 #d79920 +color11 #fabc2e + +color4 #448488 +color12 #83a597 + +color5 #b16185 +color13 #d3859a + +color6 #689d69 +color14 #8ec07b + +color7 #a89983 +color15 #ebdbb2 diff --git a/nvim/ftplugin/gitcommit.lua b/nvim/ftplugin/gitcommit.lua new file mode 100644 index 0000000..3642f44 --- /dev/null +++ b/nvim/ftplugin/gitcommit.lua @@ -0,0 +1,2 @@ +vim.keymap.set("i", "", "x", { buffer=true }) +vim.cmd('startinsert') diff --git a/nvim/ftplugin/lua.lua b/nvim/ftplugin/lua.lua new file mode 100644 index 0000000..3da2b37 --- /dev/null +++ b/nvim/ftplugin/lua.lua @@ -0,0 +1,3 @@ +vim.opt.tabstop = 2 +vim.opt.softtabstop = 2 +vim.opt.shiftwidth = 2 diff --git a/nvim/init.lua b/nvim/init.lua new file mode 100644 index 0000000..64b1c44 --- /dev/null +++ b/nvim/init.lua @@ -0,0 +1,32 @@ +require("options") +require("keymaps") + +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) +require("lazy").setup("plugins") + +vim.filetype.add({ + filename = { + ["user-dirs.dirs"] = "conf", + + ["gruvbox.conf"] = "kitty", + ["keys.conf"] = "kitty", + ["kitty.conf"] = "kitty", + + ["dot-zshenv"] = "zsh", + ["dot-zshrc"] = "zsh" + }, + pattern = { + [".*/git/config"] = "gitconfig" + } +}) diff --git a/nvim/lua/keymaps.lua b/nvim/lua/keymaps.lua new file mode 100644 index 0000000..1a62efa --- /dev/null +++ b/nvim/lua/keymaps.lua @@ -0,0 +1,31 @@ +local function swap(a, b) + vim.keymap.set("", a, b) + vim.keymap.set("", b, a) +end + +swap(";", ":") +swap("'", "`") + +vim.keymap.set("", "q", "conf q") +vim.keymap.set("", "w", "w") +vim.keymap.set("", "x", "x") + +vim.keymap.set("n", "J", "mzJ`z") +vim.keymap.set("n", "n", "nzz") +vim.keymap.set("n", "N", "Nzz") +vim.keymap.set("n", "", "zz") +vim.keymap.set("n", "", "zz") +vim.keymap.set("n", "", "nohls") + +vim.keymap.set("n", "w", "") +local function window_map(key, mapping) + local k = '' + local m = 'wincmd ' .. (mapping or key) .. '' + + vim.keymap.set({'n', 'i', 't'}, k, m) +end + +window_map("h") +window_map("j") +window_map("k") +window_map("l") diff --git a/nvim/lua/options.lua b/nvim/lua/options.lua new file mode 100644 index 0000000..8c1119f --- /dev/null +++ b/nvim/lua/options.lua @@ -0,0 +1,37 @@ +vim.g.mapleader = " " + +vim.opt.tabstop = 4 +vim.opt.softtabstop = 4 +vim.opt.shiftwidth = 4 +vim.opt.expandtab = true +vim.opt.smartindent = true + +vim.opt.hidden = true +vim.opt.backup = false +vim.opt.swapfile = false + +vim.opt.splitright = true +vim.opt.splitbelow = true + +vim.opt.number = true +vim.opt.relativenumber = true + +vim.opt.cursorline = true +vim.opt.colorcolumn = '80' +vim.opt.signcolumn = 'yes' +vim.opt.laststatus = 3 + +vim.opt.ignorecase = true +vim.opt.smartcase = true +vim.opt.incsearch = true +vim.opt.inccommand = 'nosplit' + +vim.opt.scrolloff = 5 +vim.opt.wrap = false +vim.opt.termguicolors = true +vim.opt.timeoutlen = 400 + +vim.opt.list = true +vim.opt.listchars = "eol:↲,tab:» ,trail:.," + +vim.opt.exrc = true diff --git a/nvim/lua/plugins.lua b/nvim/lua/plugins.lua new file mode 100644 index 0000000..68317ad --- /dev/null +++ b/nvim/lua/plugins.lua @@ -0,0 +1,24 @@ +return { + { + "ellisonleao/gruvbox.nvim", + config = function() + vim.cmd.colorscheme("gruvbox") + end + }, + + { + "ggandor/leap.nvim", + config = function() + require("leap").set_default_keymaps() + vim.api.nvim_set_hl(0, 'LeapBackdrop', { link = 'Comment' }) + end + }, + + { "abecodes/tabout.nvim", dependencies = { "nvim-treesitter" }, config = true }, + + { "numToStr/Comment.nvim", config = true }, + { "nvim-lualine/lualine.nvim", config = true }, + { "windwp/nvim-autopairs", config = true }, + + "fladson/vim-kitty" +} diff --git a/nvim/lua/plugins/completion.lua b/nvim/lua/plugins/completion.lua new file mode 100644 index 0000000..c01c19b --- /dev/null +++ b/nvim/lua/plugins/completion.lua @@ -0,0 +1,34 @@ +return { + "hrsh7th/nvim-cmp", + dependencies = { + "hrsh7th/cmp-buffer", + "hrsh7th/cmp-nvim-lsp", + "hrsh7th/cmp-nvim-lua", + "hrsh7th/cmp-path" + }, + config = function() + local cmp = require("cmp") + + cmp.setup { + mapping = cmp.mapping.preset.insert { + [""] = function(fallback) + if cmp.visible() then + cmp.confirm { select=true } + else + fallback() + end + end + }, + sources = { + { name = "nvim_lsp" }, + { name = "nvim_lua" }, + { name = "buffer" }, + { name = "path" } + }, + experimental = { + native_menu = false, + ghost_text = { hl_group = "Comment" } + } + } + end +} diff --git a/nvim/lua/plugins/telescope.lua b/nvim/lua/plugins/telescope.lua new file mode 100644 index 0000000..67de624 --- /dev/null +++ b/nvim/lua/plugins/telescope.lua @@ -0,0 +1,56 @@ +return { + "nvim-telescope/telescope.nvim", + dependencies = { + "nvim-lua/plenary.nvim", + "kyazdani42/nvim-web-devicons", + "nvim-telescope/telescope-file-browser.nvim", + { "nvim-telescope/telescope-fzf-native.nvim", build = "make" } + }, + config = function() + local telescope = require("telescope") + local fb_actions = require("telescope").extensions.file_browser.actions + + telescope.setup({ + pickers = { + man_pages = { + sections = {"ALL"} + } + }, + extensions = { + file_browser = { + grouped = true, + hide_parent_dir = true, + hijack_netrw = true, + initial_mode = "normal", + respect_gitignore = "false", + sorting_strategy = "ascending", + layout_config = { + prompt_position = "top" + }, + mappings = { + n = { + ["h"] = fb_actions.goto_parent_dir, + ["l"] = "select_default", + ["g"] = fb_actions.toggle_hidden + } + } + } + } + }) + + telescope.load_extension("file_browser") + telescope.load_extension("fzf") + + local builtin = require("telescope.builtin") + vim.keymap.set("", "tf", builtin.find_files) + vim.keymap.set("", "th", builtin.help_tags) + vim.keymap.set("", "tr", builtin.buffers) + vim.keymap.set("", "ts", telescope.extensions.file_browser.file_browser) + vim.keymap.set("", "tt", builtin.builtin) + + vim.keymap.set("", "tc", function() builtin.find_files({ + cwd = "$DOTS", + prompt_title = "< Dotfiles >" + }) end) + end, +} diff --git a/nvim/lua/plugins/toggleterm.lua b/nvim/lua/plugins/toggleterm.lua new file mode 100644 index 0000000..3d61f7a --- /dev/null +++ b/nvim/lua/plugins/toggleterm.lua @@ -0,0 +1,14 @@ +return { + "akinsho/toggleterm.nvim", + opts = { + open_mapping = "", + direction = "float", + size = function(term) + if term.direction == "vertical" then + return 80 + else + return 12 + end + end + } +} diff --git a/nvim/lua/plugins/treesitter.lua b/nvim/lua/plugins/treesitter.lua new file mode 100644 index 0000000..cc430d4 --- /dev/null +++ b/nvim/lua/plugins/treesitter.lua @@ -0,0 +1,15 @@ +return { + "nvim-treesitter/nvim-treesitter", + opts = { + ensure_installed = "all", + highlight = { + enable = true, + additional_vim_regex_highlighting = false + }, + indent = { + enable = true + } + }, + main = "nvim-treesitter.configs", + build = ":TSUpdate" +} diff --git a/zsh/dot-zshenv b/zsh/dot-zshenv new file mode 100644 index 0000000..f2133b9 --- /dev/null +++ b/zsh/dot-zshenv @@ -0,0 +1,9 @@ +typeset -U path +path+="$HOME/bin" + +export DOTS="$HOME/repos/dots" + +export VISUAL="nvim" +export EDITOR="nvim" + +# vim: filetype=zsh diff --git a/zsh/dot-zshrc b/zsh/dot-zshrc new file mode 100644 index 0000000..c7b78fb --- /dev/null +++ b/zsh/dot-zshrc @@ -0,0 +1,26 @@ +function create_dir() [ ! -d "$1" ] && mkdir -p "$1" +function safe_source() [ -f "$1" ] && source "$1" +function zsh_add_file() safe_source "$ZDOTDIR/$1" + +zsh_add_file "zsh-aliases" +zsh_add_file "zsh-functions" +zsh_add_file "zsh-options" + +zsh_add_plugin "Aloxaf/fzf-tab" +zsh_add_plugin "ahmubashshir/zinsults" +zsh_add_plugin "zdharma-continuum/fast-syntax-highlighting" +zsh_add_plugin "zsh-users/zsh-autosuggestions" +zsh_add_plugin "zsh-users/zsh-completions" + +create_dir "$HOME/.cache/zsh" +autoload -Uz compinit && compinit -d "$HOME/.cache/zsh/zcompdump" +zmodload zsh/complist +zstyle ':completion:*' matcher-list 'm:{a-z}={A-Za-z}' + +autoload -z edit-command-line +zle -N edit-command-line + +bindkey "^V" edit-command-line +bindkey '^K' autosuggest-execute + +# vim: filetype=zsh diff --git a/zsh/zsh-aliases b/zsh/zsh-aliases new file mode 100644 index 0000000..0118786 --- /dev/null +++ b/zsh/zsh-aliases @@ -0,0 +1,21 @@ +alias p='sudo pacman -S' +alias pu='sudo pacman -Syu' + +alias vi='nvim' +alias vif='nvim +"norm 1 tf" +startinsert' +alias vic='nvim +"norm 1 tc" +startinsert' + +alias l='exa -x --group-directories-first --icons' +alias ll='l -lbh --git --no-time' +alias lt='ll --tree' + +alias la='l -a' +alias lla='ll -a' +alias lta='lt -a --ignore-glob=".git"' + +alias cc='noglob cc' +alias wcl='wc -l' + +alias s='kitty +kitten ssh' + +# vim: filetype=zsh diff --git a/zsh/zsh-functions b/zsh/zsh-functions new file mode 100644 index 0000000..08451e0 --- /dev/null +++ b/zsh/zsh-functions @@ -0,0 +1,19 @@ +function zsh_add_plugin() { + PLUGIN_NAME=$(echo $1 | cut -d "/" -f 2) + + [ ! -d "$HOME/.local/share/zsh/plugins/$PLUGIN_NAME" ] && + git clone "https://github.com/$1.git" "$HOME/.local/share/zsh/plugins/$PLUGIN_NAME" + + safe_source "$HOME/.local/share/zsh/plugins/$PLUGIN_NAME/$PLUGIN_NAME.plugin.zsh" + safe_source "$HOME/.local/share/zsh/plugins/$PLUGIN_NAME/$PLUGIN_NAME.zsh" +} + +function cc() python -c "from math import *; print($*)" +function mkcd() mkdir -p -- $1 && cd -- $1 + +function serve() { + gem list -i '^webrick$' > /dev/null || gem install webrick + ruby -run -e httpd . -p 3000 +} + +# vim: filetype=zsh diff --git a/zsh/zsh-options b/zsh/zsh-options new file mode 100644 index 0000000..6c112ef --- /dev/null +++ b/zsh/zsh-options @@ -0,0 +1,27 @@ +create_dir "$HOME/.local/state/zsh" + +HISTFILE="$HOME/.local/state/zsh/history" +HISTSIZE=65536 +SAVEHIST=$HISTSIZE + +setopt AUTO_CD +setopt HIST_IGNORE_DUPS +setopt HIST_VERIFY +setopt INC_APPEND_HISTORY +setopt RM_STAR_SILENT +setopt NO_BEEP + +stty stop undef +zle_highlight=("paste:none") + +if command -v starship &> /dev/null; then + eval "$(starship init zsh)" +else + [ ! -d "$HOME/.local/share/zsh/plugins/pure" ] && + git clone "https://github.com/sindresorhus/pure" "$HOME/.local/share/zsh/plugins/pure" + + fpath+="$HOME/.local/share/zsh/plugins/pure" + safe_source "$HOME/.local/share/zsh/plugins/pure/pure.zsh" +fi + +# vim: filetype=zsh