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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -82,13 +82,15 @@ endfunction | |
|
||
" airline functions {{{1 | ||
" default filetypes: | ||
let s:filetypes = ['help', 'markdown', 'rst', 'org', 'text', 'asciidoc', 'tex', 'mail'] | ||
let g:airline#extensions#wordcount#filetypes = | ||
\ ['help', 'markdown', 'rst', 'org', 'text', 'asciidoc', 'tex', 'mail'] | ||
let s:lastknownfiletypes = g:airline#extensions#wordcount#filetypes | ||
function! airline#extensions#wordcount#apply(...) | ||
let filetypes = get(g:, 'airline#extensions#wordcount#filetypes', s:filetypes) | ||
let filetypes = g:airline#extensions#wordcount#filetypes | ||
|
||
" Check if filetype needs testing | ||
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 commentThe 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 commentThe 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. |
||
|
||
" Select test based on type of "filetypes": new=list, old=string | ||
if type(filetypes) == get(v:, 't_list', type([])) | ||
|
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).