-
Notifications
You must be signed in to change notification settings - Fork 188
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(icons)!: use direct
get('extension', ext)
in "file" resolution
This approach is better for the following reasons: - Simplifies resolution logic. - Allows to stop manual tracking of common extensions for speed. - Caches ALL extensions instead of only manually tracked ones. Results in better performance in real world cases (about 50% more speed). - Does not use **all** cached extensions. This was a problem because a single `get('extension', 'xxx')` call could overshadow more general filetype matching resolution. Instead, using only recognizable extensions (i.e. not coming from fallback) is better in most cases (although results in always going through until calling `vim.filetype.match()` for unknown extensions). The speed improvement also relies on the assumption that there are more recognizable extensions than fallback ones: in first case cache will be used more frequently, in second one `vim.filetype.match()` will be used twice on the uncached unrecognizable extension (first to resolve extension, second to resolve "file"). Still present issues (to be solved in upcoming commits): - It blocks matches from `vim.filetype.match()` in case file name or pattern contains recognizable extension. Previously it was only an issue for manually tracked and cached extensions, but now it can happen in many more cases. For example: - Exact file names like 'requirements.txt', 'CMakeLists.txt'. Will be solved by manually tracking Neovim's built-in ones while directing users to add those during `setup()`. - Patterns containing extension, like for 'yaml.ansible' filetype ('.*/roles/.*/tasks/.*%.ya?ml') or 'query' ('queries/.*%.scm'). Will be solved by adding `use_file_extension` callable config entry (`function(ext, basename, name) return true end` as default) for users to tweak this manually.
- Loading branch information
1 parent
4d11d9f
commit fb0faa8
Showing
3 changed files
with
74 additions
and
34 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 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