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
[wordcount] Expose the default filetype list for modification #1887
[wordcount] Expose the default filetype list for modification #1887
Conversation
...instead of requiring the user to duplicate it if they like all of the items supplied and want more.
function! airline#extensions#wordcount#apply(...) | ||
let filetypes = get(g:, 'airline#extensions#wordcount#filetypes', s:filetypes) | ||
let filetypes = g:airline#extensions#wordcount#filetypes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not something like let filetypes = uniq(sort(s:filetypes + get(g:, 'airline#extensions#wordcount#filetype', []))
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because the global variable is now guaranteed to exist (well, not guaranteed, but if it doesn't we have a bigger problem), and s:filetypes
is no longer a thing. This format allows both adding to and removing from the default set of filetypes without having to replicate it (and thus desync yourself from whatever vim-airline might do in the future).
if did_filetype() || filetypes isnot s:filetypes | ||
let s:filetypes = filetypes | ||
if did_filetype() || filetypes isnot s:lastknownfiletypes | ||
let s:lastknownfiletypes = filetypes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what is lastknownfiletypes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have to admit I'm not totally sure. I made this change ages ago in my private copy and completely forgot to PR it until I tried moving to a different computer and rediscovered it.
needs some documentation |
SFLR (a month? whoops), but that commit doesn't actually match the behaviour in my PR, @chrisbra. That only initializes the filetype list lazily, which means it still isn't possible to modify it from a vimrc. I suppose an autocmd might be able to do it, but I haven't had the chance to try, and anyway that seems unnecessarily indirect. |
allows better configuration of filetypes to be wordcounted. fixes vim-airline#1887
...instead of requiring the user to duplicate it if they like all of the items supplied and want more.