Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to pass filetype to func for user-variables #146

Open
zzs213 opened this issue Oct 23, 2020 · 0 comments
Open

how to pass filetype to func for user-variables #146

zzs213 opened this issue Oct 23, 2020 · 0 comments

Comments

@zzs213
Copy link

zzs213 commented Oct 23, 2020

When generate modeline using user-variable. The func to generate custom modeline should know which filetype to generate.

So howto pass the filetype to the func. My code as flowwing

`
let g:templates_user_variables = [
\ ['MODELINE', 'Modeline_str'],
\ ]
function! Modeline_str(type)
let modeline = {
\ 'c' : [printf('/* vi: set ft=c fo=%s tw=100 sw=8 ts=8 sts=8 fenc=utf-8 ai noet: /', s:my_formatoptions), ''],
\ 'cpp' : [printf('/
vi: set ft=cpp fo=%s tw=100 sw=8 ts=8 sts=8 fenc=utf-8 ai noet: */', s:my_formatoptions), ''],
\ 'sh' : ['#!/bin/bash',
\ printf('# vi: set ft=sh fo=%s tw=100 sw=4 ts=4 sts=4 fenc=utf-8 isk-=. ai et:', s:my_formatoptions),
\ ''],
\ 'make' : [printf('# vi: set ft=make fo=%s tw=100 sw=8 ts=8 sts=8 fenc=utf-8 ai noet:', s:my_formatoptions), ''],
\ }

if !has_key(modeline, a:type)
    return ''
endif

return modeline[a:type]

endfunction
`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant