This commit is contained in:
sfigato 2020-08-07 20:03:09 +02:00
commit d26397debf
Signed by: blallo
GPG Key ID: 0CBE577C9B72DC3F
20 changed files with 1425 additions and 0 deletions

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
.vagrant/
/.ansible-vault-password

32
README.md Normal file
View File

@ -0,0 +1,32 @@
# Dev box
An ansible role to prepare a dev environment
### How
Feed something like this to your role
```yml
dev_box:
users:
- username: root
home: /root
group: root
antibody: true
- username: qui
home: /home/qui
group: giovanimarmotte
starship: true
- username: quo
home: /home/quo
group: giovanimarmotte
antibody: true
locale: it_IT.UTF-8
- username: qua
home: /home/qua
group: giovanimarmotte
antibody: true
locale: it_IT.UTF-8
```
**WARNING**: this role is suited only for debian (buster and maybe bullseye).

31
Vagrantfile vendored Normal file
View File

@ -0,0 +1,31 @@
# This guide is optimized for Vagrant 1.7 and above.
# Although versions 1.6.x should behave very similarly, it is recommended
# to upgrade instead of disabling the requirement below.
Vagrant.require_version ">= 1.7.0"
Vagrant.configure(2) do |config|
config.vm.box = "debian/buster64"
config.vm.define "debiantest" do |m|
m.vm.hostname = "debiantest"
m.vm.network :private_network, ip: "192.168.123.2", libvirt__dhcp_enabled: false
m.vm.synced_folder ".", "/vagrant", disabled: true
end
# Disable the new default behavior introduced in Vagrant 1.7, to
# ensure that all Vagrant machines will use the same SSH key pair.
# See https://github.com/mitchellh/vagrant/issues/5005
config.ssh.insert_key = false
config.vm.provider :libvirt do |lv|
lv.cpus = 2
lv.memory = 1024
end
config.vm.provision "ansible" do |ansible|
ansible.become = true
ansible.verbose = "v"
ansible.playbook = "playbook.yml"
ansible.inventory_path = "inventory"
end
end

2
ansible.cfg Normal file
View File

@ -0,0 +1,2 @@
[defaults]
roles_path = ../:~/.ansible/roles:/etc/ansible/roles

23
generate_password.sh Executable file
View File

@ -0,0 +1,23 @@
#!/usr/bin/env bash
if ! openssl version > /dev/null; then
echo "You need openssl installed"
exit -1
fi
ANSIBLE_VAULT_PASSFILE=$PWD/.ansible-vault-password
if ! [ -f ${ANSIBLE_VAULT_PASSFILE} ]; then
echo "You need to provide the ansible vault password in a file at ${ANSIBLE_VAULT_PASSFILE}"
exit -2
fi
TMPPASSFILE=${RANDOM}.hash
openssl passwd -6 > ${TMPPASSFILE}
echo "================================"
echo " feed this to the role"
echo
ansible-vault encrypt_string --vault-password-file ${ANSIBLE_VAULT_PASSFILE} $(cat ${TMPPASSFILE})
echo "================================"
rm ${TMPPASSFILE}

5
handlers/main.yml Normal file
View File

@ -0,0 +1,5 @@
---
- name: Remove local tool-versions
file:
path: /opt/elixir_ls/.tool-versions
state: absent

1
inventory Normal file
View File

@ -0,0 +1 @@
debiantest

11
meta/main.yml Normal file
View File

@ -0,0 +1,11 @@
---
dependencies:
- role: share_access
vars:
share_access:
users: "{{ dev_box.users }}"
- role: zsh_chic
vars:
zsh_chic:
users: "{{ dev_box.users }}"
- role: jnv.debian-backports

15
playbook.yml Normal file
View File

@ -0,0 +1,15 @@
---
- hosts: debiantest
gather_facts: yes
vars_files:
- ./test_vars.yml
pre_tasks:
- name: Add dummy users
user:
name: "{{ item.username }}"
state: present
password: $6$LqIjU1/Cd$Uou/9gTKyP/qPHnI0EWcuUYg.7DsI9zNOTeDUWk8pH7/.ncgZGwIGXupGRxPNtqw/w6p/6Ls84Bddvfu3D9p9/
with_items: "{{ zsh_chic.users }}"
roles:
- dev_box

30
tasks/git-stuff.yml Normal file
View File

@ -0,0 +1,30 @@
---
- name: Ensure tig is installed
apt:
name:
- vim
- git
- ripgrep
- tig
state: present
- name: Ensure tig configuration is present
template:
src: templates/tigrc.j2
dest: "{{ item.home }}/.tigrc"
owner: "{{ item.username }}"
group: "{{ item.group|default(item.username) }}"
mode: 0644
with_items: "{{ dev_box.users }}"
- name: Ensure diff-highlight is present
shell:
cmd: make
chdir: /usr/share/doc/git/contrib/diff-highlight
- name: Add diff-highlight as diff-pager for git
ini_file:
dest: /etc/gitconfig
section: core
option: pager
value: "/usr/share/doc/git/contrib/diff-highlight/diff-highlight | less --tabs=4 -RFX"

6
tasks/locales.yml Normal file
View File

@ -0,0 +1,6 @@
---
- name: Ensure all the needed locales are present
locale_gen:
name: "{{ item.locale|default('en_US.UTF-8') }}"
state: present
with_items: "{{ dev_box.users }}"

6
tasks/main.yml Normal file
View File

@ -0,0 +1,6 @@
---
- include_tasks: locales.yml
- include_tasks: toolchains.yml
- include_tasks: vim.yml
- include_tasks: git-stuff.yml
- include_tasks: tmux.yml

31
tasks/tmux.yml Normal file
View File

