aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrien Bustany <adrien@bustany.org>2013-04-22 19:37:12 +0200
committerAndreas Schneider <asn@cryptomilk.org>2013-04-23 09:58:18 +0200
commit0d651219b5d107dc19c4e941907bfd45aea58d9d (patch)
tree78739e12a9bb61f29e8de10c8730cc815fb4e923
parent38287eb93d0f8a0d5132f25deecfde6564a1467c (diff)
downloadvim-gitmodeline-0d651219b5d107dc19c4e941907bfd45aea58d9d.tar.gz
vim-gitmodeline-0d651219b5d107dc19c4e941907bfd45aea58d9d.tar.xz
vim-gitmodeline-0d651219b5d107dc19c4e941907bfd45aea58d9d.zip
Allow setting per-format modelines
To set a format specific modeline (you'll need the filetype plugin on), just define a vim.modeline.<FT> git config entry. Example, C indented with 4 spaces, but Makefile with 8 space tabs: git config --add vim.modeline.c "ts=4 sw=4 et" git config --add vim.modeline.make "ts=8 sw=8 noet" The good old "git config --add vim.modeline xxx" still works, and is used as a fallback if no filetype specific modelines were defined.
-rw-r--r--plugin/git_modeline.vim7
1 files changed, 7 insertions, 0 deletions
diff --git a/plugin/git_modeline.vim b/plugin/git_modeline.vim
index 0b78887..70b4183 100644
--- a/plugin/git_modeline.vim
+++ b/plugin/git_modeline.vim
@@ -66,6 +66,13 @@ fun! <SID>DoSetModeline(line) abort
endfun
fun! <SID>GitConfigModeline() abort
+ let git_config_modeline = system("git config --get vim.modeline." . &ft)
+
+ if strlen(git_config_modeline)
+ call <SID>DoSetModeline(git_config_modeline)
+ return
+ endif
+
let git_config_modeline = system("git config --get vim.modeline")
if strlen(git_config_modeline)
call <SID>DoSetModeline(git_config_modeline)