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:
parent
cc40bf717d
commit
2d236b4d62
@ -480,3 +480,18 @@ else
|
|||||||
return function(substitute(a:fstr, 's:', s:_s, 'g'))
|
return function(substitute(a:fstr, 's:', s:_s, 'g'))
|
||||||
endfunction
|
endfunction
|
||||||
endif
|
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
|
||||||
|
@ -18,3 +18,13 @@ function! SpaceVim#layers#lang#python#plugins() abort
|
|||||||
call add(plugins, ['Vimjas/vim-python-pep8-indent', { 'on_ft' : 'python'}])
|
call add(plugins, ['Vimjas/vim-python-pep8-indent', { 'on_ft' : 'python'}])
|
||||||
return plugins
|
return plugins
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
function! SpaceVim#layers#lang#python#config()
|
||||||
|
|
||||||
|
call SpaceVim#layers#edit#add_ft_head_tamplate('python',
|
||||||
|
\ ['#!/usr/bin/env python',
|
||||||
|
\ '# -*- coding: utf-8 -*-',
|
||||||
|
\ '']
|
||||||
|
\ )
|
||||||
|
|
||||||
|
endfunction
|
||||||
|
Loading…
Reference in New Issue
Block a user