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

Use libuv-file-watcher to update loaded snippet-collections. #1033

Merged
merged 9 commits into from
Dec 2, 2023

Commits on Dec 2, 2023

  1. duplicate: always return the same table for retrieve_all.

    This is necessary for the key-invalidation in add_snippets, which
    expects that retrieve_all always returns the same objects.
    L3MON4D3 committed Dec 2, 2023
    Configuration menu
    Copy the full SHA
    14b20a5 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    6b8cacf View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    39c0b5b View commit details
    Browse the repository at this point in the history
  4. rename digraph-operations.

    calling add_edge twice with the same vertices will not connect the
    vertices twice.
    L3MON4D3 committed Dec 2, 2023
    Configuration menu
    Copy the full SHA
    694baa9 View commit details
    Browse the repository at this point in the history
  5. move lower-level methods out of main-module, add convenient wrappers.

    Since these functions are called by eg. all the loaders, this removes
    some potential for cyclic dependencies.
    Also add enqueable-operations-wrapper around refresh_notify and
    clean_invalidated, to prevent sending multiple updates for the same
    filetype in the same "tick"(?), and to remove some overhead that would
    result from calling clean_invalidated in quick succession (user doesn't
    care if snippets are removed a few milliseconds later, ofc).
    L3MON4D3 committed Dec 2, 2023
    Configuration menu
    Copy the full SHA
    1459438 View commit details
    Browse the repository at this point in the history
  6. fix: don't remove snippet-source set by loaders after first add.

    If the same snippet-object is added to multiple filetypes, only the
    first filetype receives the source-information.
    This is actually done by the vscode-package-loader, so not a
    theoretical concern, I guess jump-to-snippet is just not used enough for
    this to get noticed.
    L3MON4D3 committed Dec 2, 2023
    Configuration menu
    Copy the full SHA
    3f58738 View commit details
    Browse the repository at this point in the history
  7. feat: major overhaul of loaders. Check DOC.md-changes for the gist.

    Previously, we could not
    * add files that were not present when `load/lazy_load` was called to
      the collection. This is pretty annoying if one wants to add
      project-local snippets, or snippets for a new filetype (ofc).
    * load collections whose directory/package.json(c) did not exist when
      `load` was called.
      This is also an annoyance when creating project-local snippets, since
      a re-`load()` is required for the snippets to be picked up.
    * pick up on changes to the snippet-files from another neovim-instance
      (due to reloading on BufWritePost)
    
    This patch fixes all of these by modularizing the loaders a bit more,
    into one component ("Collection") which takes care of all the logic of
    loading different files, and another ("fswatchers") which notify the
    collections when a file-change is detected. This allows, first of all, a
    better design where the first concern can be nullified, and secondly, us
    to use libuvs api for file-watching, to implement the last two (if a
    potentially non-existing collection should be loaded, we can use libuv
    to wait for the collection-root/manifest-file, and create the collection
    once that exists).
    
    Another cool addition is the loader-snippet-cache, which makes it so
    that the snippet files (for vscode and snipmate) are only loaded once
    for all filetypes, and not once for each filetype. That's probably not
    noticeable though, except if a collection with many extends/languages
    for one json-file is loaded :D
    L3MON4D3 committed Dec 2, 2023
    Configuration menu
    Copy the full SHA
    3a47a1f View commit details
    Browse the repository at this point in the history
  8. Auto generate docs

    L3MON4D3 authored and github-actions[bot] committed Dec 2, 2023
    Configuration menu
    Copy the full SHA
    e13d6dd View commit details
    Browse the repository at this point in the history
  9. Format with stylua

    L3MON4D3 authored and github-actions[bot] committed Dec 2, 2023
    Configuration menu
    Copy the full SHA
    e4ad5fe View commit details
    Browse the repository at this point in the history