@ -0,0 +1,31 @@
---
- name: Ensure tmux is installed
apt:
name: tmux
state: present
- name: Ensure tmux directories are present
file:
path: "{{ item.home }}/.tmux/plugins"
state: directory
owner: "{{ item.username }}"
group: "{{ item.group|default(item.username) }}"
mode: 0755
recurse: yes
with_items: "{{ dev_box.users }}"
- name: Ensure tpm is present
git:
repo: 'https://github.com/tmux-plugins/tpm'
dest: "{{ item.home }}/.tmux/plugins/tpm"
force: yes
with_items: "{{ dev_box.users }}"
- name: Ensure tmux configuration is present
template:
src: templates/tmux.conf.j2
dest: "{{ item.home }}/.tmux.conf"
owner: "{{ item.username }}"
group: "{{ item.group|default(item.username) }}"
mode: 0644
with_items: "{{ dev_box.users }}"

169
tasks/toolchains.yml Normal file
View File

@ -0,0 +1,169 @@
---
- name: Install needed toolchains
apt:
name:
- curl
- gcc
- mypy
- gnupg2
- apt-transport-https
- jsonlint
state: present
- name: Add Yarn repo Apt signing key
apt_key:
id: 72ECF46A56B4AD39C907BBB71646B01B86E50310
url: https://dl.yarnpkg.com/debian/pubkey.gpg
state: present
- name: Add Yarn repo
apt_repository:
repo: deb https://dl.yarnpkg.com/debian/ stable main
state: present
- name: Install Yarn
apt:
name: yarn
state: present
- name: Install from backports
apt:
name:
- mosh
- node-typescript
- "golang-{{ dev_box.golang_version|default('1.14') }}"
state: present
default_release: "{{ ansible_distribution_release }}-backports"
- name: Install eslint with yarn
shell: "yarn add eslint --dev"
- name: Install prettier with yarn
shell: "yarn add --dev --exact prettier"
- name: Retrieve rustup installer
get_url:
url: https://sh.rustup.rs
dest: /tmp/rustup.sh
owner: root
group: root
mode: 0755
- name: Copy rustup installer in each user home
copy:
src: /tmp/rustup.sh
dest: "{{ item.home }}/rustup.sh"
remote_src: true
owner: "{{ item.username }}"
group: "{{ item.group|default(item.username) }}"
mode: 0755
with_items: "{{ dev_box.users }}"
- name: Install rustup for each user
shell:
cmd: "/tmp/rustup.sh -y"
chdir: "{{ item.home }}"
become_user: "{{ item.username }}"
with_items: "{{ dev_box.users }}"
changed_when: false
- name: Install the rust stable toolchain
shell:
cmd: "{{ item.home }}/.cargo/bin/rustup toolchain install stable"
chdir: "{{ item.home }}"
become_user: "{{ item.username }}"
with_items: "{{ dev_box.users }}"
- name: Ensure configuration directories are present
file:
path: "{{ item.0.home }}/.config/zsh/{{ item.1 }}"
state: directory
recurse: yes
owner: "{{ item.0.username }}"
group: "{{ item.0.group|default(item.0.username) }}"
mode: 0755
loop: "{{ dev_box.users|product(['pre', 'post'])|list }}"
- name: Ensure asdf configuration for zsh is present
template:
src: templates/01-asdf.j2
dest: "{{ item.home }}/.config/zsh/pre/01-asdf"
owner: "{{ item.username }}"
group: "{{ item.group|default(item.username) }}"
mode: 0755
loop: "{{ dev_box.users|flatten(levels=1) }}"
- name: Install asdf
git:
repo: https://github.com/asdf-vm/asdf.git
dest: "{{ item.home }}/.asdf"
force: yes
with_items: "{{ dev_box.users }}"
- name: Fix asdf directory permissions
file:
path: "{{ item.home }}/.asdf"
owner: "{{ item.username }}"
group: "{{ item.group|default(item.username) }}"
mode: 0755
with_items: "{{ dev_box.users }}"
- name: Copy elixir installer script
copy:
content: |
#!/usr/bin/env bash
source {{ item.home }}/.asdf/asdf.sh
asdf plugin-add elixir
asdf install elixir {{ dev_box.elixir_version|default('1.10.3-otp-22') }}
asdf global elixir {{ dev_box.elixir_version|default('1.10.3-otp-22') }}
dest: "{{ item.home }}/elixir_installer.sh"
owner: "{{ item.username }}"
group: "{{ item.group|default(item.username) }}"
mode: 0755
with_items: "{{ dev_box.users }}"
- name: Install elixir
shell:
cmd: "{{ item.home }}/elixir_installer.sh"
chdir: "{{ item.home }}"
become_user: "{{ item.username }}"
with_items: "{{ dev_box.users }}"
- name: Get elixir-ls
git:
repo: https://github.com/elixir-lsp/elixir-ls
dest: "/opt/elixir_ls"
force: yes
- name: Remove local tool-versions
file:
path: /opt/elixir_ls/.tool-versions
state: absent
- name: Ensure elixir-ls has needed directory
file:
path: "{{ item.home }}/.elixir_ls"
state: directory
owner: "{{ item.username }}"
group: "{{ item.group|default(item.username) }}"
mode: 0755
with_items: "{{ dev_box.users }}"
- name: Copy elixir-ls installer script
copy:
content: |
#!/usr/bin/env bash
source {{ item.home }}/.asdf/asdf.sh
mix compile && mix elixir_ls.release -o {{ item.home }}/.elixir_ls
dest: "{{ item.home }}/elixir-ls_installer.sh"
owner: "{{ item.username }}"
group: "{{ item.group|default(item.username) }}"
mode: 0755
with_items: "{{ dev_box.users }}"
- name: Compile elixir-ls
shell:
cmd: "{{ item.home }}/elixir-ls_installer.sh"
chdir: "/opt/elixir_ls"
become_user: "{{ item.username }}"
with_items: "{{ dev_box.users }}"

76
tasks/vim.yml Normal file
View File

@ -0,0 +1,76 @@
---
- name: Ensure vim and all dependencies are present
apt:
name:
- vim-nox
- git
- ripgrep
- python3-pip
- python3-venv
- powerline
state: present
- name: Ensure pynvim is present
shell: "pip3 install pynvim"
- name: create the vim autoload directory for all the provided users
file:
path: "{{ item.home }}/.vim/autoload"
state: directory
owner: "{{ item.username }}"
group: "{{ item.group|default(item.username) }}"
mode: 0755
recurse: yes
with_items: "{{ dev_box.users }}"
- name: create the vim swp directory for all the provided users
file:
path: "{{ item.home }}/.vim/swp"
state: directory
owner: "{{ item.username }}"
group: "{{ item.group|default(item.username) }}"
mode: 0755
recurse: yes
with_items: "{{ dev_box.users }}"
- name: create the vim backup directory for all the provided users
file:
path: "{{ item.home }}/.vim/backup"
state: directory
owner: "{{ item.username }}"
group: "{{ item.group|default(item.username) }}"
mode: 0755
recurse: yes
with_items: "{{ dev_box.users }}"
- name: Write the vimrc for all the provided users
template:
src: templates/vimrc.j2
dest: "{{ item.home }}/.vim/vimrc"
owner: "{{ item.username }}"
group: "{{ item.group|default(item.username) }}"
mode: 0644
with_items: "{{ dev_box.users }}"
- name: Symlink vimrc for all the provided users
file:
src: "{{ item.home }}/.vim/vimrc"
dest: "{{ item.home }}/.vimrc"
state: link
with_items: "{{ dev_box.users }}"
- name: Ensure vim.plug is present
get_url:
url: "https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim"
dest: "{{ item.home }}/.vim/autoload/plug.vim"
owner: "{{ item.username }}"
group: "{{ item.group|default(item.username) }}"
mode: 0644
with_items: "{{ dev_box.users }}"
- name: Execute PlugInstall
shell:
cmd: "su - {{ item.username }} -c 'vim -E -c PlugInstall -c q -c q'"
chdir: "{{ item.home }}"
with_items: "{{ dev_box.users }}"
ignore_errors: yes

6
templates/01-asdf.j2 Normal file
View File

@ -0,0 +1,6 @@
if [ -d $HOME/.asdf ]; then
fpath=($HOME/.asdf/completions $fpath)
. $HOME/.asdf/asdf.sh
fi
# vim: set ft=zsh et sw=0 ts=2 sts=2:

417
templates/tigrc.j2 Normal file
View File

