Skip to content

Commit

Permalink
Merge pull request #794 from j1mr10rd4n/easyedit-spf13-config
Browse files Browse the repository at this point in the history
Easily edit spf13-vim configuration
  • Loading branch information
spf13 committed Aug 3, 2015
2 parents 34de0e0 + 17f2b8f commit eeb5c57
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 0 deletions.
58 changes: 58 additions & 0 deletions .vimrc
Expand Up @@ -285,6 +285,22 @@
let maplocalleader=g:spf13_localleader
endif

" The default mappings for editing and applying the spf13 configuration
" are <leader>ev and <leader>sv respectively. Change them to your preference
" by adding the following to your .vimrc.before.local file:
" let g:spf13_edit_config_mapping='<leader>ec'
" let g:spf13_apply_config_mapping='<leader>sc'
if !exists('g:spf13_edit_config_mapping')
let s:spf13_edit_config_mapping = '<leader>ev'
else
let s:spf13_edit_config_mapping = g:spf13_edit_config_mapping
endif
if !exists('g:spf13_apply_config_mapping')
let s:spf13_apply_config_mapping = '<leader>sv'
else
let s:spf13_apply_config_mapping = g:spf13_apply_config_mapping
endif

" Easier moving in tabs and windows
" The lines conflict with the default digraph mapping of <C-K>
" If you prefer that functionality, add the following to your
Expand Down Expand Up @@ -1140,6 +1156,48 @@
" e.g. Grep current file for <search_term>: Shell grep -Hn <search_term> %
" }

function! s:IsSpf13Fork()
let s:is_fork = 0
let s:fork_files = ["~/.vimrc.fork", "~/.vimrc.before.fork", "~/.vimrc.bundles.fork"]
for fork_file in s:fork_files
if filereadable(expand(fork_file, ":p"))
let s:is_fork = 1
break
endif
endfor
return s:is_fork
endfunction

function! s:ExpandFilenameAndExecute(command, file)
execute a:command . " " . expand(a:file, ":p")
endfunction

function! s:EditSpf13Config()
call <SID>ExpandFilenameAndExecute("tabedit", "~/.vimrc")
call <SID>ExpandFilenameAndExecute("vsplit", "~/.vimrc.before")
call <SID>ExpandFilenameAndExecute("vsplit", "~/.vimrc.bundles")

execute bufwinnr(".vimrc") . "wincmd w"
call <SID>ExpandFilenameAndExecute("split", "~/.vimrc.local")
wincmd l
call <SID>ExpandFilenameAndExecute("split", "~/.vimrc.before.local")
wincmd l
call <SID>ExpandFilenameAndExecute("split", "~/.vimrc.bundles.local")

if <SID>IsSpf13Fork()
execute bufwinnr(".vimrc") . "wincmd w"
call <SID>ExpandFilenameAndExecute("split", "~/.vimrc.fork")
wincmd l
call <SID>ExpandFilenameAndExecute("split", "~/.vimrc.before.fork")
wincmd l
call <SID>ExpandFilenameAndExecute("split", "~/.vimrc.bundles.fork")
endif

execute bufwinnr(".vimrc.local") . "wincmd w"
endfunction

execute "noremap " . s:spf13_edit_config_mapping " :call <SID>EditSpf13Config()<CR>"
execute "noremap " . s:spf13_apply_config_mapping . " :source ~/.vimrc<CR>"
" }

" Use fork vimrc if available {
Expand Down
4 changes: 4 additions & 0 deletions .vimrc.before
Expand Up @@ -92,6 +92,10 @@
" Require a special keypress to enter multiple cursors mode
" let g:multi_cursor_start_key='+'

" Mappings for editing/applying spf13 config
" let g:spf13_edit_config_mapping='<leader>ev'
" let g:spf13_apply_config_mapping='<leader>sv'

" }

" Use fork before if available {
Expand Down
13 changes: 13 additions & 0 deletions README.markdown
Expand Up @@ -204,6 +204,19 @@ file to pull down your fork.

For an example of a fork of spf13-vim that provides customization in this manner see [taxilian's fork](https://github.com/taxilian/spf13-vim).

### Easily Editing Your Configuration

`<Leader>ev` opens a new tab containing the .vimrc configuration files listed above. This makes it easier to get an overview of your
configuration and make customizations.

`<Leader>sv` sources the .vimrc file, instantly applying your customizations to the currently running vim instance.

These two mappings can themselves be customized by setting the following in .vimrc.before.local:
```bash
let g:spf13_edit_config_mapping='<Leader>ev'
let g:spf13_apply_config_mapping='<Leader>sv'
```

# Plugins

spf13-vim contains a curated set of popular vim plugins, colors, snippets and syntaxes. Great care has been made to ensure that these plugins play well together and have optimal configuration.
Expand Down

0 comments on commit eeb5c57

Please sign in to comment.