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

feat: Include more labels in completion menu #402

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

patashish704
Copy link

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).

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

@Konfekt Konfekt Apr 12, 2021

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.

Copy link
Author

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(
Copy link
Contributor

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?)

Copy link
Author

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.

Copy link
Contributor

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}.

Copy link
Contributor

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.

Copy link
Author

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 ?

Copy link
Contributor

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.

Copy link
Author

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.

Copy link
Contributor

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?!

Copy link
Contributor

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.).
@alerque
Copy link
Member

alerque commented May 7, 2021

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

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(
Copy link
Contributor

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?

@Konfekt
Copy link
Contributor

Konfekt commented Dec 4, 2023

Hello @patashish704 , thank you again for your contribution. Is this ready?

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

3 participants