[vim/vim] Some way to configure different coding/indent styles (Issue #17125)

6 views
Skip to first unread message

David Mandelberg

unread,
Apr 15, 2025, 3:50:00 PM4/15/25
to vim/vim, Subscribed

Is your feature request about something that is currently impossible or hard to do? Please describe the problem.

Some projects I've been contributing to lately have indent styles that are difficult to fully capture with editorconfig.

https://man.openbsd.org/style.9

Indentation is an 8 character tab. Second level indents are four spaces.

https://www.gnu.org/prep/standards/standards.html#Formatting recommends indenting curly braces differently than vim's defaults in some places.

Describe the solution you'd like

I think some new secondary filetypes would help? So runtime/indent/style_openbsd.vim could set cinoptions appropriately and I could run :setf c.style_openbsd for a C file using OpenBSD's style.

Describe alternatives you've considered

https://github.com/editorconfig/editorconfig/wiki/EditorConfig-Properties#ideas-for-domain-specific-properties mentions indent_brace_style, but I'm not sue if that has any adoption, and there's more to some of these styles than just brace indentation.

Maybe a config variable like let b:ft_c_indent_style = 'openbsd' would make sense instead? Some styles apply to multiple languages though. I think I've seen the GNU style in at least C and C++, and I'm not sure it would make sense to add variables for every filetype a style can be used with.

Maybe a new command separate from the filetype system, like :style openbsd which would work like runtime! style/openbsd.vim? I think using filetypes probably makes more sense though since a style could use any of ftplugin (e.g., setting commentstring to // %s vs /* %s */ for languages that support either), indent (e.g., cinoptions), or maybe syntax.

Additional context

I could work on a PR for openbsd style.


Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/17125@github.com>

dseomn created an issue (vim/vim#17125)

Is your feature request about something that is currently impossible or hard to do? Please describe the problem.

Some projects I've been contributing to lately have indent styles that are difficult to fully capture with editorconfig.

https://man.openbsd.org/style.9

Indentation is an 8 character tab. Second level indents are four spaces.

https://www.gnu.org/prep/standards/standards.html#Formatting recommends indenting curly braces differently than vim's defaults in some places.

Describe the solution you'd like

I think some new secondary filetypes would help? So runtime/indent/style_openbsd.vim could set cinoptions appropriately and I could run :setf c.style_openbsd for a C file using OpenBSD's style.

Describe alternatives you've considered

https://github.com/editorconfig/editorconfig/wiki/EditorConfig-Properties#ideas-for-domain-specific-properties mentions indent_brace_style, but I'm not sue if that has any adoption, and there's more to some of these styles than just brace indentation.

Maybe a config variable like let b:ft_c_indent_style = 'openbsd' would make sense instead? Some styles apply to multiple languages though. I think I've seen the GNU style in at least C and C++, and I'm not sure it would make sense to add variables for every filetype a style can be used with.

Maybe a new command separate from the filetype system, like :style openbsd which would work like runtime! style/openbsd.vim? I think using filetypes probably makes more sense though since a style could use any of ftplugin (e.g., setting commentstring to // %s vs /* %s */ for languages that support either), indent (e.g., cinoptions), or maybe syntax.

Additional context

I could work on a PR for openbsd style.


Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/17125@github.com>

Reply all
Reply to author
Forward
0 new messages