@ -0,0 +1,417 @@
# Tig default configuration
#
# Please see 'man tigrc' for a complete reference.
# Settings
# --------
# Most of these settings can be toggleable, either via the toggle-*
# actions or via the option menu (bound to `o` by default).
# View settings
#
# Supported column types and their options:
#
# author
# - display (enum) [no|full|abbreviated|email|email-user]
# : Show author information?
# - width (int) : Fixed width when nonzero
# - maxwidth (int) : Autosize limit
#
# commit-title
# - display (bool) : Show the commit title?
# - graph (enum) [no|v2|v1] : Show the commit graph? (main view only)
# - refs (bool) : Show branches, tags and remotes? (main view only)
# - overflow (boolint) : Highlight overflows? Defaults to 50 when enabled.
#
# date
# - display (enum) [no|default|relative|relative-compact|custom]
# : Show dates?
# - local (bool) : Show local dates?
# - format (string) : Custom strftime(3) format
# Note: %Z is formatted as %z
# - width (int) : Fixed width when nonzero
#
# file-name
# - display (enum) [no|always|auto] : Show file names?
# - width (int) : Fixed width when nonzero
# - maxwidth (int) : Autosize limit
#
# file-size
# - display (enum) [no|default|units]
# : Show file sizes?
# - width (int) : Fixed width when nonzero
#
# id
# - display (bool) : Show commit/tree ID?
# - width (int) : Fixed width when nonzero
#
# line-number
# - display (bool) : Show line numbers?
# - interval (int) : Interval between line numbers; defaults to 5
# - width (int) : Fixed width when nonzero
#
# mode
# - display (bool) : Show file modes?
# - width (int) : Fixed width when nonzero
#
# ref
# - display (bool) : Show ref names?
# - width (int) : Fixed width when nonzero
# - maxwidth (int) : Autosize limit
#
# status
# - display (enum) [no|short|long] : Show status label?
#
# text
# - display (bool) : Show text?
# - commit-title-overflow (boolint) : Highlight overflow in log and diff view?
#
set blame-view = id:yes,color file-name:auto author:full date:default line-number:yes,interval=1 text
set grep-view = file-name:no line-number:yes,interval=1 text
set main-view = line-number:no,interval=5 id:no date:default author:full commit-title:yes,graph,refs,overflow=no
set refs-view = line-number:no id:no date:default author:full ref commit-title
set stash-view = line-number:no,interval=5 id:no date:default author:full commit-title
set status-view = line-number:no,interval=5 status:short file-name
set tree-view = line-number:no,interval=5 mode author:full file-size date:default id:no file-name
# Pager based views
set pager-view = line-number:no,interval=5 text
set stage-view = line-number:no,interval=5 text
set log-view = line-number:no,interval=5 text
set blob-view = line-number:no,interval=5 text
set diff-view = line-number:no,interval=5 text:yes,commit-title-overflow=no
# UI display settings
set show-changes = yes # Show changes commits in the main view?
set wrap-lines = no # Wrap long lines in pager views?
set tab-size = 8 # Number of spaces to use when expanding tabs
set line-graphics = default # Enum: ascii, default, utf-8
set truncation-delimiter = ~ # Character drawn for truncations, or "utf-8"
# Format reference names based on type.
# - head : The current HEAD.
# - tag : A signed tag.
# - local-tag : An unsigned tag.
# - remote : A remote.
# - tracked-remote : The remote tracked by current HEAD.
# - replace : A replaced reference.
# - branch : Any other reference.
# If no format is defined for `local-tag` then the one for `tag` is used.
# Similarly, `remote` is used if no `tracked-remote` format exists.
# Prefix with `hide:` to not show that reference type, e.g. `hide:remote`.
# Expects a space-separated list of format strings.
set reference-format = [branch] <tag> {remote} ~replace~
# Settings controlling how content is read from Git
set commit-order = auto # Enum: auto, default, topo, date, reverse (main)
set status-show-untracked-dirs = yes # Show files in untracked directories? (status)
set status-show-untracked-files = yes # Show untracked files?
set ignore-space = no # Enum: no, all, some, at-eol (diff)
set show-notes = yes # When non-bool passed as `--show-notes=...` (diff)
#set diff-context = 3 # Number of lines to show around diff changes (diff)
#set diff-options = -C # User-defined options for `tig show` (git-diff)
#set diff-highlight = true # String (or bool): Path to diff-highlight script,
# defaults to `diff-highlight`.
#set blame-options = -C -C -C # User-defined options for `tig blame` (git-blame)
#set log-options = --pretty=raw # User-defined options for `tig log` (git-log)
#set main-options = -n 1000 # User-defined options for `tig` (git-log)
#set mailmap = yes # Use .mailmap to show canonical name and email address
# Misc
set refresh-mode = auto # Enum: manual, auto, after-command, periodic
set refresh-interval = 10 # Interval in seconds between refreshes
set ignore-case = no # Enum: no, yes, smart-case
# Ignore case when searching? Smart-case option will
set wrap-search = yes # Wrap around to top/bottom of view when searching
set focus-child = yes # Move focus to child view when opened?
set horizontal-scroll = 50% # Number of columns to scroll as % of width
set split-view-height = 67% # Height of the bottom view for horizontal splits
set vertical-split = auto # Enum: horizontal, vertical, auto; Use auto to
# switch to horizontal split when width allows it
set split-view-width = 50% # Width of right-most view for vertical splits
set editor-line-number = yes # Automatically pass line number to editor? Used
# for opening file at specific line e.g. from a diff
set history-size = 500 # Size of persistent history, 0 to disable
set mouse = no # Enable mouse support?
set mouse-scroll = 3 # Number of lines to scroll via the mouse
set mouse-wheel-cursor = no # Prefer moving the cursor to scrolling the view?
# User-defined commands
# ---------------------
# These commands allow to run shell commands directly from within Tig.
# Unless otherwise specified, commands are run in the foreground with
# their console output shown (as if '!' was specified). When multiple
# command options are specified their behavior are combined, e.g. "?<git
# commit" will prompt the user whether to execute the command and will
# exit Tig after completion.
#
# ! Run the command in the foreground with output shown.
# @ Run the command in the background with no output.
# ? Prompt the user before executing the command.
# + Run the command synchronously, and echo the first line of output to the status bar.
# < Exit Tig after executing the command.
# > Re-open Tig instantly in the last displayed view after executing the command.
#
# User-defined commands can optionally refer to Tig's internal state
# using the following variable names, which are substituted before
# commands are run:
#
# %(head) The current ref ID. Defaults to HEAD
# %(commit) The current commit ID.
# %(blob) The current blob ID.
# %(branch) The current branch name.
# %(remote) The current remote name.
# %(tag) The current tag name.
# %(stash) The current stash name.
# %(directory) The current directory path in the tree view;
# empty for the root directory.
# %(file) The currently selected file.
# %(ref) The reference given to blame or HEAD if undefined.
# %(revargs) The revision arguments passed on the command line.
# %(fileargs) The file arguments passed on the command line.
# %(cmdlineargs) All other options passed on the command line.
# %(diffargs) The diff options from `diff-options` or `TIG_DIFF_OPTS`
# %(prompt) Prompt for the argument value.
bind main C !git checkout %(prompt)
bind status C !git commit
bind stash A ?git stash apply %(stash)
bind stash P ?git stash pop %(stash)
bind stash ! ?git stash drop %(stash)
bind refs C ?git checkout %(branch)
bind refs ! ?git branch -D %(branch)
# Normal commands
# ---------------
# View switching
bind generic m view-main
bind generic d view-diff
bind generic l view-log
bind generic t view-tree
bind generic f view-blob
bind generic b view-blame
bind generic r view-refs
bind generic p view-pager
bind generic h view-help
bind generic s view-status
bind generic S view-status # Compat binding to avoid going crazy!
bind generic c view-stage
bind generic y view-stash
bind generic g view-grep
# View manipulation
bind generic <Enter> enter # Enter and open selected entry
bind generic <Lt> back # Go back to the previous view state
bind generic <Down> next # Move to next
bind generic <C-N> next
bind generic J next
bind generic <Up> previous # Move to previous
bind generic <C-P> previous
bind generic K previous
bind generic , parent # Move to parent
bind generic <Tab> view-next # Move focus to the next view
bind generic R refresh # Reload and refresh view
bind generic <F5> refresh
bind generic O maximize # Maximize the current view
bind generic q view-close # Close the current view
bind generic Q quit # Close all views and quit
bind generic <C-C> quit # Close all views and quit
# View specific
bind status u status-update # Stage/unstage changes in file
bind status ! status-revert # Revert changes in file
bind status M status-merge # Open git-mergetool(1)
#bind status ??? :toggle status # Show short or long status labels
bind stage u status-update # Stage/unstage current diff (c)hunk
bind stage 1 stage-update-line # Stage/unstage current line
bind stage ! status-revert # Revert current diff (c)hunk
bind stage \ stage-split-chunk # Split current diff (c)hunk
bind stage @ :/^@@ # Jump to next (c)hunk
bind stage [ :toggle diff-context -1 # Decrease the diff context
bind stage ] :toggle diff-context +1 # Increase the diff context
bind diff @ :/^@@ # Jump to next (c)hunk
bind diff [ :toggle diff-context -1
bind diff ] :toggle diff-context +1
bind main G :toggle commit-title-graph # Toggle revision graph visualization
bind main F :toggle commit-title-refs # Toggle reference display (tags/branches)
bind main b !@git branch %(prompt) %(commit) # Create new branch
bind main M !@git branch -f %(prompt) %(commit) # Force move/create a branch
bind main d !?@git branch -d %(prompt) # Delete branch
# Cursor navigation
bind generic j move-down
bind generic k move-up
bind generic <C-D> move-half-page-down
bind generic <C-U> move-half-page-up
bind generic <PgDown> move-page-down
bind generic <Space> move-page-down
bind generic <PgUp> move-page-up
bind generic - move-page-up
bind generic <Home> move-first-line
bind generic <End> move-last-line
# Scrolling
bind generic | scroll-first-col
bind generic <Left> scroll-left
bind generic <Right> scroll-right
bind generic <Ins> scroll-line-up
bind generic <C-Y> scroll-line-up
bind generic <Del> scroll-line-down
bind generic <C-E> scroll-line-down
bind generic <SBack> scroll-page-up
bind generic <SFwd> scroll-page-down
# Searching
bind generic / search
bind generic ? search-back
bind generic n find-next
bind generic N find-prev
# Navigation keys used while searching
bind search <Down> find-next
bind search <C-N> find-next
bind search <C-J> find-next
bind search <Up> find-prev
bind search <C-P> find-prev
bind search <C-K> find-prev
bind search <C-C> view-close
# Option manipulation
bind generic o options # Open the options menu
# Bindings for toggling settings
bind generic I :toggle sort-order # Toggle ascending/descending sort order
bind generic i :toggle sort-field # Toggle field to sort by
bind generic <Hash> :toggle line-number # Toggle line numbers
bind generic D :toggle date # Toggle date display
bind generic A :toggle author # Toggle author display
bind generic ~ :toggle line-graphics # Toggle (line) graphics mode
bind generic F :toggle file-name # Toggle file name display
# bind generic ??? :toogle show-changes # Toggle local changes display in the main view
bind generic W :toggle ignore-space # Toggle ignoring whitespace in diffs
# bind generic ? :toggle commit-order # Toggle commit ordering
bind generic X :toggle id # Toggle commit ID display
bind generic $ :toggle commit-title-overflow
# Toggle highlighting of commit title overflow
# bind generic ??? :toggle file-size # Toggle file size format
# bind generic ??? :toggle status # Toggle status display
# bind generic ??? :toggle status-show-untracked-dirs
# Toggle display of file in untracked directories
# bind generic ??? :toggle vertical-split # Toggle vertical split
bind generic % :toggle file-filter
# Misc
bind generic e edit # Open in editor
bind generic : prompt # Open the prompt
bind generic <C-L> screen-redraw # Redraw the screen
bind generic z stop-loading # Stop all loading views
bind generic v show-version # Show Tig version
bind generic x !@sh -c "echo -n %(commit) | xclip -selection c" # Copy Hash to Clipboard
# Colors
# ------
# The colors in the UI can be customized. In addition to the colors used
# for the UI you can also define new colors to use in the pager, blob,
# diff, and stage views by placing the text to match for in quotes.
#
# Prefix the name of a view to set a color only for that view, e.g.
#
# color grep.file blue default
#
# As an example, this setting will to color Signed-off-by lines with a
# yellow foreground color and use the default background color.
#
# color " Signed-off-by" yellow default
#
# Note the four leading spaces in the string to match. This is because
# Git automatically indents commit messages by four spaces.
# general
color default 15 235
color cursor 15 241
color title-focus 242 221
color title-blur 242 221
color delimiter 213 default
color author 156 default
color date 81 default
color line-number 221 default
color mode 255 default
# main
color main-tag 213 default bold
color main-local-tag 213 default
color main-remote 221 default
color main-replace 81 default
color main-tracked 221 default bold
color main-ref 81 default
color main-head 213 default bold
color graph-commit 226 default
# status
#color stat-head 81 default
# Diff colors
color diff_add 10 default
color diff_add2 10 default
color diff_del 196 default
color diff_del2 196 default
color diff-header 221 default
color diff-index 81 default
color diff-chunk 213 default
color diff_oldmode 221 default
color diff_newmode 221 default
color 'deleted file mode' 221 default
color 'copy from' 223 default
color 'copy to' 221 default
color 'rename from' 221 default
color 'rename to' 221 default
color diff_similarity 221 default
color 'dissimilarity' 221 default
color 'diff_tree' 81 default
color diff-stat 81 default
color "Reported-by:" 156 default
color 'Author:' 156 default
color 'Commit:' 213 default
color 'AuthorDate:' 221 default
color 'CommitDate:' 221 default
color 'Date:' 81 default
color pp_refs 213 default
color palette-0 226 default
color palette-1 213 default
color palette-2 118 default
color palette-3 51 default
color palette-4 196 default
color palette-5 219 default
color palette-6 190 default
# status
color status.header 221 default
color status.section 81 default
color stat_staged 213 default
color stat_unstaged 213 default
color stat_untracked 213 default
# raw commit header
color commit 156 default
color committer 213 default
# commit message
color 'Signed-off-by' 221 default
color 'Acked-by' 221 default
color 'Tested-by' 221 default
color 'Reviewed-by' 221 default
# tree
color tree.directory 221 default
# LINE(PALETTE_0, "", COLOR_MAGENTA, COLOR_DEFAULT, 0), \
# LINE(PALETTE_1, "", COLOR_YELLOW, COLOR_DEFAULT, 0), \
# LINE(PALETTE_2, "", COLOR_CYAN, COLOR_DEFAULT, 0), \
# LINE(PALETTE_3, "", COLOR_GREEN, COLOR_DEFAULT, 0), \
# LINE(PALETTE_4, "", COLOR_DEFAULT, COLOR_DEFAULT, 0), \
# LINE(PALETTE_5, "", COLOR_WHITE, COLOR_DEFAULT, 0), \
# LINE(PALETTE_6, "", COLOR_RED, )

