Skip to content

Commit

Permalink
Copy /personal from my configs on Shopify repo
Browse files Browse the repository at this point in the history
  • Loading branch information
Lekë Mula committed Jan 22, 2023
1 parent 33954bc commit d518066
Show file tree
Hide file tree
Showing 15 changed files with 1,505 additions and 33 deletions.
1 change: 1 addition & 0 deletions .gitconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Add your preferred git settings here. This will overwrite anything in `core/configs/.gitconfig`.
5 changes: 5 additions & 0 deletions .gitignore_global
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,9 @@
# Vim
*.swp
*.swo
.undodir/

.DS_Store
tags.*
projections.json
.projections.json
10 changes: 10 additions & 0 deletions .vim/my-snippets/ruby.snippets
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
snippet testu "Create unit test class"
# typed: false
# frozen_string_literal: true

require "test_helper"

class ${1:Class}ListTest < ActiveSupport::TestCase
test$0
end
endsnippet
71 changes: 41 additions & 30 deletions .vimrc
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
" - `brew install the_silver_searcher`
"

""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Plugins
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Auto-install vim-plug: https://github.com/junegunn/vim-plug/wiki/tips#automatic-installation
let data_dir = has('nvim') ? stdpath('data') . '/site' : '~/.vim'
if empty(glob(data_dir . '/autoload/plug.vim'))
Expand Down Expand Up @@ -61,13 +64,20 @@ Plug 'sirver/ultisnips'
Plug 'honza/vim-snippets'
Plug 'liuchengxu/vim-which-key'
Plug 'tommcdo/vim-exchange'
Plug 'mattn/emmet-vim'
Plug 'ojroques/vim-oscyank', {'branch': 'main'}
Plug 'thaerkh/vim-workspace'
Plug 'maxmellon/vim-jsx-pretty'
Plug 'andrewradev/splitjoin.vim'
" Initialize plugin system
" - Automatically executes `filetype plugin indent on` and `syntax enable`.
call plug#end()

""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => General Config
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"https://vimdoc.sourceforge.net/htmldoc/intro.html#key-notation
autocmd StdinReadPre * let s:std_in=1
autocmd VimEnter * if argc() == 0 && !exists('s:std_in') | NERDTree | wincmd p | endif

" Set leader key
nnoremap <SPACE> <Nop>
Expand All @@ -81,14 +91,9 @@ let mapleader=" "
":nnoremap <C-r>n :set<Space>rnu!<CR>
":nnoremap <C-n> :set<Space>nu!<CR>

" Fix ctags relative path from ./tmp folder
set notagrelative
" Git gutter refresh rate
set updatetime=100
" Copy to clipboard after any yank (works even over SSH)
autocmd TextYankPost * if v:event.operator is 'y' && v:event.regname is '' | execute 'OSCYankReg "' | endif

" Yank/Copy to clipboard
vnoremap <C-c> "*y :let @+=@*<CR>
map <C-v> "+P
" Cursor change on edit mode
" replace the number after '\e[]'
" Ps = 0 -> blinking block.
Expand All @@ -101,8 +106,13 @@ map <C-v> "+P
let &t_SI = "\e[6 q"
let &t_EI = "\e[2 q"

" Workspace
let g:workspace_autocreate = 1
let g:workspace_session_directory = $HOME . '/.vim/sessions/'
let g:workspace_autosave_always = 1

""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Text Objects
" => Text Objects (documentation)
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" ]m - Go to start of "next method"
" ]M - Go to end of "next method"
Expand Down Expand Up @@ -142,7 +152,7 @@ let g:which_key_map.s.n = 'disable-spell-comletion'
let g:which_key_map.t = { 'name' : '+file-tree' }
nnoremap <leader>tt :NERDTreeToggle<CR>
let g:which_key_map.t.t = 'toggle-file-tree'
nnoremap <leader>tf :NERDTreeFind %<CR>
nnoremap <leader>tf :NERDTreeFind %<CR>zz
let g:which_key_map.t.f = 'file-tree-find-file'
nnoremap <leader><space> :Buffers<CR>
Expand All @@ -162,7 +172,7 @@ vnoremap g? y:execute "!open 'https://www.google.com/search?q=" . expand("<C-r>0
" Workaround for URL navigation on Shopify spin remote instance
nnoremap <leader>gx :execute "!open '" . shellescape("<cWORD>") . "'"<cr>
vnoremap <leader>gx y:execute "!open '" . shellescape("<C-r>0") . "'"<cr>
nmap <leader>gcp :let @*=join([expand('%'), line(".")], ':')<CR>
nnoremap <leader>gcp :let @"=join([expand('%'), line(".")], ':')<CR>:OSCYankReg "<CR>
let g:which_key_map.c = { 'name' : '+quickfix' }
nnoremap <leader>cc :cc<CR>
Expand Down Expand Up @@ -196,31 +206,33 @@ nnoremap <leader>ws :setlocal list!<cr>
" Snippets
imap <C-l> <Plug>(coc-snippets-expand)
vmap <C-j> <Plug>(coc-snippets-select)
let g:UltiSnipsSnippetDirectories=["my-snippets", "UltiSnips"]

""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Ruby/Rails
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
:let ruby_spellcheck_strings = 1
let g:autotagTagsFile = 'tmp/tags'
let g:autotagStartMethod='fork'
let g:rails_ctags_arguments=['-f tmp/tags', '-R', '--exclude=tmp', '--exclude=log', '--exclude=.git','--languages=Ruby', '.', '$(bundle list --paths)']
"ctags -f tmp/tags -R --exclude=tmp --exclude=log --exclude=.git . $(bundle list --paths)
"ctags -f tmp/tags -R --exclude=tmp --exclude=log --exclude=.git . $(bundle list --paths)
vmap <leader>gt :call I18nTranslateString()<CR>
vmap <leader>dt :call I18nDisplayTranslation()<CR>
" Yank/Copy fully quialified class name to clipboard
let g:yankfqn_register = '*'
nmap yfc :call YankFQN()<CR>:let @"=@*<CR>
let g:yankfqn_register = '"'
nmap <leader>gcc :call YankFQN()<CR>:OSCYankReg "<CR>
# https://github.com/tpope/vim-rails/issues/503#issuecomment-1158877143
" https://github.com/tpope/vim-rails/issues/503#issuecomment-1158877143
command AC :execute "e " . eval('rails#buffer().alternate()')
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Folding
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
:setlocal foldmethod=syntax
" https://stackoverflow.com/a/15087735
setlocal foldmethod=indent
set foldlevel=99
" :set foldmethod=indent
" :set foldlevel=99
:let ruby_fold = 0
set nofoldenable
" :let ruby_fold = 0
" set nofoldenable

""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Autocompletion
Expand All @@ -244,12 +256,6 @@ nnoremap <C-t>h <Esc>:tabprevious<CR>
nnoremap <C-t>l <Esc>:tabnext<CR>
nnoremap <C-t>t <Esc>:tabnew<CR>
" Remap splits navigation to just CTRL + hjkl
nnoremap <C-h> <C-w>h
nnoremap <C-j> <C-w>j
nnoremap <C-k> <C-w>k
nnoremap <C-l> <C-w>l
" Make adjusing split sizes a bit more friendly
noremap <silent> <C-j>j :resize +15<CR>
noremap <silent> <C-k>k :resize -15<CR>
Expand Down Expand Up @@ -296,7 +302,7 @@ let g:which_key_map.g = {
\ }
nmap ]h <Plug>(GitGutterNextHunk)
nmap [h <Plug>(GitGutterPrevHunk)
nnoremap <leader>gcu :CocCommand git.copyUrl<CR>
nnoremap <leader>gcu :let @" = execute('.GBrowse!')<CR>:OSCYankReg "<CR>
nnoremap <leader>gbl :Git blame<CR>
nnoremap <leader>gbr v:GBrowse<CR>
vnoremap <leader>gbr :GBrowse<CR>
Expand Down Expand Up @@ -342,7 +348,7 @@ let g:fzf_layout = { 'down': '40%' }
" 'previous-history' instead of 'down' and 'up'.
let g:fzf_history_dir = '~/.local/share/fzf-history'

command! -bang -nargs=? Ag call fzf#vim#ag(<q-args>, "--hidden --ignore .git", fzf#vim#with_preview(), <bang>0)
command! -bang -nargs=? Ag call fzf#vim#ag(<q-args>, "--hidden --ignore sorbet/rbi --ignore .git", fzf#vim#with_preview(), <bang>0)

" https://github.com/junegunn/fzf.vim/issues/27#issuecomment-608294881
" "Raw" version of ag; arguments directly passed to ag
Expand Down Expand Up @@ -376,15 +382,15 @@ command! -bang -nargs=+ -complete=dir AgIn call s:ag_in(<bang>0, <f-args>)
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => COC
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
let g:coc_global_extensions = ['coc-json', 'coc-git', 'coc-css', 'coc-html', 'coc-docker', 'coc-eslint', 'coc-snippets', 'coc-sql', 'coc-yank', 'coc-tsserver']
let g:coc_global_extensions = ['coc-json', 'coc-git', 'coc-css', 'coc-html', 'coc-docker', 'coc-eslint', 'coc-snippets', 'coc-sql', 'coc-yank', 'coc-tsserver', 'coc-solargraph']
" https://github.com/neoclide/coc.nvim#example-vim-configuration
" Some servers have issues with backup files, see #649.
set nobackup
set nowritebackup

" Having longer updatetime (default is 4000 ms = 4 s) leads to noticeable
" delays and poor user experience.
set updatetime=300
set updatetime=1000

" Always show the signcolumn, otherwise it would shift the text each time
" diagnostics appear/become resolved.
Expand Down Expand Up @@ -449,6 +455,8 @@ nmap <leader>rn <Plug>(coc-rename)
" Formatting selected code.
xmap <leader>f <Plug>(coc-format-selected)
nmap <leader>f <Plug>(coc-format-selected)
" Formatting current file
nmap <leader>fd :CocCommand editor.action.formatDocument<CR>
augroup mygroup
autocmd!
Expand Down Expand Up @@ -538,6 +546,9 @@ syntax enable
set encoding=UTF-8
let g:airline_powerline_fonts = 1
filetype plugin indent on
set autoindent
set cindent
set smartindent
set omnifunc=syntaxcomplete#Complete
" after a re-source, fix syntax matching issues (concealing brackets):
" https://github.com/ryanoasis/vim-devicons/issues/154#issuecomment-222032236
Expand Down
4 changes: 4 additions & 0 deletions aliases.zsh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
alias gcofzf='git checkout $(git branch --all | fzf)'
alias gcobfzf='git checkout -b $(git branch --all | fzf)'
alias gcob='git checkout -b'
alias mkdir='mkdir -p'
39 changes: 39 additions & 0 deletions antigen_bundles.zsh
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Additional oh-my-zsh plugins to include
# Default bundles included can be seen in core/default_bundles.zsh
# See https://github.com/ohmyzsh/ohmyzsh/wiki/Plugins for available oh-my-zsh plugins.
# See https://github.com/zsh-users/antigen/wiki/Commands#antigen-bundle for instructions on including custom plugins.
#
# Include a plugin with `antigen bundle <plugin-name>`.

# Do not wrap `antigen theme` or `antigen bundle` in conditions. Antigen has cache invalidation issues.
# If you want to conditionally load bundles, uncomment the following line:
# ANTIGEN_CACHE=false
# You can read more in https://github.com/zsh-users/antigen/wiki/Commands#antigen-theme for info on how to define
# custom caching keys for different environments, if you desire that. The cache speeds up your terminal startup, so
# try to avoid disabling the cache unless you have no other choice.

# Staples theme: https://github.com/romkatv/powerlevel10k
antigen theme romkatv/powerlevel10k

# https://github.com/zsh-users/zsh-autosuggestions
antigen bundle zsh-users/zsh-autosuggestions
# https://github.com/zsh-users/zsh-syntax-highlighting
antigen bundle zsh-users/zsh-syntax-highlighting
# https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins/aliases
antigen bundle aliases
# https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins/git
antigen bundle git
# https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins/bundler
antigen bundle bundler
# https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins/dotenv
antigen bundle dotenv
# https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins/macos
antigen bundle macos
# https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins/rake
antigen bundle rake
# https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins/rbenv
antigen bundle rbenv
# https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins/ruby
antigen bundle ruby
# https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins/rails
antigen bundle rails
75 changes: 75 additions & 0 deletions bin/shopify_projections.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# frozen_string_literal: true

require "json"

result = {}

components = Dir.glob('**/app')
.delete_if { |dir | dir.start_with?('app/assets/') }
.delete_if { |dir | dir.start_with?('gems/') }
.delete_if { |dir | dir.start_with?('sorbet/') }
.map { |dir| dir.split("/")[1..-2] }

%w[ts js].each do |x|
result["*.test.#{x}"] = {
alternate: %w[ts js].map do |y|
[
"{}.#{y}",
"{dirname|dirname}{basename}.#{y}",
]
end.flatten,
}
result["*.#{x}"] = {
alternate: %w[ts js].map do |y|
[
"{}.test.#{y}",
"{dirname}/__tests__/{basename}.test.#{y}",
]
end.flatten,
}
end

template = [
"# frozen_string_literal: true",
"# typed: true",
"",
"class {camelcase|capitalize|colons}",
"end",
]

components.each do |component|
component = component.join("/")
warn component

result["components/#{component}/app/*.rb"] = {
"alternate": [
"components/#{component}/test/{}_test.rb",
"components/#{component}/test/unit/{}_test.rb",
],
"type": "source",
"template": template,
}
result["components/#{component}/app/models/*.rb"] = {
"alternate": [
"components/#{component}/test/{}_test.rb",
"components/#{component}/test/unit/{}_test.rb",
],
"type": "model",
"template": template,
}
result["components/#{component}/test/unit/*_test.rb"] = {
"alternate": [
"components/#{component}/app/models/{}.rb",
"components/#{component}/app/{}.rb",
],
"type": "test",
"template": "",
}
result["components/#{component}/test/*_test.rb"] = {
"alternate": "components/#{component}/app/{}.rb",
"type": "test",
"template": "",
}
end

puts result.to_json
2 changes: 2 additions & 0 deletions coc-settings.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
{
"html.format.templating": true,
"coc.preferences.formatOnType": true,
"languageserver": {
"ruby-lsp": {
"command": "bundle",
Expand Down
Loading

0 comments on commit d518066

Please sign in to comment.