Last active
May 29, 2017 12:58
-
-
Save chew-z/606622a9d5dc121edee9c03920abc21b to your computer and use it in GitHub Desktop.
My today's .vimrc state
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" Only MacVim-related options here | |
" | |
" | |
" start in fullscreen mode | |
" set fullscreen | |
set guifont=Roboto\ Mono\ Medium:h14 | |
" This is best with iTerm window on left and MacVim on right pane (on my screen) | |
set columns=125 | |
set lines=50 | |
set antialias | |
highlight Comment gui=italic | |
set linespace=2 | |
if (exists('+colorcolumn')) | |
set colorcolumn=80 | |
highlight ColorColumn ctermbg=9 | |
endif | |
" show tabs OS style (MacVim) | |
" set guioptions+=e | |
" vim-workspace view as default | |
" toggle vim-workspace and MacVim tab view with <Ctrl-Tab>, see below | |
set guioptions-=e | |
" | |
set showtabline=2 | |
" remove ugly scrollbars (MacVim) | |
set guioptions-=r | |
" | |
" Disable the print key for MacVim | |
macmenu &File.Print key=<nop> | |
" | |
" indent with Cmd-[ Cmd-] just like Sublime Text | |
noremap <D-[> << | |
noremap <D-]> >> | |
vnoremap <D-[> <gv | |
vnoremap <D-]> >gv | |
" | |
" Look up word in Dictionary.app | |
nnoremap <D-d> :Silent open dict://<cword><CR><CR> | |
inoremap <D-d> <C-\><C-o> :Silent open dict://<cword><CR><CR> | |
" reload ~/.vimrc Cmd+R like in browser | |
noremap <D-r> :source $MYVIMRC<CR> | |
" | |
" | |
" Jump between tabs - NOT in VIM (Cmd-Tab is system windos toggle) | |
noremap <M-Tab> gt | |
" | |
" Toggle between vim-workspace view and MacVim view | |
nnoremap <M-Tab> :call ToggleWorkspace()<CR> | |
" | |
" Close current buffer | |
" macmenu &File.Close key=<nop> | |
" noremap <D-w> :WSClose<CR> | |
" | |
" close buffer ignoring changes - (D-W == S-D-w) | |
" macmenu &File.Close\ Window key=<nop> | |
" nnoremap <D-W> :WSClose!<CR> | |
" close all buffers but current | |
nnoremap <M-w> :WSBufOnly<CR> | |
" close all buffers but current - enforce | |
nnoremap <M-W> :WSBufOnly!<CR> | |
" | |
" Open new tab. Uses the current buffer to load into the new tab's window | |
" Cmd-w in MacVim closes current buffer - same as <C-t> | |
macmenu &File.New\ Tab key=<nop> | |
nnoremap <D-t> :WSTabNew<CR> | |
" | |
" Set fzf launcher script for MacVim | |
let g:fzf_launcher = "/usr/local/bin/fzf_MacVim %s" | |
" for MacVim with script we have to escape '!' character twice (no joking) in --glob option | |
" - otherwise we getting errors caused by bash/zsh expansion of ! | |
command! -bang -nargs=* Rg | |
\ call fzf#vim#grep( | |
\ "rg --column --color=always --no-heading --smart-case --hidden --follow --glob '\\!.git/*' ".shellescape(<q-args>), 1, | |
\ <bang>0 ? fzf#vim#with_preview('up:60%') | |
\ : fzf#vim#with_preview('right:50%:hidden', '?'), | |
\ <bang>0) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" set shell explicte | |
set shell=/usr/local/bin/zsh | |
augroup vimrc | |
" Remove all vimrc autocommands | |
autocmd! | |
" change to directory of current file automatically | |
autocmd BufEnter * silent! lcd %:p:h | |
augroup END | |
" ---- Language, spelling, dictionary --- | |
set spelllang= | |
" if spelllang is set <C-x><C-s> to get spelling suggestions | |
set spell | |
" dictionary autocomplete <C-x><C-k> | |
" set dictionary+=/usr/share/dict/words | |
" Large English language Moby Thesaurus - <C-x><C-t> [<C-y> <C-e>] | |
" Thesaurus function in VIM is a nonsense - use Thesauri as omnifunc | |
" set thesaurus+=~/.vim/spell/en.mobythes.txt | |
" Thesauri (using ripgrep under hood) - <C-x><C-u> or <Tab> in some filetypes | |
" let g:mobythesaurus_file=$HOME . "/.vim/spell/en.mobythes.txt" | |
" set completefunc=CompleteThesauri | |
" | |
" ---- source sub modules ---- | |
" functions | |
source ~/.vimrc_functions | |
" simple settings | |
source ~/.vimrc_sets | |
" key mappings | |
source ~/.vimrc_keys | |
" source .vimrc after save | |
" autocmd bufwritepost .vimrc source $MYVIMRC | |
" When switch to other tab or to other app leave insert mode | |
au FocusLost,TabLeave * call feedkeys("\<C-\>\<C-n>") | |
" add Plugins and their settings | |
source ~/.vimrc_plugins | |
" | |
" ---- Color scheme ---- | |
" | |
" let g:seoul256_background = 235 | |
" colo seoul256 | |
" | |
" start with colorscheme adequate to daylight | |
" /.vim/autoload/sunset.vim | |
" | |
let g:sunset_latitude=5.88 " Pulau Weh aprox. | |
let g:sunset_longitude=95.25 " | |
let g:sunset_utc_offset = 7 " WIB (Asia/Jakarta) | |
let g:sunset_hm = sunset#hm(strftime('%H'), strftime('%M')) | |
let g:sunset_sunrise = sunset#calculate(1) | |
let g:sunset_sunset = sunset#calculate(0) | |
if (g:sunset_hm > g:sunset_sunset) | |
Mirage | |
elseif (g:sunset_hm > g:sunset_sunrise) | |
Day | |
elseif (g:sunset_hm < g:sunset_sunrise) | |
Night | |
endif | |
" | |
" hi clear SpellBad | |
" hi SpellBad cterm=underline | |
" if (v:version >= 700) | |
" highlight SpellBad ctermfg=Red term=Reverse guisp=Red gui=undercurl ctermbg=White | |
" highlight SpellCap ctermfg=Green term=Reverse guisp=Green gui=undercurl ctermbg=White | |
" highlight SpellLocal ctermfg=Cyan term=Underline guisp=Cyan gui=undercurl ctermbg=White | |
" highlight SpellRare ctermfg=Magenta term=underline guisp=Magenta gui=undercurl ctermbg=White | |
" endif |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" Functions used in .vimrc | |
" Toggle languages Pl/En/Off | |
let g:myLangList = [ "", "pl", "en"] | |
function! ToggleSpellLang() | |
if !exists( 'b:myLang') | |
if &spell | |
let b:myLang = index(g:myLangList, &spelllang) | |
else | |
let b:myLang = 0 | |
endif | |
endif | |
let b:myLang += 1 | |
if b:myLang >= len(g:myLangList) | let b:myLang = 0 | endif | |
if b:myLang == 0 | |
setlocal nospell | |
else | |
execute "setlocal spell spelllang =" . get(g:myLangList, b:myLang, "en") | |
endif | |
if b:myLang == 1 | |
let g:mobythesaurus_file=$HOME . "/.vim/spell/pl.thes.txt" | |
elseif b:myLang == 2 | |
let g:mobythesaurus_file=$HOME . "/.vim/spell/en.mobythes.txt" | |
endif | |
" highlight clear SpellBad | |
" highlight SpellBad cterm=underline | |
echom "language:" get(g:myLangList, b:myLang) | |
endfunction | |
" brighten/dim background - a'la macOS dim screen function keys | |
" 233 (darkest) ~ 239 (lightest) 252 (darkest) ~ 256 (lightest) | |
function! Seoul256Brighten() | |
if g:seoul256_background == 239 | |
let g:seoul256_background = 252 | |
elseif g:seoul256_background == 256 | |
let g:seoul256_background = 256 | |
else | |
let g:seoul256_background += 1 | |
endif | |
colo seoul256 | |
endfunction | |
" | |
function! Seoul256Dim() | |
if g:seoul256_background == 252 | |
let g:seoul256_background = 239 | |
elseif g:seoul256_background == 233 | |
let g:seoul256_background = 233 | |
else | |
let g:seoul256_background -= 1 | |
endif | |
colo seoul256 | |
endfunction | |
" Completor plugin | |
function! ToggleCompletorAutoTrigger() | |
if g:completor_auto_trigger == 1 | |
let g:completor_auto_trigger = 0 | |
else | |
let g:completor_auto_trigger = 1 | |
endif | |
endfunction | |
" | |
" define new silent command | |
" http://vi.stackexchange.com/questions/1942/how-to-execute-shell-commands-silently | |
" | |
command! -nargs=1 Silent execute ':silent !'.<q-args> | execute ':redraw!' | |
" | |
" Prose vs. Code | |
" | |
command! Night | |
\ let g:ayucolor = 'dark' | | |
\ let g:limelight_conceal_guifg = '#0F1419' | | |
\ colorscheme ayu | |
" | |
command! Day | |
\ let g:ayucolor = 'light' | | |
\ let g:limelight_conceal_guifg = '#FAFAFA' | | |
\ colorscheme ayu | |
" | |
command! Mirage | |
\ let g:ayucolor = 'mirage' | | |
\ let g:limelight_conceal_guifg = '#212733' | | |
\ colorscheme ayu | |
" | |
" Toggle focus for prose writing. Toggle Goyo independently but goyo_leave() | |
" resets some s:focus() settings... like fulscreen, ALE, showbreak etc. | |
" | |
function! s:focus() | |
if !exists( "g:focus" ) | |
let g:focus = 0 | |
endif | |
if g:focus == 0 | |
let g:focus = 1 | |
set nonumber | |
set noshowmode | |
set noshowcmd | |
let &showbreak="↳ " | |
autocmd! InsertLeave * :set norelativenumber | |
ALEDisable | |
if has('gui_macvim') | |
" NOT prefer native fullscreen in MacVim Preferences | |
" :h fuoptions - vim will remember and return to window position | |
set guifont=Courier\ Prime:h18 | |
set fuoptions = "maxvert, maxhorz" | |
" set lines=45 | |
set columns=125 | |
set fullscreen | |
" use <Cmd-=> <Cmd--> to resize font. Works better. | |
endif | |
else | |
let g:focus = 0 | |
set number | |
set showmode | |
set showcmd | |
let &showbreak="" | |
autocmd! InsertLeave * :set relativenumber | |
ALEEnable | |
if has('gui_macvim') | |
set guifont=Roboto\ Mono\ Medium:h14 | |
set fuoptions = "maxvert, maxhorz" | |
" set lines=45 | |
set nofullscreen | |
set columns=125 | |
endif | |
endif | |
endfunction | |
" | |
" :Focus and next :Goyo works best. | |
command! Focus call <SID>focus() | |
" | |
" Marriage of fzf and completor plugin | |
" https://nondev.io/Fuzzy-completion-in-Vim | |
" | |
let g:fuzzyfunc = 'completor#completefunc' | |
" let g:fuzzyfunc = &omnifunc | |
" | |
function! FuzzyCompleteFunc(findstart, base) | |
let Func = function(get(g:, 'fuzzyfunc', &omnifunc)) | |
let results = Func(a:findstart, a:base) | |
if a:findstart | |
return results | |
endif | |
if type(results) == type({}) && has_key(results, 'words') | |
let l:words = [] | |
for result in results.words | |
call add(words, result.word . ' ' . result.menu) | |
endfor | |
elseif len(results) | |
let l:words = results | |
endif | |
if len(l:words) | |
let result = fzf#run({ 'source': l:words, 'options': printf('--query "%s" +s', a:base) }) | |
" let result = fzf#run({ 'source': l:words, 'down': '~40%', 'options': printf('--query "%s" +s', a:base) }) | |
if empty(result) | |
return [ a:base ] | |
endif | |
return [ split(result[0])[0] ] | |
else | |
return [ a:base ] | |
endif | |
endfunction | |
function! FuzzyFuncTrigger() | |
setlocal completefunc=FuzzyCompleteFunc | |
setlocal completeopt=menu | |
call feedkeys("\<c-x>\<c-u>", 'n') | |
endfunction | |
inoremap <C-x><C-j> <C-o>:call FuzzyFuncTrigger()<CR> | |
" | |
" Clever Tab | |
" | |
function! CleverTab() | |
if pumvisible() | |
return "\<C-n>" | |
endif | |
" if strpart( getline('.'), 0, col('.')-1 ) =~ '^\s*$' | |
" if col('.') == 1 || strpart(getline('.'), col('.') - 2, 2) !~ '^\w' | |
let l:col = col('.') - 1 | |
if !l:col || getline('.')[l:col - 1] !~# '\k' | |
return "\<Tab>" | |
elseif exists('&omnifunc') && &omnifunc ==# 'CompleteThesauri' | |
return "\<C-x>\<C-o>" | |
elseif exists('&completefunc') && &completefunc ==# 'completor#completefunc' | |
return "\<C-x>\<C-u>\<C-p>" | |
elseif exists('&completefunc') && &completefunc != '' | |
return "\<C-x>\<C-u>" | |
else | |
return "\<C-n>" | |
endif | |
endfunction | |
" | |
" Change statusline color when enetering Insert mode | |
" | |
function! InsertStatuslineColor() | |
if g:ayucolor==# 'dark' | |
hi statusline guibg=#253340 | |
elseif g:ayucolor==# 'light' | |
hi statusline guibg=#F0EEE4 | |
elseif g:ayucolor==# 'mirage' | |
hi statusline guibg=#343F4C | |
endif | |
endfunction | |
" | |
function! NormalStatuslineColor() | |
if g:ayucolor==# 'dark' | |
hi statusline guibg=#0F1419 | |
elseif g:ayucolor==# 'light' | |
hi statusline guibg=#FAFAFA | |
elseif g:ayucolor==# 'mirage' | |
hi statusline guibg=#212733 | |
endif | |
endfunction | |
" | |
au InsertEnter * call InsertStatuslineColor() | |
au InsertLeave * call NormalStatuslineColor() | |
" | |
" Helper function for vim-workspace plugin (for ayo colors) | |
" | |
function! g:WorkspaceSetCustomColors() | |
if !exists('g:ayucolor') | let ayucolor="light" | endif | |
if g:ayucolor==# 'dark' | |
highlight WorkspaceBufferCurrent guifg=#FFEE99 guibg=#253340 | |
highlight WorkspaceTabCurrent guifg=#FFEE99 guibg=#253340 | |
highlight WorkspaceBufferActive guifg=#FF7733 guibg=#0F1419 | |
highlight WorkspaceBufferHidden guifg=#5C6773 guibg=#0F1419 | |
highlight WorkspaceTabHidden guifg=#5C6773 guibg=#0F1419 | |
highlight WorkspaceFill guifg=#5C6773 guibg=#0F1419 | |
elseif g:ayucolor==# 'light' | |
highlight WorkspaceBufferCurrent guifg=#A37ACC guibg=#F0EEE4 | |
highlight WorkspaceTabCurrent guifg=#A37ACC guibg=#F0EEE4 | |
highlight WorkspaceBufferActive guifg=#FF7733 guibg=#FAFAFA | |
highlight WorkspaceBufferHidden guifg=#ABB0B6 guibg=#FAFAFA | |
highlight WorkspaceTabHidden guifg=#ABB0B6 guibg=#FAFAFA | |
highlight WorkspaceFill guifg=#ABB0B6 guibg=#FAFAFA | |
elseif g:ayucolor==# 'mirage' | |
highlight WorkspaceBufferCurrent guifg=#D4BFFF guibg=#343F4C | |
highlight WorkspaceTabCurrent guifg=#D4BFFF guibg=#343F4C | |
highlight WorkspaceBufferActive guifg=#FFAE57 guibg=#212733 | |
highlight WorkspaceBufferHidden guifg=#5C6773 guibg=#212733 | |
highlight WorkspaceTabHidden guifg=#5C6773 guibg=#212733 | |
highlight WorkspaceFill guifg=#5C6773 guibg=#212733 | |
endif | |
endfunction | |
" | |
function! ToggleWorkspace() | |
if !exists('g:workspace_tabs') | let g:workspace_tabs = 0 | endif | |
if g:workspace_tabs | |
let g:workspace_tabs = 0 | |
set guioptions-=e | |
else | |
let g:workspace_tabs = 1 | |
set guioptions+=e | |
endif | |
endfunction | |
" | |
" | |
" I map paste clipboard to Ctrl-v but also need <C-v> prefix for inputing special chars | |
" Toggle with F11 | |
if !exists('g:toggle_paste') | let g:toggle_paste = 0 | endif | |
function! TogglePaste() | |
if g:toggle_paste | |
let g:toggle_paste = 0 | |
inoremap <C-v> <C-r><C-o>+ | |
echom '<C-v> in paste mode' | |
else | |
let g:toggle_paste = 1 | |
inoremap <C-v> <C-v> | |
echom '<C-v> in special key mode' | |
endif | |
endfunction | |
" | |
" | |
" https://jordanelver.co.uk/blog/2015/05/27/working-with-vim-colorschemes/ | |
" place a cursor over element and check which groups are being applied | |
" | |
function! SynStack() | |
if exists('*synstack') | |
echo map(synstack(line('.'), col('.')), 'synIDattr(v:val, "name")') | |
endif | |
endfunction | |
" | |
nnoremap <C-h> :call SynStack()<CR> | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" ---- Key mappings ---- | |
" | |
" Change mapleader to Space! | |
let mapleader = "\<Space>" | |
" | |
" Do time out on mappings and others | |
set timeout | |
" Wait {num} ms before timing out a mapping | |
augroup FastEsc | |
autocmd InsertEnter * :set timeoutlen=10 | |
autocmd InsertLeave * :set timeoutlen=600 | |
augroup END | |
" | |
" | |
" move with arrows by display lines rather then actual lines | |
" <Home> = <Fn-Left> <End> = <Fn-Right> - beg/end of visual line | |
" <Left> <Right> - move by word | |
vnoremap <Home> g^ | |
vnoremap <End> g$ | |
vnoremap <Left> b | |
vnoremap <Right> e | |
vnoremap <Up> gk | |
vnoremap <Down> gj | |
nnoremap <Home> g^ | |
nnoremap <End> g$ | |
nnoremap <Left> b | |
nnoremap <Right> e | |
nnoremap <Up> gk | |
nnoremap <Down> gj | |
inoremap <Left> <C-c>Bi | |
inoremap <Right> <C-c>Ea | |
" | |
" indenting - also with Sublime Text style Cmd-] Cmd-[ in ~/.gvimrc | |
vnoremap < <gv | |
vnoremap > >gv | |
" | |
" Del, Copy, Paste | |
" | |
" This should be prefered over Cmd-C/X/V as this is real paste | |
" with Cmd-V the text is inserted in the buffer as if typed and re-intended | |
" https://vi.stackexchange.com/questions/730 | |
" | |
" quietly delete visual selection (copy to black register) | |
" with Del key (in iTerm Del must be mapped as ^? not ^H) | |
vnoremap <Del> "_d | |
" copy/yank selected to system clipboard | |
vnoremap <C-c> "+y | |
" cut to system clipboard | |
vnoremap <C-x> "+d | |
" and paste | |
set pastetoggle=<F10> | |
nnoremap <C-v> <F10>"+p<F10> | |
vnoremap <C-v> <F10>"+p<F10> | |
" :h i_ctrl-r | |
inoremap <C-v> <C-r><C-o>+ | |
" unmap <C-v> in insert mode with <F11> | |
noremap <F11> :call TogglePaste()<CR> | |
" | |
" Quit fucking visual mode to insert (no delay) | |
vnoremap i <C-c>i | |
" | |
" | |
" Tabs and buffer including vim-workspace mappings | |
" | |
" Jump between tabs | |
" noremap <C-Tab> :tabnext<CR> | |
" noremap <S-C-Tab> :tabprevious<CR> | |
" WON'T WORK in VIM but try Ctrl-PgUp/PgDown (on Macbook Fn-ArrowUp/Down) | |
" | |
" open current buffer in new tab | |
nnoremap <C-t> :WSTabNew<CR> | |
" | |
" Next/Prev buffer | |
nnoremap <C-Tab> :WSNext<CR> | |
inoremap <C-Tab> <C-o>:WSNext<CR> | |
" VIM does not allow mapping <C-Tab> as Tab is really just Ctrl-I. | |
nnoremap <Tab> :WSPrev<CR> | |
" close the current buffer. If is has unsaved changes, an error will be shown, and the buffer will stay open | |
nnoremap <C-b> :WSClose<CR> | |
" With <Alt-w> close all buffers but current | |
nnoremap w :WSBufOnly<CR> | |
"With <Alt-W> close all buffers but current - enforce! | |
nnoremap W :WSBufOnly!<CR> | |
" | |
" (using ESC-w == Alt-w in iTerm2 with Option key as +ESC). | |
" The trick here is that you cannot input this using <C-v> in MacVim only in VIM | |
" as MacVim sees Alt-key differently then iTerm2/VIM. | |
" | |
nnoremap <leader>o :only<CR> | |
inoremap <leader>o <C-o>:only<CR> | |
" | |
" Quit VIM with Ctrl-q | |
" | |
" This helps Ctrl-Q to reach VIM. | |
" https://stackoverflow.com/questions/7883803 | |
silent !stty -ixon > /dev/null 2>/dev/null | |
nnoremap <C-q> :x<CR> | |
inoremap <C-q> <ESC>:x<CR> | |
" | |
" do not enter Ex mode accidentally, enetr Command mode instead | |
nnoremap Q q: | |
" | |
" press <space> twice in normal mode to save file [Cmd+S also works in MacVim] | |
nnoremap <leader><leader> :w<CR> | |
" | |
" press <ESC> twice in insert mode to quit to normal mode and save file | |
inoremap <ESC> <ESC>:w<CR> | |
" | |
" close all splits except one with cursor | |
nnoremap <leader>w :on<CR> | |
" | |
" Switch CWD to the directory of the open buffer | |
noremap <leader>cd :cd %:p:h<cr>:pwd<cr> | |
" | |
" show buffers list and select (chose number or part of name) | |
nnoremap <leader>b :ls<CR>:b<Space> | |
" | |
" find and replace | |
" https://elliotekj.com/2016/08/30/better-find-and-replace-in-vim/ | |
noremap <leader>r :%s///cg<left><left><left> | |
" noremap <leader>rl :s///g<left><left> | |
" | |
" For editing markdown files (and Vim-Notes). | |
" Convert selected text to link (url comes from OSX clipboard) | |
" 'i' like image 'l' like link | |
" `> `< - go to end, beggining of selection, "*p - insert OSX clipboard | |
vnoremap <leader>l <ESC>`<i[<ESC>`>la](<C-R><C-R>*)<ESC> | |
vnoremap <leader>i <ESC>`<i<ESC> | |
" | |
" remove last search highlight by hitting return. | |
" n will find the next occurrence (which will be highlighted again) | |
nnoremap <silent> <CR> :nohlsearch<CR><CR> | |
" | |
" Toggle languages Pl/En/Off | |
nnoremap <C-l> :call ToggleSpellLang()<CR> | |
inoremap <C-l> <C-\><C-o>:call ToggleSpellLang()<CR> | |
" | |
" Spelling suggestions http://stackoverflow.com/questions/5312235 | |
nnoremap <leader>s ea<C-X><C-S> | |
" | |
"Files - fzf | |
" nnoremap <leader>o :Files<cr> | |
nnoremap <C-p> :Files<cr> | |
" | |
" Open url with Choosy - it depends on Choosy settings also but works well | |
" Can be made infinitely more complicated/sofisticated (with Choosy logic for | |
" handling urls). | |
function! LinkOpen() | |
let word = expand("<cWORD>") | |
" exe "! open -a Chromium_ " . word | |
" exe "! open 'x-choosy://best.running/" . word . "'" | |
exe "! open 'x-choosy://open/" . word . "'" | |
endfunction | |
" Ctrl+click to open | |
nnoremap <C-LeftMouse> <LeftMouse> :call LinkOpen()<CR> | |
" | |
" brighten/dim background - a'la macOS dim screen function keys | |
" 233 (darkest) ~ 239 (lightest) 252 (darkest) ~ 256 (lightest) | |
nnoremap <F1> :call Seoul256Dim()<CR> | |
nnoremap <F2> :call Seoul256Brighten()<CR> | |
" | |
" Insert current date under cursor using Fn4 (also in insert mode) | |
" Maping used mostly in Vim Notes | |
nnoremap <F4> "=strftime("%a, %d %b %Y")<CR>P | |
inoremap <F4> <C-R>=strftime("%a, %d %b %Y")<CR> | |
" | |
" | |
" <Space>d [Cmd+D in MacVim] on top of a word to look it up in Dictionary.app | |
" nmap <leader>d :Silent open dict://<cword><CR><CR> | |
" nnoremap <leader>d "dyiw:call MacDict(@d)<CR> | |
" Opens a new tab with the current buffer's path | |
" Super useful when editing files in the same directory | |
" | |
" noremap <leader>te :tabedit <c-r>=expand("%:p:h")<cr>/ | |
" mappings for TwitVim | |
" nnoremap <F3> :FriendsTwitter<CR> | |
" nnoremap <S-F3> :ListTwitter forex-i<CR> | |
" nnoremap <A-F3> :ListTwitter forex-ii<CR> | |
" nnoremap <D-F3> :ListTwitter macro<CR> | |
" <Leader><Leader> - refreshes the timeline. See |:RefreshTwitter|. | |
" <C-PgUp> / <C-PgDown> serves 2nd (older) page of list/timeline and back | |
" | |
" Folds - toggle with F9 | |
" inoremap <F9> <C-o>za | |
" nnoremap <F9> za | |
" onoremap <F9> <C-c>za | |
" vnoremap <F9> zf |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
scriptencoding utf-8 | |
" ---- Options for plugins ---- | |
" | |
" TwitVim | |
" | |
" show only the time | |
" let twitvim_timestamp_format = '%I:%M %p' | |
" " Under Mac OS, the following will use the default browser | |
" let twitvim_browser_cmd = 'open' | |
" let twitvim_proxy = "127.0.0.1:8118" | |
" " The system default for socket timeouts may be as long as a few minutes, so | |
" " TwitVim will appear to hang for that length of time before displaying | |
" " an error message. | |
" let twitvim_net_timeout = 45 | |
" let twitvim_show_header = 1 | |
" " let twitvim_filter_enable = 1 | |
" " let twitvim_filter_regex = '@GetGlue\|/youtu\.be/' | |
" let twitvim_bitly_key ="0b611eed56f7b6782bd334c5f065eb320c55f225" | |
" let twitvim_count = 50 | |
" " default location for :TrendTwitter | |
" " let twitvim_woeid = 523920 | |
" | |
" virtualenv | |
" | |
let g:virtualenv_auto_activate = 1 | |
let g:virtualenv_stl_format = '%n' | |
" | |
" autopep8 | |
" | |
" use F8 to run autopep8 (as defined in /.vim/ftplugin/python.vim) | |
" there is also yapf | |
" add aggressive option (--aggressive) | |
let g:autopep8_aggressive = 1 | |
let g:autopep8_disable_show_diff = 1 | |
" let g:autopep8_diff_type='vertical' | |
" | |
" Ultisnips | |
" | |
" expand snipets via Completor | |
let g:UltiSnipsExpandTrigger = '<C-u>' | |
" iTerm2 / Left Option key = +Esc | |
let g:UltiSnipsListSnippets = 'õ' | |
" let g:UltiSnipsJumpForwardTrigger = '<C-j>' | |
" let g:UltiSnipsJumpBackwardTrigger = '<C-k>' | |
" | |
" Completor | |
" | |
" completors - gpip3 install jedi (and 'toggle' in virtualenv) | |
" | |
" Use virtualenv python3 or brew python3 when without virtualenv. | |
" However you must do 'toggle' to add global packages (including jedi) to path. | |
" It will break if virtualenv's project is python2. | |
" Too many combinations - this is best posible compromise. | |
let g:completor_python_binary = 'python3' | |
" let g:completor_python_binary = '/usr/local/bin/python3' | |
" Explicitly allow/block completions ONLY for file types in list | |
let g:completor_whitelist = ['python'] | |
" let g:completor_blacklist = ['python'] | |
" Disable buffers and file completion | |
" let g:completor_disable_buffer = 1 | |
" let g:completor_disable_filename = 1 | |
" let g:completor_disable_ultisnips = 1 | |
let g:completor_completion_delay = 80 | |
let g:completor_auto_trigger = 1 | |
" | |
" use Tab for complete functions | |
inoremap <expr> <silent> <Tab> CleverTab() | |
" select with <Enter> | |
inoremap <expr> <CR> pumvisible() ? "\<C-y>" : "\<CR>" | |
" Toggle Completor popup when gets in the way | |
inoremap <C-a> <C-\><C-o>:call ToggleCompletorAutoTrigger()<CR> | |
" | |
" vim-notes | |
" | |
let g:notes_directories = ['~/Notes/Current'] | |
let g:notes_suffix = '.txt' | |
" let g:notes_markdown_program = '/usr/local/bin/multimarkdown' | |
let g:notes_markdown_program = "/usr/local/bin/cmark" | |
" | |
" vim-markdown | |
" | |
" enable conceal for italic, bold, inline-code and link text (disabled by default) | |
let g:markdown_enable_conceal = 1 | |
" disable spell checking (enabled by default) | |
let g:markdown_enable_spell_checking = 1 | |
" disable default mappings (enabled by default) | |
let g:markdown_enable_mappings = 0 | |
" | |
" ALE | |
" | |
let g:ale_linters = { | |
\ 'html': ['tidy'], | |
\ 'javascript': ['flow'], | |
\ 'markdown': ['proselint', 'vale'], | |
\ 'perl': ['perl', 'perlcritic'], | |
\ 'python': ['flake8'], | |
\ 'text': ['proselint', 'vale'], | |
\ 'vim': ['vint'], | |
\ } | |
" A given filetype can be mapped to use the linters run for another given filetype | |
let g:ale_linter_aliases = {'mkd': 'markdown', 'notes': 'markdown', 'mail': 'text'} | |
let g:ale_javascript_flow_use_global = 1 | |
" when to run linters | |
" 'always', 'insert', 'normal', 'never' | |
let g:ale_lint_on_text_changed = 'never' | |
" run the linters whenever leaving insert mode | |
let g:ale_lint_on_insert_leave = 1 | |
let g:ale_lint_delay = 200 | |
" set 0 if you don't want linters to run on opening a file | |
let g:ale_lint_on_enter = 1 | |
let g:ale_lint_on_save = 1 | |
" Status line | |
let g:ale_statusline_format = ['🔥 %d', '⚡️ %d', '🌈 ok'] | |
" keep the sign gutter open at all times (avoid weird zig when results come in) | |
let g:ale_sign_column_always = 0 | |
" Message format | |
let g:ale_echo_msg_error_str = 'E' | |
let g:ale_echo_msg_warning_str = 'W' | |
let g:ale_echo_msg_format = '[%linter%] %s [%severity%]' | |
let g:ale_sign_error = '>>' | |
let g:ale_sign_warning = '--' | |
" quicklist | |
" let g:ale_set_loclist = 0 | |
" let g:ale_set_quickfix = 1 | |
" let g:ale_open_list = 1 | |
" let g:ale_keep_list_window_open = 0 | |
" | |
" Goyo and Limelight | |
" | |
" Color name (:help gui-colors) or RGB color | |
let g:limelight_conceal_ctermfg = 'white' | |
" Adjust to current color scheme (find out what is your background color) | |
let g:limelight_conceal_guifg = '#FAFAFA' | |
" Default: 0.5 | |
let g:limelight_default_coefficient = 0.5 | |
" Number of preceding/following paragraphs to include (default: 0) | |
let g:limelight_paragraph_span=2 | |
" Highlighting priority (default: 10) | |
" Set it to -1 not to overrule hlsearch | |
let g:limelight_priority = -1 | |
let g:goyo_linenr = 1 | |
let g:goyo_height = '85%' | |
let g:goyo_width = 80 | |
" Goyo - distraction free writing | |
" <Ctrl-Cmd-F>to go fullscreen in MacVim | |
" | |
" | |
function! s:goyo_enter() | |
autocmd! InsertLeave * :set norelativenumber | |
set nonumber | |
set noshowmode | |
set noshowcmd | |
set nofoldenable | |
set scrolloff=99 | |
let &showbreak = '↳ ' | |
Limelight | |
endfunction | |
" | |
function! s:goyo_leave() | |
" Limelight! | |
" Practically goyo_leave() is toggling focus() back | |
let g:focus = 0 | |
set number | |
set showmode | |
set showcmd | |
set foldenable | |
set scrolloff=5 | |
let &showbreak = '' | |
autocmd! InsertLeave * :set relativenumber | |
ALEEnable | |
if has('gui_macvim') | |
set fuoptions = "maxvert, maxhorz" | |
" set lines=45 | |
set columns=125 | |
set nofullscreen | |
set guifont=Roboto\ Mono\ Medium:h14 | |
redraw! | |
endif | |
endfunction | |
" | |
autocmd! User GoyoEnter nested call <SID>goyo_enter() | |
autocmd! User GoyoLeave nested call <SID>goyo_leave() | |
" | |
" fzf | |
" | |
let g:fzf_launcher = '/usr/local/bin/fzf %s' | |
" in VIM only - MacVim is using layout options from .zshrc | |
let g:fzf_layout = { 'down': '~80%' } | |
" | |
" :Rg command - search within files - start fzf with hidden preview window that can be enabled with "?" | |
command! -bang -nargs=* Rg | |
\ call fzf#vim#grep( | |
\ "rg --column --color=always --no-heading --smart-case --hidden --follow --glob '!.git/*' ".shellescape(<q-args>), 1, | |
\ <bang>0 ? fzf#vim#with_preview('up:60%') | |
\ : fzf#vim#with_preview('right:50%:hidden', '?'), | |
\ <bang>0) | |
" Search my Notes | |
command! -bang -nargs=* Notes | |
\ call fzf#vim#grep( | |
\ 'rg --no-heading --vimgrep '.shellescape(<q-args>).' ~/Notes ', 1, | |
\ <bang>0 ? fzf#vim#with_preview('up:60%') | |
\ : fzf#vim#with_preview('right:50%:hidden', '?'), | |
\ <bang>0) | |
" Augmenting Ag command | |
" Ag doesn't fully support .gitignore. It doesn't support unicode. | |
" Default options are --nogroup --column --color | |
let s:ag_folder = ' $HOME/Documents $HOME/Notes ' | |
let s:ag_options = ' ' | |
command! -bang -nargs=* Ag | |
\ call fzf#vim#grep( | |
\ 'ag --nogroup --column --color '.s:ag_options.shellescape(<q-args>).s:ag_folder, 1, | |
\ <bang>0 ? fzf#vim#with_preview('up:60%') | |
\ : fzf#vim#with_preview('right:50%:hidden', '?'), | |
\ <bang>0) | |
" | |
" Using locate - :Locate / will list every file on the system. | |
" command! -nargs=1 -bang Locate call fzf#run(fzf#wrap( | |
" \ {'source': 'locate <q-args>', 'options': '-m'}, <bang>0)) | |
" | |
let s:jxa_folder = '$HOME/Documents/VIM/thrasher/jxa' | |
function! s:itunes_handler(line) | |
let l:track = split(a:line, ' | ') | |
" call append(line('$'), a:line) | |
" normal! ^zz | |
let l:title = l:track[len(l:track)-1] | |
let l:playlist = substitute(l:track[0], ' $', '', '') | |
" echom l:playlist | |
" echom join(l:track, ' ') | |
" This is never called unless we re-bind Enter in fzf | |
let l:cmd = 'osascript -l JavaScript ' . s:jxa_folder . '/iTunes_Play_Playlist_Track.scpt ' . shellescape(l:playlist) . ' ' . shellescape(l:title) | |
" echom l:cmd | |
call system(l:cmd) | |
" echom l:resp | |
endfunction | |
command! -nargs=* Itunes call fzf#run({ | |
\ 'source': 'osascript -l JavaScript ' . s:jxa_folder . '/iTunes_Search_fzf.scpt ' . <q-args>, | |
\ 'sink': function('<sid>itunes_handler'), | |
\ 'options': '--header "Enter to play track. Esc to exit."' . | |
\ ' --preview="echo -e {} | tr ''|'' ''\n'' | gsed -e ''s/^ //g'' | tail -r " ' . | |
\ ' --preview-window down:4:wrap' . | |
\ ' --bind "?:toggle-preview"' . | |
\ ' --bind "enter:execute-silent(echo -n {} | gsed -e ''s/^\(.*\) | \(.*\) | \(.*\) | \(.*$\)/\"\1\" \"\4\"/'' | xargs osascript -l JavaScript ' . s:jxa_folder . '/iTunes_Play_Playlist_Track.scpt ' . ')" ' | |
\ }) | |
" | |
" Thrasher | |
" | |
" let g:thrasher_verbose = 0 | |
" " 0 - search Library (play playlist) - long query | |
" " 1 - search Apple Music playlists (play playlist) | |
" let g:thrasher_mode = 0 | |
" " Browse all tracks (also not downloaded) | |
" let g:thrasher_online = 0 | |
" " use system notifications | |
" let g:thrasher_notify= 0 | |
" | |
" vim-workspace | |
" | |
" Mappings are defined in .vimrc_keys | |
" | |
" let g:workspace_tab_icon = "#" | |
let g:workspace_subseparator = '📎' | |
" let g:workspace_subseparator = "|" | |
let g:workspace_tab_icon = '📌' | |
" | |
" ---- Plugins ---- | |
" | |
" | |
" vim-plug | |
call plug#begin('~/.vim/plugged') | |
" fzf | |
Plug '/usr/local/opt/fzf' | |
Plug 'junegunn/fzf.vim' | |
" Seoul256 colorscheme | |
Plug 'junegunn/seoul256.vim' | |
" Distraction free editing | |
Plug 'junegunn/goyo.vim' | |
" automatic with focus | |
Plug 'junegunn/limelight.vim' | |
" Markdown preview in Chrome | |
Plug 'junegunn/vim-xmark' | |
" vim-notes | |
Plug 'xolox/vim-misc' | |
Plug 'xolox/vim-notes' | |
" Ale - Asynchronous Lint Engine | |
Plug 'w0rp/ale' | |
" Asynchronous autocomplete - for python jedi | |
Plug 'maralla/completor.vim' | |
" Ultisnips - the engine. | |
Plug 'SirVer/ultisnips' | |
" Snippets are separated from the engine. | |
Plug 'honza/vim-snippets' | |
" Toggle comments | |
Plug 'tpope/vim-commentary' | |
" autoformat with PEP8 it is sometimes better then yapf | |
Plug 'tell-k/vim-autopep8', {'for': 'python'} | |
" virtualenv.vim | |
Plug 'jmcantrell/vim-virtualenv' | |
" Perl | |
Plug 'vim-perl/vim-perl', { 'for': 'perl' } | |
" Markdown | |
" Plug 'plasticboy/vim-markdown' | |
Plug 'gabrielelana/vim-markdown' | |
" No-BS Python code folding | |
Plug 'tmhedberg/SimpylFold', { 'for': 'python' } | |
" buffers and tabs, combined in the tabline | |
Plug 'bagrat/vim-workspace' | |
" Plug 'vim-scripts/TwitVim' | |
" HN in vim | |
" Plug 'ryanss/vim-hackernews' | |
" MacDict - search macOS system dictionary from Vim | |
Plug 'jonhiggs/MacDict.vim' | |
" Thrasher - music player for VIM | |
" Plug 'pmeinhardt/thrasher' | |
" Plug 'chew-z/thrasher' | |
" Plug 'chew-z/thrasher', { 'branch': 'devel' } | |
Plug 'chew-z/itunes.vim' | |
" Plug 'chew-z/itunes.vim', { 'branch': 'devel' } | |
" | |
call plug#end() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" | |
if $TERM_PROGRAM =~# 'iTerm' | |
" gui colors if running iTerm | |
set termguicolors | |
" Fix Del (^?) in iTerm2 - :h fixdel | |
set t_kb= | |
fixdel | |
endif | |
" backspace - set t_kb / delete - set t_kD | |
" large terminal mouse support in Vim | |
" https://www.iterm2.com/faq.html | |
if has('mouse_sgr') | |
set ttymouse=sgr | |
endif | |
" Allow using Alt/Opt mappings <M- <A- in MacVim | |
if has('gui_macvim') | |
set macmeta | |
set macthinstrokes | |
set antialias | |
endif | |
" | |
" Use the OS clipboard by default (on versions compiled with `+clipboard`) | |
" - it exactly means that clipboard register to be automatically used unless another register is specified | |
" Vim (not MacVim) cannot depend on iTerm's clipboard support | |
" Use native Vim copy instead. ie. 2yy to copy two lines . | |
set clipboard+=unnamed | |
" Make Vim more useful | |
" Enable syntax highlighting | |
" syntax on will overrule commands like :highlight | |
" but syntax enable not - see docs | |
syntax enable | |
" set comment in italics | |
highlight Comment cterm=italic | |
" Enable file type detection | |
filetype on | |
filetype plugin on | |
" not vi compatible | |
set nocompatible | |
" A buffer becomes hidden when it is abandoned | |
set hidden | |
" | |
" Enhance command-line completion | |
set wildmenu | |
set wildignore=*.o,*.obj,*.bak,*.exe,*.py[co],*.swp,*~,*.pyc,.svn | |
" Allow cursor keys in insert mode | |
set esckeys | |
" Allow backspace in insert mode | |
set backspace=indent,eol,start | |
" Optimize for fast terminal connections | |
set ttyfast | |
" Add the g flag to search/replace by default | |
set gdefault | |
" Use UTF-8 without BOM | |
set encoding=utf-8 nobomb | |
scriptencoding utf-8 | |
" Don’t add empty newlines at the end of files | |
set binary | |
set noendofline | |
" we like long history | |
set history=2048 | |
" Centralize backups, swapfiles and undo history | |
set backup | |
set backupdir=~/.vim/backups | |
set directory=~/.vim/swaps | |
if exists('&undodir') | |
set undofile | |
set undodir=~/.vim/undo | |
endif | |
" Don’t create backups when editing files in certain directories | |
set backupskip=/tmp/*,/private/tmp/* | |
" Respect modeline in files | |
set modeline | |
set modelines=4 | |
" Enable per-directory .vimrc files and disable unsafe commands in them | |
set exrc | |
set secure | |
" Enable line numbers | |
set number | |
" Highlight current line | |
set cursorline | |
" Make tabs 4 spaces | |
set tabstop=4 | |
set shiftwidth=4 | |
set softtabstop=4 | |
set expandtab | |
" Show “invisible” characters | |
set listchars=tab:▸\ ,trail:·,eol:¬,nbsp:_ | |
set list | |
" Highlight searches | |
set hlsearch | |
" Ignore case of searches | |
set ignorecase | |
" but be case sensitive when uppercase in search term | |
set smartcase | |
" Highlight dynamically as pattern is typed | |
set incsearch | |
" For regular expressions turn magic on | |
set magic | |
" Show matching brackets when text indicator is over them | |
set showmatch | |
" How many tenths of a second to blink when matching brackets | |
set matchtime=4 | |
" Enable mouse in all modes | |
set mouse=a | |
" Disable error bells | |
set noerrorbells | |
" Don’t reset cursor to start of line when moving around. | |
set nostartofline | |
" Show the cursor position | |
set ruler | |
" Don’t show the intro message when starting Vim | |
set shortmess=atI | |
" Show the current mode | |
set showmode | |
" Show the filename in the window titlebar | |
set title | |
" Always show status line | |
set laststatus=2 | |
" status line | |
" set statusline=[%n]\ %<%F\ \ [%M%R%H%W%Y]\ [%{ALEGetStatusLine()}]\ [%{virtualenv#statusline()}]\ [%{thrasher#status()}]\ %=\ line:\ %l/%L\ col:\ %c\ \ \ %p%%\ \ \ @%{strftime(\"%H:%M\")} | |
set statusline=[%n]\ %<%F\ \ [%M%R%H%W%Y]\ [%{ALEGetStatusLine()}]\ \ %=\ line:\ %l/%L\ col:\ %c\ \ \ %p%%\ \ \ @%{strftime(\"%H:%M\")} | |
" Show the (partial) command as it’s being typed | |
set showcmd | |
" gq on highlighted text will reformat text using par (width, [justify], quotes) | |
" gggqG to reformat text with par. But be carefull! par adds hard-wraps(CR) which I am not used to. | |
set formatprg=par\ w80q | |
" cino options | |
" set cino=l1g1t0:0 " How should cindentation be accomplished | |
" | | | | | |
" | | | +-- ": place case labels N chars from prev. indent | |
" | | +---- "t place function return type N chars from margin | |
" | +------ "g place scope declarations N chars from indent of block | |
" +-------- "l align with a case label instead of statement after | |
" Use relative line numbers | |
" if exists("&relativenumber") | |
" set relativenumber | |
" au BufReadPost * set relativenumber | |
" endif | |
" Toggle relative numbers not in Insert mode | |
" autocmd InsertEnter * :set norelativenumber | |
" autocmd InsertLeave * :set relativenumber | |
" autocmd FocusLost * :set number | |
" autocmd FocusGained * :set relativenumber | |
" Start scrolling five lines before the horizontal window border | |
set scrolloff=5 | |
" Don't redraw while executing macros (good performance config) | |
set lazyredraw | |
" Return to last edit position when opening files (You want this!) | |
autocmd BufReadPost * | |
\ if line("'\"") > 0 && line("'\"") <= line("$") | | |
\ exe "normal! g`\"" | | |
\ endif | |
" Remember info about open buffers on close | |
set viminfo^=% | |
" search in subfolders when using :find | |
set path+=$PWD/** | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment