Skip to content

Instantly share code, notes, and snippets.

@rhysd
Created February 12, 2014 05:12
Show Gist options
  • Save rhysd/8950382 to your computer and use it in GitHub Desktop.
Save rhysd/8950382 to your computer and use it in GitHub Desktop.
diff --git a/gitconfig b/gitconfig
index 660103e..8c7682d 100644
--- a/gitconfig
+++ b/gitconfig
@@ -52,3 +52,5 @@
email = lin90162@yahoo.co.jp
[push]
default = simple
+[github]
+ user = rhysd
diff --git a/vimrc b/vimrc
index 6ccd972..ad25eb2 100644
--- a/vimrc
+++ b/vimrc
@@ -453,6 +453,24 @@ function! s:open_calendar_app()
endif
endfunction
+" typo したファイル名を検出
+Autocmd BufWriteCmd *[,*] call s:write_check_typo(expand('<afile>'))
+function! s:write_check_typo(file)
+ let writecmd = 'write'.(v:cmdbang ? '!' : '').' '.a:file
+ if exists('b:write_check_typo_nocheck')
+ execute writecmd
+ return
+ endif
+ let prompt = "possible typo: really want to write to '" . a:file . "'?(y/n):"
+ let input = input(prompt)
+ if input ==# 'YES'
+ execute writecmd
+ let b:write_check_typo_nocheck = 1
+ elseif input =~? '^y\(es\)\=$'
+ execute writecmd
+ endif
+endfunction
+
" 基本マッピング {{{
" ; と : をスワップ
noremap : ;
@@ -590,12 +608,18 @@ inoremap <C-r>+ <C-o>:set paste<CR><C-r>+<C-o>:set nopaste<CR>
" コンマ後には空白を入れる
inoremap , ,<Space>
" 賢く行頭・非空白行頭・行末の移動
-nnoremap <silent>M :<C-u>call <SID>smart_move('g^')<CR>
-nnoremap <silent>H :<C-u>call <SID>smart_move('g0')<CR>
-nnoremap <silent>L :<C-u>call <SID>smart_move('g$')<CR>
+nnoremap <silent>M :<C-u>call <SID>rotate_horizontal_move('g^')<CR>
+nnoremap <silent>H :<C-u>call <SID>rotate_horizontal_move('g0')<CR>
+nnoremap <silent>L :<C-u>call <SID>rotate_horizontal_move('g$')<CR>
+nnoremap gM ^
+nnoremap gH 0
+nnoremap gL $
vnoremap M g^
vnoremap H g0
vnoremap L g$
+vnoremap gM ^
+vnoremap gH 0
+vnoremap gL $
" スクリーン内移動
nnoremap gh H
nnoremap gl L
@@ -678,7 +702,7 @@ AutocmdFT gitrebase nnoremap <buffer><C-f> :<C-u>Fixup<CR>
" 初回のみ a:cmd の動きをして,それ以降は行内をローテートする
let s:smart_line_pos = -1
-function! s:smart_move(cmd)
+function! s:rotate_horizontal_move(cmd)
let line = line('.')
if s:smart_line_pos == line . a:cmd
call <SID>rotate_in_line()
@@ -772,13 +796,11 @@ NeoBundle 'kana/vim-smartinput'
NeoBundle 'kana/vim-niceblock'
NeoBundle 'thinca/vim-scouter'
NeoBundle 'h1mesuke/vim-alignta'
-NeoBundle 'rhysd/gem-gist.vim'
NeoBundle 'rhysd/clever-f.vim', 'dev'
NeoBundle 'rhysd/unite-zsh-cdr.vim'
NeoBundle 'mhinz/vim-signify'
" NeoBundle 'ujihisa/vimshell-ssh'
" NeoBundle 'ujihisa/neco-look'
-
NeoBundle 'kana/vim-submode'
NeoBundle 'bling/vim-airline'
NeoBundle 'rhysd/vim-numberstar'
@@ -787,7 +809,6 @@ NeoBundle 'rhysd/vim-vspec-matchers'
NeoBundle 'ujihisa/unite-colorscheme'
NeoBundle 'rhysd/unite-locate'
NeoBundle 'rhysd/conflict-marker.vim'
-NeoBundle 'vim-jp/vital.vim'
NeoBundle 'rhysd/conflict-marker.vim'
NeoBundle 'rhysd/vim-window-adjuster'
@@ -865,14 +886,12 @@ NeoBundleLazy 'rhysd/vim-operator-evalruby', {
\ }
NeoBundleLazy 'rhysd/vim-operator-surround', {
+ \ 'depends' : 'tpope/vim-repeat',
\ 'autoload' : {
- \ 'mappings' : [
- \ '<Plug>(operator-surround-append)',
- \ '<Plug>(operator-surround-delete)',
- \ '<Plug>(operator-surround-replace)',
- \ ]
+ \ 'mappings' : '<Plug>(operator-surround-'
\ }
\ }
+
NeoBundleLazy 'deris/vim-operator-insert', {
\ 'autoload' : {
\ 'mappings' : [
@@ -918,6 +937,7 @@ NeoBundleLazy 'tyru/open-browser-github.vim', {
\ }
NeoBundleLazy 'rhysd/tmpwin.vim'
+NeoBundleLazy 'vim-jp/vital.vim'
NeoBundleLazy 'kannokanno/previm', {
\ 'depends' : 'tyru/open-browser.vim',
@@ -1026,8 +1046,6 @@ NeoBundleLazy 'tpope/vim-fugitive', {
\ }
\ }
-NeoBundleLazy 'tpope/vim-repeat'
-
NeoBundleLazy 'rbtnn/puyo.vim', {
\ 'autoload' : {
\ 'commands' : 'Puyo'
@@ -1075,7 +1093,6 @@ NeoBundleLazy 'thinca/vim-visualstar', {
\ }
\ }
-
NeoBundleLazy 'daisuzu/rainbowcyclone.vim', {
\ 'autoload' : {
\ 'mappings' : [
@@ -1089,6 +1106,12 @@ NeoBundleLazy 'daisuzu/rainbowcyclone.vim', {
\ },
\ }
+NeoBundleLazy 'mattn/gist-vim', {
+ \ 'depends' : 'mattn/webapi-vim',
+ \ 'autoload' : {
+ \ 'commands' : 'Gist',
+ \ }
+ \ }
" if_lua プラグイン
let s:meet_neocomplete_requirements = has('lua') && (v:version > 703 || (v:version == 703 && has('patch885')))
@@ -1592,6 +1615,15 @@ AutocmdFT haml inoremap <expr> k getline('.')[col('.') - 2] ==# 'k' ? "\<BS>%" :
AutocmdFT haml SetIndent 2
AutocmdFT javascript nnoremap <buffer><silent><Leader>no :<C-u>VimShellInteractive node<CR>
Autocmd BufRead,BufNew,BufNewFile *.ejs setlocal ft=html
+
+function! s:generate_html()
+ if &filetype ==# 'haml' && executable('haml')
+ let html = expand('%:p:r') . '.html'
+ let cmdline = join(['haml', expand('%'), '>', html], ' ')
+ call vimproc#system_bg(cmdline)
+ endif
+endfunction
+Autocmd BufWritePost *.haml call <SID>generate_html()
"}}}
" Markdown {{{
@@ -1763,7 +1795,6 @@ let g:neocomplete#force_overwrite_completefunc = 1
if !exists('g:neocomplete#force_omni_input_patterns')
let g:neocomplete#force_omni_input_patterns = {}
endif
-let g:neocomplete#force_omni_input_patterns.cpp = '[^.[:digit:] *\t]\%(\.\|->\)\|::'
" let g:neocomplete#force_omni_input_patterns.javascript = '[^. \t]\.\w*'
let g:neocomplete#force_omni_input_patterns.python = '\%([^. \t]\.\|^\s*@\|^\s*from\s.\+import \|^\s*from \|^\s*import \)\w*'
" neosnippet だけは短いキーワードでも候補に出す
@@ -3340,6 +3371,10 @@ endfunction
AutocmdFT python call <SID>jedi_settings()
" }}}
+" gist-vim
+let g:gist_open_browser_after_post = 1
+let g:gist_update_on_write = 0
+
" プラットフォーム依存な設定をロードする "{{{
function! SourceIfExist(path)
if filereadable(a:path)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment