1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-01-24 02:20:03 +08:00

Auto add buffer head

This commit is contained in:
wsdjeg 2017-07-28 08:07:50 +08:00
parent cc40bf717d
commit 2d236b4d62
2 changed files with 25 additions and 0 deletions

View File

@ -480,3 +480,18 @@ else
return function(substitute(a:fstr, 's:', s:_s, 'g'))
endfunction
endif
augroup spacevim_layer_edit
au!
autocmd BufNewFile *.py call <SID>add_buffer_head()
augroup END
let s:ft_head_tp = {}
function! s:add_buffer_head() abort
if has_key(s:ft_head_tp, &ft)
call setline(1, s:ft_head_tp[&ft])
endif
endfunction
function! SpaceVim#layers#edit#add_ft_head_tamplate(ft, tamp)
call extend(s:ft_head_tp, {a:ft : a:tamp})
endfunction

View File

@ -18,3 +18,13 @@ function! SpaceVim#layers#lang#python#plugins() abort
call add(plugins, ['Vimjas/vim-python-pep8-indent', { 'on_ft' : 'python'}])
return plugins
endfunction
function! SpaceVim#layers#lang#python#config()
call SpaceVim#layers#edit#add_ft_head_tamplate('python',
\ ['#!/usr/bin/env python',
\ '# -*- coding: utf-8 -*-',
\ '']
\ )
endfunction