Skip to content

Instantly share code, notes, and snippets.

@litemerafrukt
Created August 31, 2016 10:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save litemerafrukt/9496238855187e748fa5dbab05802bab to your computer and use it in GitHub Desktop.
Save litemerafrukt/9496238855187e748fa5dbab05802bab to your computer and use it in GitHub Desktop.
My .vimrc
" Vundle
" https://github.com/VundleVim/Vundle.vim
" $ git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim
set nocompatible " be iMproved, required
filetype off " required
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" let Vundle manage Vundle, required
Plugin 'VundleVim/Vundle.vim'
Plugin 'Shougo/unite.vim'
Plugin 'Shougo/vimproc.vim'
Plugin 'Shougo/unite-outline'
Plugin 'rstacruz/vim-fastunite'
Plugin 'Shougo/neomru.vim'
Plugin 'tsukkee/unite-tag'
Plugin 'ujihisa/unite-colorscheme'
Plugin 'mhinz/vim-startify'
Plugin 'hecal3/vim-leader-guide'
" Plugin 'ctjhoa/spacevim' " Not needed anymore
" Plugin 'kien/rainbow_parentheses.vim'
Plugin 'tpope/vim-vinegar'
Plugin 'tpope/vim-fugitive'
Plugin 'easymotion/vim-easymotion'
Plugin 'Shougo/vimfiler.vim'
Plugin 'scrooloose/nerdtree'
Plugin 'scrooloose/syntastic'
" Plugin 'posva/vim-vue' " Activate when vue
" Plugin 'sekel/vim-vue-syntastic'
Plugin 'tpope/vim-surround' "change surrounding, 'cs'
Plugin 'tpope/vim-commentary'
Plugin 'itchyny/lightline.vim'
Plugin 'rking/ag.vim'
Plugin 'skwp/greplace.vim'
" Plugin 'pangloss/vim-javascript'
" Plugin 'jelera/vim-javascript-syntax'
Plugin 'othree/yajs.vim'
Plugin 'Valloric/YouCompleteMe'
Plugin 'ternjs/tern_for_vim'
Plugin 'SirVer/ultisnips'
Plugin 'tobyS/vmustache' " Dependency for pdv
Plugin 'tobyS/pdv'
Plugin 'StanAngeloff/php.vim'
Plugin 'captbaritone/better-indent-support-for-php-with-html'
Plugin 'alvan/vim-php-manual' " The php manual shift-k to view in vim ctrl-k to open web
Plugin 'shawncplus/phpcomplete.vim'
Plugin 'othree/html5.vim' " html5 syntax highlight
" Plugin 'rstacruz/sparkup', {'rtp': 'vim/'}
Plugin 'mattn/emmet-vim'
Plugin 'Raimondi/delimitMate'
Plugin 'iandoe/vim-osx-colorpicker'
" Plugin 'ap/vim-css-color' " Do not work well...
Plugin 'junegunn/goyo.vim'
" Plugin 'wavded/vim-stylus'
" All of your Plugins must be added before the following line
call vundle#end() " required
filetype plugin indent on " required
" To ignore plugin indent changes, instead use:
"
" Brief help
" :PluginList - lists configured plugins
" :PluginInstall - installs plugins; append `!` to update or just :PluginUpdate
" :PluginSearch foo - searches for foo; append `!` to refresh local cache
" :PluginClean - confirms removal of unused plugins; append `!` to auto-approve removal
"
" see :h vundle for more details or wiki for FAQ
" Put your non-Plugin stuff after this line
"-------------- Standar misc -----------------
set backspace=indent,eol,start "Default backspace behave
let mapleader=' ' "Kinda namespace for my commands. Use <Leader>
set number "linenumbers
set noerrorbells visualbell t_vb= "No bells
set autowriteall "Auto write file when switching buffer
set linebreak
set expandtab "Use softtabstop spaces instead of tab characters for indentation
set shiftwidth=4 "Indent by 4 spaces when using >>, <<, == etc.
set softtabstop=4 "Indent by 4 spaces when pressing <TAB>
set autoindent "Keep indentation from previous line
set smartindent "Automatically inserts indentation in some cases
" set cindent "Like smartindent, but stricter and more customisable
" Disable MacVim save shortcut (done in .gvimrc)
" macmenu File.Save key=<nop>
set nofoldenable " disable folding
"-------------- Visuals -----------------
syntax enable
set t_Co=256 " This is may or may not needed.
" colorscheme ---
set background=dark
" colorscheme atom-dark
" colorscheme deep-space
" colorscheme hybrid
" colorscheme solarized
" colorscheme base16-flat
colorscheme base16-materia
" colorscheme OneDark
" colorscheme material-theme
" colorscheme seti
" colorscheme mustang
" colorscheme for teminal ---
if !has("gui_running")
colorscheme atom
endif
set cursorline
" set guifont=fira_code_retina:h13 " The font and font size
set guifont=fira_code_light:h13 " The font and font size
set linespace=3 " Set linespacing for macvim
" set guifont=monoid_retina:h12
" set guifont=iosevka:h13
" set guifont=mononoki:h13
" set guifont=topazplus_a600a1200a4000:h13
" set guifont=hasklig_light:h13 " The font and font size
" set guifont=hasklig:h13 " The font and font size
" set guifont=Input:h13 " The font and font size
set macligatures " Pretty mac-stuffs
set nuw=3 " linenumber width
set guioptions-=e " We don't want Gui tabs.
set nowrap
" no line number, toggle with <Leader>ln
set nonumber
" show matching bracket etc
set showmatch
" set colorcolumn=83 " Line att char lenght
"We'll fake a custom left padding for each window.
hi LineNr guibg=bg
set foldcolumn=1
hi foldcolumn guibg=bg
" Get rid of ugly split borders.
" hi vertsplit guifg=bg guibg=bg
" hi vertsplit guifg=#374E77
" hi vertsplit guibg=bg
" No scrollbars
set guioptions-=l
set guioptions-=L
set guioptions-=r
set guioptions-=R
"-------------- Session -----------------
set ssop-=options " do not store global and local values in a session
set ssop-=folds " do not store folds
"-------------- vim-startify -----------------
let g:startify_commands = [{'v': ['vimFiler', 'VimFiler']}]
let g:startify_bookmarks = [ {'p': '~/programmering'}, {'h': '~/webbprogrammering/htmlphp/me'} ]
let g:startify_asii = [
\ ' __',
\ '.--.--.|__|.--------.',
\ '| | || || |',
\ ' \___/ |__||__|__|__|',
\ '-------------- ftw ---'
\]
function! s:filter_header(lines) abort
let longest_line = max(map(copy(a:lines), 'len(v:val)'))
let centered_lines = map(copy(a:lines),
\ 'repeat(" ", (&columns / 2) - (longest_line / 2)) . v:val')
return centered_lines
endfunction
let g:startify_custom_header = s:filter_header(g:startify_asii)
" let g:startify_custom_header = 'map(g:ascii + startify#fortune#boxed(), "\" \".v:val")'
let g:startify_enable_special = 0
let g:startify_files_number = 8
let g:startify_relative_path = 1
let g:startify_change_to_dir = 1
let g:startify_update_oldfiles = 1
let g:startify_session_autoload = 1
let g:startify_session_persistence = 1
let g:startify_session_delete_buffers = 1
let g:startify_session_dir = '~/.vim/sessions'
let g:startify_list_order = [
\ ['Sessions'], 'sessions',
\ ['Recent files'], 'files',
\ ['Recent dir'], 'dir',
\ ['Bookmarks'], 'bookmarks',
\ ['Commands'], 'commands'
\ ]
let g:startify_session_sort = 1
"-------------- phpcomplete -------------------
let g:phpcomplete_parse_docblock_comments = 1
"-------------- Emmet -------------------
let g:user_emmet_install_global = 0
autocmd FileType php,html,css EmmetInstall
let g:user_emmet_leader_key='<C-z>'
"-------------- Easy motion -------------------
" Why oh why does this even work!
" I think it kind of resets the prefix thingy
" Well a bug killed a bug..
map ,, <Plug>(easymotion-prefix)
"-------------- Vim leader --------------------
" When using vim leader, shorten time to menu
set timeoutlen=500
"-------------- Goyo -----------------
let g:goyo_width = 123 " (default: 80)
let g:goyo_height = 100 " (default: 85%)
"-------------- VimFiler -----------------
" let g:vimfiler_as_default_explorer = 1
" Set current dir to chosen file
" (but leave it of since i work with sessions...)
" let g:vimfiler_enable_auto_cd = 1
"-------------- fastunite / Unite -----------------
let g:fastunite_default_options = {
\ 'direction' : 'bot',
\}
" Make all commands show on :Unite command
call unite#custom#source('command', 'max_candidates', 0)
"-------------- vim-airline -----------------
" " tab-bar show or noshow
" let g:airline#extensions#tabline#enabled = 0
" " Always show statusbar
" set laststatus=2
" " let g:airline_theme='solarized'
" let g:airline_theme='tomorrow'
" " let g:airline_powerline_fonts = 1
" let g:airline_left_sep=''
" let g:airline_right_sep=''
"-------------- lightline -----------------
let g:lightline = {
\ 'colorscheme': 'wombat',
\ 'active': {
\ 'left': [ [ 'mode', 'paste' ], [ 'fugitive', 'filename' ] ],
\ 'right': [ [ 'syntastic', 'lineinfo' ], ['percent'], [ 'fileformat', 'fileencoding', 'filetype' ] ]
\ },
\ 'component_function': {
\ 'fugitive': 'LightLineFugitive',
\ 'filename': 'LightLineFilename',
\ 'fileformat': 'LightLineFileformat',
\ 'filetype': 'LightLineFiletype',
\ 'fileencoding': 'LightLineFileencoding',
\ 'mode': 'LightLineMode',
\ },
\ 'component_expand': {
\ 'syntastic': 'SyntasticStatuslineFlag',
\ },
\ 'component_type': {
\ 'syntastic': 'error',
\ },
\ 'subseparator': { 'left': '|', 'right': '|' }
\ }
function! LightLineModified()
return &ft =~ 'help' ? '' : &modified ? '+' : &modifiable ? '' : '-'
endfunction
function! LightLineReadonly()
return &ft !~? 'help' && &readonly ? 'RO' : ''
endfunction
function! LightLineFilename()
" let fname = expand('%:t')
let fname = expand('%')
return fname == 'ControlP' && has_key(g:lightline, 'ctrlp_item') ? g:lightline.ctrlp_item :
\ fname == '__Tagbar__' ? g:lightline.fname :
\ fname =~ '__Gundo\|NERD_tree' ? '' :
\ &ft == 'vimfiler' ? vimfiler#get_status_string() :
\ &ft == 'unite' ? unite#get_status_string() :
\ &ft == 'vimshell' ? vimshell#get_status_string() :
\ ('' != LightLineReadonly() ? LightLineReadonly() . ' ' : '') .
\ ('' != fname ? fname : '[No Name]') .
\ ('' != LightLineModified() ? ' ' . LightLineModified() : '')
endfunction
function! LightLineFugitive()
try
if expand('%:t') !~? 'Tagbar\|Gundo\|NERD' && &ft !~? 'vimfiler' && exists('*fugitive#head')
let mark = '' " edit here for cool mark
let branch = fugitive#head()
return branch !=# '' ? mark.branch : ''
endif
catch
endtry
return ''
endfunction
function! LightLineFileformat()
return winwidth(0) > 70 ? &fileformat : ''
endfunction
function! LightLineFiletype()
return winwidth(0) > 70 ? (&filetype !=# '' ? &filetype : 'no ft') : ''
endfunction
function! LightLineFileencoding()
return winwidth(0) > 70 ? (&fenc !=# '' ? &fenc : &enc) : ''
endfunction
function! LightLineMode()
let fname = expand('%:t')
return &ft == 'unite' ? 'Unite' :
\ &ft == 'vimfiler' ? 'VimFiler' :
\ &ft == 'vimshell' ? 'VimShell' :
\ winwidth(0) > 60 ? lightline#mode() : ''
endfunction
augroup AutoSyntastic
autocmd!
autocmd BufWritePost *.js,*.vue,*.html,*jsx,*.php call s:syntastic()
augroup END
function! s:syntastic()
SyntasticCheck
call lightline#update()
endfunction
let g:unite_force_overwrite_statusline = 0
let g:vimfiler_force_overwrite_statusline = 0
let g:vimshell_force_overwrite_statusline = 0
" Always show statusbar
set laststatus=2
"-------------- pdv -----------------
let g:pdv_template_dir = $HOME ."/.vim/bundle/pdv/templates_snip"
"-------------- grep replace -----------------
" Use Ag for search
set grepprg=ag
let g:grep_cmd_opts = '--line-numbers --noheading'
"-------------- Search -----------------
set ignorecase " Ignore case when searching
set smartcase " Ignore case if search pattern
" is all lowercase, case-sensitive
" otherwise
set hlsearch " Highlight search terms
set incsearch " Show search matches as you type
"-------------- Manage splits -----------------
set splitbelow
set splitright
"-------------- NERDTree -----------------
let g:NERDTreeHijackNetrw = 0
"------------ Syntastic -------------
" Suggested defaults
set statusline+=%#warningmsg#
set statusline+=%{SyntasticStatuslineFlag()}
set statusline+=%*
" let g:syntastic_always_populate_loc_list = 1
" let g:syntastic_auto_loc_list = 1
let g:syntastic_check_on_open = 1
let g:syntastic_check_on_wq = 0
" My settings
" let g:syntastic_css_checkers = ['csslint']
let g:syntastic_javascript_checkers = ['eslint']
let g:syntastic_vue_checkers = ['eslint']
let g:syntastic_php_checkers = ['php', 'phpcs', 'phpmd']
let g:syntastic_php_phpcs_args="--standard=/Users/Any/programmering/.phpcs.xml"
let g:phpqa_messdetector_ruleset = "/path/to/phpmd.xml"
let g:syntastic_enable_signs = 0 " Turn on/off signs (0/1)
" let g:syntastic_error_symbol = '›' " For syntax errors, defaults to '>>'
" let g:syntastic_style_error_symbol = '?' " For style errors, defaults to 'S>'
" let g:syntastic_warning_symbol = '›' " For syntax warnings, defaults to '>>'
" let g:syntastic_style_warning_symbol = '?' " For style warnings, defaults to 'S>'
" ------------ UltiSnips ------------
let g:UltiSnipsSnippetDirectories=[$HOME.'/.vim/ultisnips']
" Trigger configuration. Do not use <tab> if you use https://github.com/Valloric/YouCompleteMe.
" let g:UltiSnipsExpandTrigger = "<C-l>"
" let g:UltiSnipsJumpForwardTrigger = "<C-j>"
" let g:UltiSnipsJumpBackwardTrigger = "<C-k>"
let g:UltiSnipsExpandTrigger = '<D-space>'
let g:UltiSnipsJumpForwardTrigger = '<D-space>'
" let g:UltiSnipsJumpBackwardTrigger = '<c-k>'
" let g:UltiSnipsListSnippets = '<c-m>'
"------------ Auto-Commands -------------
" Auto source .vimrc on save
augroup autosourcing
autocmd!
autocmd BufWritePost .vimrc source %
augroup END
" Remove trailing witespace
fun! <SID>StripTrailingWhitespaces()
let l = line(".")
let c = col(".")
%s/\s\+$//e
call cursor(l, c)
endfun
autocmd BufWritePre * :call <SID>StripTrailingWhitespaces()
" ------------------------------------------
" ------------------------------------------
" ------------------------------------------
" ------------ Notes and tips ------------
" Marks - coola grejer
" m + <bokstav> - sätter ett märke i filen som man kommer tillbaka till med
" ' + <bokstav>
" shift + m + <bokstav> - samma fast även mellan filer.
" ' + 0 - öppnar filen som var öppen när vim stängdes senast.
"-------------- Mappings -----------------
" file stuff ------------------
" Save in Normal mode (block Substitute)
nmap <D-s> :w<CR>
" Exit to Normal mode upon save [Cmd+S]
imap <D-s> <Esc>:w<CR>
vmap <D-s> <Esc>:w<CR>
" editor tweaks ------------------
" atom thingie
inoremap <D-ENTER> <esc>o
inoremap <D-S-ENTER> <esc>O
" mapp cmd + hjkl to
" arrows in insert mode
" only works in fullscreen
inoremap <D-h> <left>
inoremap <D-j> <down>
inoremap <D-k> <up>
inoremap <D-l> <right>
" <alt> + <enter> to down one, tab and insertmode
inoremap <M-CR> <cr><cr><up><tab>
" turn of you complete me diagnostic mapping
let g:ycm_key_detailed_diagnostics = ''
" get out of insert mode with fd and öö
inoremap fd <esc>
inoremap öö <esc>
" and get out of visual mode
vnoremap § <esc>
vnoremap öö <esc>
" Swedish keyboards have $ in awkward place -> remap for php dev
" Quick insert $ (for php)
imap ,, $
" ää to get to end of line
inoremap ää <esc>A
" And for end of line in visual mode & normal mode
vnoremap ää $
nnoremap ää $
" Add ; at end of line
imap ;; <Esc>A;
nmap ;; A;<Esc>
" VimFiler -----------------------
" Use vinegar instead!
" Easy start vimfiler
" nnoremap - :VimFiler<cr>
"------------------------ end mappings ------------------------
"------------------------ vim leader menu ------------------------
" easy vim - inspired by spacevim and spacemacs
" Modified from: Camille Tjhoa <http://github.com/ctjhoa>
" Version: 0.1
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Integrate with vim-leader-guide
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
if !exists('g:lmap')
let g:lmap = {}
endif
" Start the leader guide thingy
function! s:spacevim_displayfunc()
let g:leaderGuide#displayname = substitute(g:leaderGuide#displayname, '\c<cr>$', '', '')
let g:leaderGuide#displayname = substitute(g:leaderGuide#displayname, '^<SID>', '', '')
endfunction
let g:leaderGuide_displayfunc = [function('s:spacevim_displayfunc')]
call leaderGuide#register_prefix_descriptions("<Space>", "g:lmap")
nnoremap <silent> <leader> :<c-u>LeaderGuide '<Space>'<CR>
vnoremap <silent> <leader> :<c-u>LeaderGuideVisual '<Space>'<CR>
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Helpers
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
function! s:spacevim_bind(map, binding, name, value, isCmd)
if a:isCmd
let l:value = ':' . a:value . '<cr>'
else
let l:value = a:value
endif
if a:map == "map"
let l:noremap = 'noremap'
elseif a:map == "nmap"
let l:noremap = 'nnoremap'
elseif a:map == "vmap"
let l:noremap = 'vnoremap'
endif
execute l:noremap . " <silent> <SID>" . a:name . " " . l:value
execute a:map . " <leader>" . a:binding . " <SID>" . a:name
endfunction
function! s:spacevim_get_visual_selection()
let [lnum1, col1] = getpos("'<")[1:2]
let [lnum2, col2] = getpos("'>")[1:2]
let lines = getline(lnum1, lnum2)
let lines[-1] = lines[-1][: col2 - 2]
let lines[0] = lines[0][col1 - 1:]
return join(lines, "\n")
endfunction
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Bindings
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
call s:spacevim_bind('map', '<Tab>', 'last-buffer', 'b#', 1)
call s:spacevim_bind('map', '!', 'shell-cmd', 'call feedkeys(":! ")', 1)
call s:spacevim_bind('map', '/', 'file-fuzzy-search', 'Unite -start-insert line:all', 1)
" call s:spacevim_bind('map', '//', 'search-project', 'UniteWithInput grep:.', 1)
call s:spacevim_bind('nmap', '*', 'search-project-w/word', 'UniteWithCursorWord -start-insert grep:.', 1)
" --------- lmf ---------
" Don't know how to do it in visual selsection...
" call s:spacevim_bind('vmap', '*', 'smart-search-with-input', 'call SpacevimSmartSearchWithInput(1)', 1)
call s:spacevim_bind('map', '0', 'window-0', '1wincmd w', 1)
call s:spacevim_bind('map', '1', 'window-1', '2wincmd w', 1)
call s:spacevim_bind('map', '2', 'window-2', '3wincmd w', 1)
call s:spacevim_bind('map', '3', 'window-3', '4wincmd w', 1)
call s:spacevim_bind('map', '4', 'window-4', '5wincmd w', 1)
" call s:spacevim_bind('map', '5', 'window-5', '6wincmd w', 1)
" call s:spacevim_bind('map', '6', 'window-6', '7wincmd w', 1)
" call s:spacevim_bind('map', '7', 'window-7', '8wincmd w', 1)
" call s:spacevim_bind('map', '8', 'window-8', '9wincmd w', 1)
" call s:spacevim_bind('map', '9', 'window-9', '10wincmd w', 1)
" call s:spacevim_bind('map', ':', 'commands', 'call SpacevimCommands()', 1)
call s:spacevim_bind('map', ':', 'commands', 'Unite -start-insert command', 1)
call s:spacevim_bind('nmap', ';', 'vim-commentary-operator', 'Commentary', 1)
nmap <silent> <SID>vim-commentary-line <Plug>(CommentaryLine)
" --- lmf -----
" Don't think this is needed
" nmap <Leader>;; <SID>vim-commentary-line
call s:spacevim_bind('vmap', ';', 'vim-commentary-operator', '''<,''>Commentary', 1)
" applications {{{
let g:lmap.a = { 'name' : '+applications' }
" call s:spacevim_bind('map', 'au', 'undo-tree-visualize', 'UndotreeToggle', 1)
call s:spacevim_bind('map', 'ac', 'ColorHEX', 'ColorHEX', 1)
call s:spacevim_bind('map', 'ad', 'PDV', 'call pdv#DocumentWithSnip()', 1)
" }}}
" buffers {{{
let g:lmap.b = { 'name' : '+buffers' }
call s:spacevim_bind('map', 'bb', 'buffers', 'call SpacevimBuffers()', 1)
call s:spacevim_bind('map', 'bd', 'kill-this-buffer', 'bd', 1)
call s:spacevim_bind('map', 'bn', 'next-useful-buffer', 'bnext', 1)
call s:spacevim_bind('map', 'bp', 'previous-useful-buffer', 'bprevious', 1)
call s:spacevim_bind('map', 'bR', 'safe-revert-buffer', 'e', 1)
" buffers/move {{{
let g:lmap.b.m = { 'name' : '+move' }
call s:spacevim_bind('map', 'bmr', 'buf-rotate-down-right', 'wincmd r', 1)
call s:spacevim_bind('map', 'bmR', 'buf-rotate-up-left', 'wincmd R', 1)
" }}}
" }}}
" ------ lmf ------
" comile/comments {{{
" let g:lmap.c = { 'name' : '+compile/comments' }
" }}}
" ------ lmf ------
" capture/colors {{{
" let g:lmap.C = { 'name' : '+capture/colors' }
" }}}
" errors {{{
let g:lmap.e = { 'name' : '+errors' }
call s:spacevim_bind('map', 'el', 'error-list', 'Errors', 1)
call s:spacevim_bind('map', 'et', 'toggle-mode', 'SyntasticToggleMode', 1)
call s:spacevim_bind('map', 'en', 'next-error', 'call SpacevimErrorNext()', 1)
" call s:spacevim_bind('map', 'eN', 'previous-error', 'call SpacevimErrorPrev()', 1)
call s:spacevim_bind('map', 'ep', 'previous-error', 'call SpacevimErrorPrev()', 1)
" }}}
" files {{{
let g:lmap.f = { 'name' : '+files' }
call s:spacevim_bind('map', 'fc', 'copy-file', 'saveas', 1)
call s:spacevim_bind('map', 'fD', 'delete-current-buffer-file', 'Remove', 1)
call s:spacevim_bind('map', 'fE', 'sudo-edit', 'call feedkeys(":SudoEdit ")', 1)
call s:spacevim_bind('map', 'ff', 'find-files', 'Unite -start-insert file', 1)
call s:spacevim_bind('map', 'fp', 'find-project-files', 'Unite -start-insert file_rec/async', 1)
call s:spacevim_bind('map', 'fr', 'recentf', 'Unite -start-insert file_mru', 1)
call s:spacevim_bind('map', 'fR', 'rename-current-buffer-file', 'call feedkeys(":Rename ")', 1)
call s:spacevim_bind('map', 'fs', 'save-buffer', 'write', 1)
call s:spacevim_bind('map', 'f*', 'Startify', 'Startify', 1)
call s:spacevim_bind('map', 'fn', 'new-buffer', 'enew', 1)
call s:spacevim_bind('map', 'fS', 'write-all', 'wa', 1)
call s:spacevim_bind('map', 'fv', 'vf-explorer-toggle', 'VimFilerExplorer', 1)
call s:spacevim_bind('map', 'ft', 'explorer-toggle', 'NERDTreeToggle', 1)
call s:spacevim_bind('map', 'fx', 'vf-explorer-buffer', 'VimFiler', 1)
" files/vim {{{
let g:lmap.f.e = { 'name' : '+vim' }
call s:spacevim_bind('map', 'fed', '.vimrc', 'tabedit $MYVIMRC', 1)
call s:spacevim_bind('map', 'fes', 'ultisnips', 'tabedit ~/.vim/ultisnips/', 1)
call s:spacevim_bind('map', 'feR', 'sync-configuration', 'source $MYVIMRC', 1)
call s:spacevim_bind('map', 'fev', 'display-vim-version', 'version', 1)
" }}}
" }}}
" git/versions-control {{{
let g:lmap.g = { 'name' : '+git/versions-control' }
call s:spacevim_bind('map', 'gb', 'git-blame', 'Gblame', 1)
call s:spacevim_bind('map', 'gc', 'git-commit', 'Gcommit', 1)
call s:spacevim_bind('map', 'gC', 'git-checkout', 'Git checkout', 1)
call s:spacevim_bind('map', 'gd', 'git-diff', 'Gdiff', 1)
call s:spacevim_bind('map', 'gD', 'git-diff-head', 'Gdiff HEAD', 1)
call s:spacevim_bind('map', 'gf', 'git-fetch', 'Gfetch', 1)
call s:spacevim_bind('map', 'gF', 'git-pull', 'Gpull', 1)
call s:spacevim_bind('map', 'gi', 'git-init', 'Git init', 1)
call s:spacevim_bind('map', 'gl', 'git-log', 'call SpacevimGitLog()', 1)
call s:spacevim_bind('map', 'gr', 'git-checkout-current-file', 'Gread', 1)
call s:spacevim_bind('map', 'gR', 'git-remove-current-file', 'Gremove', 1)
call s:spacevim_bind('map', 'gs', 'git-status', 'Gstatus', 1)
call s:spacevim_bind('map', 'gS', 'git-stage-file', 'call feedkeys(":Git add -- ")', 1)
call s:spacevim_bind('map', 'gw', 'git-stage-current-file', 'Gwrite', 1)
" }}}
" insertion {{{
let g:lmap.i = { 'name' : '+insertion' }
call s:spacevim_bind('nmap', 'ij', 'vim-insert-line-below', 'mao<Esc>`a', 0)
call s:spacevim_bind('nmap', 'ik', 'vim-insert-line-above', 'maO<Esc>`a', 0)
" }}}
" join/split {{{
let g:lmap.j = { 'name' : '+join/split' }
call s:spacevim_bind("nmap", "j=", "indent-region-or-buffer", "mzgg=G`z", 0)
call s:spacevim_bind("vmap", "j=", "indent-region-or-buffer", "==", 0)
call s:spacevim_bind('map', 'jj', 'sp-newline', 'i<CR><Esc>', 0)
" call s:spacevim_bind('map', 'jJ', 'split-and-newline', 'i<CR><Esc>', 0) " same as j.j ?
call s:spacevim_bind('map', 'jo', 'open-line', 'i<CR><Esc>k$', 0)
" }}}
" projects {{{
let g:lmap.p = { 'name' : '+project' }
call s:spacevim_bind('map', 'pd', 'cd-buffer-dir', 'cd %:p:h', 1)
call s:spacevim_bind('map', 'ps', 'session-save', 'call feedkeys(":SSave ")', 1)
call s:spacevim_bind('map', 'po', 'session-open', 'call feedkeys(":SLoad ")', 1)
call s:spacevim_bind('map', 'pD', 'session-delete', 'call feedkeys(":SDelete ")', 1)
call s:spacevim_bind('map', 'pc', 'session-close', 'SClose', 1)
call s:spacevim_bind('map', 'pf', 'project-find-file', 'UniteWithProjectDir -start-insert file_rec/async', 1)
" }}}
" quit {{{
let g:lmap.q = { 'name' : '+quit' }
call s:spacevim_bind('map', 'qq', 'prompt-kill-vim', 'quit', 1)
call s:spacevim_bind('map', 'qQ', 'kill-vim', 'quit!', 1)
call s:spacevim_bind('map', 'qs', 'save-buffers-kill-vim', 'xa', 1)
" }}}
" " registers/rings {{{
" let g:lmap.r = { 'name' : '+registers/rings' }
" " }}}
" ---------- lmf ------------
" registers {{{
let g:lmap.r = { 'name' : '+registers' }
call s:spacevim_bind('map', 'ra', 'show-all', 'Unite register', 1)
call s:spacevim_bind('map', 'rr', 'show-.0abcd', 'Unite register:.0abcd', 1)
" registers/yank {{{
let g:lmap.r.y = { 'name' : '+yank' }
call s:spacevim_bind('map', 'rya', 'yank-line->a', '"ayy', 0)
call s:spacevim_bind('map', 'ryb', 'yank-line->b', '"byy', 0)
call s:spacevim_bind('map', 'ryc', 'yank-selection->c', '"cy', 0)
call s:spacevim_bind('map', 'ryd', 'yank-selection->d', '"dy', 0)
" registers/put {{{
let g:lmap.r.p = { 'name' : '+put' }
call s:spacevim_bind('map', 'rpa', 'put->a', '"ap', 0)
call s:spacevim_bind('map', 'rpb', 'put->b', '"bp', 0)
call s:spacevim_bind('map', 'rpc', 'put->c', '"cp', 0)
call s:spacevim_bind('map', 'rpd', 'put->d', '"dp', 0)
call s:spacevim_bind('map', 'rp0', 'p->0', '"0p', 0)
" nnoremap <leader>p "0p
" }}}
" search/symbol {{{
let g:lmap.s = { 'name' : '+search/symbol' }
call s:spacevim_bind('map', 'sc', 'highlight-clear-all', 'noh', 1)
call s:spacevim_bind('map', 'su', 'unite', 'Unite', 1)
call s:spacevim_bind('map', 'so', 'unite-outline', 'Unite outline', 1)
call s:spacevim_bind('map', 'sf', 'file-fuzzy-search', 'Unite -start-insert line:all', 1)
call s:spacevim_bind('map', 'sd', 'file-fuzzy-w/word', 'UniteWithCursorWord line:all', 1)
call s:spacevim_bind('map', 'sp', 'search-project', 'UniteWithInput grep:.', 1)
call s:spacevim_bind('nmap', 'sw', 'search-project-w/word', 'UniteWithCursorWord -start-insert grep:.', 1)
call s:spacevim_bind('nmap', 'sr', 'search-resume', 'UniteResume', 1)
" call s:spacevim_bind('vmap', 'sP', 'smart-search-with-input', 'call SpacevimSmartSearchWithInput(1)', 1)
" }}}
" spelling {{{
let g:lmap.S = { 'name' : '+spelling' }
call s:spacevim_bind('map', 'St', 'toggle-spelling', 'set spell!', 1)
call s:spacevim_bind('nmap', 'Ss', 'suggestions', 'z=', 0)
call s:spacevim_bind('nmap', 'Sn', 'next', ']s', 0)
call s:spacevim_bind('nmap', 'Sp', 'previous', '[s', 0)
call s:spacevim_bind('nmap', 'Sa', 'add-word', 'zg', 0)
call s:spacevim_bind('nmap', 'Si', 'incorrect-word', 'zw', 0)
" spelling/language {{{
let g:lmap.S.l = { 'name' : '+language' }
call s:spacevim_bind('nmap', 'Sls', 'swedish', 'set spelllang=sv', 1)
call s:spacevim_bind('nmap', 'Sle', 'english', 'set spelllang=en', 1)
" }}}
" }}}
" toggles {{{
let g:lmap.t = { 'name' : '+toggles' }
call s:spacevim_bind('map', 'tg', 'zen-edit', 'Goyo', 1)
call s:spacevim_bind('map', 'tw', 'line-wrap', 'set wrap!', 1)
call s:spacevim_bind('map', 'tl', 'truncate-line', 'set invwrap', 1)
call s:spacevim_bind('map', 'tn', 'line-numbers', 'set invnumber', 1)
call s:spacevim_bind('map', 'tr', 'linum-relative-toggle', 'set invrelativenumber', 1)
" registers/rings {{{
let g:lmap.t.h = { 'name' : '+highlight' }
call s:spacevim_bind('nmap', 'thc', 'highlight-indentation-current-column', 'set invcursorcolumn', 1)
call s:spacevim_bind('nmap', 'thl', 'highlight-current-line-globaly', 'set invcursorline', 1)
" }}}
" }}}
" UI toggles/themes {{{
let g:lmap.T = { 'name' : '+UI toggles/themes' }
call s:spacevim_bind('map', 'Td', 'version-control-margin', 'GitGutterToggle', 1)
call s:spacevim_bind('map', 'Tc', 'colorscheme', 'Unite -start-insert colorscheme', 1)
" }}}
" windows {{{
let g:lmap.w = { 'name' : '+windows' }
call s:spacevim_bind('map', 'w<right>', 'win-inc-horizontal', 'vertical resize +30', 1)
call s:spacevim_bind('map', 'w<left>', 'win-dec-horizontal', 'vertical resize -30', 1)
call s:spacevim_bind('map', 'w<up>', 'win-inc-vertical', 'resize +30', 1)
call s:spacevim_bind('map', 'w<down>', 'win-dec-vertical', 'resize -30', 1)
call s:spacevim_bind('map', 'w=', 'balance-windows', 'wincmd =', 1)
call s:spacevim_bind('map', 'wd', 'delete-window', 'q', 1)
call s:spacevim_bind('map', 'wh', 'window-left', 'wincmd h', 1)
call s:spacevim_bind('map', 'wH', 'window-move-far-left', 'wincmd H', 1)
call s:spacevim_bind('map', 'wj', 'window-down', 'wincmd j', 1)
call s:spacevim_bind('map', 'wJ', 'window-move-far-down', 'wincmd J', 1)
call s:spacevim_bind('map', 'wk', 'window-up', 'wincmd k', 1)
call s:spacevim_bind('map', 'wK', 'window-move-far-up', 'wincmd K', 1)
call s:spacevim_bind('map', 'wl', 'window-right', 'wincmd l', 1)
call s:spacevim_bind('map', 'wL', 'window-move-far-right', 'wincmd L', 1)
call s:spacevim_bind('map', 'wm', 'maximize-buffer', 'call SpacevimMaximizeBuffer()', 1)
call s:spacevim_bind('map', 'ws', 'split-window-below', 'split', 1)
call s:spacevim_bind('map', 'wS', 'split-window-below-and-focus', 'split\|wincmd w', 1)
call s:spacevim_bind('map', 'wv', 'split-window-right', 'vsplit', 1)
call s:spacevim_bind('map', 'wV', 'split-window-right-and-focus', 'vsplit\|wincmd w', 1)
call s:spacevim_bind('map', 'ww', 'other-window', 'wincmd w', 1)
" }}}
" " text {{{
" let g:lmap.x = { 'name' : '+text' }
" " }}}
nmap <silent> <SID>easymotion <Plug>(easymotion-s)
nmap <Leader><space> <SID>easymotion
vmap <silent> <SID>easymotion <Plug>(easymotion-s)
vmap <Leader><space> <SID>easymotion
nmap <silent> <SID>easymotion-line <Plug>(easymotion-bd-jk)
nmap <Leader><space><space> <SID>easymotion-line
vmap <silent> <SID>easymotion-line <Plug>(easymotion-bd-jk)
vmap <Leader><space><space> <SID>easymotion-line
" " zoom {{{
" let g:lmap.z = { 'name' : '+zoom' }
" " }}}
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Helper functions
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
function! SpacevimBuffers()
if exists(':Buffers')
execute "Buffers"
elseif exists('g:loaded_unite')
execute "Unite -start-insert buffer"
elseif exists('g:loaded_ctrlp')
execute "CtrlPBuffer"
else
execute "buffers"
endif
endfunction
function! SpacevimErrorList()
let old_last_winnr = winnr('$')
SyntasticToggleMode
if old_last_winnr == winnr('$')
" Nothing was closed, open syntastic error location panel
SyntasticCheck
endif
endfunction
" fixes some weirdness in the case of only one error
" SEE: https://github.com/scrooloose/syntastic/issues/32
" also causes it to cycle around, which is quite nice!
function! SpacevimErrorPrev()
try
lprev
catch /^Vim\%((\a\+)\)\=:E553/
llast
endtry
endfunction
function! SpacevimErrorNext()
try
lnext
catch /^Vim\%((\a\+)\)\=:E553/
lfirst
endtry
endfunction
function! SpacevimGitLog()
if exists(':GV')
execute "GV"
else
execute "silent! Glog<CR>:bot copen"
endif
endfunction
function! SpacevimMaximizeBuffer()
if exists("s:maximize_session")
exec "source " . s:maximize_session
call delete(s:maximize_session)
unlet s:maximize_session
let &hidden=s:maximize_hidden_save
unlet s:maximize_hidden_save
else
let s:maximize_hidden_save = &hidden
let s:maximize_session = tempname()
set hidden
exec "mksession! " . s:maximize_session
only
endif
endfunction
" vim:set ft=vim sw=2 sts=2 et:
" vim:fdm=marker
" PHPdoc highlighting
function! PhpSyntaxOverride()
hi! def link phpDocTags phpDefine
hi! def link phpDocParam phpType
endfunction
augroup phpSyntaxOverride
autocmd!
autocmd FileType php call PhpSyntaxOverride()
augroup END
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment