This single file set up a whole bunch of stuff - mainly, emacs - some scripts and tools.
My name and e-mail, so if I lost my computer, anyone could easely launch emacs, open this file and discover how to reach me.
(setq user-full-name "Ulisses Caon"
user-mail-address "[email protected]")
Hack is a great font, it handles 0 and O like a champ! Also, look at that: ‘| L 1 l I i’! Awesome! I used to code with a 12pt font, but after some years on the road - working mostly with old systems, built by coworkers who don’t give a crap about standards - I decided I needed more code on the screen. Also, got new glasses .
(setq doom-font (font-spec :family "Hack Nerd Font" :size 11)
doom-variable-pitch-font (font-spec :family "sans" :size 11))
Gruvbox is the best theme I’ve seen so far. I know dark themes are sexy and all, but I had too much eyestrain using dark themes. I like to work on a well lit room, so light themes end up being easier on my eyes.
(setq doom-theme 'doom-gruvbox-light)
Line numbers are really cool if you use vim/evil. 8j 12k v22j… Life changer
(setq display-line-numbers-type t)
(setq doom-line-numbers-style 'relative)
Transparency helps me visualize the awesome wallpapers I have.
(set-frame-parameter (selected-frame) 'alpha '(90 90))
(add-to-list 'default-frame-alist '(alpha 90 90))
Default org mode directory
(setq org-directory "~/org/")
Maybe more than I actually need, but still…
;;; init.el -*- lexical-binding: t; -*-
(doom! :input
:completion
company ; the ultimate code completion backend
ivy ; a search engine for love and life
:ui
doom ; what makes DOOM look the way it does
doom-dashboard ; a nifty splash screen for Emacs
doom-quit ; DOOM quit-message prompts when you quit Emacs
(emoji +unicode) ; 🙂
hl-todo ; highlight TODO/FIXME/NOTE/DEPRECATED/HACK/REVIEW
ligatures ; ligatures and symbols to make your code pretty again
modeline ; snazzy, Atom-inspired modeline, plus API
neotree ; a project drawer, like NERDTree for vim
ophints ; highlight the region an operation acts on
(popup +defaults) ; tame sudden yet inevitable temporary windows
tabs ; a tab bar for Emacs
unicode ; extended unicode support for various languages
vc-gutter ; vcs diff in the fringe
vi-tilde-fringe ; fringe tildes to mark beyond EOB
window-select ; visually switch windows
workspaces ; tab emulation, persistence & separate workspaces
zen ; distraction-free coding or writing
:editor
(evil +everywhere); come to the dark side, we have cookies
file-templates ; auto-snippets for empty files
fold ; (nigh) universal code folding
multiple-cursors ; editing in many places at once
rotate-text ; cycle region at point between text candidates
snippets ; my elves. They type so I don't have to
word-wrap ; soft wrapping with language-aware indent
:emacs
dired ; making dired pretty [functional]
electric ; smarter, keyword-based electric-indent
undo ; persistent, smarter undo for your inevitable mistakes
vc ; version-control and Emacs, sitting in a tree
:term
eshell ; the elisp shell that works everywhere
vterm ; the best terminal emulation in Emacs
:checkers
syntax ; tasing you for every semicolon you forget
:tools
debugger ; FIXME stepping through code, to help you add bugs
docker
(eval +overlay) ; run code, run (also, repls)
lookup ; navigate your code and its documentation
lsp
magit ; a git porcelain for Emacs
make ; run make tasks from Emacs
taskrunner ; taskrunner for all your projects
:os
tty ; improve the terminal Emacs experience
:lang
data ; config/data formats
elixir ; erlang done right
emacs-lisp ; drown in parentheses
erlang ; an elegant language for a more civilized age
json ; At least it ain't XML
javascript ; all(hope(abandon(ye(who(enter(here))))))
markdown ; writing docs for people to ignore
org ; organize your plain life in plain text
rest ; Emacs as a REST client
(ruby +rails) ; 1.step {|i| p "Ruby is #{i.even? ? 'love' : 'life'}"}
sh ; she sells {ba,z,fi}sh shells on the C xor
web ; the tubes
yaml ; JSON, but readable
:app
calendar
emms
(rss +org) ; emacs as an RSS reader
:config
(default +bindings +smartparens))
call plug#begin('~/.vim/plugged')
" autocomplete
Plug 'neoclide/coc.nvim', {'tag': '*', 'branch': 'release'}
" editing
" Plug 'mattn/emmet-vim'
Plug 'AndrewRadev/tagalong.vim'
Plug 'Chiel92/vim-autoformat'
Plug 'alvan/vim-closetag'
Plug 'cohama/lexima.vim'
Plug 'frazrepo/vim-rainbow'
Plug 'terryma/vim-multiple-cursors'
Plug 'tpope/vim-surround'
Plug 'junegunn/goyo.vim'
Plug 'haya14busa/incsearch.vim'
Plug 'tpope/vim-commentary'
Plug 'AndrewRadev/splitjoin.vim'
Plug 'gregsexton/MatchTag'
" project
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
Plug 'junegunn/fzf.vim'
Plug 'tpope/vim-vinegar'
Plug 'francoiscabrol/ranger.vim'
Plug 'rhysd/git-messenger.vim'
" docker
Plug 'ekalinin/Dockerfile.vim'
" status line
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
" snippets
Plug 'SirVer/ultisnips'
Plug 'honza/vim-snippets'
" git
Plug 'airblade/vim-gitgutter'
Plug 'tpope/vim-fugitive'
Plug 'tpope/vim-rhubarb'
" php
Plug 'dominikduda/vim_current_word'
Plug 'adoy/vim-php-refactoring-toolbox'
Plug 'noahfrederick/vim-composer'
" terraform
Plug 'hashivim/vim-terraform'
" style
Plug 'ryanoasis/vim-devicons'
" sql
Plug 'tpope/vim-dadbod'
Plug 'joereynolds/SQHell.vim'
" random
Plug 'mhinz/vim-startify'
" Plug 'bagrat/vim-buffet'
Plug 'airblade/vim-rooter'
call plug#end()
" General Settings
filetype plugin on
set encoding=utf8 " enables UFT-8
set autowriteall " autosave file if vim exits
set relativenumber " set the line number indicator as relative to line is currently in
set copyindent " copy with indentation
syntax on " syntax highlight
" Nice tabs
set guioptions-=e
" Spacing
set expandtab " turn tabs into spaces
set tabstop=4 " each tab will have 2 spaces
set shiftwidth=4 " identation for 2
set number " show numbers
set smartindent " make identation work
set clipboard=unnamed " fix clipboard identation
set autoindent " set autoindent for newlines
set si
filetype plugin indent on " fix autoindent based on filetype
autocmd FileType json syntax match Comment +\/\/.\+$+
General keymaps for neovim
nnoremap <SPACE> <Nop>
let mapleader=" "
nnoremap <Leader>gb :Gblame<CR> " git blame
nmap <Leader>vpi :PlugInstall<cr>
nmap <Leader>vpu :PlugUpdate<cr>
nmap <Leader>vpc :PlugClean<cr> y <cr>
" FZF
nmap <Leader>p :ProjectFiles<cr>
nmap <Leader>s :Lines<cr>
nmap <Leader>f :Rg<cr>
noremap <Leader><C-J> <C-W><C-J> :q <cr>
noremap <Leader><C-H> <C-W><C-H> :q <cr>
noremap <Leader><C-L> <C-W><C-L> :q <cr>
noremap <Leader><C-K> <C-W><C-K> :q <cr>
nnoremap ; :
nnoremap gn :tabnew<cr>
map / <Plug>(incsearch-forward)
map ? <Plug>(incsearch-backward)
map g/ <Plug>(incsearch-stay)
TODO: fix it for neovim
" Source vimrc file on save
augroup autosourcing
autocmd!
autocmd BufWritePost .init.vim source %
augroup END
nmap <Leader>ev :tabedit $MYVIMRC<cr>
Configure coc-vim for ease of use
" tab completion
inoremap <silent><expr> <TAB>
\ pumvisible() ? "\<C-n>" :
\ <SID>check_back_space() ? "\<TAB>" :
\ coc#refresh()
inoremap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<C-h>"
function! s:check_back_space() abort
let col = col('.') - 1
return !col || getline('.')[col - 1] =~# '\s'
endfunction
if exists('*complete_info')
inoremap <expr> <cr> complete_info()["selected"] != "-1" ? "\<C-y>" : "\<C-g>u\<CR>"
else
inoremap <expr> <cr> pumvisible() ? "\<C-y>" : "\<C-g>u\<CR>"
endif
" navigation
nmap <silent> gd <Plug>(coc-definition)
nmap <silent> gy <Plug>(coc-type-definition)
nmap <silent> gi <Plug>(coc-implementation)
nmap <silent> gr <Plug>(coc-references)
" documentation
nnoremap <silent> K :call <SID>show_documentation()<CR>
function! s:show_documentation()
if (index(['vim','help'], &filetype) >= 0)
execute 'h '.expand('<cword>')
else
call CocAction('doHover')
endif
endfunction
" renaming
nmap <leader>rn <Plug>(coc-rename)
" Formatting selected code.
xmap <leader>f <Plug>(coc-format-selected)
nmap <leader>f <Plug>(coc-format-selected)
augroup mygroup
autocmd!
" Setup formatexpr specified filetype(s).
autocmd FileType typescript,json setl formatexpr=CocAction('formatSelected')
" Update signature help on jump placeholder.
autocmd User CocJumpPlaceholder call CocActionAsync('showSignatureHelp')
augroup end
" Map function and class text objects
" NOTE: Requires 'textDocument.documentSymbol' support from the language server.
xmap if <Plug>(coc-funcobj-i)
omap if <Plug>(coc-funcobj-i)
xmap af <Plug>(coc-funcobj-a)
omap af <Plug>(coc-funcobj-a)
xmap ic <Plug>(coc-classobj-i)
omap ic <Plug>(coc-classobj-i)
xmap ac <Plug>(coc-classobj-a)
omap ac <Plug>(coc-classobj-a)
" Use CTRL-S for selections ranges.
" Requires 'textDocument/selectionRange' support of LS, ex: coc-tsserver
nmap <silent> <C-s> <Plug>(coc-range-select)
xmap <silent> <C-s> <Plug>(coc-range-select)
" Add `:Format` command to format current buffer.
command! -nargs=0 Format :call CocAction('format')
" Add `:Fold` command to fold current buffer.
command! -nargs=? Fold :call CocAction('fold', <f-args>)
" Add `:OR` command for organize imports of the current buffer.
command! -nargs=0 OR :call CocAction('runCommand', 'editor.action.organizeImport')
" fix colors
hi CocInfoFloat guifg=#202020 guibg=#303030
" explore all things
nmap <space>e :CocCommand explorer<CR>
This file import the others and define some basic standards
" external files
source ~/.config/nvim/general.vim
source ~/.config/nvim/list.vim
source ~/.config/nvim/coc.vim
source ~/.config/nvim/keymaps.vim
source ~/.config/nvim/meta.vim
" current word
hi CurrentWord ctermfg=NONE ctermbg=NONE cterm=bold
hi CurrentWordTwins ctermfg=NONE ctermbg=NONE cterm=underline
" brackets
let g:rainbow_active = 0
" messages
let g:git_messenger_close_on_cursor_moved=0
" autoformat
noremap <F3> :Autoformat<CR>
" snippets
let g:UltiSnipsExpandTrigger = "<nop>"
" fzf
function! s:find_git_root()
return system('git rev-parse --show-toplevel 2> /dev/null')[:-2]
endfunction
command! ProjectFiles execute 'Files' s:find_git_root()
" ALE
let g:ale_fixers = {'javascript': ['standard', 'standard'], 'ruby': ['rubocop'], 'eruby': ['ruumba'], 'haml': ['haml-lint']}
let g:airline#extensions#ale#enabled = 1
highlight ALEWarning ctermbg=DarkGreen
highlight ALEWarning ctermfg=Black
" Autoclose
let g:closetag_filenames = '*.html.*,*.xhtml,*.phtml'
" Eruby
augroup twig_ft
au!
autocmd BufNewFile,BufRead *.html.erb set syntax=eruby
augroup END
" Testing
nmap <silent> t<C-n> :TestNearest<CR>
nmap <silent> t<C-f> :TestFile<CR>
nmap <silent> t<C-s> :TestSuite<CR>
nmap <silent> t<C-l> :TestLast<CR>
nmap <silent> t<C-g> :TestVisit<CR>
colorscheme zellner
I like to have CapsLock maped to Escape (Esc) bacause of Vim. Also, if I hold CapsLock, it works as another Control key (because Emacs). Also, my thinkpad has an US keyboard, which doesn’t play nice with portuguese characters.
#!/bin/bash
setxkbmap -layout us -variant altgr-intl -option caps:ctrl_modifier
xcape -e 'Caps_Lock=Escape;Control_L=Escape;Control_R=Escape'
I often keep the same wallpaper for a year or so. As I already use feh as an image viewer, being able to set a wallpeper with it makes a lot of sense.
#!/bin/bash
feh --bg-scale /home/ulisses/img/wallpaper.jpg
Everytime I dock/undock my thinkpad, I need to tell it which screens to use. There are a lot of ways to automate it, but I really enjoy being able to do it myself.
#!/bin/bash
isConnected=$(cat /sys/class/drm/card0-DP-2/status)
connected="connected"
if [ "$isConnected" == "$connected" ]; then
xrandr --output VGA-1 --off --output LVDS-1 --primary --mode 1366x768 --pos 306x1080 --rotate normal --output HDMI-3 --off --output HDMI-2 --off --output HDMI-1 --off --output DP-3 --off --output DP-2 --mode 1920x1080 --pos 0x0 --rotate normal --output DP-1 --off
else
xrandr --output VGA-1 --off --output LVDS-1 --primary --mode 1366x768 --pos 0x0 --rotate normal --output HDMI-3 --off --output HDMI-2 --off --output HDMI-1 --off --output DP-3 --off --output DP-2 --off --output DP-1 --off
fi
This piece of crap initializes everything I need
#!/bin/bash
slstatus &
setkbd
docked && setbg
picom &
Make everything executable
chmod +x /home/ulisses/.local/bin/setkbd
chmod +x /home/ulisses/.local/bin/setbg
chmod +x /home/ulisses/.local/bin/docked
chmod +x /home/ulisses/.local/bin/boot
Make then system accessible
sudo rm /usr/local/bin/setkbd
sudo rm /usr/local/bin/setbg
sudo rm /usr/local/bin/docked
sudo rm /usr/local/bin/boot
sudo ln -s /home/ulisses/.local/bin/setkbd /usr/local/bin/setkbd
sudo ln -s /home/ulisses/.local/bin/setbg /usr/local/bin/setbg
sudo ln -s /home/ulisses/.local/bin/docked /usr/local/bin/docked
sudo ln -s /home/ulisses/.local/bin/boot /usr/local/bin/boot
DWM has a patch that allows an autostart script to execute, I just run the boot script, but a lot of stuff could be done here.
#!/bin/bash
boot
chmod +x /home/ulisses/.dwm/autostart.sh
I often need to upload test images when I’m working on a webapp. Profile pictures, galleries, attachments… This script was born so I’ll never have to look for images again
#!/bin/bash
i=1;
die () {
echo >&2 "$@"
exit 1
}
echo $1 | grep -E -q '^[0-9]+$' || die "Tell me how many images you need"
while [[ $i -le $1 ]]
do
[[ $i -lt 10 ]] && a="0${i}" || a="$i"
FILE="${PWD}/${a}".jpg
if [ ! -f "$FILE" ]; then
convert -size 1920x1080 canvas:khaki "${a}.jpg"
fi
w=$(identify -format '%w' $a.jpg)
h=$(identify -format '%h' $a.jpg)
w=$((w/2))
h=$((h/2))
convert -pointsize 90 -fill black -draw 'text '"$w"','"$h"' "'"$a"'"' "${a}".jpg "${a}".jpg
echo "Created image ${a}.jpg"
(( i = i + 1 ))
done
chmod +x ~/.local/bin/rig