-
-
Notifications
You must be signed in to change notification settings - Fork 245
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
- Loading branch information
Showing
19 changed files
with
2,497 additions
and
737 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
--- This module stores all files loaded by any of the loaders, ordered by their | ||
--- filetype, and other data. | ||
--- This is to facilitate luasnip.loaders.edit_snippets, and to handle | ||
--- persistency of data, which is not given if it is stored in the module-file, | ||
--- since the module-name we use (luasnip.loaders.*) is not necessarily the one | ||
--- used by the user (luasnip/loader/*, for example), and the returned modules | ||
--- are different tables. | ||
|
||
local autotable = require("luasnip.util.auto_table").autotable | ||
|
||
local M = { | ||
lua_collections = {}, | ||
lua_ft_paths = autotable(2), | ||
|
||
snipmate_collections = {}, | ||
snipmate_ft_paths = autotable(2), | ||
-- set by loader. | ||
snipmate_cache = nil, | ||
|
||
vscode_package_collections = {}, | ||
vscode_standalone_watchers = {}, | ||
vscode_ft_paths = autotable(2), | ||
-- set by loader. | ||
vscode_cache = nil, | ||
} | ||
|
||
return M |
Oops, something went wrong.