On Windows, both forward slash `/` and backslash `\\` work as the path
separator. Linux and MacOS can have backslash as a valid filename
character.
Unit tests are also provided for each platform because `Path.parent`
depends on the local variable `sep` which depends on `jit.os`.
Fixes#1168
Sometimes the treesitter-language-name coincides with the filetype (like for cpp), but in other cases, these are wholly different (lang: latex, filetype: tex/sty/cls). So, to be more accomodating and forego the need on the users part to define the correct `ls.filetype_extend`, we resolve language to filetypes in here.
This restores the pre-d9cb6ab-behaviour of completely leaving a snippet once $0 is reached, instead of leaving the possibility of jumping back into it.
This behaviour can be turned on or off via `exit_roots`, and, like the other settings that superseded `history`, `exit_roots` will be set s.t. `history` still/again behaves as expected.
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
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.
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).