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
feat: Include more labels in completion menu #402
base: master
Are you sure you want to change the base?
Conversation
Previously the 'completion' module could suggest only bibliographical entries in the omni-completion menu. Add capability that includes more entries in the omni-completion menu. These additional entries include labels for figures, tables, equations, listings etc. Furthermore, also include in the omni-completion menu, the names of images that are not yet used in the current buffer (markdown document).
Use case-sensitive regex compares to get by the vint errors.
This again to get past the vint check.
@@ -18,8 +18,28 @@ function! pandoc#completion#Init() abort "{{{1 | |||
let g:pandoc#completion#bib#use_preview = 0 | |||
endif | |||
endif | |||
|
|||
" | |||
" If your images are in the same directory as the markdown file, they are included |
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.
Is figures
that standard? Most natural would be images
(what I use). Also, rather figs
than fig
following the convention to name a directory in the plural form (Documents
, Pictures
, Downloads
...)
I now realize that g:pandoc#completion#figdirpre
is not initialized by default; if there is such a standard (like labelling section by sec:...
) maybe it could be set to it.
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.
added a commit to take care of this.
" | ||
fun! s:FetchRefLabels() abort | ||
let l:reflist = [] | ||
call execute( |
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.
Maybe this could be done for all open buffers at least by bufdo
? (...and at some point by all globbed markdown in the work dir?)
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.
This makes sense when you split your work among multiple files.I have made use of the bufdo feature in the most recent commit.
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.
Good job! It makes sense to restrict to only all those buffers that have &l:filetype='pandoc'
.
There is also argdo
after argadd *.{pandoc,md}
(where the extensions are given by ftdetect/pandoc.vim
). The argument list should be stored and restore.
Maybe optionally glob in the all sub directories, that is, argadd **/*.{pandoc,md}
.
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.
Thinking about it, **/*.{pandoc,md}
seems more reasonable by default. Since this could take time, better load it once initially and then refresh it by an autocmd BufWrite
.
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.
Do you still wish to store and restore arglist ?
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.
Yes. Temporarily overriding the arglist is, not unusual in Vimscript, not the cleanest solution, but readily implemented once everything set up for the buffer list. Perhaps the autocmd
update can be skipped for the time being: New items are in the buffer list anyway. Of course such a buffer can be closed, but whether the effort is worth it remains questionable.
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.
Added a variable called g:pandoc#completion#refsources that lets the user to choose to use all pandoc files from currently opened buffers, or to use all 'pandoc' files in the current directory (recursively). This is in the most recent commit.
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.
Very good. Thank you! Let's see if the maintainers @alerque and @fmoralesc deem it good to go?!
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.
Is there a way to avoid the flicker when the completion entry list is first populated?
In the comments make refer to images as 'images' instead of 'figures'. In the code, replace 'fig' with 'img'.
Previously, the list of internal references was fetched only from the current buffer. Add a feature to fetch this list from all open buffers. The list of image paths to be inserted should be updated accordingly.
Previously, the reference labels were fetched from all open buffers. Add an option by which the user can choose to use all 'pandoc' files in the current directoy (recursively) as sources of these reference labels (such as fig:,tbl:,lst:,eq: etc.).
Thanks for taking the time to contribute this! I haven't had the bandwidth to follow along as this progressed, but I'm glad to see @Konfekt is on this. Please do feel free to specifically request PR review when you feel like it's ready. |
call extend(l:pandocfiles, glob('**/*.pd', 1, 1)) | ||
call extend(l:pandocfiles, glob('**/*.pdc', 1, 1)) | ||
execute 'argadd ' . join(l:pandocfiles) | ||
if get(g:, 'pandoc#filetypes#pandoc_markdown', 1) == 1 |
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.
For some reason the entries in globbed files in the current work dir did not appear. Only those of open buffers.
" | ||
fun! s:FetchRefLabels() abort | ||
let l:reflist = [] | ||
call execute( |
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.
Is there a way to avoid the flicker when the completion entry list is first populated?
Hello @patashish704 , thank you again for your contribution. Is this ready? |
Previously the 'completion' module could suggest only bibliographical
entries in the omni-completion menu. Add capability that includes more
entries in the omni-completion menu.
These additional entries include labels for figures, tables, equations,
listings etc. Furthermore, also include in the omni-completion menu, the
names of images that are not yet used in the current buffer (markdown
document).