" vim: nowrap fdm=marker scriptencoding utf-8 if !has('nvim') unlet! skip_defaults_vim source $VIMRUNTIME/defaults.vim endif source ~/dotfiles/packages.vim " Personal preferences not set by sensible.vim let g:mapleader=',' set history=5000 set showcmd set nojoinspaces set complete-=t " set listchars=tab:▸\ ,eol:¬ set foldlevelstart=99 set noswapfile if has('mouse') set mouse=nv endif set diffopt=filler,vertical set ruler if has('nvim') set inccommand=nosplit endif " Define a group for autocommands augroup vimrc autocmd! augroup END function! FormatprgLocal(filter) if !empty(v:char) return 1 else let l:command = v:lnum.','.(v:lnum+v:count-1).'!'.a:filter echo l:command execute l:command endif endfunction if has('autocmd') augroup ragtag_filetypes autocmd! autocmd FileType markdown call RagtagInit() augroup END let g:pandoc_pipeline = 'pandoc --from=html --to=markdown' let g:pandoc_pipeline .= ' | pandoc --from=markdown --to=html' autocmd vimrc FileType html setlocal formatexpr=FormatprgLocal(pandoc_pipeline) endif " Colorscheme set termguicolors set background=light silent! colorscheme solarized8_light set hidden " Plugin configuration {{{1 " netrw.vim {{{2 let g:netrw_banner=0 " Don't show undo files in the explorer let g:netrw_list_hide='\.un\~$' " neomake {{{2 let g:neomake_javascript_enabled_makers = ['eslint'] if exists(':Neomake') autocmd! vimrc BufWritePost * Neomake endif " if emoji#available() " let g:neomake_warning_sign = { 'text': emoji#for('exclamation') } " let g:neomake_error_sign = { 'text': emoji#for('x') } " let g:neomake_info_sign = { 'text': emoji#for('8ball') } " let g:neomake_message_sign = { 'text': emoji#for('pencil2') } " endif " syntastic {{{2 let g:syntastic_mode_map = { \ 'mode': 'passive', \ 'active_filetypes': [ \ 'javascript' \ ], \ 'passive_filetypes': [ \ 'html', \ 'ruby' \ ] \ } let g:syntastic_ruby_checkers=['bx rubocop', 'mri'] nnoremap ZS :SyntasticCheck nnoremap ZT :SyntasticToggle " Vim-ruby {{{2 " let ruby_fold=1 " Vim-rspec {{{2 map t :w:call RunCurrentSpecFile() map s :w:call RunNearestSpec() map l :w:call RunLastSpec() map a :w:call RunAllSpecs() let g:rspec_command = 'Dispatch rspec {spec}' " Markdown {{{2 let g:markdown_fenced_languages = ['ruby', 'javascript'] " FIXME: " Markdown files have foldmethod=syntax when both of these options are set: " let ruby_fold=1 " let g:markdown_fenced_languages = ['ruby', 'javascript'] " to debug, run :verbose set foldmethod? " " Solarized8 {{{2 nnoremap B :exe "colors" (g:colors_name =~# "dark" \ ? substitute(g:colors_name, 'dark', 'light', '') \ : substitute(g:colors_name, 'light', 'dark', '') \ ) function! Solarized8Contrast(delta) let l:schemes = map(['_low', '_flat', '', '_high'], '"solarized8_".(&background).v:val') exe 'colors' l:schemes[((a:delta+index(l:schemes, g:colors_name)) % 4 + 4) % 4] endfunction nmap - :call Solarized8Contrast(-v:count1) nmap + :call Solarized8Contrast(+v:count1) " Ctlr-P {{{2 let g:ctrlp_jump_to_buffer = 0 let g:ctrlp_working_path_mode = 0 let g:ctrlp_user_command = 'find %s -type f' " Denite {{{2 " vim/after/plugin/denite.vim " Ragel {{{2 augroup ragel autocmd! autocmd BufNewFile,BufRead *.rl setfiletype ragel augroup END let g:ragel_default_subtype='ruby' " Mappings and commands {{{1 " Override defaults {{{2 nnoremap Q command! -nargs=0 -bang Qa qall! command! -nargs=0 -bang QA qall! " File opening {{{2 cnoremap %% getcmdtype() == ':' ? fnameescape(expand('%:h')).'/' : '%%' map ew :e %% map es :sp %% map ev :vsp %% map et :tabe %% " Prompt to open file with same name, different extension map er :e =expand("%:r")."." " Fix the & command in normal+visual modes {{{2 nnoremap & :&& xnoremap & :&& " Strip trailing whitespace {{{2 function! Preserve(command) let l:save = winsaveview() execute a:command call winrestview(l:save) endfunction command! TrimWhitespace call Preserve("%s/\\s\\+$//e") nmap _$ :TrimWhitespace " Visual line repeat {{{2 xnoremap . :normal . xnoremap @ :call ExecuteMacroOverVisualRange() function! ExecuteMacroOverVisualRange() echo '@'.getcmdline() execute ":'<,'>normal @".nr2char(getchar()) endfunction " Experimental mappings {{{2 nnoremap g" /\v<"> command! Path :call EchoPath() function! EchoPath() echo join(split(&path, ','), '\n') endfunction command! TagFiles :call EchoTags() function! EchoTags() echo join(split(&tags, ','), '\n') endfunction " let g:EasyClipUseSubstituteDefaults = 1 " nmap gs SubstituteOverMotionMap " nmap gss SubstituteLine " xmap gs p " let g:EasyClipUseCutDefaults = 0 " nmap x MoveMotionPlug " xmap x MoveMotionXPlug " nmap xx MoveMotionLinePlug nmap cp TransposeCharacters nnoremap TransposeCharacters xp \:call repeat#set("\TransposeCharacters") " ember-cli {{{2 command! -nargs=* Ember :echo system('ember ') if exists('*smartinput#define_rule') call smartinput#clear_rules() call smartinput#define_rule({ \'at': '{\%#', \'char': '{', \'input': '{}}', \'filetype': ['html.handlebars'] \ }) call smartinput#define_rule({ \'at': '\%#}}', \'char': '}', \'input': '', \'filetype': ['html.handlebars'] \ }) call smartinput#define_rule({ \'at': '}}\%#', \'char': '}', \'input': '', \'filetype': ['html.handlebars'] \ }) call smartinput#define_rule({ \'at': '{{\%#}}', \'char': '', \'input': '', \'filetype': ['html.handlebars'] \ }) call smartinput#define_rule({ \'at': '{{}}\%#', \'char': '', \'input': '', \'filetype': ['html.handlebars'] \ }) endif augroup javascript autocmd! autocmd FileType javascript setlocal suffixesadd+=.debug.js,.js augroup END let g:mustache_operators=0 augroup emoji_complete autocmd! autocmd FileType markdown setlocal completefunc=emoji#complete augroup END if exists(':terminal') tnoremap '"'.nr2char(getchar()).'pi' autocmd vimrc TermOpen * nnoremap I I autocmd vimrc TermOpen * nnoremap A A autocmd vimrc TermOpen * nnoremap C i autocmd vimrc TermOpen * nnoremap D i autocmd vimrc TermOpen * nnoremap cc i autocmd vimrc TermOpen * nnoremap dd i endif " https://github.com/neovim/neovim/pull/2076#issuecomment-76998265 nnoremap h nnoremap j nnoremap k nnoremap l vnoremap h vnoremap j vnoremap k vnoremap l inoremap h inoremap j inoremap k inoremap l cnoremap h cnoremap j cnoremap k cnoremap l if has('nvim') tnoremap h tnoremap j tnoremap k tnoremap l tnoremap endif