From 17f7e0c453b18f794f7a9a1c76fd6d55dae64deb Mon Sep 17 00:00:00 2001 From: William Carroll Date: Fri, 16 Dec 2016 11:00:08 -0500 Subject: [PATCH] Updates aliases and vim keybindings --- aliases.sh | 2 +- configs/.ctags | 15 ++++++++++ configs/.vimrc | 79 ++++++++++++++++++++++++++++++++++---------------- 3 files changed, 70 insertions(+), 26 deletions(-) diff --git a/aliases.sh b/aliases.sh index 1910156b5..36149a41a 100644 --- a/aliases.sh +++ b/aliases.sh @@ -8,7 +8,7 @@ alias grep="egrep" alias c="clear" -alias vi="vim" +alias vim="nvim" alias find="find -E" diff --git a/configs/.ctags b/configs/.ctags index 7899e7a21..c018567f2 100644 --- a/configs/.ctags +++ b/configs/.ctags @@ -7,6 +7,21 @@ --exclude=tmp +--langdef=Elixir +--langmap=Elixir:.ex.exs +--regex-Elixir=/^[ \t]*def(p?)[ \t]+([a-z_][a-zA-Z0-9_?!]*)/\2/f,functions,functions (def ...)/ +--regex-Elixir=/^[ \t]*defcallback[ \t]+([a-z_][a-zA-Z0-9_?!]*)/\1/c,callbacks,callbacks (defcallback ...)/ +--regex-Elixir=/^[ \t]*defdelegate[ \t]+([a-z_][a-zA-Z0-9_?!]*)/\1/d,delegates,delegates (defdelegate ...)/ +--regex-Elixir=/^[ \t]*defexception[ \t]+([A-Z][a-zA-Z0-9_]*\.)*([A-Z][a-zA-Z0-9_?!]*)/\2/e,exceptions,exceptions (defexception ...)/ +--regex-Elixir=/^[ \t]*defimpl[ \t]+([A-Z][a-zA-Z0-9_]*\.)*([A-Z][a-zA-Z0-9_?!]*)/\2/i,implementations,implementations (defimpl ...)/ +--regex-Elixir=/^[ \t]*defmacro(p?)[ \t]+([a-z_][a-zA-Z0-9_?!]*)\(/\2/a,macros,macros (defmacro ...)/ +--regex-Elixir=/^[ \t]*defmacro(p?)[ \t]+([a-zA-Z0-9_?!]+)?[ \t]+([^ \tA-Za-z0-9_]+)[ \t]*[a-zA-Z0-9_!?!]/\3/o,operators,operators (e.g. "defmacro a <<< b")/ +--regex-Elixir=/^[ \t]*defmodule[ \t]+([A-Z][a-zA-Z0-9_]*\.)*([A-Z][a-zA-Z0-9_?!]*)/\2/m,modules,modules (defmodule ...)/ +--regex-Elixir=/^[ \t]*defprotocol[ \t]+([A-Z][a-zA-Z0-9_]*\.)*([A-Z][a-zA-Z0-9_?!]*)/\2/p,protocols,protocols (defprotocol...)/ +--regex-Elixir=/^[ \t]*Record\.defrecord[ \t]+:([a-zA-Z0-9_]+)/\1/r,records,records (defrecord...)/ +--regex-Elixir=/^[ \t]*test[ \t]+\"([a-z_][a-zA-Z0-9_?! ]*)\"*/\1/t,tests,tests (test ...)/ + + --regex-ruby=/.*alias(_method)?[[:space:]]+:([[:alnum:]_=!?]+),?[[:space:]]+:([[:alnum:]_=!]+)/\2/f,function/ --regex-ruby=/(^|[:;])[ \t]*([A-Z][[:alnum:]_]+) *=/\2/c,class,constant/ --regex-ruby=/(^|;)[ \t]*(has_many|belongs_to|has_one|has_and_belongs_to_many)\(? *:([[:alnum:]_]+)/\3/f,function,association/ diff --git a/configs/.vimrc b/configs/.vimrc index 55b03752c..a40b3d629 100644 --- a/configs/.vimrc +++ b/configs/.vimrc @@ -21,9 +21,17 @@ Plugin 'Raimondi/delimitMate' " Displays git-tracked C*UD ops within gutter. Plugin 'airblade/vim-gitgutter' + +" Fuzzy-finder Plugin 'kien/ctrlp.vim' + +" Grep file contents Plugin 'mileszs/ack.vim' + +" JS support Plugin 'pangloss/vim-javascript' + +" Visual dir-tree navigation Plugin 'scrooloose/nerdtree' " Syntax Highlighting Support @@ -65,6 +73,9 @@ Plugin 'christoomey/vim-tmux-navigator' " Async `:make` for code linting etc. Plugin 'neomake/neomake' +" Color pack +Plugin 'flazz/vim-colorschemes' + call vundle#end() " required filetype plugin indent on " required @@ -94,6 +105,9 @@ let g:neomake_elixir_credo_maker = { " Enables the list of buffers. let g:airline#extensions#tabline#enabled = 1 +" Buffer numbers alongside files +let g:airline#extensions#tabline#buffer_nr_show = 1 + " Shows the filename only. let g:airline#extensions#tabline#fnamemod = ':t' @@ -101,7 +115,20 @@ let g:airline#extensions#tabline#fnamemod = ':t' let g:airline_powerline_fonts = 1 " Change Airline theme -let g:airline_theme = 'base16_google' +let g:airline_theme = 'hybrid' + + +" Jump to buffers. +nmap :1b +nmap :2b +nmap :3b +nmap :4b +nmap :5b +nmap :6b +nmap :7b +nmap :8b +nmap :9b + " It's the twenty-first century...no swaps. @@ -171,8 +198,7 @@ set mouse=a set hlsearch " Search for gibberish to clear the most recent search -" nnoremap / :set hlsearch! -noremap / /__wc_gibberish__ +noremap / :silent! /__wc_gibberish__/:echo "Search cleared." " Use custom-made snippets. @@ -207,10 +233,10 @@ inoremap A " Manage Vertical and Horizontal splits -nnoremap vs :vs -nnoremap vv :vs -nnoremap sp :sp -nnoremap ss :sp +nnoremap sl :vsl +nnoremap sh :vs +nnoremap sj :spj +nnoremap sk :sp " Move around splits with @@ -228,7 +254,7 @@ nnoremap q :bdelete " CtrlP config " Set default CtrlP command. -let g:ctrlp_cmd = 'CtrlP' +let g:ctrlp_cmd = 'CtrlPBuffer' " let g:ctrlp_cmd = 'CtrlPMRU' " Set runtime path @@ -268,8 +294,8 @@ nnoremap Y y$ " nnoremap k -" reload file after git changes -nnoremap :e +" Shorter binding for window rotations +nnoremap " Basic settings @@ -281,7 +307,7 @@ set shiftwidth=2 set background=dark syntax enable -colorscheme solarized +colorscheme hybrid set history=1000 set undolevels=1000 @@ -293,6 +319,10 @@ set t_Co=255 highlight Comment cterm=italic +" remap redo key that is eclipsed by `rotate` currently +nnoremap U :redo + + " Repeat last colon-command nnoremap ;; @: vnoremap ;; @: @@ -322,7 +352,7 @@ nnoremap V"+y vnoremap "+y inoremap "+pa -nnoremap o"+p +" nnoremap o"+p vnoremap "+p @@ -396,7 +426,7 @@ vnoremap // y/"N " trim trailing whitespace on save -autocmd BufWritePre *.{js,py,tpl,less,html,ex} :%s/\s\+$//e +autocmd BufWritePre *.{js,py,tpl,less,html,ex,exs,txt} :%s/\s\+$//e " set default font and size @@ -420,24 +450,25 @@ nnoremap t :call ExTestToggle() " Jumps from an Elixir module file to an Elixir test file. fun! ExTestToggle() - if expand('%:e') == "ex" - let l:test_file_name = expand('%:t:r') . "_test.exs" - let l:test_file_dir = substitute(expand('%:p:h'), "/lib/core/", "/lib/test/", "") - let l:full_test_path = join([test_file_dir, test_file_name], "/") + + let test_file_name = expand('%:t:r') . "_test.exs" + let test_file_dir = substitute(expand('%:p:h'), "/lib/", "/test/", "") + let full_test_path = join([test_file_dir, test_file_name], "/") e `=full_test_path` elseif match(expand('%:t'), "_test.exs") != -1 - let l:current_file_name = expand('%:t:r') - let l:offset_amt = strlen(current_file_name) - strlen("_test") - let l:module_file_name = strpart(current_file_name, 0, offset_amt) . ".ex" - let l:module_file_dir = substitute(expand('%:p:h'), "/test/", "/lib/core/", "") - let l:full_module_path = join([module_file_dir, module_file_name], "/") + + let test_file_name = expand('%:t:r') + let offset_amt = strlen(test_file_name) - strlen("_test") + let module_file_name = strpart(test_file_name, 0, offset_amt) . ".ex" + let module_file_dir = substitute(expand('%:p:h'), "/test/", "/lib/", "") + let full_module_path = join([module_file_dir, module_file_name], "/") e `=full_module_path` - endif + endif endfun @@ -449,5 +480,3 @@ fun! CreateNonExistingDirsAndFile() w endfun - -