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

[wordcount] Expose the default filetype list for modification #1887

Closed
wants to merge 1 commit into from
Closed

[wordcount] Expose the default filetype list for modification #1887

wants to merge 1 commit into from

Conversation

na-sa-do
Copy link

...instead of requiring the user to duplicate it if they like all of the items supplied and want more.

...instead of requiring the user to duplicate it if they like all of the
items supplied and want more.
@na-sa-do na-sa-do changed the title Expose the default filetype list for modification [wordcount] Expose the default filetype list for modification Mar 12, 2019
function! airline#extensions#wordcount#apply(...)
let filetypes = get(g:, 'airline#extensions#wordcount#filetypes', s:filetypes)
let filetypes = g:airline#extensions#wordcount#filetypes
Copy link
Member

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', []))

Copy link
Author

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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is lastknownfiletypes?

Copy link
Author

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.

@chrisbra
Copy link
Member

needs some documentation

@chrisbra chrisbra closed this in 45205aa Mar 19, 2019
@na-sa-do
Copy link
Author

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.

YCbCr pushed a commit to YCbCr/vim-airline that referenced this pull request May 26, 2019
allows better configuration of filetypes to be wordcounted.

fixes vim-airline#1887
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

Successfully merging this pull request may close these issues.

None yet

2 participants