From 658d95fb368fe256fb1ffe547c5181dcfeaec39d Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Wed, 11 Jun 2025 22:30:24 +0000 Subject: [PATCH] Refactor: Migrate dotfiles management from homemaker to stow This commit completes the migration from homemaker to stow for managing your dotfiles. Key changes: - All dotfiles previously managed by homemaker or manually are now organized into subdirectories under the `stow/` directory (e.g., `stow/bash`, `stow/git`, `stow/nvim`, `stow/tmux`, `stow/inputrc`, `stow/zsh`). - The `README.md` has been extensively updated to: - Remove all references to homemaker and its Go dependency. - Provide clear instructions for installing stow. - Detail the `stow` commands needed to link each configuration package. - Refresh and consolidate dependency installation instructions (e.g., for Neovim, Tmux, general development tools). - Incorporate setup steps previously found in scripts (e.g., Powerline font installation from `tmux.sh`). - The `docker/Dockerfile` has been updated to: - Install `stow`. - Use `stow` commands to set up dotfiles within the Docker image, replacing the homemaker logic. - Old files related to the homemaker setup and unused configurations have been removed: - `install.sh` - `config.toml` - `vim.sh` - `init.vim` and `vimrc` (assuming Neovim is the primary editor; these were not migrated to stow). - Utility scripts: - `tmux_init.sh` (a user script) has been moved to `scripts/tmux_init.sh`. The README now advises adding this `scripts` directory to your PATH. - `tmux.sh` has been deleted as its functionality is now documented in the README. This change simplifies the dotfile management process, relying on the well-established `stow` utility and providing clearer setup instructions. --- README.md | 376 ++++++++---- config.toml | 108 ---- docker/Dockerfile | 12 +- init.vim | 685 --------------------- install.sh | 15 - tmux_init.sh => scripts/tmux_init.sh | 0 bash_aliases => stow/bash/bash_aliases | 0 bashrc => stow/bash/bashrc | 0 bashrc__mac => stow/bash/bashrc.mac | 0 gitconfig => stow/git/gitconfig | 0 inputrc => stow/inputrc/inputrc | 0 tmux.conf__mac => stow/tmux/tmux.conf.mac | 0 tmux.sh | 15 - vim.sh | 15 - vimrc | 705 ---------------------- 15 files changed, 271 insertions(+), 1660 deletions(-) delete mode 100644 config.toml delete mode 100644 init.vim delete mode 100755 install.sh rename tmux_init.sh => scripts/tmux_init.sh (100%) rename bash_aliases => stow/bash/bash_aliases (100%) rename bashrc => stow/bash/bashrc (100%) rename bashrc__mac => stow/bash/bashrc.mac (100%) rename gitconfig => stow/git/gitconfig (100%) rename inputrc => stow/inputrc/inputrc (100%) rename tmux.conf__mac => stow/tmux/tmux.conf.mac (100%) delete mode 100644 tmux.sh delete mode 100644 vim.sh delete mode 100755 vimrc diff --git a/README.md b/README.md index af841e3..2f10f55 100755 --- a/README.md +++ b/README.md @@ -1,174 +1,324 @@ -dotfiles -======== +# dotfiles +Personal dotfiles managed with `stow`. -## Installtion -### Get repo +## Installation + +### 1. Get Repo + +Choose one of the following methods: + +**HTTPS:** +```bash +cd +git clone https://github.com/tdmanv/dotfiles.git ``` + +**SSH:** +```bash cd git clone git@github.com:tdmanv/dotfiles.git ``` -``` + +**Manual Download (if git is not available):** +```bash cd curl -sLO https://github.com/tdmanv/dotfiles/archive/master.tar.gz tar xvf master.tar.gz -mv dotfiles-master +mv dotfiles-master dotfiles # Ensure the directory is named 'dotfiles' ``` -### Install stow +### 2. Install Stow + +`stow` is used to create symbolic links from the files in this repository to your home directory. + +**macOS (using Homebrew):** +```bash +brew install stow ``` -# Mac -homebrew install stow -#Linux +**Linux (Debian/Ubuntu):** +```bash +sudo apt-get update sudo apt-get install stow ``` -### Install go +For other distributions, please use your system's package manager. -TODO: try https://github.com/sbonaiva/govm +### 3. Install General Dependencies -https://go.dev/doc/install +These are common dependencies that many of the configurations might need. Specific tools might have additional dependencies listed in their respective sections. -``` -curl https://go.dev/dl/go1.19.3.linux-amd64.tar.gz -sudo rm -rf /usr/local/go && sudo tar -C /usr/local -xzf go1.19.3.linux-amd64.tar.gz -sudo ln -s /usr/local/go/bin/go /usr/local/bin +```bash +# For Debian/Ubuntu based systems +sudo apt-get install -y git curl build-essential python3-dev cmake -# Using snap (linux only) -sudo snap install go +# For macOS (many of these might be pre-installed or managed by brew) +# Ensure you have Xcode Command Line Tools: xcode-select --install +# brew install git curl cmake ``` -#### Configure Shell: zsh -``` -# Install oh my zsh -# run commands listed here: https://ohmyz.sh/#install - -# Install oh my posh -# run commands listed here: https://ohmyposh.dev/docs/installation/macos#set-up-your-terminal +## Configuration -# Create configuration files -stow --dir "${HOME}/dotfiles/stow" --target "${HOME}" -v 5 zsh -``` - -#### Configure tmux -``` -sudo apt-get install tmux +All configurations are managed using `stow`. The general command structure is: +`stow --dir "${HOME}/dotfiles/stow" --target "${TARGET_PATH}" -S ` +Make sure you are in the `dotfiles` directory when running these commands, or adjust `"${HOME}/dotfiles/stow"` accordingly. -# Install the tmux config -stow --dir "${HOME}/dotfiles/stow" --target "${HOME}" -v 5 tmux +### Bash -# Install tmux plugin manager -# https://github.com/tmux-plugins/tpm -git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm +To link Bash configuration files (e.g., `.bashrc`, `.bash_aliases`): -# Install plugings using +I when in a tmux session +```bash +stow --dir "${HOME}/dotfiles/stow" --target "${HOME}" -S bash ``` -### Install files using homemaker (deprecating) - +**macOS users:** The `stow/bash/bashrc.mac` file contains macOS-specific configurations. You can source it from your main `~/.bashrc` file by adding a line like: +```bash +if [[ "$(uname)" == "Darwin" ]]; then + source "${HOME}/dotfiles/stow/bash/bashrc.mac" # Adjust path if necessary +fi +``` +(Note: The stowed `bashrc` might already include logic to source this.) +### Git -## install neovim mac -https://github.com/neovim/neovim/blob/master/INSTALL.md +To link Git configuration files (e.g., `.gitconfig`): +```bash +stow --dir "${HOME}/dotfiles/stow" --target "${HOME}" -S git ``` -# Install using brew -brew install neovim -# Link config using stow -mkdir -p "${HOME}/.config/nvim" -stow --dir "${HOME}/dotfiles/stow" --target "${HOME}/.config/nvim/" -v 5 nvim +### Inputrc -# Add extensions -brew install ripgrep +To link Inputrc configuration (e.g., `.inputrc` for readline behavior): +```bash +stow --dir "${HOME}/dotfiles/stow" --target "${HOME}" -S inputrc ``` -# Install node -# https://github.com/nvm-sh/nvm -curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.5/install.sh | bash -nvm install --lts -# Update npm -npm install -g npm@10.1.0 -# Install bash language server -npm i -g bash-language-server -``` +### Neovim (nvim) -#### Python -``` -``` +#### Install Neovim -#### Glcoud -``` -sudo apt-get install apt-transport-https ca-certificates gnupg +**macOS (using Homebrew):** +```bash +brew install neovim ``` -#### Tmux -https://github.com/erikw/tmux-powerline?tab=readme-ov-file -Install plugins in tmux I - -## Misc -### codespaces -https://github.com/codespaces +**Linux (AppImage - recommended for latest versions):** +```bash +curl -LO https://github.com/neovim/neovim/releases/latest/download/nvim.appimage +chmod u+x nvim.appimage +sudo mv nvim.appimage /usr/local/bin/nvim # Or any other location in your PATH ``` -gh codespace create --devcontainer-path ".devcontainer/buildimage/devcontainer.json" --repo kastenhq/k10 --machine basicLinux32gb --branch devcontainer - +Refer to the [Neovim installation guide](https://github.com/neovim/neovim/blob/master/INSTALL.md) for other installation methods. + +#### Install Neovim Dependencies + +For a full experience with LSPs, linters, formatters, and plugins: + +* **Python support:** + ```bash + python3 -m pip install --user --upgrade pynvim + ``` +* **Node.js and npm (for LSPs like `bash-language-server`, `tsserver`, etc.):** + See the "Node.js / NVM" section below. +* **Ripgrep (for Telescope search and other plugins):** + ```bash + # macOS + brew install ripgrep + # Linux + sudo apt-get install ripgrep + ``` +* **Other dependencies** (compilers like `gcc`/`clang`, `make`, `unzip`, etc.) might be needed for specific plugins or language servers. + +#### Link Neovim Configuration + +```bash +mkdir -p "${HOME}/.config/nvim" +stow --dir "${HOME}/dotfiles/stow" --target "${HOME}/.config/nvim" -S nvim ``` -# Deprecated -#### Linux +### Tmux -cd dotfiles -go install foosoft.net/projects/homemaker@latest -~/go/bin/homemaker --verbose --task=bash --variant=linux config.toml . +#### Install Tmux -## Install neovim +```bash +# Linux (Debian/Ubuntu) +sudo apt-get install tmux -## Linux +# macOS (using Homebrew) +brew install tmux ``` -curl -LO https://github.com/neovim/neovim/releases/latest/download/nvim.appimage -sudo mv nvim.appimage /usr/local/bin/nvim -python3 -m pip install --user --upgrade pynvim -sudo apt-get install python3-neovim -# Deprecated using homemaker -~/go/bin/homemaker --verbose --task=nvim_config --variant=linux config.toml . -``` +#### Link Tmux Configuration -#### Tmux (deprecated) +```bash +stow --dir "${HOME}/dotfiles/stow" --target "${HOME}" -S tmux ``` -~/go/bin/homemaker --verbose --task=tmux config.toml . +**macOS users:** The `stow/tmux/tmux.conf.mac` file contains macOS-specific configurations. It is typically sourced automatically by the main `tmux.conf`. + +#### Tmux Plugin Manager (TPM) + +1. Install TPM: + ```bash + git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm + ``` +2. Install plugins: + * Launch Tmux. + * Press `prefix + I` (capital 'i') to fetch and install plugins defined in `tmux.conf`. (prefix is usually `Ctrl-b` or `Ctrl-a`). + +#### Tmux Powerline Fonts (Optional) + +For some themes (like powerline-based ones) to render correctly, you might need to install powerline-patched fonts: + +1. **Install Fontconfig (if not present):** + ```bash + # Linux (Debian/Ubuntu) + sudo apt-get install fontconfig + # macOS: Usually handled by the system or Homebrew. + ``` +2. **Download and Install a Powerline Font:** + You can find many pre-patched fonts. A common one is `PowerlineSymbols.otf`. + ```bash + wget https://github.com/Lokaltog/powerline/raw/develop/font/PowerlineSymbols.otf + # For user-specific install (recommended): + mkdir -p ~/.local/share/fonts + mv PowerlineSymbols.otf ~/.local/share/fonts/ + # Or system-wide: + # sudo mv PowerlineSymbols.otf /usr/share/fonts/opentype/ # Path may vary + ``` +3. **Update Font Cache:** + ```bash + fc-cache -vf ~/.local/share/fonts/ # For user-specific + # sudo fc-cache -vf /usr/share/fonts/ # For system-wide + ``` +4. **Configure Fontconfig (Optional, for specific font matching):** + This step might not always be necessary if your terminal emulator correctly picks up the font. + ```bash + wget https://github.com/Lokaltog/powerline/raw/develop/font/10-powerline-symbols.conf + # For user-specific install: + mkdir -p ~/.config/fontconfig/conf.d + mv 10-powerline-symbols.conf ~/.config/fontconfig/conf.d/ + # Or system-wide: + # sudo mv 10-powerline-symbols.conf /etc/fonts/conf.d/ + ``` +5. Configure your terminal emulator to use a Powerline-patched font. + +### Zsh + +#### Install Zsh + +```bash +# Linux (Debian/Ubuntu) +sudo apt-get install zsh + +# macOS (usually pre-installed, or use Homebrew) +# brew install zsh ``` +You might want to set Zsh as your default shell: `chsh -s $(which zsh)` -``` -# log in/out to reset bash -~/go/bin/homemaker --verbose --task=vim --variant=linux config.toml . +#### Install Oh My Zsh (Optional, but common) -# YCM requires some dependencies to be built -# https://github.com/ycm-core/YouCompleteMe -sudo apt-get update -sudo apt install vim-nox cmake python3-dev build-essential -cd ~/.vim/bundle/YouCompleteMe -python3 install.py --all +Follow the instructions on the [Oh My Zsh website](https://ohmyz.sh/#install). -# https://docs.docker.com/engine/install/ubuntu/#install-using-the-repository -sudo apt-get install \ - ca-certificates \ - curl \ - gnupg \ - lsb-release +#### Install Oh My Posh (Optional, for custom prompts) -sudo mkdir -p /etc/apt/keyrings -curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg +Follow the instructions on the [Oh My Posh website](https://ohmyposh.dev/docs/installation). - echo \ - "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \ - $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null +#### Link Zsh Configuration -sudo apt-get update -sudo apt-get install docker-ce docker-ce-cli -# https://www.digitalocean.com/community/questions/how-to-fix-docker-got-permission-denied-while-trying-to-connect-to-the-docker-daemon-socket +```bash +stow --dir "${HOME}/dotfiles/stow" --target "${HOME}" -S zsh +``` +This will link files like `.zshrc`. The provided `.zshrc` might be configured to work with Oh My Zsh and Oh My Posh if you choose to install them. + +### Node.js / NVM (Node Version Manager) + +NVM allows you to manage multiple Node.js versions. This is useful for Neovim LSPs and other development tools. + +1. **Install NVM:** + ```bash + curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.5/install.sh | bash + ``` + (Check the [NVM GitHub page](https://github.com/nvm-sh/nvm) for the latest install script version.) + You'll need to source NVM in your shell, or close and reopen your terminal. Add the following to your `.bashrc` or `.zshrc` if the installer doesn't: + ```bash + export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_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 + ``` + +2. **Install Node.js (e.g., latest LTS):** + ```bash + nvm install --lts + nvm use --lts + nvm alias default 'lts/*' # Set LTS as default for new shells + ``` + +3. **Update npm (Node Package Manager):** + ```bash + npm install -g npm # To the latest version + ``` + +4. **Install Global npm Packages (Example):** + ```bash + # Bash Language Server (for Neovim LSP) + npm i -g bash-language-server + ``` + +## Miscellaneous + +### Google Cloud SDK (gcloud) + +Follow the official [Google Cloud SDK installation guide](https://cloud.google.com/sdk/docs/install) for your operating system. +A common method for Linux: + +```bash +sudo apt-get install apt-transport-https ca-certificates gnupg +echo "deb [signed-by=/usr/share/keyrings/cloud.google.gpg] https://packages.cloud.google.com/apt cloud-sdk main" | sudo tee -a /etc/apt/sources.list.d/google-cloud-sdk.list +curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key --keyring /usr/share/keyrings/cloud.google.gpg add - +sudo apt-get update && sudo apt-get install google-cloud-sdk +``` +### Docker + +Follow the official [Docker installation guide](https://docs.docker.com/engine/install/) for your OS. +For Ubuntu: + +1. **Set up the repository:** + ```bash + sudo apt-get update + sudo apt-get install ca-certificates curl gnupg lsb-release + sudo mkdir -p /etc/apt/keyrings + curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg + echo \ + "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \ + $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null + ``` +2. **Install Docker Engine:** + ```bash + sudo apt-get update + sudo apt-get install docker-ce docker-ce-cli containerd.io docker-compose-plugin + ``` +3. **Post-installation steps (optional, to run Docker without sudo):** + Refer to [Docker post-installation steps](https://docs.docker.com/engine/install/linux-postinstall/). + ```bash + sudo groupadd docker + sudo usermod -aG docker $USER + newgrp docker # Activate changes, or log out and back in + ``` + +### Codespaces (GitHub) + +To create a GitHub Codespace using a specific devcontainer configuration: + +```bash +gh codespace create --devcontainer-path ".devcontainer/buildimage/devcontainer.json" --repo / --machine --branch +``` +Example: +```bash +gh codespace create --devcontainer-path ".devcontainer/buildimage/devcontainer.json" --repo kastenhq/k10 --machine basicLinux32gb --branch devcontainer ``` +Refer to `gh codespace create --help` for more options. diff --git a/config.toml b/config.toml deleted file mode 100644 index f65e9bb..0000000 --- a/config.toml +++ /dev/null @@ -1,108 +0,0 @@ -# -# macros -# -[macros.install] - prefix = ["sudo", "apt-get", "install", "-y", "--force-yes"] - -# Not implemented -[macros.install__mac] - prefix = ["INVALID_COMMAND", "ABORT"] - -[macros.clone] - prefix = ["git", "clone"] - -# -# languages -# - -[tasks.python] - cmds = [["@install", "python-dev", "python-pip"]] - -# -# vim plugins -# -[tasks.vim_plugin_ag] - cmds = [ - ["wget", "http://swiftsignal.com/packages/ubuntu/precise/the-silver-searcher_0.14-1_amd64.deb"], - ["dpkg", "-i", "the-silver-searcher_0.14-1_amd64.deb"], - ["pwd"], - ["rm", "the-silver-searcher_0.14-1_amd64.deb"], - ] - -# -# tools -# - -[tasks.input] - links = [["${HM_DEST}/.inputrc", "inputrc"]] - -[tasks.bash] - deps = ["bash__common"] - links = [["${HM_DEST}/.bashrc", "bashrc"]] -[tasks.bash__mac] - deps = ["bash__common"] - links = [["${HM_DEST}/.bashrc", "bashrc__mac"]] -[tasks.bash__common] - links = [["${HM_DEST}/.bash_aliases", "bash_aliases"]] - -[tasks.git] - # cmds = [["@install", "git"]] - links = [["${HM_DEST}/.gitconfig", "gitconfig"]] - -[tasks.tmux] - #cmds = [["@install", "tmux"]] - links = [ - ["${HM_DEST}/.tmux_init.sh", "tmux_init.sh"], - ["${HM_DEST}/.tmux.conf", "tmux.conf"] - ] - -[tasks.tmux__mac] - links = [["${HM_DEST}/.tmux.conf", "tmux.conf__mac"]] - -[tasks.tmux_powerline] - cmds = [ - ["wget", "https://github.com/Lokaltog/powerline/raw/develop/font/PowerlineSymbols.otf", "https://github.com/Lokaltog/powerline/raw/develop/font/10-powerline-symbols.conf"], - ["install", "fontconfig"], - ["mv", "PowerlineSymbols.otf", "/usr/share/fonts/"], - ["fc-cache", "-vf"], - ["mv", "10-powerline-symbols.conf", "/etc/fonts/conf.d/"], - ] - -[tasks.nvim_config] - links = [["${HM_DEST}/.config/nvim/init.vim", "init.vim"]] - -[tasks.vimrc] - links = [["${HM_DEST}/.vimrc", "vimrc"]] - -[tasks.vim_upgrade] - cmds = [ - ["add-apt-repository", "ppa:nmi/vim-snapshots"], - ["apt-get", "update"], - ["@install", "vim"], - ] - -[tasks.vim_complete] - deps = ["vim_extra"] - cmds = [["@install", "cmake", "g++"]] - -[tasks.vim_extra] - deps = ["vim", "vim_plugin_ag"] - cmds = [["@install", "exuberant-ctags", "cscope"]] - -[tasks.vim] - deps = ["git", "vimrc"] - cmds = [ - ["@clone", "https://github.com/gmarik/vundle.git", "${HM_DEST}/.vim/bundle/vundle"], - ["vim", "+BundleInstall", "+qall"], - ] - #["@install", "vim", "bash-completion", "python-dev"], - -[tasks.misc] - cmds = [["@install", "xclip"]] - -# -# high level tasks -# - -[tasks.default] - deps = ["input", "bash", "git", "tmux", "vim"] diff --git a/docker/Dockerfile b/docker/Dockerfile index 1ec2dca..cba2fd6 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -4,13 +4,17 @@ WORKDIR /root ENV DEBIAN_FRONTEND noninteractive RUN apt-get update && \ - apt-get install -y vim git wget exuberant-ctags cscope bash-completion cmake g++ python-dev python-pip silversearcher-ag + apt-get install -y vim git wget exuberant-ctags cscope bash-completion cmake g++ python-dev python-pip silversearcher-ag stow RUN git clone https://github.com/tdmanv/dotfiles.git && \ cd dotfiles && \ - wget https://foosoft.net/projects/homemaker/dl/homemaker_linux_amd64.tar.gz && \ - tar xvf homemaker_linux_amd64.tar.gz && \ - ./homemaker_linux_amd64/homemaker --clobber --verbose config.toml . + stow --dir /root/dotfiles/stow -S bash -t /root -v && \ + stow --dir /root/dotfiles/stow -S git -t /root -v && \ + stow --dir /root/dotfiles/stow -S inputrc -t /root -v && \ + mkdir -p /root/.config/nvim && \ + stow --dir /root/dotfiles/stow -S nvim -t /root/.config/nvim -v && \ + stow --dir /root/dotfiles/stow -S tmux -t /root -v && \ + stow --dir /root/dotfiles/stow -S zsh -t /root -v # Clean up APT when done. #RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* diff --git a/init.vim b/init.vim deleted file mode 100644 index 93d28b9..0000000 --- a/init.vim +++ /dev/null @@ -1,685 +0,0 @@ -" vim-bootstrap 2023-05-03 18:18:18 - -"***************************************************************************** -"" Vim-Plug core -"***************************************************************************** -let vimplug_exists=expand('~/.config/nvim/autoload/plug.vim') -if has('win32')&&!has('win64') - let curl_exists=expand('C:\Windows\Sysnative\curl.exe') -else - let curl_exists=expand('curl') -endif - -let g:vim_bootstrap_langs = "go,html,javascript,python,typescript" -let g:vim_bootstrap_editor = "nvim" " nvim or vim -let g:vim_bootstrap_theme = "dogrun" -let g:vim_bootstrap_frams = "vuejs" - -if !filereadable(vimplug_exists) - if !executable(curl_exists) - echoerr "You have to install curl or first install vim-plug yourself!" - execute "q!" - endif - echo "Installing Vim-Plug..." - echo "" - silent exec "!"curl_exists" -fLo " . shellescape(vimplug_exists) . " --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim" - let g:not_finish_vimplug = "yes" - - autocmd VimEnter * PlugInstall -endif - -" Required: -call plug#begin(expand('~/.config/nvim/plugged')) - -"***************************************************************************** -"" Plug install packages -"***************************************************************************** -Plug 'scrooloose/nerdtree' -Plug 'jistr/vim-nerdtree-tabs' -Plug 'tpope/vim-commentary' -Plug 'tpope/vim-fugitive' -Plug 'vim-airline/vim-airline' -Plug 'vim-airline/vim-airline-themes' -Plug 'airblade/vim-gitgutter' -Plug 'vim-scripts/grep.vim' -Plug 'vim-scripts/CSApprox' -Plug 'Raimondi/delimitMate' -Plug 'majutsushi/tagbar' -Plug 'dense-analysis/ale' -Plug 'Yggdroot/indentLine' -Plug 'editor-bootstrap/vim-bootstrap-updater' -Plug 'tpope/vim-rhubarb' " required by fugitive to :Gbrowse -Plug 'wadackel/vim-dogrun' -Plug 'Exafunction/codeium.vim' " TODO remove later - -if isdirectory('/usr/local/opt/fzf') - Plug '/usr/local/opt/fzf' | Plug 'junegunn/fzf.vim' -else - Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --bin' } - Plug 'junegunn/fzf.vim' -endif -let g:make = 'gmake' -if exists('make') - let g:make = 'make' -endif -Plug 'Shougo/vimproc.vim', {'do': g:make} - -"" Vim-Session -Plug 'xolox/vim-misc' -Plug 'xolox/vim-session' - -"" Snippets -Plug 'SirVer/ultisnips' -Plug 'honza/vim-snippets' - -"***************************************************************************** -"" Custom bundles -"***************************************************************************** - -" go -"" Go Lang Bundle -" Plug 'fatih/vim-go', {'do': ':GoInstallBinaries'} TMP - - -" html -"" HTML Bundle -Plug 'hail2u/vim-css3-syntax' -Plug 'gko/vim-coloresque' -Plug 'tpope/vim-haml' -Plug 'mattn/emmet-vim' - - -" javascript -"" Javascript Bundle -Plug 'jelera/vim-javascript-syntax' - - -" python -"" Python Bundle -" Plug 'davidhalter/jedi-vim' -" Plug 'raimon49/requirements.txt.vim', {'for': 'requirements'} - - -" typescript -Plug 'leafgarland/typescript-vim' -Plug 'HerringtonDarkholme/yats.vim' - - -" vuejs -Plug 'posva/vim-vue' -Plug 'leafOfTree/vim-vue-plugin' - - - -"***************************************************************************** -"***************************************************************************** - -"" Include user's extra bundle -if filereadable(expand("~/.config/nvim/local_bundles.vim")) - source ~/.config/nvim/local_bundles.vim -endif - -call plug#end() - -" Required: -filetype plugin indent on - - -"***************************************************************************** -"" Basic Setup -"*****************************************************************************" -"" Encoding -set encoding=utf-8 -set fileencoding=utf-8 -set fileencodings=utf-8 - - -"" Fix backspace indent -set backspace=indent,eol,start - -"" Tabs. May be overridden by autocmd rules -set tabstop=4 -set softtabstop=0 -set shiftwidth=4 -set expandtab - -"" Map leader to , -let mapleader=',' - -"" Enable hidden buffers -set hidden - -"" Searching -set hlsearch -set incsearch -set ignorecase -set smartcase - -set fileformats=unix,dos,mac - -if exists('$SHELL') - set shell=$SHELL -else - set shell=/bin/bash -endif - -" session management -let g:session_directory = "~/.config/nvim/session" -let g:session_autoload = "no" -let g:session_autosave = "no" -let g:session_command_aliases = 1 - -"***************************************************************************** -"" Visual Settings -"***************************************************************************** -syntax on -set ruler -set number - -let no_buffers_menu=1 -"colorscheme dogrun - -" Better command line completion -set wildmenu - -" mouse support -set mouse=a - -set mousemodel=popup -set t_Co=256 -set guioptions=egmrti -set gfn=Monospace\ 10 - -if has("gui_running") - if has("gui_mac") || has("gui_macvim") - set guifont=Menlo:h12 - set transparency=7 - endif -else - let g:CSApprox_loaded = 1 - - " IndentLine - let g:indentLine_enabled = 1 - let g:indentLine_concealcursor = '' - let g:indentLine_char = '┆' - let g:indentLine_faster = 1 - - -endif - - - -"" Disable the blinking cursor. -set gcr=a:blinkon0 - -au TermEnter * setlocal scrolloff=0 -au TermLeave * setlocal scrolloff=3 - - -"" Status bar -set laststatus=2 - -"" Use modeline overrides -set modeline -set modelines=10 - -set title -set titleold="Terminal" -set titlestring=%F - -set statusline=%F%m%r%h%w%=(%{&ff}/%Y)\ (line\ %l\/%L,\ col\ %c)\ - -" Search mappings: These will make it so that going to the next one in a -" search will center on the line it's found in. -nnoremap n nzzzv -nnoremap N Nzzzv - -if exists("*fugitive#statusline") - set statusline+=%{fugitive#statusline()} -endif - -" vim-airline -let g:airline_theme = 'powerlineish' -let g:airline#extensions#branch#enabled = 1 -let g:airline#extensions#ale#enabled = 1 -let g:airline#extensions#tabline#enabled = 1 -let g:airline#extensions#tagbar#enabled = 1 -let g:airline_skip_empty_sections = 1 - -"***************************************************************************** -"" Abbreviations -"***************************************************************************** -"" no one is really happy until you have this shortcuts -cnoreabbrev W! w! -cnoreabbrev Q! q! -cnoreabbrev Qall! qall! -cnoreabbrev Wq wq -cnoreabbrev Wa wa -cnoreabbrev wQ wq -cnoreabbrev WQ wq -cnoreabbrev W w -cnoreabbrev Q q -cnoreabbrev Qall qall - -"" NERDTree configuration -let g:NERDTreeChDirMode=2 -let g:NERDTreeIgnore=['node_modules','\.rbc$', '\~$', '\.pyc$', '\.db$', '\.sqlite$', '__pycache__'] -let g:NERDTreeSortOrder=['^__\.py$', '\/$', '*', '\.swp$', '\.bak$', '\~$'] -let g:NERDTreeShowBookmarks=1 -let g:nerdtree_tabs_focus_on_files=1 -let g:NERDTreeMapOpenInTabSilent = '' -let g:NERDTreeWinSize = 50 -set wildignore+=*/tmp/*,*.so,*.swp,*.zip,*.pyc,*.db,*.sqlite,*node_modules/ -nnoremap :NERDTreeFind -nnoremap :NERDTreeToggle - -" grep.vim -nnoremap f :Rgrep -let Grep_Default_Options = '-IR' -let Grep_Skip_Files = '*.log *.db' -let Grep_Skip_Dirs = '.git node_modules' - -" terminal emulation -nnoremap sh :terminal - - -"***************************************************************************** -"" Commands -"***************************************************************************** -" remove trailing whitespaces -command! FixWhitespace :%s/\s\+$//e - -"***************************************************************************** -"" Functions -"***************************************************************************** -if !exists('*s:setupWrapping') - function s:setupWrapping() - set wrap - set wm=2 - set textwidth=79 - endfunction -endif - -"***************************************************************************** -"" Autocmd Rules -"***************************************************************************** -"" The PC is fast enough, do syntax highlight syncing from start unless 200 lines -augroup vimrc-sync-fromstart - autocmd! - autocmd BufEnter * :syntax sync maxlines=200 -augroup END - -"" Remember cursor position -augroup vimrc-remember-cursor-position - autocmd! - autocmd BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g`\"" | endif -augroup END - -"" txt -augroup vimrc-wrapping - autocmd! - autocmd BufRead,BufNewFile *.txt call s:setupWrapping() -augroup END - -"" make/cmake -augroup vimrc-make-cmake - autocmd! - autocmd FileType make setlocal noexpandtab - autocmd BufNewFile,BufRead CMakeLists.txt setlocal filetype=cmake -augroup END - -set autoread - -"***************************************************************************** -"" Mappings -"***************************************************************************** - -"" Split -noremap h :split -noremap v :vsplit - -"" Git - Commented since I use g for go -"noremap ga :Gwrite -"noremap gc :Git commit --verbose -"noremap gsh :Git push -"noremap gll :Git pull -"noremap gs :Git -"noremap gb :Git blame -"noremap gd :Gvdiffsplit -"noremap gr :GRemove - -" session management -nnoremap so :OpenSession -nnoremap ss :SaveSession -nnoremap sd :DeleteSession -nnoremap sc :CloseSession - -"" Tabs -nnoremap gt -nnoremap gT -nnoremap :tabnew - -"" Set working directory -nnoremap . :lcd %:p:h - -"" Opens an edit command with the path of the currently edited file filled in -noremap e :e =expand("%:p:h") . "/" - -"" Opens a tab edit command with the path of the currently edited file filled -noremap te :tabe =expand("%:p:h") . "/" - -"" fzf.vim -set wildmode=list:longest,list:full -set wildignore+=*.o,*.obj,.git,*.rbc,*.pyc,__pycache__ -let $FZF_DEFAULT_COMMAND = "find * -path '*/\.*' -prune -o -path 'node_modules/**' -prune -o -path 'target/**' -prune -o -path 'dist/**' -prune -o -type f -print -o -type l -print 2> /dev/null" - -" The Silver Searcher -if executable('ag') - let $FZF_DEFAULT_COMMAND = 'ag --hidden --ignore .git -g ""' - set grepprg=ag\ --nogroup\ --nocolor -endif - -" ripgrep -if executable('rg') - let $FZF_DEFAULT_COMMAND = 'rg --files --hidden --follow --glob "!.git/*"' - set grepprg=rg\ --vimgrep - command! -bang -nargs=* Find call fzf#vim#grep('rg --column --line-number --no-heading --fixed-strings --ignore-case --hidden --follow --glob "!.git/*" --color "always" '.shellescape().'| tr -d "\017"', 1, 0) -endif - -cnoremap =expand("%:p:h") . "/" -nnoremap b :Buffers -" Modified from e -nnoremap j :FZF -m -"Recovery commands from history through FZF -nmap y :History: - -" snippets -let g:UltiSnipsExpandTrigger="" -let g:UltiSnipsJumpForwardTrigger="" -let g:UltiSnipsJumpBackwardTrigger="" -let g:UltiSnipsEditSplit="vertical" - -" ale -let g:ale_linters = {} - -" Tagbar -nmap :TagbarToggle -let g:tagbar_autofocus = 1 - -" Disable visualbell -set noerrorbells visualbell t_vb= -if has('autocmd') - autocmd GUIEnter * set visualbell t_vb= -endif - -"" Copy/Paste/Cut -if has('unnamedplus') - set clipboard=unnamed,unnamedplus -endif - -noremap YY "+y -noremap p "+gP -noremap XX "+x - -if has('macunix') - " pbcopy for OSX copy/paste - vmap :!pbcopy - vmap :w !pbcopy -endif - -"" Buffer nav -noremap z :bp -noremap q :bp -noremap x :bn -noremap w :bn - -"" Close buffer -noremap c :bd - -"" Clean search (highlight) -nnoremap :noh - -"" Switching windows -noremap j -noremap k -noremap l -noremap h - -"" Vmap for maintain Visual Mode after shifting > and < -vmap < >gv - -"" Move visual block -vnoremap J :m '>+1gv=gv -vnoremap K :m '<-2gv=gv - -"" Open current line on GitHub -nnoremap o :.Gbrowse - -"***************************************************************************** -"" Custom configs -"***************************************************************************** - -" go -" vim-go -" run :GoBuild or :GoTestCompile based on the go file -function! s:build_go_files() - let l:file = expand('%') - if l:file =~# '^\f\+_test\.go$' - call go#test#Test(0, 1) - elseif l:file =~# '^\f\+\.go$' - call go#cmd#Build(0) - endif -endfunction - -let g:go_list_type = "quickfix" -let g:go_fmt_command = "goimports" -let g:go_fmt_fail_silently = 1 - -let g:go_highlight_types = 1 -let g:go_highlight_fields = 1 -let g:go_highlight_functions = 1 -let g:go_highlight_methods = 1 -let g:go_highlight_operators = 1 -let g:go_highlight_build_constraints = 1 -let g:go_highlight_structs = 1 -let g:go_highlight_generate_tags = 1 -let g:go_highlight_space_tab_error = 0 -let g:go_highlight_array_whitespace_error = 0 -let g:go_highlight_trailing_whitespace_error = 0 -let g:go_highlight_extra_types = 1 - -autocmd BufNewFile,BufRead *.go setlocal noexpandtab tabstop=4 shiftwidth=4 softtabstop=4 - -augroup completion_preview_close - autocmd! - if v:version > 703 || v:version == 703 && has('patch598') - autocmd CompleteDone * if !&previewwindow && &completeopt =~ 'preview' | silent! pclose | endif - endif -augroup END - -augroup go - - au! - au Filetype go command! -bang A call go#alternate#Switch(0, 'edit') - au Filetype go command! -bang AV call go#alternate#Switch(0, 'vsplit') - au Filetype go command! -bang AS call go#alternate#Switch(0, 'split') - au Filetype go command! -bang AT call go#alternate#Switch(0, 'tabe') - - au FileType go nmap dd (go-def-vertical) - au FileType go nmap dv (go-doc-vertical) - au FileType go nmap db (go-doc-browser) - - au FileType go nmap r (go-run) - au FileType go nmap t (go-test) - au FileType go nmap gt (go-coverage-toggle) - au FileType go nmap i (go-info) - au FileType go nmap l (go-metalinter) - au FileType go nmap :GoDecls - au FileType go nmap dr :GoDeclsDir - au FileType go imap :GoDecls - au FileType go imap dr :GoDeclsDir - au FileType go nmap rb :call build_go_files() - -augroup END - -" ale -:call extend(g:ale_linters, { - \"go": ['golint', 'go vet'], }) - - -" html -" for html files, 2 spaces -autocmd Filetype html setlocal ts=2 sw=2 expandtab - - -" javascript -let g:javascript_enable_domhtmlcss = 1 - -" vim-javascript -augroup vimrc-javascript - autocmd! - autocmd FileType javascript setl tabstop=4|setl shiftwidth=4|setl expandtab softtabstop=4 -augroup END - - -" python -" vim-python -augroup vimrc-python - autocmd! - autocmd FileType python setlocal expandtab shiftwidth=4 tabstop=8 colorcolumn=79 - \ formatoptions+=croq softtabstop=4 - \ cinwords=if,elif,else,for,while,try,except,finally,def,class,with -augroup END - -" jedi-vim -" let g:jedi#popup_on_dot = 0 -" let g:jedi#goto_assignments_command = "g" -" let g:jedi#goto_definitions_command = "d" -" let g:jedi#documentation_command = "K" -" let g:jedi#usages_command = "n" -" let g:jedi#rename_command = "r" -" let g:jedi#show_call_signatures = "0" -" let g:jedi#completions_command = "" -" let g:jedi#smart_auto_mappings = 0 - -" ale -:call extend(g:ale_linters, { - \'python': ['flake8'], }) - -" vim-airline -let g:airline#extensions#virtualenv#enabled = 1 - -" Syntax highlight -let python_highlight_all = 1 - - -" typescript -let g:yats_host_keyword = 1 - - - -" vuejs -" vim vue -let g:vue_disable_pre_processors=1 -" vim vue plugin -let g:vim_vue_plugin_load_full_syntax = 1 - - -"***************************************************************************** -"***************************************************************************** - -"" Include user's local vim config -if filereadable(expand("~/.config/nvim/local_init.vim")) - source ~/.config/nvim/local_init.vim -endif - -"***************************************************************************** -"" Convenience variables -"***************************************************************************** - -" vim-airline -if !exists('g:airline_symbols') - let g:airline_symbols = {} -endif - -if !exists('g:airline_powerline_fonts') - let g:airline#extensions#tabline#left_sep = ' ' - let g:airline#extensions#tabline#left_alt_sep = '|' - let g:airline_left_sep = '▶' - let g:airline_left_alt_sep = '»' - let g:airline_right_sep = '◀' - let g:airline_right_alt_sep = '«' - let g:airline#extensions#branch#prefix = '⤴' "➔, ➥, ⎇ - let g:airline#extensions#readonly#symbol = '⊘' - let g:airline#extensions#linecolumn#prefix = '¶' - let g:airline#extensions#paste#symbol = 'ρ' - let g:airline_symbols.linenr = '␊' - let g:airline_symbols.branch = '⎇' - let g:airline_symbols.paste = 'ρ' - let g:airline_symbols.paste = 'Þ' - let g:airline_symbols.paste = '∥' - let g:airline_symbols.whitespace = 'Ξ' -else - let g:airline#extensions#tabline#left_sep = '' - let g:airline#extensions#tabline#left_alt_sep = '' - - " powerline symbols - let g:airline_left_sep = '' - let g:airline_left_alt_sep = '' - let g:airline_right_sep = '' - let g:airline_right_alt_sep = '' - let g:airline_symbols.branch = '' - let g:airline_symbols.readonly = '' - let g:airline_symbols.linenr = '' -endif - -"***************************************************************************** -"" My Modifications -"***************************************************************************** - -map Y y$ - -" NerdTree -map :NERDTreeToggle - -" Fast editing of the .vimrc -map e :tabnew! ~/.config/nvim/init.vim :vsp ~/.vimrc - -" Tab configuration -map tn :tabnew -map te :tabedit -map tc :tabclose -map tm :tabmove - -" Git helpers -vmap b :!git blame =expand("%:p") \| sed -n =line("',=line("'>") p -autocmd BufRead .git/COMMIT_EDITMSG setlocal spell -autocmd BufRead .git/COMMIT_EDITMSG set tw=70 - -" vim-go mappings -au FileType go map gp :GoImports -au FileType go map gi :GoImplements -au FileType go map gb :GoDescribe -au FileType go map gd :tabedit %gT:GoDef - -" Silver Searcher mappings -nmap a lb"tye:Ag t - -map n :tabnew -" Use the arrows to something usefull -map gt -map gT - -let g:codeium_enabled = v:false - - - - - - - - - - - diff --git a/install.sh b/install.sh deleted file mode 100755 index 0460bdf..0000000 --- a/install.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/bash - -set -uex - -# default installation on linux - -## ensure go and git are installed is installed -type go >/dev/null -type git >/dev/null - -## download homemaker -go install foosoft.net/projects/homemaker@latest -${HOME}/go/bin/homemaker -clobber --verbose --task=bash --variant=linux config.toml . - - diff --git a/tmux_init.sh b/scripts/tmux_init.sh similarity index 100% rename from tmux_init.sh rename to scripts/tmux_init.sh diff --git a/bash_aliases b/stow/bash/bash_aliases similarity index 100% rename from bash_aliases rename to stow/bash/bash_aliases diff --git a/bashrc b/stow/bash/bashrc similarity index 100% rename from bashrc rename to stow/bash/bashrc diff --git a/bashrc__mac b/stow/bash/bashrc.mac similarity index 100% rename from bashrc__mac rename to stow/bash/bashrc.mac diff --git a/gitconfig b/stow/git/gitconfig similarity index 100% rename from gitconfig rename to stow/git/gitconfig diff --git a/inputrc b/stow/inputrc/inputrc similarity index 100% rename from inputrc rename to stow/inputrc/inputrc diff --git a/tmux.conf__mac b/stow/tmux/tmux.conf.mac similarity index 100% rename from tmux.conf__mac rename to stow/tmux/tmux.conf.mac diff --git a/tmux.sh b/tmux.sh deleted file mode 100644 index 234fd37..0000000 --- a/tmux.sh +++ /dev/null @@ -1,15 +0,0 @@ -#! /bin/sh -# -# font.sh -# Copyright (C) 2015 manville -# -# Distributed under terms of the MIT license. -# - - -wget https://github.com/Lokaltog/powerline/raw/develop/font/PowerlineSymbols.otf https://github.com/Lokaltog/powerline/raw/develop/font/10-powerline-symbols.conf -sudo apt-get install fontconfig -sudo mv PowerlineSymbols.otf /usr/share/fonts/ -sudo fc-cache -vf -sudo mv 10-powerline-symbols.conf /etc/fonts/conf.d/ - diff --git a/vim.sh b/vim.sh deleted file mode 100644 index 088b3a8..0000000 --- a/vim.sh +++ /dev/null @@ -1,15 +0,0 @@ -#! /bin/sh -# -# vim.sh -# Copyright (C) 2015 manville -# -# Distributed under terms of the MIT license. -# - - -sudo add-apt-repository ppa:fcwu-tw/ppa - -sudo apt-get update - -sudo apt-get install vim exuberant-ctags cscope bash-completion cmake g++ python-dev - diff --git a/vimrc b/vimrc deleted file mode 100755 index ed0e9bf..0000000 --- a/vimrc +++ /dev/null @@ -1,705 +0,0 @@ -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -" => General -"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -" Sets how many lines of history VIM has to remember set history=700 -" Enable filetype plugin filetype plugin on filetype indent on " Set to auto read when a file is changed from the outside set autoread - -" With a map leader it's possible to do extra key combinations -" like w saves the current file -let mapleader = "," -let g:mapleader = "," - -" Fast saving -nmap w :w! - -" Fast editing of the .vimrc -map e :tabnew! ~/.vimrc - -" When vimrc is edited, reload it -autocmd! bufwritepost .vimrc source ~/.vimrc - - -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -" => VIM user interface -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -" Set 7 lines to the curors - when moving vertical.. -set so=7 - -set wildmenu "Turn on WiLd menu - -set ruler "Always show current position - -set cmdheight=2 "The commandbar height - -set hid "Change buffer - without saving - -" Set backspace config -set backspace=eol,start,indent -set whichwrap+=<,>,h,l - -set ignorecase "Ignore case when searching -set smartcase - -set hlsearch "Highlight search things - -set incsearch "Make search act like search in modern browsers -set nolazyredraw "Don't redraw while executing macros - -set magic "Set magic on, for regular expressions - -set showmatch "Show matching bracets when text indicator is over them -set mat=2 "How many tenths of a second to blink - -" No sound on errors -set noerrorbells -set novisualbell -set t_vb= -set tm=500 - - -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -" => Colors and Fonts -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -syntax enable "Enable syntax hl - -" Set font according to system - -if has("gui_running") - set guioptions-=T - set t_Co=256 - set background=dark - "colorscheme peaksea - colorscheme zellner - set nonu -else - colorscheme zellner - set background=dark - set nonu -endif - -set encoding=utf8 -try - lang en_US -catch -endtry - -set ffs=unix,dos,mac "Default file types - - -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -" => Files, backups and undo -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -" Turn backup off, since most stuff is in SVN, git anyway... -set nobackup -set nowb -set noswapfile - - -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -" => Text, tab and indent related -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -set shiftwidth=4 -set tabstop=4 -set smarttab - -set lbr -set tw=500 - -set ai "Auto indent -set si "Smart indet -set wrap "Wrap lines - - -"""""""""""""""""""""""""""""" -" => Visual mode related -"""""""""""""""""""""""""""""" -" Really useful! -" In visual mode when you press * or # to search for the current selection -vnoremap * :call VisualSearch('f') -vnoremap # :call VisualSearch('b') - -" When you press gv you vimgrep after the selected text -vnoremap gv :call VisualSearch('gv') -" map g :vimgrep // **/*. - - -function! CmdLine(str) - exe "menu Foo.Bar :" . a:str - emenu Foo.Bar - unmenu Foo -endfunction - -" From an idea by Michael Naumann -function! VisualSearch(direction) range - let l:saved_reg = @" - execute "normal! vgvy" - - let l:pattern = escape(@", '\\/.*$^~[]') - let l:pattern = substitute(l:pattern, "\n$", "", "") - - if a:direction == 'b' - execute "normal ?" . l:pattern . "^M" - elseif a:direction == 'gv' - call CmdLine("vimgrep " . '/'. l:pattern . '/' . ' **/*.') - elseif a:direction == 'f' - execute "normal /" . l:pattern . "^M" - endif - - let @/ = l:pattern - let @" = l:saved_reg -endfunction - - - -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -" => Command mode related -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -" Smart mappings on the command line -cno $h e ~/ -cno $d e ~/Desktop/ -cno $j e ./ -cno $c e eCurrentFileDir("e") - -" $q is super useful when browsing on the command line -cno $q eDeleteTillSlash() - -" Bash like keys for the command line -cnoremap -cnoremap -cnoremap - -cnoremap -cnoremap - -func! Cwd() - let cwd = getcwd() - return "e " . cwd -endfunc - -func! DeleteTillSlash() - let g:cmd = getcmdline() - if MySys() == "linux" || MySys() == "mac" - let g:cmd_edited = substitute(g:cmd, "\\(.*\[/\]\\).*", "\\1", "") - else - let g:cmd_edited = substitute(g:cmd, "\\(.*\[\\\\]\\).*", "\\1", "") - endif - if g:cmd == g:cmd_edited - if MySys() == "linux" || MySys() == "mac" - let g:cmd_edited = substitute(g:cmd, "\\(.*\[/\]\\).*/", "\\1", "") - else - let g:cmd_edited = substitute(g:cmd, "\\(.*\[\\\\\]\\).*\[\\\\\]", "\\1", "") - endif - endif - return g:cmd_edited -endfunc - -func! CurrentFileDir(cmd) - return a:cmd . " " . expand("%:p:h") . "/" -endfunc - - -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -" => Moving around, tabs and buffers -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -" Map space to / (search) and c-space to ? (backgwards search) -"map / -"map ? -map :noh - -" Smart way to move btw. split windows -map j -map k -map h -map l - -" Close the current buffer -map bd :Bclose - -" Close all the buffers -map ba :1,300 bd! - -" Use the arrows to something usefull -map gt -map gT - -" Tab configuration -map tn :tabnew -map te :tabedit -map tc :tabclose -map tm :tabmove - -" When pressing cd switch to the directory of the open buffer -map cd :cd %:p:h - - -command! Bclose call BufcloseCloseIt() -function! BufcloseCloseIt() - let l:currentBufNum = bufnr("%") - let l:alternateBufNum = bufnr("#") - - if buflisted(l:alternateBufNum) - buffer # - else - bnext - endif - - if bufnr("%") == l:currentBufNum - new - endif - - if buflisted(l:currentBufNum) - execute("bdelete! ".l:currentBufNum) - endif -endfunction - -" Specify the behavior when switching between buffers -try - set switchbuf=usetab,newtab - set stal=2 -catch -endtry - - -"""""""""""""""""""""""""""""" -" => Statusline -"""""""""""""""""""""""""""""" -" Always hide the statusline -set laststatus=2 - -" Format the statusline -set statusline=\ %{HasPaste()}%F%m%r%h\ %w\ \ CWD:\ %r%{CurDir()}%h\ \ \ Line:\ %l/%L:%c - - -function! CurDir() - let curdir = substitute(getcwd(), '/Users/amir/', "~/", "g") - return curdir -endfunction - -function! HasPaste() - if &paste - return 'PASTE MODE ' - else - return '' - endif -endfunction - - -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -" => Parenthesis/bracket expanding -"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -vnoremap $1 `>a)` -vnoremap $2 `>a]` -vnoremap $3 `>a}` -vnoremap $$ `>a"` -vnoremap $q `>a'` -vnoremap $e `>a"` - -" Map auto complete of (, ", ', [ -"inoremap $1 ()i -"inoremap $2 []i -"inoremap $3 {}i -"inoremap $4 {o}O -"inoremap $q ''i -"inoremap $e ""i -"inoremap $t <>i - - -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -" => General Abbrevs -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -iab xdate =strftime("%d/%m/%y %H:%M:%S") - - -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -" => Editing mappings -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -"Remap VIM 0 -map 0 ^ - -"Move a line of text using ALT+[jk] or Comamnd+[jk] on mac -nmap mz:m+`z -nmap mz:m-2`z -vmap :m'>+`mzgv`yo`z -vmap :m'<-2`>my` Cope -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -" Do :help cope if you are unsure what cope is. It's super useful! -map cc :botright cope -map n :cn -map p :cp - - -"""""""""""""""""""""""""""""" -" => bufExplorer plugin -"""""""""""""""""""""""""""""" -let g:bufExplorerDefaultHelp=0 -let g:bufExplorerShowRelativePath=1 -map o :BufExplorer - - -"""""""""""""""""""""""""""""" -" => Minibuffer plugin -"""""""""""""""""""""""""""""" -let g:miniBufExplModSelTarget = 1 -let g:miniBufExplorerMoreThanOne = 2 -let g:miniBufExplModSelTarget = 0 -let g:miniBufExplUseSingleClick = 1 -let g:miniBufExplMapWindowNavVim = 1 -let g:miniBufExplVSplit = 25 -let g:miniBufExplSplitBelow=1 - -let g:bufExplorerSortBy = "name" - -autocmd BufRead,BufNew :call UMiniBufExplorer - -map u :TMiniBufExplorer - - -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -" => Spell checking -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -"Pressing ,ss will toggle and untoggle spell checking -map ss :setlocal spell! - -"Shortcuts using -map sn ]s -map sp [s -map sa zg -map s? z= - - -"""""""""""""""""""""""""""""" -" => Docs section -"""""""""""""""""""""""""""""" - -autocmd Filetype rst setlocal tabstop=2 - -"""""""""""""""""""""""""""""" -" => Python section -"""""""""""""""""""""""""""""" - -let python_highlight_all = 1 -autocmd FileType python set omnifunc=jedi#complete - -au FileType python syn keyword pythonDecorator True None False self - -au BufNewFile,BufRead *.jinja set syntax=htmljinja -au BufNewFile,BufRead *.mako set ft=mako - -au FileType python inoremap $r return -au FileType python inoremap $i import -au FileType python inoremap $p print -au FileType python inoremap $f #--- PH ----------------------------------------------FP2xi -au FileType python map 1 /class -au FileType python map 2 /def -au FileType python map C ?class -au FileType python map D ?def - - -"""""""""""""""""""""""""""""" -" => Command-T -"""""""""""""""""""""""""""""" -"let g:CommandTMaxHeight = 15 -set wildignore+=*.o,*.obj,.git,*.pyc,*.class, -noremap j :CommandT -noremap y :CommandTFlush - -"actually, lets use ctrlP -noremap j :CtrlP -"this means ctrlp won't change its directory -let g:ctrlp_working_path_mode = '' - - -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -" => MISC -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -" Remove the Windows ^M - when the encodings gets messed up -noremap m mmHmt:%s///ge'tzt'm - -"Quickly open a buffer for scripbble -map q :e ~/buffer -au BufRead,BufNewFile ~/buffer iab xh1 =========================================== - -map pp :setlocal paste! - -map bb :cd .. - -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -" => My Stuff -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" - -"highlight OverLength ctermbg=red ctermfg=white guibg=#592929 -"match OverLength /\%81v.\+/ - -vmap b :!git blame =expand("%:p") \| sed -n =line("',=line("'>") p - -autocmd BufRead .git/COMMIT_EDITMSG setlocal spell -autocmd BufRead .git/COMMIT_EDITMSG set tw=70 -map Y y$ - -map :!grep -nr " ./* -map gf gf -imap jj jj -noremap :wa:make clean; make -nmap s :tab split -nmap x :%!xxd - -set tabpagemax=50 -"map ^yEIcout << "pi: " << pi << endl; - -map za -set foldnestmax=2 -set expandtab - - -au FileType yml set expandtab -au FileType yml set shiftwidth=2 -au FileType yml set tabstop=2 -au FileType yml set foldmethod=manual - -au FileType yaml set expandtab -au FileType yaml set shiftwidth=2 -au FileType yaml set tabstop=2 -au FileType yaml set foldmethod=manual - -au FileType python set expandtab -au FileType python set shiftwidth=4 -au FileType python set tabstop=4 -au FileType python set foldmethod=manual -let python_version_2 = 0 - -au FileType cpp set foldmethod=syntax - - -au BufNewFile * silent! 0r /home/tdmanv/.vim/templates/%:e.tpl - -au BufNewFile,BufRead *.r set filetype=r -au BufNewFile,BufRead *.R set filetype=r -au BufNewFile,BufRead *.tex set filetype=tex - -au! BufNewFile,BufRead *.csv setf csv - - -"""""""""""""""""""""""""""""" -" => Golang Section -"""""""""""""""""""""""""""""" - -au FileType go map gp :GoImports -au FileType go map gi :GoImplements -au FileType go map gb :GoDescribe -au FileType go map gd :tabedit %gT:GoDef -"au FileType go map gf :GoDeclsDir - -"let g:go_def_mode = 'godef' -let g:go_def_mode='gopls' -let g:go_info_mode='gopls' - -"La Tex -"IMPORTANT: grep will sometimes skip displaying the file name if you -" search in a singe file. This will confuse Latex-Suite. Set your grep -" program to always generate a file-name. - -set grepprg=grep\ -nH\ $* - - -"set errorformat=%*[^"]"%f"%*\D%l: %m,"%f"%*\D%l: %m,%-G%f:%l: (Each undeclared identifier is reported only once,%-G%f:%l: for each function it appears in.),%-GIn file included from %f:%l:%c,%-GIn file included from %f:%l,%-Gfrom %f:%l:%c,%-Gfrom %f:%l,%f:%l:%c:%m,%f(%l):%m,%f:%l:%m,"%f"\, line %l%*\D%c%*[^ ] %m,%D%*\a[%*\d]: Entering directory `%f',%X%*\a[%*\d]: Leaving directory `%f',%D%*\a: Entering directory `%f',%X%*\a: Leaving directory `%f',%DMaking %*\a in %f,%f|%l| %m -"set errorformat=%*[^"]"%f"%*\D%l: %m,"%f"%*\D%l: %m,%-G%f:%l: (Each undeclared identifier is reported only once,%-G%f:%l: for each function it appears in.),%-Gfrom %f:%l:%c,%-Gfrom %f:%l,%f:%l:%c:%m,%f(%l):%m,%f:%l:%m,"%f"\, line %l%*\D%c%*[^ ] %m,%D%*\a[%*\d]: Entering directory `%f',%X%*\a[%*\d]: Leaving directory `%f',%D%*\a: Entering directory `%f',%X%*\a: Leaving directory `%f',%DMaking %*\a in %f,%f|%l| %m - -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""r -" => html -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -au BufNewFile,BufRead *.vue set filetype=javascript - -au FileType html set tabstop=2 -au FileType html set shiftwidth=2 -au FileType javascript set tabstop=2 -au FileType javascript set shiftwidth=2 - -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""r -" => html -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -au FileType html set tabstop=2 -au FileType html set shiftwidth=2 -au FileType javascript set tabstop=2 -au FileType javascript set shiftwidth=2 - -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""r -" => ruby -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -au BufNewFile,BufRead *.pp set syntax=ruby -au FileType ruby set expandtab -au FileType ruby set shiftwidth=2 -au FileType ruby set tabstop=2 - -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""r -" => java -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -au FileType java set expandtab -au FileType java set shiftwidth=4 -au FileType java set tabstop=4 -au FileType java set foldmethod=syntax - -"let g:EclimCompletionMethod = 'omnifunc' - -noremap :!bash -c -i mvn_check \| tee /tmp/mvn_check.txt :cf /tmp/mvn_check.txt -noremap :tabnew:!mvn compile \| tee /tmp/mvn_compile.txt :cf /tmp/mvn_compile.txt - -set errorformat=[ERROR]\ %f:[%l\\,%v]\ %m -set errorformat+=[WARNING]\ %f:[%l\\,%v]\ %m -set errorformat+=%f:%l:%v:\ %m -set errorformat+=%f:%l:\ %m - -autocmd BufRead *.java set include=^#\s*import -autocmd BufRead *.java set includeexpr=substitute(v:fname,'\\.','/','g') - -autocmd FileType java set tags=~/.java-ctags - -set complete=.,w,k -set dictionary=~/.vimKeywords - -"let g:vjde_completion_key='' -let g:vjde_ctags_exts='java' -let g:SuperTabDefaultCompletionType = "" - -set number - -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""r -" => vimgdb -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" - -syntax enable " enable syntax highlighting -set previewheight=12 " set gdb window initial height -run macros/gdb_mappings.vim " source key mappings listed in this document -"set asm=0 " don't show any assembly stuff -"set gdbprg=/usr/bin/gdb - - -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -" => vundle -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -set nocompatible -filetype off - -set rtp+=~/.vim/bundle/vundle/ -call vundle#rc() - -" let Vundle manage Vundle -" required! - -"git clone https://github.com/gmarik/vundle.git ~/.vim/bundle/vundle -"Bundle 'gmarik/vundle' -Bundle 'vim-airline/vim-airline' -Bundle 'vim-airline/vim-airline-themes' -Bundle 'scrooloose/nerdtree' -Bundle 'majutsushi/tagbar' -Bundle 'kien/ctrlp.vim' -Bundle 'rking/ag.vim' -Bundle 'aperezdc/vim-template' -Bundle 'tpope/vim-surround' -Bundle 'vim-scripts/TaskList.vim' -Bundle 'godlygeek/tabular' -"Bundle 'vim-scripts/Vim-JDE' -Bundle 'tpope/vim-fugitive' -Bundle 'vim-scripts/git-time-lapse' -Bundle 'vim-scripts/autoload_cscope.vim' -"Bundle 'SirVer/ultisnips' -Bundle 'ycm-core/YouCompleteMe' -Bundle 'salsifis/vim-transpose' -Bundle 'fatih/vim-go' -Bundle 'mattn/emmet-vim' -Bundle 'davidhalter/jedi-vim' - - -filetype plugin indent on - -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -" => Tabular shortcuts -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -vmap = Tabularize /^[^=]*/l0 -vmap ] Tabularize /^[^\[]*/l0 - -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -" => Powerline setup -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" - -" https://bhilburn.org/moving-to-vim-airline-from-vim-powerline/ -set encoding=utf-8 -set t_Co=256 -let g:airline_powerline_fonts = 1 -if !exists('g:airline_symbols') - let g:airline_symbols = {} -endif -let g:airline_symbols.space = "\ua0" -let g:airline#extensions#tabline#enabled = 1 -let g:airline#extensions#tabline#show_buffers = 0 -let g:airline_theme = 'molokai' -let g:airline_theme='powerlineish' -let g:airline_theme = 'badwolf' - -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -" => NerdTree / Taglist -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -map :NERDTreeToggle -map :TagbarToggle - -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -" => cscope -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -function! LoadCscope() - let db = findfile("cscope.out", ".;") - if (!empty(db)) - let path = strpart(db, 0, match(db, "/cscope.out$")) - set nocscopeverbose " suppress 'duplicate connection' error - exe "cs add " . db . " " . path - set cscopeverbose - endif -endfunction -au BufEnter /* call LoadCscope() - -set cscopequickfix=g-,s-,c-,d-,i-,t-,e- -nmap cc lb"tye:cs f c t -nmap cg lb"tye:cs f g t -nmap cd lb"tye:cs f d t -nmap ct lb"tye:cs f t t -nmap a lb"tye:Ag t - -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -" => git-time-lapse -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -map gt :call TimeLapse() - -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -" => Markdown -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -au BufNewFile,BufRead *.md set syntax=markdown -autocmd BufWrite *.md :call DeleteTrailingWS() - -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -" => Quick Commands -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -map r :r!"date +'%M'" -map tw :set tw=80 -map n :tabnew -map f :echo expand('%:p') -