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

vim plugin should support scoped configuration vars #1179

Open
rpdelaney opened this issue Nov 28, 2019 · 0 comments
Open

vim plugin should support scoped configuration vars #1179

rpdelaney opened this issue Nov 28, 2019 · 0 comments
Labels
C: vim Vim plugin T: enhancement New feature or request

Comments

@rpdelaney
Copy link

rpdelaney commented Nov 28, 2019

Problem statement

I use files in .vim/after/ftplugin to set filetype specific settings in vim. For example:

after/ftplugin/python.vim
---
autocmd BufWritePre <buffer> execute ':Black'
let g:black_linelength = 79

This pattern is useful because configuration variables irrelevant to the file type I'm handling are not set, and also I avoid executing every autocmd for every buffer I open.

However, the vim-black plugin does not read variables set in the local scope. Therefore, every time I open a buffer with filetype python, g:black_linelength is set. This could also give rise to conflicts in settings when files from different projects with different style conventions are open at the same time in different buffers.

Proposed solution

vim-black should provide support for configuration options at each appropriate scope level:

buffer-variable    b:     Local to the current buffer.
window-variable    w:     Local to the current window.
tabpage-variable   t:     Local to the current tab page.
global-variable    g:     Global.

Variables with the lowest scope should take precedence over others. For instance, if b:black_linelength is 120, but g:black_linelength is 79, Black should enforce line length 120.

Considered alternatives

N/A

If there is support for this I could try to put a PR together. (But be warned, my vimscript is even worse than my python ;)

@rpdelaney rpdelaney added the T: enhancement New feature or request label Nov 28, 2019
@rpdelaney rpdelaney changed the title vim plugin should support buffer scoped configuration vars vim plugin should support scoped configuration vars Nov 28, 2019
@JelleZijlstra JelleZijlstra added the C: vim Vim plugin label May 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C: vim Vim plugin T: enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants