See lua/libbuf/state.lua
for the plugin state read from and written to memory.
Principle
-
state._dir_storage
andstate._filepath_storage
contain file paths relating to files on the file system, which have annotations.
-
- Dependencies for lookup and cleanup are modeled via bidirectional edges
- Directories can own abs_dirpaths or rel_filepaths and each of those know which directory owns them (or if none, but only in case of a directory)
- Edges are represented as
Edges
absdirpath_hash -> {any_hash1, any_hash2, ..}
- Note: Ownership can be retrieved from comparing the paths
absdirpath_hash with any_hashX
, because-
dirpaths
must be absolute making them always owning filepaths
-
dirpath1
can only owndirpath2
, whendirpath1
is prefix ofdirpath2
.
-
-
- Annotations can be indexed via non-continuous integers:
For unmapped handles all indices are negative:
-1 -> { hash:{hash_abs_dir,hash_rel_filepath}, group:groupname, etc }
For mapped handles all indices are positive including 0:
0 -> { hash:{hash_abs_dir,hash_rel_filepath}, group:groupname, etc }
-
- Master buffer provides an overview over all buffers with annotations.
-
- Terminals are handled special to make completion and search work, but execution and collection of results is redirected to plenary jobs to retrieve the file including terminal escapes for the color codes.
Problems
-
- Subprojects are not modeled accurately. Consider
/home/user/proj1
/home/user/proj1/subproj2
/home/user/proj1/subproj2/src/file1
/home/user/proj1/subproj3/src/file1
subproj2
and subproj3
are not modeled as being subprojects of proj1
, so
the prefix path is "wasted".