7
templates/tmux.conf.j2 Normal file
View File

@ -0,0 +1,7 @@
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-sensible'
set -g @plugin 'jimeh/tmux-themepack'
set -g @themepack 'powerline/double/yellow'
run -b '~/.tmux/plugins/tpm/tpm'
set-option -g history-limit 50000
set -g default-terminal screen-256color

539
templates/vimrc.j2 Normal file
View File

@ -0,0 +1,539 @@
let $VIMHOME = expand('~/.vim')
" check if in tty
let g:is_tty = system('case $(tty) in (/dev/tty[0-9]) echo 1;; (*) echo 0;; esac')
" vim-plug init
if empty(glob('~/.vim/autoload/plug.vim'))
system('curl -fLo ~/.vim/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim')
autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
endif
""" Set python3 path
let g:python3_host_prog = "/usr/bin/python"
let g:python_host_prog='/usr/bin/python'
call plug#begin('~/.vim/bundle')
""" Install Plugs
" clipboard
Plug 'haya14busa/vim-poweryank'
" powerline-vim
Plug 'powerline/powerline'
" vim-eunuch
Plug 'tpope/vim-eunuch'
" vim-commentary
Plug 'tpope/vim-commentary'
" vim-markbar
Plug 'Yilin-Yang/vim-markbar'
" vim-rooter
Plug 'airblade/vim-rooter'
" win-resizer
Plug 'simeji/winresizer'
" Deoplete.vim
Plug 'Shougo/deoplete.nvim'
Plug 'roxma/nvim-yarp'
Plug 'roxma/vim-hug-neovim-rpc'
Plug 'deoplete-plugins/deoplete-go', { 'do': 'make' }
Plug 'deoplete-plugins/deoplete-jedi'
let g:deoplete#enable_at_startup = 1
" neosnippets
Plug 'Shougo/neosnippet.vim'
Plug 'Shougo/neosnippet-snippets'
" fzf
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }
Plug 'junegunn/fzf.vim'
" NERDTree
Plug 'scrooloose/nerdtree'
Plug 'Xuyuanp/nerdtree-git-plugin'
" NERTCommenter
Plug 'scrooloose/nerdcommenter'
" tagbar
" Plug 'majutsushi/tagbar'
" vim-fugitive
Plug 'tpope/vim-fugitive'
" dadbod (sql)
Plug 'tpope/vim-dadbod'
" Dart
" Plug 'bartekd/vim-dart'
Plug 'dart-lang/dart-vim-plugin'
" Kotlin
Plug 'udalov/kotlin-vim'
" Elixir
Plug 'elixir-editors/vim-elixir'
Plug 'GrzegorzKozub/vim-elixirls', { 'do': ':ElixirLsCompileSync' }
" Elm
Plug 'Zaptic/elm-vim'
" GraphQL
Plug 'jparise/vim-graphql'
" Scss
Plug 'cakebaker/scss-syntax.vim'
" ALE
"Plug 'w0rp/ale'
Plug 'dense-analysis/ale'
let g:ale_completion_enabled = 0
" LanguageClient
Plug 'autozimu/LanguageClient-neovim', {
\ 'branch': 'next',
\ 'do': 'bash install.sh',
\ }
" Colorschemes
Plug 'junegunn/seoul256.vim'
Plug 'scwood/vim-hybrid'
Plug 'kristijanhusak/vim-hybrid-material'
Plug 'srcery-colors/srcery-vim'
Plug 'nightsense/cosmic_latte'
Plug 'rafi/awesome-vim-colorschemes'
Plug 'altercation/vim-colors-solarized'
Plug 'franbach/miramare'
Plug 'sainnhe/edge'
" indent-guides
Plug 'nathanaelkane/vim-indent-guides'
" Dockerfile.vim
Plug 'ekalinin/Dockerfile.vim'
" YAML
Plug 'mrk21/yaml-vim'
" Python
Plug 'ambv/black'
" TOML
Plug 'cespare/vim-toml'
" Autoclose
Plug 'jiangmiao/auto-pairs'
" vim-multiple-cursor
Plug 'terryma/vim-multiple-cursors'
" rust.vim
" Plug 'rust-lang/rust.vim'
" nginx.vim
Plug 'chr4/nginx.vim'
" typescript
Plug 'HerringtonDarkholme/yats.vim'
Plug 'leafgarland/typescript-vim'
Plug 'ianks/vim-tsx'
"Plug 'mhartington/nvim-typescript', {'do': './install.sh'}
call plug#end()
"""
""" vim-rooter
"let g:rooter_change_directory_for_non_project_files = 'current':
""" neosnippets
" Plugin key-mappings.
" Note: It must be "imap" and "smap". It uses <Plug> mappings.
imap <C-k> <Plug>(neosnippet_expand_or_jump)
smap <C-k> <Plug>(neosnippet_expand_or_jump)
xmap <C-k> <Plug>(neosnippet_expand_target)
" SuperTab like snippets behavior.
" Note: It must be "imap" and "smap". It uses <Plug> mappings.
"imap <expr><TAB>
" \ pumvisible() ? "\<C-n>" :
" \ neosnippet#expandable_or_jumpable() ?
" \ "\<Plug>(neosnippet_expand_or_jump)" : "\<TAB>"
smap <expr><TAB> neosnippet#expandable_or_jumpable() ?
\ "\<Plug>(neosnippet_expand_or_jump)" : "\<TAB>"
" For conceal markers.
if has('conceal')
set conceallevel=2 concealcursor=niv
endif
""" LanguageClient
" Required for operations modifying multiple buffers like rename.
set hidden
" let g:LanguageClient_serverCommands = {
" \ 'javascript': ['/usr/local/bin/javascript-typescript-stdio'],
" \ 'javascript.jsx': ['tcp://127.0.0.1:2089'],
" \ 'python': ['/usr/local/bin/pyls'],
" \ 'ruby': ['~/.rbenv/shims/solargraph', 'stdio'],
" \ }
let g:LanguageClient_serverCommands = {
\ 'rust': ['/usr/bin/rustup', 'run', 'stable', 'rls'],
\ 'elixir': ['/usr/lib/elixir-ls/language_server.sh'],
\ }
" note that if you are using Plug mapping you should not use `noremap` mappings.
nmap <F5> <Plug>(lcn-menu)
" Or map each action separately
nmap <silent>K <Plug>(lcn-hover)
nmap <silent> gd <Plug>(lcn-definition)
nmap <silent> <F2> <Plug>(lcn-rename)
""" ALE configuration
let g:ale_sign_error = '->'
let g:ale_sign_warning = '~>'
" let g:ale_sign_error = '✘'
" let g:ale_sign_warning = '⚠'
if has('nvim')
let s:user_dir = stdpath('config')
else
let s:user_dir = has('win32') ? expand('~/vimfiles') : expand('~/.vim')
endif
let g:ale_elixir_elixir_ls_release='~/.elixir_ls/'
let g:ale_linters = {
\ 'javascript': ['eslint'],
\ 'typescript': ['tsserver', 'tslint'],
\ 'python': ['pylint'],
\ 'rust': ['rls'],
\ 'elixir': ['elixir-ls'],
\ 'go': ['gopls'],
\ 'json': ['jsonlint'],
\}
let g:ale_fixers = {
\ 'javascript': ['prettier'],
\ 'typescript': ['prettier'],
\ 'python': ['black', 'python-language-server'],
\ 'rust': ['rustfmt'],
\ 'elixir': ['mix_format'],
\ 'graphql': ['prettier'],
\ 'perl': ['perltidy'],
\ 'go': ['gofmt'],
\ 'json': ['prettier'],
\}
let g:ale_rust_rls_config = {
\ 'rust': {
\ 'clippy_preference': 'on'
\ }
\ }
let g:ale_echo_msg_error_str = 'Err'
let g:ale_echo_msg_warning_str = 'Warn'
let g:ale_echo_msg_format = '[%linter%] %s [%severity%]'
let g:ale_go_langserver_executable = 'gopls'
let g:airline#extensions#ale#enabled = 1
let g:ale_completion_enabled = 1
let g:ale_lint_on_enter = 0
let g:ale_lint_on_text_changed = 'never'
highlight ALEErrorSign ctermbg=NONE ctermfg=red
highlight ALEWarningSign ctermbg=NONE ctermfg=yellow
let g:ale_linters_explicit = 1
let g:ale_lint_on_save = 1
let g:ale_fix_on_save = 1
""" deoplete
" let g:deoplete#sources = {'go': ['deoplete-go'], 'python': ['deoplete-jedi']}
call deoplete#custom#option('omni_patterns', { 'go': '[^. *\t]\.\w*' })
""" Themes and colors
if exists('+termguicolors')
let &t_8f = "\<Esc>[38;2;%lu;%lu;%lum"
let &t_8b = "\<Esc>[48;2;%lu;%lu;%lum"
set termguicolors
endif
function! LightOrDarkness()
if &background==?"dark"
set background=light
colorscheme edge
hi Search guibg=Green
elseif &background==?"light"
set background=dark
colorscheme miramare
hi Search guibg=Purple
endif
endfunction
" Needed for kitty not to f*ck up the background color
let &t_ut=''
set background=dark
let g:miramare_enable_italic = 0
let g:miramare_disable_italic_comment = 1
let g:miramare_transparent_background = 0
colorscheme miramare
set number
let g:enable_bold_font = 1
let g:enable_italic_font = 1
""" FZF
let g:fzf_commits_log_options = '--graph --color=always --format="%C(auto)%h%d %s %C(black)%C(bold)%cr"'
let g:fzf_action = {
\ 'ctrl-t': 'tabedit',
\ 'ctrl-v': 'vsplit',
\ 'ctrl-x': 'split' }
let g:fzf_buffers_jump = 1
let g:fzf_commands_expect = 'alt-enter,ctrl-x'
""" NERDTree
" Close NERDTree automatically after opening a file with it.
let g:NERDTreeQuitOnOpen = 1
" Use a single click for opening things in NERDTree
let g:NERDTreeMouseMode = 3
let g:NERDTreeMapActivateNode = '<Space>'
let g:NERDTreeIgnore = [
\ '\.pyc$',
\ '^__pycache__$',
\ '^\.mypy_cache$',
\]
" 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(<q-args>).'| tr -d "\017"', 1, <bang>0)
endif
" Search in files with ripgrep + preview with bat
function! Fzf_dev()
let l:fzf_files_options = '--preview "bat --style=numbers,changes --color always {2..-1} | head -'.&lines.'"'
function! s:files()
let l:files = split(system($FZF_DEFAULT_COMMAND), '\n')
return s:format_list(l:files)
endfunction
function! s:format_list(candidates)
let l:result = []
for l:candidate in a:candidates
let l:filename = fnamemodify(l:candidate, ':p:t')
let l:icon = ">-"
call add(l:result, printf('%s %s', l:icon, l:candidate))
endfor
return l:result
endfunction
function! s:edit_file(item)
let l:pos = stridx(a:item, ' ')
let l:file_path = a:item[pos+1:-1]
execute 'silent e' l:file_path
endfunction
call fzf#run({
\ 'source': <sid>files(),
\ 'sink': function('s:edit_file'),
\ 'options': '-m ' . l:fzf_files_options,
\ 'down': '40%' })
endfunction
""" indentation seek functions
" Jump to the next or previous line that has the same level or a lower
" level of indentation than the current line.
"
" exclusive (bool): true: Motion is exclusive
" false: Motion is inclusive
" fwd (bool): true: Go to next line
" false: Go to previous line
" lowerlevel (bool): true: Go to line with lower indentation level
" false: Go to line with the same indentation level
" skipblanks (bool): true: Skip blank lines
" false: Don't skip blank lines
function! NextIndent(exclusive, fwd, lowerlevel, skipblanks)
let line = line('.')
let column = col('.')
let lastline = line('$')
let indent = indent(line)
let stepvalue = a:fwd ? 1 : -1
while (line > 0 && line <= lastline)
let line = line + stepvalue
if ( ! a:lowerlevel && indent(line) == indent ||
\ a:lowerlevel && indent(line) < indent)
if (! a:skipblanks || strlen(getline(line)) > 0)
if (a:exclusive)
let line = line - stepvalue
endif
exe line
exe "normal " column . "|"
return
endif
endif
endwhile
endfunction
" Moving back and forth between lines of same or lower indentation.
nnoremap <silent> [l :call NextIndent(0, 0, 0, 1)<CR>
nnoremap <silent> ]l :call NextIndent(0, 1, 0, 1)<CR>
nnoremap <silent> [L :call NextIndent(0, 0, 1, 1)<CR>
nnoremap <silent> ]L :call NextIndent(0, 1, 1, 1)<CR>
vnoremap <silent> [l <Esc>:call NextIndent(0, 0, 0, 1)<CR>m'gv''
vnoremap <silent> ]l <Esc>:call NextIndent(0, 1, 0, 1)<CR>m'gv''
vnoremap <silent> [L <Esc>:call NextIndent(0, 0, 1, 1)<CR>m'gv''
vnoremap <silent> ]L <Esc>:call NextIndent(0, 1, 1, 1)<CR>m'gv''
onoremap <silent> [l :call NextIndent(0, 0, 0, 1)<CR>
onoremap <silent> ]l :call NextIndent(0, 1, 0, 1)<CR>
onoremap <silent> [L :call NextIndent(1, 0, 1, 1)<CR>
onoremap <silent> ]L :call NextIndent(1, 1, 1, 1)<CR>
""" general
set nospell
" restore screen after quitting
" au VimLeave * :!clear
packloadall
silent! helptags ALL
" Enable persistent undo
set undodir=$VIMHOME/.undo//
set undofile
set undolevels=1000 "maximum number of changes that can be undone
set undoreload=10000 "maximum number lines to save for undo on a buffer reload
" Automatically re-open files after they have changed without prompting.
" This can be a little more destructive, but a lot less annoying.
set autoread
set autoindent
set showmatch
" Put all special files in the right place
set backupdir=$VIMHOME/backup//
set directory=$VIMHOME/swp//
" Draw tabs and trailing spaces.
" set listchars=tab:<->
let g:indent_guides_enable_on_vim_startup = 1
let g:indent_guides_start_level = 2
let g:indent_guides_guide_size = 1
set listchars=tab:\ ,trail:•,extends:#,nbsp:.
"set listchars=tab:-->,trail:$,extends:#,nbsp:.
hi IndentGuidesOdd ctermbg=white
hi IndentGuidesEven ctermbg=lightgrey
set list
" Set the right margin.
set colorcolumn=89
" Automatically split words at the margin.
" set wrap
" Default to spaces instead of tabs
set expandtab
" Set tab width to 4.
set tabstop=4
set shiftwidth=4
" Setting this will make backspace delete space indents
set softtabstop=4
" Disable automatic wrapping.
set textwidth=0
" Enable highlight on search patterns matches
set hlsearch
hi Search guibg=Purple
" Make :Q and :W work like :q and :w
command! W w
command! Q q
command! WQ wq
command! Wq wq
command! WW w ! sudo tee %:t
" Make completion smarter.
set ignorecase
set smartcase
" viminfo settings
" '100 : Remember marks for 100 previously edited files.
" <50 : ???
" s10 : ???
" h : ???
" "100 : Save 100 lines for each register
" :50 : Remember 50 lines of command history
set viminfo='100,<50,s10,h,\"100,:50
" Jump at last opened cursor position position, if valid
if has("autocmd")
au BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$")
\| exe "normal! g'\"" | endif
endif
" Warn about not being able to write to .viminfo, which messes up restoring
" the cursor position when editing.
let s:info_filename = expand('~/.viminfo')
if !empty(glob(s:info_filename)) && !filewritable(s:info_filename)
echoerr 'The .viminfo file cannot be written to!'
endif
""" powerline
let g:powerline_pycmd = "py3"
""" keybindings
let mapleader = ','
noremap <leader>ad :ALEGoToDefinition<CR>
nnoremap <leader>af :ALEFix<cr>
noremap <leader>ar :ALEFindReferences<CR>
nnoremap <leader>r :ALENextWrap<CR>
nnoremap <leader>R :ALEPreviousWrap<CR>
nnoremap <silent> <C-d> :bd<CR>
nnoremap <C-e> :NERDTree<CR>
nnoremap <leader>r :redo<CR>
nnoremap <C-h> <C-w><Left>
nnoremap <C-j> <C-w><Down>
nnoremap <C-k> <C-w><Up>
nnoremap <C-l> <C-w><Right>
nnoremap <leader>b :Gblame<CR>
nnoremap <C-p> :FZF<CR>
nnoremap <C-a> :Buffers<CR>
nnoremap <C-F> :Files<CR>
nnoremap <C-\> :Rg<CR>
nnoremap <leader>s :call Fzf_dev()<CR>
nnoremap <leader>c :Commits<CR>
nnoremap <leader>b :Gblame<CR>
nnoremap <leader><esc> :silent! nohls<cr>
nnoremap <leader><Tab> :bnext<CR>
nnoremap <leader>\ :bprev<CR>
nnoremap <Leader>m <Plug>ToggleMarkbar
nnoremap <Leader>mo <Plug>OpenMarkbar
nnoremap <Leader>mc <Plug>CloseMarkbar
nnoremap <Leader>L :call LightOrDarkness()<CR>
map <Leader>y <Plug>(operator-poweryank-osc52)
" vim: set et sw=0 ts=4 sts=0:

16
test_vars.yml Normal file
View File

@ -0,0 +1,16 @@
---
dev_box:
users:
- username: root
home: /root
group: root
antibody: true
- username: qui
home: /home/qui
group: qui
starship: true
- username: quo
home: /home/quo
group: quo
antibody: true
locale: it_IT.UTF-8