├── dev.retry ├── .gitignore_global ├── templates ├── gitignore_global ├── vimrc.before ├── bash_profile ├── eslintrc ├── ackrc ├── inputrc ├── gitconfig ├── ghostty-config ├── config.fish ├── lua.config ├── bashrc ├── vimrc.after ├── zshrc └── init.vim ├── tasks ├── python_utilities.yml ├── utilities.yml ├── vim.yml ├── redhat.yml ├── git_extras.yml ├── nodejs_utilities.yml ├── dotfiles.yml ├── debian.yml └── macosx.yml ├── Makefile ├── Dockerfile ├── README.md └── dev.yml /dev.retry: -------------------------------------------------------------------------------- 1 | localhost 2 | -------------------------------------------------------------------------------- /.gitignore_global: -------------------------------------------------------------------------------- 1 | *.un~ 2 | -------------------------------------------------------------------------------- /templates/gitignore_global: -------------------------------------------------------------------------------- 1 | *.un~ 2 | -------------------------------------------------------------------------------- /tasks/python_utilities.yml: -------------------------------------------------------------------------------- 1 | - name: Install HTTPie 2 | pip: name=httpie 3 | -------------------------------------------------------------------------------- /templates/vimrc.before: -------------------------------------------------------------------------------- 1 | " Map the key to , 2 | let mapleader = "," 3 | -------------------------------------------------------------------------------- /templates/bash_profile: -------------------------------------------------------------------------------- 1 | # include .bashrc if it exists 2 | if [ -f ~/.bashrc ]; then 3 | . ~/.bashrc 4 | fi 5 | -------------------------------------------------------------------------------- /templates/eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "eslint-config-airbnb", 3 | "rules": { 4 | "semi": [2, "never"] 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /tasks/utilities.yml: -------------------------------------------------------------------------------- 1 | - name: install z, a quick jump utility 2 | git: repo=https://github.com/rupa/z.git dest=/opt/z 3 | become: yes 4 | tags: 5 | - z 6 | - install 7 | 8 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | 2 | check: 3 | ansible-playbook -i ~/ansible_hosts dev.yml --check --diff 4 | 5 | install: 6 | ansible-playbook -i ~/ansible_hosts dev.yml 7 | 8 | facts: 9 | ansible all -i ~/ansible_hosts -m setup 10 | -------------------------------------------------------------------------------- /tasks/vim.yml: -------------------------------------------------------------------------------- 1 | - name: Install vim-plug 2 | shell: sh -c 'curl -fLo "${XDG_DATA_HOME:-$HOME/.local/share}"/nvim/site/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim' 3 | 4 | -------------------------------------------------------------------------------- /templates/ackrc: -------------------------------------------------------------------------------- 1 | --type-add=js=.js,.json 2 | --type-add=css=.sass,.less,.scss 3 | --type-set=coffeescript=.coffee 4 | --type-set=eco-template=.eco 5 | --type-set=markdown=.markdown,.mdown,.md,.mkd,.mkdn 6 | --type-add=html=.html 7 | --type-add=drupal=.module,.info,.inc 8 | -------------------------------------------------------------------------------- /templates/inputrc: -------------------------------------------------------------------------------- 1 | set completion-ignore-case On 2 | set bell-style none 3 | set editing-mode vi 4 | 5 | $if mode=vi 6 | set keymap vi-command 7 | "gg": beginning-of-history 8 | "G": end-of-history 9 | set keymap vi-insert 10 | "jj": vi-movement-mode 11 | "\C-p": history-search-backward 12 | -------------------------------------------------------------------------------- /tasks/redhat.yml: -------------------------------------------------------------------------------- 1 | - name: install common utilities on Fedora machines 2 | yum: name={{ item }} state=present 3 | tags: install 4 | with_items: 5 | - xz-devel 6 | - tmux 7 | - ctags 8 | - mosh 9 | - vim-enhanced 10 | - smem 11 | 12 | # - include: the_silver_searcher_from_source.yml 13 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu 2 | MAINTAINER Kyle Mathews "mathews.kyle@gmail.com" 3 | 4 | RUN apt-get update; apt-get install -y software-properties-common; apt-add-repository --yes --update ppa:ansible/ansible; 5 | RUN apt-get install ansible -y 6 | ADD . /opt/config 7 | WORKDIR /opt/config 8 | RUN echo "localhost ansible_connection=local" >> ~/.ansible_hosts 9 | RUN ansible-playbook dev.yml -i ~/.ansible_hosts -v 10 | -------------------------------------------------------------------------------- /tasks/git_extras.yml: -------------------------------------------------------------------------------- 1 | - name: See if Git Extras is installed and updated 2 | shell: '[ "$(git extras -v)" = 1.9.0 ] && echo "Found" || echo ""' 3 | register: git_extras_installed 4 | - name: Clone the Git Extras repo 5 | git: repo=https://github.com/visionmedia/git-extras.git dest=/tmp/git-extras 6 | when: (not git_extras_installed.stdout) 7 | - name: Build Git Extras 8 | command: make install chdir=/tmp/git-extras 9 | when: (not git_extras_installed.stdout) 10 | -------------------------------------------------------------------------------- /tasks/nodejs_utilities.yml: -------------------------------------------------------------------------------- 1 | - name: Ensures ./npm-global directory exists 2 | file: path=~/.npm-global state=directory 3 | 4 | - name: Configure NPM to install globals in home directory 5 | shell: npm config set prefix '~/.npm-global' 6 | 7 | - name: Install Node.js utilities 8 | npm: name={{ item }} global=yes 9 | become: yes 10 | with_items: 11 | - gatsby-cli 12 | - gatsby-dev-cli 13 | - jsonlint 14 | - js-yaml 15 | - eslint 16 | - eslint-plugin-flowtype 17 | - eslint-config-prettier 18 | - eslint-config-google 19 | - eslint-plugin-react 20 | - prettier 21 | - babel-eslint 22 | - eslint-plugin-react 23 | - yarn 24 | - typescript-language-server 25 | - eslint_d 26 | - n 27 | # - prisma 28 | - lerna 29 | -------------------------------------------------------------------------------- /templates/gitconfig: -------------------------------------------------------------------------------- 1 | [user] 2 | name = Kyle Mathews 3 | email = mathews.kyle@gmail.com 4 | [color] 5 | diff = auto 6 | status = auto 7 | branch = auto 8 | [push] 9 | default = tracking 10 | [alias] 11 | ai = add --interactive 12 | unstage = reset HEAD 13 | 14 | # Committing 15 | c = commit -v 16 | cm = commit -m 17 | ca = commit --amend 18 | caa = commit -a --amend -C HEAD 19 | 20 | # Shortcuts for commands 21 | s = status 22 | a = add 23 | co = checkout 24 | b = branch 25 | l = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative 26 | lc = log ORIG_HEAD.. --stat --no-merges 27 | f = fetch 28 | p = push 29 | d = diff 30 | dc = diff --cached 31 | da = diff HEAD 32 | da2 = diff HEAD^ 33 | wtf = !git-wtf 34 | [core] 35 | excludesfile = ~/.gitignore_global 36 | editor = nvim 37 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Install my dotfiles and common utilities on the different machines I work on. 2 | 3 | Uses Ansible to make it all easy. 4 | 5 | To run it do something like `ansible-playbook dev.yml -i ~/.ansible_hosts -Kv` 6 | 7 | The `-K` is necessary for localhost. Otherwise don't use that flag. 8 | 9 | A sample .ansible_hosts file might look like this: 10 | 11 | ```` 12 | localhost ansible_connection=local 13 | 14 | [vps] 15 | 104.131.132.128 ansible_ssh_user=root 16 | ```` 17 | 18 | ## Macs 19 | Install Homebrew manually and then run `brew install ansible` to get 20 | Ansible working. Then clone this repo, create a ~/.ansible_hosts file, and run the above command. 21 | 22 | ### Manual post-install steps which perhaps could be automated but which aren't atm 23 | 24 | * Import iterm2 solarized theme from the downloads folder 25 | * Set iterm2 font to inconsolata 13pt 26 | * Copy ssh keys 27 | * run `brew cask alfred link` 28 | * Set iterm2 scrollback to unlimited 29 | * Up ULIMIT 30 | 31 | ## Docker image 32 | These dotfiles + config + Ubuntu are now a Docker image! 33 | 34 | To run it with your ssh port forwarding: 35 | 36 | `docker run -rm -t -i -v $(dirname $SSH_AUTH_SOCK):$(dirname 37 | $SSH_AUTH_SOCK) -e SSH_AUTH_SOCK=$SSH_AUTH_SOCK kyma/dev-image bash` 38 | -------------------------------------------------------------------------------- /tasks/dotfiles.yml: -------------------------------------------------------------------------------- 1 | - name: install .bash_profile 2 | action: template src=templates/bash_profile dest=~/.bash_profile 3 | tags: dotfile 4 | 5 | - name: install .bashrc 6 | action: template src=templates/bashrc dest=~/.bashrc 7 | tags: dotfile 8 | 9 | - name: install .zshrc 10 | action: template src=templates/zshrc dest=~/.zshrc 11 | tags: dotfile 12 | 13 | - name: install .gitconfig 14 | action: template src=templates/gitconfig dest=~/.gitconfig 15 | tags: dotfile 16 | 17 | 18 | - name: Ensures nvim config directory exists 19 | file: path=~/.config/nvim/lua state=directory 20 | 21 | - name: install nvim init.vim 22 | action: template src=templates/init.vim dest=~/.config/nvim/init.vim 23 | tags: dotfile 24 | 25 | - name: install nvim lua config 26 | action: template src=templates/lua.config dest=~/.config/nvim/lua/lua.config 27 | tags: dotfile 28 | 29 | - name: install .gitignore_global 30 | action: template src=templates/gitignore_global dest=~/.gitignore_global 31 | tags: dotfile 32 | 33 | - name: install git auto-complete library 34 | get_url: url=https://raw.github.com/git/git/master/contrib/completion/git-prompt.sh dest=~/.git-prompt.sh 35 | 36 | - name: install .inputrc 37 | action: template src=templates/inputrc dest=~/.inputrc 38 | tags: dotfile 39 | -------------------------------------------------------------------------------- /dev.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # This playbook deploys the dotfiles and utilities that I like to have around while 3 | # developing. 4 | - name: copy all dotfiles to the home directory and install commonly used utilities 5 | # Have to run localhost seperate from other servers as need to ask for password 6 | # locally but not remote and ansible can't handle this use case yet. 7 | hosts: localhost 8 | #hosts: all:!localhost 9 | 10 | tasks: 11 | - name: create group by operating system 12 | action: group_by key={{ansible_os_family}} 13 | tags: testing 14 | 15 | - hosts: Darwin 16 | tasks: 17 | - include: tasks/macosx.yml 18 | - include: tasks/dotfiles.yml 19 | - include: tasks/nodejs_utilities.yml 20 | - include: tasks/vim.yml 21 | - include: tasks/utilities.yml 22 | - include: tasks/python_utilities.yml 23 | 24 | - hosts: Debian 25 | tasks: 26 | - include: tasks/dotfiles.yml 27 | - include: tasks/vim.yml 28 | - include: tasks/debian.yml 29 | - include: tasks/nodejs_utilities.yml 30 | - include: tasks/utilities.yml 31 | - include: tasks/python_utilities.yml 32 | 33 | - hosts: RedHat 34 | tasks: 35 | - include: tasks/redhat.yml 36 | - include: tasks/dotfiles.yml 37 | - include: tasks/nodejs_utilities.yml 38 | - include: tasks/vim.yml 39 | - include: tasks/utilities.yml 40 | - include: tasks/python_utilities.yml 41 | -------------------------------------------------------------------------------- /templates/ghostty-config: -------------------------------------------------------------------------------- 1 | window-theme = "dark" 2 | macos-option-as-alt = true 3 | mouse-hide-while-typing = true 4 | cursor-style = block 5 | cursor-style-blink = true 6 | 7 | clipboard-read = "allow" 8 | clipboard-paste-protection = false 9 | clipboard-trim-trailing-spaces = true 10 | 11 | font-family = "Inconsolata" 12 | font-size = 15 13 | font-style = "Medium" 14 | font-family-bold = "Inconsolata" 15 | font-style-bold = "Bold" 16 | font-family-italic = "Inconsolata" 17 | font-style-italic = "Italic" 18 | font-family-bold-italic = "Inconsolata" 19 | font-style-bold-italic = "Bold Italic" 20 | font-feature = zero 21 | font-feature = ss01 22 | font-feature = ss02 23 | font-feature = ss03 24 | font-feature = ss04 25 | font-feature = ss05 26 | font-feature = ss06 27 | font-feature = calt 28 | font-feature = liga 29 | 30 | background-opacity = 0.95 31 | 32 | # https://github.com/mbadolato/iTerm2-Color-Schemes/blob/master/ghostty/catppuccin-mocha 33 | palette = 0=#45475a 34 | palette = 1=#f38ba8 35 | palette = 2=#a6e3a1 36 | palette = 3=#f9e2af 37 | palette = 4=#89b4fa 38 | palette = 5=#f5c2e7 39 | palette = 6=#94e2d5 40 | palette = 7=#bac2de 41 | palette = 8=#585b70 42 | palette = 9=#f38ba8 43 | palette = 10=#a6e3a1 44 | palette = 11=#f9e2af 45 | palette = 12=#89b4fa 46 | palette = 13=#f5c2e7 47 | palette = 14=#94e2d5 48 | palette = 15=#a6adc8 49 | background = 1e1e2e 50 | foreground = cdd6f4 51 | cursor-color = f5e0dc 52 | selection-background = 585b70 53 | selection-foreground = cdd6f4 54 | -------------------------------------------------------------------------------- /templates/config.fish: -------------------------------------------------------------------------------- 1 | set normal (set_color normal) 2 | set magenta (set_color magenta) 3 | set yellow (set_color yellow) 4 | set green (set_color green) 5 | set red (set_color red) 6 | set gray (set_color -o black) 7 | 8 | # Fish git prompt 9 | set __fish_git_prompt_showdirtystate 'yes' 10 | set __fish_git_prompt_showstashstate 'yes' 11 | set __fish_git_prompt_showuntrackedfiles 'yes' 12 | set __fish_git_prompt_showupstream 'yes' 13 | set __fish_git_prompt_color_branch yellow 14 | set __fish_git_prompt_color_upstream_ahead green 15 | set __fish_git_prompt_color_upstream_behind red 16 | 17 | # Status Chars 18 | set __fish_git_prompt_char_dirtystate '⚡' 19 | set __fish_git_prompt_char_stagedstate '→' 20 | set __fish_git_prompt_char_untrackedfiles '☡' 21 | set __fish_git_prompt_char_stashstate '↩' 22 | set __fish_git_prompt_char_upstream_ahead '+' 23 | set __fish_git_prompt_char_upstream_behind '-' 24 | 25 | 26 | function fish_prompt 27 | set last_status $status 28 | 29 | set_color $fish_color_cwd 30 | printf '%s' (prompt_pwd) 31 | set_color normal 32 | 33 | printf '%s ' (__fish_git_prompt) 34 | 35 | set_color normal 36 | end 37 | 38 | # Load binaries from /usr/local/bin first (e.g. homebrew packages) 39 | set PATH /usr/local/bin /usr/sbin $PATH 40 | 41 | # Load Go binaries 42 | set PATH=$PATH /usr/local/opt/go/libexec/bin 43 | 44 | # Aliases 45 | alias vi 'nvim' 46 | alias vim 'nvim' 47 | alias gats-dev 'node ~/programs/gatsby/packages/gatsby-dev-cli/src/index.js' 48 | 49 | # Github auth 50 | set -x GITHUB_AUTH 5ad35e3771281bfedf5f36b8e86c502ab59d9975 51 | 52 | # Set git editor to vim 53 | set -x GIT_EDITOR nvim 54 | 55 | # NPM auth 56 | set -x NPM_TOKEN a303078c-d139-4d81-8cab-3e13cae5da8b 57 | 58 | # tabtab source for serverless package 59 | # uninstall by removing these lines or running `tabtab uninstall serverless` 60 | [ -f /usr/local/lib/node_modules/serverless/node_modules/tabtab/.completions/serverless.fish ]; and . /usr/local/lib/node_modules/serverless/node_modules/tabtab/.completions/serverless.fish 61 | # tabtab source for sls package 62 | # uninstall by removing these lines or running `tabtab uninstall sls` 63 | [ -f /usr/local/lib/node_modules/serverless/node_modules/tabtab/.completions/sls.fish ]; and . /usr/local/lib/node_modules/serverless/node_modules/tabtab/.completions/sls.fish 64 | -------------------------------------------------------------------------------- /tasks/debian.yml: -------------------------------------------------------------------------------- 1 | # - name: Install Docker GPG key 2 | # shell: "curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --batch --yes --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg" 3 | # become: yes 4 | 5 | # - name: Install docker engine repo 6 | # shell: 'echo \ 7 | # "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu 8 | # $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null' 9 | 10 | - name: Update apt-get repo and cache 11 | apt: update_cache=yes force_apt_get=yes cache_valid_time=3600 12 | become: yes 13 | 14 | - name: Upgrade all apt packages 15 | apt: upgrade=dist force_apt_get=yes 16 | become: yes 17 | 18 | - name: install common utilities on Debian machines 19 | apt: pkg={{ item }} state=present 20 | tags: install 21 | become: yes 22 | with_items: 23 | - curl 24 | - git 25 | - build-essential 26 | - tmux 27 | - smem # Tool that does good job of figuring out "real" memory use of processes 28 | - automake 29 | - silversearcher-ag 30 | - fzf 31 | - fd-find 32 | - ripgrep 33 | - kitty 34 | - luajit 35 | - python 36 | - python3-pip 37 | - golang-go 38 | # For building nvim 39 | - ninja-build 40 | - gettext 41 | - libtool 42 | - libtool-bin 43 | - autoconf 44 | - automake 45 | - cmake 46 | - g++ 47 | - pkg-config 48 | - unzip 49 | - curl 50 | - doxygen 51 | # - docker-ce 52 | # - docker-ce-cli 53 | # - containerd.io 54 | - libpng-dev # required for some node packages to compile 55 | - zsh 56 | - ufw 57 | - glances # nice top-like tool 58 | - tmux 59 | 60 | - name: Ensures ./local/bin directory exists 61 | file: path=~/.local/bin state=directory 62 | 63 | - name: link fdfind binary to fd 64 | shell: "ln -sf $(which fdfind) ~/.local/bin/fd" 65 | 66 | # - name: Add user to docker group 67 | # become: yes 68 | # shell: "groupadd docker && gpasswd -a ${USER} docker && service docker restart && newgrp docker" 69 | # # This errors on subsquent runs 70 | # ignore_errors: yes 71 | 72 | # This requires a password so do it manually until want to figure out ansible's way 73 | # - name: Set zsh as the default shell 74 | # shell: 'chsh -s $(which zsh)' 75 | 76 | - name: Install ohmyzsh 77 | shell: 'sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"' 78 | ignore_errors: yes 79 | 80 | ## 81 | # node.js installation (latest stable instead of Ubuntu's out-of-date one) 82 | # 83 | - name: Node.js | Run the debian setup. 84 | shell: "curl -fsSL https://deb.nodesource.com/setup_14.x | bash" 85 | tags: nodejs 86 | become: yes 87 | 88 | - name: Node.js | Install nodejs and npm 89 | apt: pkg={{ item }} state=present 90 | tags: nodejs 91 | become: yes 92 | with_items: 93 | - nodejs 94 | 95 | - name: install neovim 96 | shell: 97 | cmd: "add-apt-repository ppa:neovim-ppa/unstable -y; apt-get update; apt-get install neovim" 98 | ignore_errors: yes 99 | 100 | # Ubuntu is on an old version of go that doesn't have `go install` yet 101 | - name: install efm language server (for neovim) 102 | shell: "go get github.com/mattn/efm-langserver" 103 | 104 | # docker-compose 105 | # - name: Install docker-compose 106 | # shell: "curl -L https://github.com/docker/compose/releases/download/v2.1.0/docker-compose-$(uname -s)-$(uname -m) -o /usr/local/bin/docker-compose && chmod +x /usr/local/bin/docker-compose" 107 | # become: yes 108 | 109 | - name: Add firewall blocking all ports except 22 110 | shell: "ufw allow 22 && ufw enable --force enable" 111 | become: yes 112 | ignore_errors: yes 113 | -------------------------------------------------------------------------------- /templates/lua.config: -------------------------------------------------------------------------------- 1 | local nvim_lsp = require("lspconfig") 2 | local format_async = function(err, _, result, _, bufnr) 3 | if err ~= nil or result == nil then return end 4 | if not vim.api.nvim_buf_get_option(bufnr, "modified") then 5 | local view = vim.fn.winsaveview() 6 | vim.lsp.util.apply_text_edits(result, bufnr) 7 | vim.fn.winrestview(view) 8 | if bufnr == vim.api.nvim_get_current_buf() then 9 | vim.api.nvim_command("noautocmd :update") 10 | end 11 | end 12 | end 13 | vim.lsp.handlers["textDocument/formatting"] = format_async 14 | _G.lsp_organize_imports = function() 15 | local params = { 16 | command = "_typescript.organizeImports", 17 | arguments = {vim.api.nvim_buf_get_name(0)}, 18 | title = "" 19 | } 20 | vim.lsp.buf.execute_command(params) 21 | end 22 | local on_attach = function(client, bufnr) 23 | local buf_map = vim.api.nvim_buf_set_keymap 24 | vim.cmd("command! LspDef lua vim.lsp.buf.definition()") 25 | vim.cmd("command! LspFormatting lua vim.lsp.buf.formatting()") 26 | vim.cmd("command! LspCodeAction lua vim.lsp.buf.code_action()") 27 | vim.cmd("command! LspHover lua vim.lsp.buf.hover()") 28 | vim.cmd("command! LspRename lua vim.lsp.buf.rename()") 29 | vim.cmd("command! LspOrganize lua lsp_organize_imports()") 30 | vim.cmd("command! LspRefs lua vim.lsp.buf.references()") 31 | vim.cmd("command! LspTypeDef lua vim.lsp.buf.type_definition()") 32 | vim.cmd("command! LspImplementation lua vim.lsp.buf.implementation()") 33 | vim.cmd("command! LspDiagPrev lua vim.lsp.diagnostic.goto_prev()") 34 | vim.cmd("command! LspDiagNext lua vim.lsp.diagnostic.goto_next()") 35 | vim.cmd( 36 | "command! LspDiagLine lua vim.lsp.diagnostic.show_line_diagnostics()") 37 | vim.cmd("command! LspSignatureHelp lua vim.lsp.buf.signature_help()") 38 | buf_map(bufnr, "n", "gd", ":LspDef", {silent = true}) 39 | buf_map(bufnr, "n", "gr", ":LspRename", {silent = true}) 40 | buf_map(bufnr, "n", "gR", ":LspRefs", {silent = true}) 41 | buf_map(bufnr, "n", "gy", ":LspTypeDef", {silent = true}) 42 | buf_map(bufnr, "n", "K", ":LspHover", {silent = true}) 43 | buf_map(bufnr, "n", "gs", ":LspOrganize", {silent = true}) 44 | buf_map(bufnr, "n", "[a", ":LspDiagPrev", {silent = true}) 45 | buf_map(bufnr, "n", "]a", ":LspDiagNext", {silent = true}) 46 | buf_map(bufnr, "n", "ga", ":LspCodeAction", {silent = true}) 47 | buf_map(bufnr, "n", "a", ":LspDiagLine", {silent = true}) 48 | buf_map(bufnr, "i", "", " LspSignatureHelp", 49 | {silent = true}) 50 | if client.resolved_capabilities.document_formatting then 51 | vim.api.nvim_exec([[ 52 | augroup LspAutocommands 53 | autocmd! * 54 | autocmd BufWritePost LspFormatting 55 | augroup END 56 | ]], true) 57 | end 58 | end 59 | nvim_lsp.tsserver.setup { 60 | on_attach = function(client) 61 | client.resolved_capabilities.document_formatting = false 62 | on_attach(client) 63 | end 64 | } 65 | local filetypes = { 66 | typescript = "eslint", 67 | typescriptreact = "eslint", 68 | } 69 | local linters = { 70 | eslint = { 71 | sourceName = "eslint", 72 | command = "eslint_d", 73 | rootPatterns = {".eslintrc.js", "package.json"}, 74 | debounce = 100, 75 | args = {"--stdin", "--stdin-filename", "%filepath", "--format", "json"}, 76 | parseJson = { 77 | errorsRoot = "[0].messages", 78 | line = "line", 79 | column = "column", 80 | endLine = "endLine", 81 | endColumn = "endColumn", 82 | message = "${message} [${ruleId}]", 83 | security = "severity" 84 | }, 85 | securities = {[2] = "error", [1] = "warning"} 86 | } 87 | } 88 | local formatters = { 89 | prettier = {command = "prettier", args = {"--stdin-filepath", "%filepath"}} 90 | } 91 | local formatFiletypes = { 92 | typescript = "prettier", 93 | typescriptreact = "prettier" 94 | } 95 | nvim_lsp.diagnosticls.setup { 96 | on_attach = on_attach, 97 | filetypes = vim.tbl_keys(filetypes), 98 | init_options = { 99 | filetypes = filetypes, 100 | linters = linters, 101 | formatters = formatters, 102 | formatFiletypes = formatFiletypes 103 | } 104 | } 105 | 106 | -------------------------------------------------------------------------------- /tasks/macosx.yml: -------------------------------------------------------------------------------- 1 | # - homebrew_tap: 2 | # name: Homebrew/homebrew-cask-versions 3 | 4 | - homebrew_tap: 5 | name: Homebrew/homebrew-cask-fonts 6 | 7 | # - name: Install xQuartz, necessary dependency for several homebrew recipes 8 | # homebrew_cask: name=xquartz state=present 9 | 10 | - name: Update Homebrew and Upgrade all homebrew packages 11 | homebrew: update_homebrew=yes upgrade_all=yes 12 | 13 | - name: install neovim 14 | homebrew: name=neovim state=head 15 | tags: install macosx 16 | ignore_errors: true 17 | 18 | - name: install common utilities on Mac OSX with homebrew 19 | homebrew: name={{ item }} state=present 20 | tags: install macosx 21 | ignore_errors: true 22 | with_items: 23 | # - ctags 24 | - the_silver_searcher 25 | - tmux 26 | - wget 27 | - git 28 | - go 29 | - ssh-copy-id 30 | # - htop-osx 31 | # - nmap 32 | - watch 33 | - node 34 | # - neovim 35 | - coreutils 36 | # - ccat 37 | - fzf 38 | # - tig 39 | # - fish 40 | # - mas # Install from Mac Store 41 | # - hub 42 | - z 43 | - fd 44 | - fzf 45 | - ripgrep 46 | - docker-compose 47 | - efm-langserver # for neovim 48 | - gh # github cli 49 | - git-extras 50 | 51 | 52 | - name: Install ohmyzsh 53 | shell: 'sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"' 54 | ignore_errors: yes 55 | 56 | - name: Install binaries with Homebrew cask 57 | homebrew_cask: name={{ item }} state=present 58 | tags: install macosx 59 | ignore_errors: true 60 | with_items: 61 | # - alfred # Better launcher 62 | - adobe-acrobat-reader 63 | # - android-file-transfer 64 | - discord 65 | # - dropbox 66 | # - evernote 67 | - firefox 68 | - font-fira-code 69 | #- flash 70 | #- flux 71 | - gimp 72 | - google-chrome 73 | - google-chrome-canary 74 | #- google-hangouts 75 | - handbrake 76 | #- hipchat 77 | #- heroku-toolbelt 78 | - inkscape 79 | - iterm2 80 | - keepassxc 81 | - kindle 82 | #- lighttable 83 | #- limechat 84 | #- lyx 85 | - meld 86 | - ngrok 87 | - scapple 88 | #- silverlight 89 | # - slack 90 | # - spotify 91 | # - sublime-text 92 | # - rstudio # R IDE 93 | #- vagrant 94 | - vlc 95 | - wireshark 96 | #- qlcolorcode # This and the following are quicklook plugins 97 | #- qlstephen 98 | #- qlmarkdown 99 | #- quicklook-json 100 | #- qlprettypatch 101 | #- quicklook-csv 102 | #- betterzipql 103 | #- webp-quicklook 104 | #- suspicious-package 105 | #- skitch 106 | #- skype 107 | # - zoom 108 | - kitty 109 | - docker 110 | 111 | #- name: Install mac store apps 112 | # command: mas install 668208984 # Giphy Capture 113 | 114 | - name: Enable quicklook plugins (which just got installed) 115 | command: qlmanage -r 116 | 117 | - name: Install the inconsolata font—a very nice monospace font. 118 | get_url: url=http://levien.com/type/myfonts/Inconsolata.otf dest=/Library/Fonts/Inconsolata.otf 119 | 120 | # System settings, many from https://github.com/mathiasbynens/dotfiles/blob/master/.osx 121 | - name: Speedup the default keyboard repeat rates 122 | command: defaults write -g InitialKeyRepeat -int 15 # normal minimum is 15 (225 ms) 123 | 124 | - command: defaults write -g KeyRepeat -int 2 # normal minimum is 2 (30 ms) 125 | 126 | - name: Disable the “Are you sure you want to open this application?” dialog 127 | command: defaults write com.apple.LaunchServices LSQuarantine -bool false 128 | 129 | - name: Automatically hide and show the Dock 130 | command: defaults write com.apple.dock autohide -bool true 131 | 132 | - name: Trackpad — enable tap to click for this user and for the login screen 133 | command: defaults write com.apple.driver.AppleBluetoothMultitouch.trackpad Clicking -bool true 134 | - command: defaults -currentHost write NSGlobalDomain com.apple.mouse.tapBehavior -int 1 135 | - command: defaults write NSGlobalDomain com.apple.mouse.tapBehavior -int 1 136 | 137 | - name: Download iterm2 color scheme for solarized 138 | get_url: url=https://github.com/altercation/solarized/raw/master/iterm2-colors-solarized/Solarized%20Dark.itermcolors dest=~/Downloads 139 | 140 | - name: Increase sound quality for Bluetooth headphones/headsets 141 | command: defaults write com.apple.BluetoothAudioAgent "Apple Bitpool Min (editable)" -int 40 142 | 143 | #- name: Install pip with easy_install 144 | #command: sudo easy_install pip 145 | #sudo: true 146 | -------------------------------------------------------------------------------- /templates/bashrc: -------------------------------------------------------------------------------- 1 | # ~/.bashrc: executed by bash(1) for non-login shells. 2 | # see /usr/share/doc/bash/examples/startup-files (in the package bash-doc) 3 | # for examples 4 | 5 | # If not running interactively, don't do anything 6 | [ -z "$PS1" ] && return 7 | 8 | # don't put duplicate lines in the history. See bash(1) for more options 9 | # ... or force ignoredups and ignorespace 10 | HISTCONTROL=ignoredups:ignorespace 11 | 12 | # append to the history file, don't overwrite it 13 | shopt -s histappend 14 | 15 | # for setting history length see HISTSIZE and HISTFILESIZE in bash(1) 16 | HISTSIZE=1000 17 | HISTFILESIZE=2000 18 | 19 | # check the window size after each command and, if necessary, 20 | # update the values of LINES and COLUMNS. 21 | shopt -s checkwinsize 22 | 23 | # make less more friendly for non-text input files, see lesspipe(1) 24 | [ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)" 25 | 26 | # set variable identifying the chroot you work in (used in the prompt below) 27 | if [ -z "$debian_chroot" ] && [ -r /etc/debian_chroot ]; then 28 | debian_chroot=$(cat /etc/debian_chroot) 29 | fi 30 | 31 | # set a fancy prompt (non-color, unless we know we "want" color) 32 | case "$TERM" in 33 | xterm-color) color_prompt=yes;; 34 | esac 35 | 36 | # uncomment for a colored prompt, if the terminal has the capability; turned 37 | # off by default to not distract the user: the focus in a terminal window 38 | # should be on the output of commands, not on the prompt 39 | #force_color_prompt=yes 40 | 41 | if [ -n "$force_color_prompt" ]; then 42 | if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then 43 | # We have color support; assume it's compliant with Ecma-48 44 | # (ISO/IEC-6429). (Lack of such support is extremely rare, and such 45 | # a case would tend to support setf rather than setaf.) 46 | color_prompt=yes 47 | else 48 | color_prompt= 49 | fi 50 | fi 51 | 52 | if [ "$color_prompt" = yes ]; then 53 | PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ ' 54 | else 55 | PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ ' 56 | fi 57 | unset color_prompt force_color_prompt 58 | 59 | # If this is an xterm set the title to user@host:dir 60 | case "$TERM" in 61 | xterm*|rxvt*) 62 | PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1" 63 | ;; 64 | *) 65 | ;; 66 | esac 67 | 68 | # enable color support of ls and also add handy aliases 69 | if [ -x /usr/bin/dircolors ]; then 70 | test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)" 71 | alias ls='ls --color=auto' 72 | #alias dir='dir --color=auto' 73 | #alias vdir='vdir --color=auto' 74 | 75 | alias grep='grep --color=auto' 76 | alias fgrep='fgrep --color=auto' 77 | alias egrep='egrep --color=auto' 78 | fi 79 | 80 | # some more ls aliases 81 | alias ll='ls -alF' 82 | alias la='ls -A' 83 | alias l='ls -CF' 84 | 85 | # Add an "alert" alias for long running commands. Use like so: 86 | # sleep 10; alert 87 | 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$//'\'')"' 88 | 89 | # Alias definitions. 90 | # You may want to put all your additions into a separate file like 91 | # ~/.bash_aliases, instead of adding them here directly. 92 | # See /usr/share/doc/bash-doc/examples in the bash-doc package. 93 | 94 | if [ -f ~/.bash_aliases ]; then 95 | . ~/.bash_aliases 96 | fi 97 | 98 | # enable git programmable completion features (you don't need to enable 99 | # this, if it's already enabled in /etc/bash.bashrc and /etc/profile 100 | # sources /etc/bash.bashrc). 101 | source ~/.git-prompt.sh 102 | 103 | # Alias g as git 104 | alias g='git' 105 | 106 | GIT_PS1_SHOWDIRTYSTATE=1 107 | GIT_PS1_SHOWSTASHSTATE=1 108 | GIT_PS1_SHOWUNTRACKEDFILES=1 109 | GIT_PS1_SHOWUPSTREAM="auto" 110 | 111 | PS1='\[\e[1;32m\]$(__git_ps1 " (%s)")\[\e[m\]' 112 | PS1="\[\e[1;36m\]\h:\W\[\e[m\]$PS1\[\e[1;36m\]$ \[\e[m\]" 113 | export PS1 114 | 115 | # Add Gem to the PATH 116 | export PATH=/var/lib/gems/1.8/bin:$PATH 117 | 118 | # Add Go to the PATH 119 | export GOPATH=$HOME/gocode 120 | export PATH=$PATH:$GOPATH/bin 121 | 122 | source /opt/z/z.sh 123 | 124 | [[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function* 125 | 126 | alias grp='grep -rInP' 127 | alias vim='nvim' 128 | 129 | export ANSIBLE_HOSTS=~/.ansible_hosts 130 | 131 | # Alias smem with common prefixes 132 | alias mem='smem -r -k' 133 | 134 | # Load binaries from /usr/local/bin first (e.g. homebrew packages) 135 | export PATH=/usr/local/bin:$PATH 136 | export PATH="$HOME/.local/bin:$PATH" 137 | 138 | # set PATH so it includes my private bin if it exists 139 | if [ -d "$HOME/bin" ]; then 140 | PATH="$HOME/bin:$PATH" 141 | fi 142 | 143 | # Set default editor 144 | export EDITOR=vim 145 | -------------------------------------------------------------------------------- /templates/vimrc.after: -------------------------------------------------------------------------------- 1 | set t_Co=16 2 | set background=dark 3 | colorscheme desert 4 | 5 | " Filetypes 6 | " Php, php3, php4, etc. 7 | au BufNewFile,BufRead *.{module,install} set filetype=php.drupal | runtime! ftplugin/php.vim | runtime! syntax/php.vim 8 | au BufRead,BufNewFile *.cjsx set filetype=coffee 9 | 10 | " Show a colored column at 85 characters. 11 | set colorcolumn=85 12 | 13 | " The normal backup pattern vim uses (move file to backup location then 14 | " rewrite latest version) breaks Brunch as it thinks the file has been 15 | " deleted. So copy to overwrite the backup file not move. 16 | set backupcopy=yes 17 | 18 | " Save file automatically when lose focus 19 | au FocusLost * :wa 20 | 21 | " Strip all trailing whitespace in the current file 22 | nnoremap W :%s/\s\+$//:let @/='' 23 | 24 | " Map jj to to make it easier to move to normal mode 25 | inoremap jj 26 | 27 | " Make it easier to work with split windows 28 | 29 | " Open a new vertical split and switch to it 30 | nnoremap w vl 31 | 32 | " Open a new horizontal split and switch to it 33 | nnoremap h sl 34 | 35 | " Hack to get C-h working in neovim 36 | if has('nvim') 37 | let $NVIM_TUI_ENABLE_CURSOR_SHAPE=1 38 | nmap h 39 | tnoremap 40 | endif 41 | 42 | " Map Ctrl plus normal navigation keys to move around splits 43 | nnoremap h 44 | nnoremap j 45 | nnoremap k 46 | nnoremap l 47 | nnoremap = 48 | 49 | " Mapping for using Ack 50 | nnoremap a :Ack 51 | 52 | " Get Ack to work 53 | let g:ackprg = 'ag --nogroup --nocolor --column' 54 | 55 | " Fold tag function 56 | nnoremap ft vatzf 57 | 58 | " Create an undo file for each file edited. 59 | set undofile 60 | 61 | " Clear out search 62 | nnoremap :noh 63 | 64 | " Make Tab work for switching between matching bracket pairs 65 | nnoremap % 66 | vnoremap % 67 | 68 | " Open up this file in a new vertical split window 69 | nnoremap vc :e ~/.vimrc.local 70 | 71 | " Make moving between tabs sane 72 | map tl :tabnext 73 | map th :tabprev 74 | map tn :tabnew 75 | map td :tabclose 76 | 77 | " Map ; to : 78 | nnoremap ; : 79 | 80 | " Remove 'flashing' in GVIM 81 | set novb 82 | 83 | " Bindings for Tagbar 84 | let g:tagbar_usearrows = 1 85 | nnoremap l :TagbarToggle 86 | 87 | " Bind leader-u to open a terminal window in a new split window. 88 | nnoremap u :ConqueTerm bash --login 89 | 90 | " Bind leader-r to reformat a paragraph when in writing mode. 91 | nnoremap r gqap 92 | 93 | " double percentage sign in command mode is expanded 94 | " to directory of current file - http://vimcasts.org/e/14 95 | cnoremap %% =expand('%:h').'/' 96 | 97 | " Binding for buffer search using buffer search by CtrlP 98 | :nmap :CtrlPBuffer 99 | 100 | " Set the font to Consolas on windows and Inconsolata every else. 101 | " Code from http://stackoverflow.com/questions/3316244/set-gvim-font-in-vimrc-file 102 | if has("gui_running") 103 | if has("gui_gtk2") 104 | set guifont=Inconsolata\ 12 105 | elseif has("gui_win32") 106 | set guifont=Consolas:h11:cANSI 107 | endif 108 | endif 109 | 110 | function! EscapeString (string) 111 | let string=a:string 112 | " Escape regex characters 113 | let string = escape(string, '^$.*\/~[]') 114 | " Escape the line endings 115 | let string = substitute(string, '\n', '\\n', 'g') 116 | return string 117 | endfunction 118 | 119 | " Get the current visual block for search and replaces 120 | " This function passed the visual block through a string escape function 121 | " Based on this - http://stackoverflow.com/questions/676600/vim-replace-selected-text/677918#677918 122 | function! GetVisual() range 123 | " Save the current register and clipboard 124 | let reg_save = getreg('"') 125 | let regtype_save = getregtype('"') 126 | let cb_save = &clipboard 127 | set clipboard& 128 | 129 | " Put the current visual selection in the " register 130 | normal! ""gvy 131 | let selection = getreg('"') 132 | 133 | " Put the saved registers and clipboards back 134 | call setreg('"', reg_save, regtype_save) 135 | let &clipboard = cb_save 136 | 137 | "Escape any special characters in the selection 138 | let escaped_selection = EscapeString(selection) 139 | 140 | return escaped_selection 141 | endfunction 142 | 143 | " Start the find and replace command across the entire file 144 | vmap z :%s/=GetVisual()/ 145 | 146 | " Ignore node_modules directories and others 147 | unlet g:ctrlp_custom_ignore 148 | let g:ctrlp_custom_ignore = 'node_modules\|DS_Store\|git' 149 | 150 | " Set folding for coffeescript files. 151 | au BufNewFile,BufReadPost *.coffee setl foldmethod=indent nofoldenable 152 | 153 | " Javascript React/ESLint setup 154 | let g:jsx_ext_required = 0 " Allow JSX in normal JS files 155 | let g:syntastic_javascript_checkers = ['eslint'] 156 | -------------------------------------------------------------------------------- /templates/zshrc: -------------------------------------------------------------------------------- 1 | # If you come from bash you might have to change your $PATH. 2 | # export PATH=$HOME/bin:/usr/local/bin:$PATH 3 | 4 | # Path to your oh-my-zsh installation. 5 | export ZSH="$HOME/.oh-my-zsh" 6 | 7 | # Set name of the theme to load --- if set to "random", it will 8 | # load a random theme each time oh-my-zsh is loaded, in which case, 9 | # to know which specific one was loaded, run: echo $RANDOM_THEME 10 | # See https://github.com/ohmyzsh/ohmyzsh/wiki/Themes 11 | ZSH_THEME="robbyrussell" 12 | 13 | # Set list of themes to pick from when loading at random 14 | # Setting this variable when ZSH_THEME=random will cause zsh to load 15 | # a theme from this variable instead of looking in $ZSH/themes/ 16 | # If set to an empty array, this variable will have no effect. 17 | # ZSH_THEME_RANDOM_CANDIDATES=( "robbyrussell" "agnoster" ) 18 | 19 | # Uncomment the following line to use case-sensitive completion. 20 | # CASE_SENSITIVE="true" 21 | 22 | # Uncomment the following line to use hyphen-insensitive completion. 23 | # Case-sensitive completion must be off. _ and - will be interchangeable. 24 | # HYPHEN_INSENSITIVE="true" 25 | 26 | # Uncomment one of the following lines to change the auto-update behavior 27 | # zstyle ':omz:update' mode disabled # disable automatic updates 28 | # zstyle ':omz:update' mode auto # update automatically without asking 29 | # zstyle ':omz:update' mode reminder # just remind me to update when it's time 30 | 31 | # Uncomment the following line to change how often to auto-update (in days). 32 | # zstyle ':omz:update' frequency 13 33 | 34 | # Uncomment the following line if pasting URLs and other text is messed up. 35 | # DISABLE_MAGIC_FUNCTIONS="true" 36 | 37 | # Uncomment the following line to disable colors in ls. 38 | # DISABLE_LS_COLORS="true" 39 | 40 | # Uncomment the following line to disable auto-setting terminal title. 41 | # DISABLE_AUTO_TITLE="true" 42 | 43 | # Uncomment the following line to enable command auto-correction. 44 | # ENABLE_CORRECTION="true" 45 | 46 | # Uncomment the following line to display red dots whilst waiting for completion. 47 | # You can also set it to another string to have that shown instead of the default red dots. 48 | # e.g. COMPLETION_WAITING_DOTS="%F{yellow}waiting...%f" 49 | # Caution: this setting can cause issues with multiline prompts in zsh < 5.7.1 (see #5765) 50 | # COMPLETION_WAITING_DOTS="true" 51 | 52 | # Uncomment the following line if you want to disable marking untracked files 53 | # under VCS as dirty. This makes repository status check for large repositories 54 | # much, much faster. 55 | # DISABLE_UNTRACKED_FILES_DIRTY="true" 56 | 57 | # Uncomment the following line if you want to change the command execution time 58 | # stamp shown in the history command output. 59 | # You can set one of the optional three formats: 60 | # "mm/dd/yyyy"|"dd.mm.yyyy"|"yyyy-mm-dd" 61 | # or set a custom format using the strftime function format specifications, 62 | # see 'man strftime' for details. 63 | # HIST_STAMPS="mm/dd/yyyy" 64 | 65 | # Would you like to use another custom folder than $ZSH/custom? 66 | # ZSH_CUSTOM=/path/to/new-custom-folder 67 | 68 | # Which plugins would you like to load? 69 | # Standard plugins can be found in $ZSH/plugins/ 70 | # Custom plugins may be added to $ZSH_CUSTOM/plugins/ 71 | # Example format: plugins=(rails git textmate ruby lighthouse) 72 | # Add wisely, as too many plugins slow down shell startup. 73 | plugins=(git) 74 | 75 | source $ZSH/oh-my-zsh.sh 76 | 77 | # User configuration 78 | 79 | # export MANPATH="/usr/local/man:$MANPATH" 80 | 81 | # You may need to manually set your language environment 82 | # export LANG=en_US.UTF-8 83 | 84 | # Preferred editor for local and remote sessions 85 | # if [[ -n $SSH_CONNECTION ]]; then 86 | # export EDITOR='vim' 87 | # else 88 | # export EDITOR='mvim' 89 | # fi 90 | 91 | # Compilation flags 92 | # export ARCHFLAGS="-arch x86_64" 93 | 94 | # Set personal aliases, overriding those provided by oh-my-zsh libs, 95 | # plugins, and themes. Aliases can be placed here, though oh-my-zsh 96 | # users are encouraged to define aliases within the ZSH_CUSTOM folder. 97 | # For a full list of active aliases, run `alias`. 98 | # 99 | # Example aliases 100 | # alias zshconfig="mate ~/.zshrc" 101 | # alias ohmyzsh="mate ~/.oh-my-zsh" 102 | 103 | alias vim='nvim' 104 | 105 | # Add Go to the PATH 106 | export GOPATH=$HOME/gocode 107 | export PATH=$PATH:$GOPATH/bin 108 | 109 | source /opt/z/z.sh 110 | 111 | # Load binaries from /usr/local/bin first (e.g. homebrew packages) 112 | export PATH=/usr/local/bin:$PATH 113 | export PATH="$HOME/.local/bin:$PATH" 114 | 115 | # set PATH so it includes my private bin if it exists 116 | if [ -d "$HOME/bin" ]; then 117 | PATH="$HOME/bin:$PATH" 118 | fi 119 | 120 | # Set default editor 121 | export EDITOR=vim 122 | 123 | # For mansion 124 | export GATSBY_REPO_DIR=~/programs 125 | 126 | # Set local npm globals path. 127 | export PATH=~/.npm-global/bin:$PATH 128 | 129 | export SPANNER_EMULATOR_HOST=localhost:9010 130 | 131 | # Include file with sensitive env vars I don't want to version control. 132 | source ~/.zsh_env_vars 133 | -------------------------------------------------------------------------------- /templates/init.vim: -------------------------------------------------------------------------------- 1 | let mapleader = ',' 2 | 3 | if empty(glob('~/.vim/autoload/plug.vim')) 4 | silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs 5 | \ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim 6 | autocmd VimEnter * PlugInstall --sync | source $MYVIMRC 7 | endif 8 | 9 | call plug#begin('~/.config/nvim/plugged') 10 | 11 | " surround plugin 12 | Plug 'https://tpope.io/vim/surround.git' 13 | 14 | " Color schemes 15 | Plug 'sjl/badwolf' 16 | Plug 'altercation/vim-colors-solarized' 17 | Plug 'sts10/vim-mustard' 18 | Plug 'NLKNguyen/papercolor-theme' 19 | Plug 'fatih/molokai' 20 | Plug 'morhetz/gruvbox' 21 | Plug 'arcticicestudio/nord-vim' 22 | 23 | " Elxir 24 | Plug 'elixir-editors/vim-elixir' 25 | 26 | " highlight color values in code. 27 | Plug 'norcalli/nvim-colorizer.lua' 28 | 29 | " Make LSP diagnostic colors work better for older color schemes 30 | Plug 'folke/lsp-colors.nvim' 31 | 32 | " Add Trouble plugin for better display of diagnostic info 33 | Plug 'kyazdani42/nvim-web-devicons' 34 | Plug 'folke/trouble.nvim' 35 | 36 | " LSP 37 | Plug 'anott03/nvim-lspinstall' 38 | Plug 'neovim/nvim-lspconfig' 39 | " Plug 'nvimdev/lspsaga.nvim' 40 | 41 | " vsnip. 42 | Plug 'hrsh7th/cmp-vsnip' 43 | Plug 'hrsh7th/vim-vsnip' 44 | 45 | " Auto complete 46 | Plug 'hrsh7th/cmp-nvim-lsp' 47 | Plug 'hrsh7th/cmp-buffer' 48 | Plug 'hrsh7th/cmp-path' 49 | Plug 'hrsh7th/cmp-cmdline' 50 | Plug 'hrsh7th/nvim-cmp' 51 | 52 | " File finder 53 | " Plug 'camspiers/snap' 54 | Plug 'nvim-lua/plenary.nvim' 55 | Plug 'nvim-telescope/telescope.nvim', { 'branch': '0.1.x' } 56 | Plug 'nvim-telescope/telescope-fzf-native.nvim', { 'do': 'make' } 57 | 58 | " Treesitter 59 | Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'} 60 | Plug 'nvim-treesitter/playground' 61 | 62 | " A statusline plugin 63 | Plug 'vim-airline/vim-airline' 64 | Plug 'vim-airline/vim-airline-themes' 65 | " enable showing buffers in tab nav 66 | let g:airline#extensions#tabline#enabled = 1 67 | let g:airline_theme='papercolor' 68 | 69 | " commenting code 70 | Plug 'scrooloose/nerdcommenter' 71 | 72 | " Git/GitHub helpers 73 | Plug 'tpope/vim-fugitive' 74 | Plug 'tpope/vim-rhubarb' 75 | Plug 'kepano/flexoki-neovim' 76 | 77 | " Markdown preview 78 | Plug 'iamcco/markdown-preview.nvim', { 'do': 'cd app && yarn install' } 79 | 80 | call plug#end() 81 | 82 | 83 | syntax enable 84 | " let g:gruvbox_contrast_dark = 'hard' 85 | " colorscheme gruvbox 86 | " set background=light 87 | colorscheme mustard 88 | set colorcolumn=85 " Show a colored column at 85 characters. 89 | 90 | " Enable true color 91 | if exists('+termguicolors') 92 | let &t_8f = "\[38;2;%lu;%lu;%lum" 93 | let &t_8b = "\[48;2;%lu;%lu;%lum" 94 | set termguicolors 95 | endif 96 | 97 | set number " show line numbers in the gutter. 98 | " set relativenumber " numbers are relative to the cursor. 99 | set cursorline " highlight current line as easier to find it. 100 | set nowrap " Don't wrap long lines. 101 | set tabstop=2 " number of visual spaces per TAB 102 | set softtabstop=2 " Number of spaces to add instead of a tab 103 | set expandtab " tabs are spaces 104 | set shiftwidth=2 " an autoindent (with <<) is two spaces 105 | set list " Show invisible characters 106 | set smartindent 107 | set autoindent 108 | set showmatch " highlight matching [{()}] 109 | set wildmenu " visual autocomplete for the command menu. 110 | filetype plugin indent on " load filetype-specific indent files 111 | set lazyredraw " redraw only when we need to e.g. not in middle of macro. 112 | 113 | " Strip all trailing whitespace in the current file 114 | nnoremap W :%s/\s\+$//:let @/='' 115 | 116 | " Map jj to to make it easier to move to normal mode 117 | inoremap jj 118 | 119 | " Edit file at the current buffers directory 120 | nmap ew :e =expand('%:h').'/' 121 | 122 | " Make it easier to work with split windows 123 | 124 | " Open a new vertical split and switch to it 125 | nnoremap w vl 126 | 127 | " Open a new horizontal split and switch to it 128 | nnoremap h sl 129 | 130 | " Map Ctrl plus normal navigation keys to move around splits 131 | nnoremap h 132 | nnoremap j 133 | nnoremap k 134 | nnoremap l 135 | nnoremap = 136 | 137 | " Create an undo file for each file edited. 138 | set undofile 139 | 140 | " Search config 141 | set incsearch " search as characters are entered 142 | set hlsearch " highlight matches 143 | set ignorecase " case insensitive search... 144 | set smartcase " ... unless they contain at least one capital letter 145 | nnoremap :noh " Clear out search 146 | 147 | " move vertically by visual line 148 | nnoremap j gj 149 | nnoremap k gk 150 | 151 | " Make Tab work for switching between matching bracket pairs 152 | nnoremap % 153 | vnoremap % 154 | 155 | " map ; to : 156 | nmap ; : 157 | 158 | " completion 159 | lua <'] = cmp.mapping.scroll_docs(-4), 180 | [''] = cmp.mapping.scroll_docs(4), 181 | [''] = cmp.mapping.complete(), 182 | [''] = cmp.mapping.abort(), 183 | [''] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items. 184 | }), 185 | sources = cmp.config.sources({ 186 | { name = 'nvim_lsp' }, 187 | { name = 'vsnip' }, -- For vsnip users. 188 | -- { name = 'luasnip' }, -- For luasnip users. 189 | -- { name = 'ultisnips' }, -- For ultisnips users. 190 | -- { name = 'snippy' }, -- For snippy users. 191 | }, { 192 | { name = 'buffer' }, 193 | }) 194 | }) 195 | 196 | -- Set configuration for specific filetype. 197 | cmp.setup.filetype('gitcommit', { 198 | sources = cmp.config.sources({ 199 | { name = 'git' }, -- You can specify the `git` source if [you were installed it](https://github.com/petertriho/cmp-git). 200 | }, { 201 | { name = 'buffer' }, 202 | }) 203 | }) 204 | 205 | -- Use buffer source for `/` and `?` (if you enabled `native_menu`, this won't work anymore). 206 | cmp.setup.cmdline({ '/', '?' }, { 207 | mapping = cmp.mapping.preset.cmdline(), 208 | sources = { 209 | { name = 'buffer' } 210 | } 211 | }) 212 | 213 | 214 | -- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore). 215 | cmp.setup.cmdline(':', { 216 | mapping = cmp.mapping.preset.cmdline(), 217 | sources = cmp.config.sources({ 218 | { name = 'path' } 219 | }, { 220 | { name = 'cmdline' } 221 | }) 222 | }) 223 | 224 | -- Set up lspconfig. 225 | local capabilities = require('cmp_nvim_lsp').default_capabilities() 226 | -- Replace with each lsp server you've enabled. 227 | require('lspconfig')['tailwindcss'].setup { 228 | capabilities = capabilities 229 | } 230 | require('lspconfig')['tsserver'].setup { 231 | capabilities = capabilities, 232 | settings = { 233 | implicitProjectConfiguration = { 234 | checkJs = true 235 | }, 236 | } 237 | } 238 | require('lspconfig')['efm'].setup { 239 | capabilities = capabilities 240 | } 241 | EOF 242 | 243 | " NerdCommenter 244 | let g:NERDSpaceDelims = 1 " add space after comment delimiter 245 | 246 | function! EscapeString (string) 247 | let string=a:string 248 | " Escape regex characters 249 | let string = escape(string, '^$.*\/~[]') 250 | " Escape the line endings 251 | let string = substitute(string, '\n', '\\n', 'g') 252 | return string 253 | endfunction 254 | 255 | " Get the current visual block for search and replaces 256 | " This function passed the visual block through a string escape function 257 | " Based on this - http://stackoverflow.com/questions/676600/vim-replace-selected-text/677918#677918 258 | function! GetVisual() range 259 | " Save the current register and clipboard 260 | let reg_save = getreg('"') 261 | let regtype_save = getregtype('"') 262 | let cb_save = &clipboard 263 | set clipboard& 264 | 265 | " Put the current visual selection in the " register 266 | normal! ""gvy 267 | let selection = getreg('"') 268 | 269 | " Put the saved registers and clipboards back 270 | call setreg('"', reg_save, regtype_save) 271 | let &clipboard = cb_save 272 | 273 | "Escape any special characters in the selection 274 | let escaped_selection = EscapeString(selection) 275 | 276 | return escaped_selection 277 | endfunction 278 | 279 | " Start the find and replace command across the entire file 280 | vmap z :%s/=GetVisual()/ 281 | 282 | "" Setup tailwindcss lsp 283 | lua require'lspconfig'.tailwindcss.setup{} 284 | 285 | lua <'}, function () 324 | " snap.run({ 325 | " prompt = 'Files', 326 | " producer = fzf(producer_file), 327 | " select = select_file.select, 328 | " multiselect = select_file.multiselect, 329 | " views = {preview_file} 330 | " }) 331 | " end) 332 | 333 | " snap.register.map({'n'}, {'ff'}, function () 334 | " snap.run({ 335 | " prompt = 'Grep', 336 | " producer = limit(10000, producer_vimgrep), 337 | " select = select_vimgrep.select, 338 | " multiselect = select_vimgrep.multiselect, 339 | " views = {preview_vimgrep} 340 | " }) 341 | " end) 342 | 343 | " snap.register.map({'n'}, {'fb'}, function () 344 | " snap.run({ 345 | " prompt = 'Buffers', 346 | " producer = fzf(producer_buffer), 347 | " select = select_file.select, 348 | " multiselect = select_file.multiselect, 349 | " views = {preview_file} 350 | " }) 351 | " end) 352 | 353 | " snap.register.map({'n'}, {'fo'}, function () 354 | " snap.run({ 355 | " prompt = 'Oldfiles', 356 | " producer = fzf(producer_oldfile), 357 | " select = select_file.select, 358 | " multiselect = select_file.multiselect, 359 | " views = {preview_file} 360 | " }) 361 | " end) 362 | 363 | " snap.register.map({'n'}, {'m'}, function () 364 | " snap.run({ 365 | " prompt = 'Grep', 366 | " producer = limit(10000, producer_vimgrep), 367 | " select = select_vimgrep.select, 368 | " multiselect = select_vimgrep.multiselect, 369 | " initial_filter = vim.fn.expand('') 370 | " }) 371 | " end) 372 | " EOF 373 | 374 | " Find files using Telescope command-line sugar. 375 | nnoremap Telescope find_files 376 | nnoremap ff Telescope live_grep 377 | nnoremap fb Telescope buffers 378 | nnoremap fh Telescope help_tags 379 | 380 | 381 | lua << EOF 382 | -- To get fzf loaded and working with telescope, you need to call 383 | -- load_extension, somewhere after setup function: 384 | require('telescope').setup{ 385 | pickers = { 386 | find_files = { 387 | find_command = { "fd", "--hidden", "--type", "file" }, 388 | }, 389 | } 390 | } 391 | require('telescope').load_extension('fzf') 392 | 393 | local lspconfig = require'lspconfig' 394 | 395 | -- npm i -g eslint_d 396 | -- brew install efm-langserver 397 | local eslint = { 398 | lintCommand = "eslint_d -f unix --stdin --stdin-filename ${INPUT}", 399 | lintStdin = true, 400 | lintFormats = {"%f:%l:%c: %m"}, 401 | lintIgnoreExitCode = true, 402 | formatCommand = "eslint_d --fix-to-stdout --stdin --stdin-filename=${INPUT}", 403 | formatStdin = true 404 | } 405 | 406 | local prettier = { 407 | formatCommand = "prettier --stdin-filepath ${INPUT}", 408 | formatStdin = true, 409 | } 410 | 411 | local function eslint_config_exists() 412 | local eslintrc = vim.fn.glob(".eslint*", 0, 1) 413 | 414 | if not vim.tbl_isempty(eslintrc) then 415 | return true 416 | end 417 | 418 | if vim.fn.filereadable("package.json") then 419 | if vim.fn.json_decode(vim.fn.readfile("package.json"))["eslintConfig"] then 420 | return true 421 | end 422 | end 423 | 424 | return false 425 | end 426 | 427 | vim.lsp.handlers["textDocument/formatting"] = function(err, _, result, _, bufnr) 428 | if err ~= nil or result == nil then 429 | return 430 | end 431 | if not vim.api.nvim_buf_get_option(bufnr, "modified") then 432 | local view = vim.fn.winsaveview() 433 | vim.lsp.util.apply_text_edits(result, bufnr) 434 | vim.fn.winrestview(view) 435 | if bufnr == vim.api.nvim_get_current_buf() then 436 | vim.api.nvim_command("noautocmd :update") 437 | end 438 | end 439 | end 440 | 441 | -- You will likely want to reduce updatetime which affects CursorHold 442 | -- note: this setting is global and should be set only once 443 | vim.o.updatetime = 250 444 | vim.cmd [[autocmd! CursorHold,CursorHoldI * lua vim.diagnostic.open_float(nil, {focus=false})]] 445 | vim.cmd [[autocmd! CursorHold,CursorHoldI * lua vim.diagnostic.open_float(nil, {focus=false, scope="cursor"})]] 446 | 447 | local on_attach = function(client) 448 | local au = vim.api.nvim_create_autocmd 449 | local ag = vim.api.nvim_create_augroup 450 | local clear_au = vim.api.nvim_clear_autocmds 451 | 452 | -- Autoformat on save 453 | local augroup = ag("LspFormatting", { clear = false }) 454 | if client.supports_method("textDocument/formatting") then 455 | au({"InsertLeave", "BufWritePre"}, { 456 | clear_au({ group = augroup, buffer = bufnr }), 457 | group = augroup, 458 | buffer = bufnr, 459 | callback = function() 460 | vim.lsp.buf.format() 461 | end, 462 | }) 463 | end 464 | 465 | -- Show diagnostics in hoverbox if cursor pauses on underlined text 466 | vim.api.nvim_create_autocmd("CursorHold", { 467 | buffer = bufnr, 468 | callback = function() 469 | local opts = { 470 | focusable = false, 471 | close_events = { "BufLeave", "CursorMoved", "InsertEnter", "FocusLost" }, 472 | border = 'rounded', 473 | source = 'always', 474 | prefix = ' ', 475 | scope = 'cursor', 476 | } 477 | vim.diagnostic.open_float(nil, opts) 478 | end 479 | }) 480 | 481 | -- Keyboard mappings for nvim lua commands 482 | -- from https://github.com/YodaEmbedding/dotfiles/blob/master/nvim/.config/nvim/lua/mappings/_nvim_lsp.lua 483 | local map = vim.keymap.set 484 | 485 | -- Already handled by Telescope: 486 | map("m", "gd", vim.lsp.buf.definition) 487 | map("m", "gi", vim.lsp.buf.implementation) 488 | map("m", "gr", vim.lsp.buf.references) 489 | 490 | -- Navigation 491 | map("m", "gCi", vim.lsp.buf.incoming_calls) 492 | map("m", "gCo", vim.lsp.buf.outgoing_calls) 493 | map("m", "gD", vim.lsp.buf.declaration) 494 | map("m", "gS", vim.lsp.buf.document_symbol) 495 | map("m", "gt", vim.lsp.buf.type_definition) 496 | map("m", "gw", vim.lsp.buf.workspace_symbol) 497 | 498 | -- Documentation 499 | map("i", "", vim.lsp.buf.signature_help) 500 | -- map("n", "", vim.lsp.buf.signature_help) 501 | map("n", "K", vim.lsp.buf.hover, { noremap = true, silent = true }) 502 | 503 | -- Diagnostics 504 | map("m", "[d", vim.diagnostic.goto_prev) 505 | map("m", "]d", vim.diagnostic.goto_next) 506 | map("m", "z", vim.diagnostic.setloclist) 507 | map("m", "e", vim.diagnostic.open_float) 508 | 509 | -- Refactoring 510 | local ok, actions_preview = pcall(require, "actions-preview") 511 | map("n", "a", ok and actions_preview.code_actions or vim.lsp.buf.code_action) 512 | map("n", "", vim.lsp.buf.rename) 513 | map("n", "", vim.lsp.buf.format) 514 | 515 | -- Workspaces 516 | -- map("n", "wa", vim.lsp.buf.add_workspace_folder) 517 | -- map("n", "wl", function() 518 | -- print(vim.inspect(vim.lsp.buf.list_workspace_folders())) 519 | -- end) 520 | -- map("n", "wr", vim.lsp.buf.remove_workspace_folder) 521 | end 522 | 523 | vim.diagnostic.config({ 524 | virtual_text = { 525 | source = "always", -- Or "if_many" 526 | }, 527 | float = { 528 | source = "always", -- Or "if_many" 529 | }, 530 | }) 531 | 532 | lspconfig.tsserver.setup { 533 | on_attach = function(client) 534 | -- Disable to avoid conflicts with prettier 535 | client.server_capabilities.documentFormattingProvider = false 536 | on_attach(client) 537 | end 538 | } 539 | 540 | --[[ 541 | on_attach = on_attach, 542 | 543 | root_dir = function() 544 | if not eslint_config_exists() then 545 | return nil 546 | end 547 | return vim.fn.getcwd() 548 | end, 549 | --]] 550 | lspconfig.efm.setup{ 551 | on_attach = on_attach, 552 | init_options = {documentFormatting = true}, 553 | settings = { 554 | rootMarkers = {".git/"}, 555 | languages = { 556 | javascript = {eslint}, 557 | javascriptreact = {eslint}, 558 | ["javascript.jsx"] = {eslint}, 559 | typescript = {eslint}, 560 | ["typescript.tsx"] = {eslint}, 561 | typescriptreact = {eslint}, 562 | markdown = {eslint}, 563 | json = {prettier}, 564 | }, 565 | }, 566 | filetypes = { 567 | "javascript", 568 | "javascriptreact", 569 | "javascript.jsx", 570 | "typescript", 571 | "typescript.tsx", 572 | "typescriptreact", 573 | "markdown", 574 | "json", 575 | }, 576 | } 577 | EOF 578 | 579 | " Setup Trouble plugin 580 | lua << EOF 581 | require("trouble")--.setup { 582 | -- your configuration comes here 583 | -- or leave it empty to use the default settings 584 | -- refer to the configuration section below 585 | -- } 586 | EOF 587 | 588 | 589 | " " Setup Navigator plugin 590 | " lua <