mirror of
https://github.com/nix-community/nixvim.git
synced 2025-11-09 03:56:05 +01:00
dev/list-plugins: remove 'state' feature as all plugins have been migrated
This commit is contained in:
parent
deb32aecac
commit
beba0820c3
1 changed files with 6 additions and 37 deletions
|
|
@ -56,16 +56,9 @@ class Kind(Enum):
|
||||||
MISC = 3
|
MISC = 3
|
||||||
|
|
||||||
|
|
||||||
class State(Enum):
|
|
||||||
UNKNOWN = "❔"
|
|
||||||
NEW = "✅"
|
|
||||||
OLD = "❌"
|
|
||||||
|
|
||||||
|
|
||||||
KNOWN_PATHS: dict[
|
KNOWN_PATHS: dict[
|
||||||
str,
|
str,
|
||||||
tuple[
|
tuple[
|
||||||
State, # If the implem is "legacy" or up to date
|
|
||||||
Kind, # Vim / Neovim / misc
|
Kind, # Vim / Neovim / misc
|
||||||
bool, # Has deprecation warnings
|
bool, # Has deprecation warnings
|
||||||
],
|
],
|
||||||
|
|
@ -87,7 +80,6 @@ for telescope_extension_name, has_depr_warnings in {
|
||||||
KNOWN_PATHS[
|
KNOWN_PATHS[
|
||||||
f"plugins/by-name/telescope/extensions/{telescope_extension_name}.nix"
|
f"plugins/by-name/telescope/extensions/{telescope_extension_name}.nix"
|
||||||
] = (
|
] = (
|
||||||
State.NEW,
|
|
||||||
Kind.MISC,
|
Kind.MISC,
|
||||||
has_depr_warnings,
|
has_depr_warnings,
|
||||||
)
|
)
|
||||||
|
|
@ -107,12 +99,10 @@ DEPRECATION_REGEX: list[re.Pattern] = [
|
||||||
@dataclass
|
@dataclass
|
||||||
class Plugin:
|
class Plugin:
|
||||||
path: str
|
path: str
|
||||||
state: State
|
|
||||||
kind: Kind
|
kind: Kind
|
||||||
dep_warnings: bool
|
dep_warnings: bool
|
||||||
|
|
||||||
def __str__(self) -> str:
|
def __str__(self) -> str:
|
||||||
state_icon: str = self.state.value
|
|
||||||
kind_icon: str
|
kind_icon: str
|
||||||
match self.kind:
|
match self.kind:
|
||||||
case Kind.NEOVIM:
|
case Kind.NEOVIM:
|
||||||
|
|
@ -125,9 +115,7 @@ class Plugin:
|
||||||
assert False
|
assert False
|
||||||
deprecation_icon: str = "⚠️ " if self.dep_warnings else " "
|
deprecation_icon: str = "⚠️ " if self.dep_warnings else " "
|
||||||
|
|
||||||
return (
|
return f"| {kind_icon}\033[0m | {deprecation_icon} | {self.path}"
|
||||||
f"| {kind_icon}\033[0m | {state_icon} | {deprecation_icon} | {self.path}"
|
|
||||||
)
|
|
||||||
|
|
||||||
def print_markdown(self) -> None:
|
def print_markdown(self) -> None:
|
||||||
print(f"- [ ] {self.path} ({self.kind.name.lower()})")
|
print(f"- [ ] {self.path} ({self.kind.name.lower()})")
|
||||||
|
|
@ -146,36 +134,26 @@ def parse_file(path: str) -> Optional[Plugin]:
|
||||||
file_content = f.read()
|
file_content = f.read()
|
||||||
|
|
||||||
known_path: str
|
known_path: str
|
||||||
props: tuple[State, Kind, bool]
|
props: tuple[Kind, bool]
|
||||||
for known_path, props in KNOWN_PATHS.items():
|
for known_path, props in KNOWN_PATHS.items():
|
||||||
if known_path in path:
|
if known_path in path:
|
||||||
return Plugin(
|
return Plugin(
|
||||||
path=path,
|
path=path,
|
||||||
state=props[0],
|
kind=props[0],
|
||||||
kind=props[1],
|
dep_warnings=props[1],
|
||||||
dep_warnings=props[2],
|
|
||||||
)
|
)
|
||||||
|
|
||||||
state: State = State.UNKNOWN
|
|
||||||
kind: Kind
|
kind: Kind
|
||||||
if re.match(
|
if re.match(
|
||||||
re.compile(r".*mkNeovimPlugin", re.DOTALL),
|
re.compile(r".*mkNeovimPlugin", re.DOTALL),
|
||||||
file_content,
|
file_content,
|
||||||
):
|
):
|
||||||
kind = Kind.NEOVIM
|
kind = Kind.NEOVIM
|
||||||
state = State.NEW
|
|
||||||
elif re.match(
|
|
||||||
re.compile(r".*require.+setup", re.DOTALL),
|
|
||||||
file_content,
|
|
||||||
):
|
|
||||||
kind = Kind.NEOVIM
|
|
||||||
state = State.OLD
|
|
||||||
elif re.match(
|
elif re.match(
|
||||||
re.compile(r".*mkVimPlugin", re.DOTALL),
|
re.compile(r".*mkVimPlugin", re.DOTALL),
|
||||||
file_content,
|
file_content,
|
||||||
):
|
):
|
||||||
kind = Kind.VIM
|
kind = Kind.VIM
|
||||||
state = State.NEW
|
|
||||||
else:
|
else:
|
||||||
raise ValueError(
|
raise ValueError(
|
||||||
f"I was not able to categorize `{path}`. Consider adding it to `EXCLUDES` or `KNOWN_PATHS`."
|
f"I was not able to categorize `{path}`. Consider adding it to `EXCLUDES` or `KNOWN_PATHS`."
|
||||||
|
|
@ -183,7 +161,6 @@ def parse_file(path: str) -> Optional[Plugin]:
|
||||||
|
|
||||||
return Plugin(
|
return Plugin(
|
||||||
path=path,
|
path=path,
|
||||||
state=state,
|
|
||||||
kind=kind,
|
kind=kind,
|
||||||
dep_warnings=has_deprecation_warnings(string=file_content),
|
dep_warnings=has_deprecation_warnings(string=file_content),
|
||||||
)
|
)
|
||||||
|
|
@ -211,10 +188,8 @@ def main(args) -> None:
|
||||||
for plugin_path in filtered_paths:
|
for plugin_path in filtered_paths:
|
||||||
plugin: Optional[Plugin] = parse_file(path=plugin_path)
|
plugin: Optional[Plugin] = parse_file(path=plugin_path)
|
||||||
if plugin is not None:
|
if plugin is not None:
|
||||||
if (
|
if (args.kind is None or plugin.kind.name.lower() == args.kind) and (
|
||||||
(args.kind is None or plugin.kind.name.lower() == args.kind)
|
not args.deprecation_warnings or plugin.dep_warnings
|
||||||
and (args.state is None or plugin.state.name.lower() == args.state)
|
|
||||||
and (not args.deprecation_warnings or plugin.dep_warnings)
|
|
||||||
):
|
):
|
||||||
if args.markdown:
|
if args.markdown:
|
||||||
plugin.print_markdown()
|
plugin.print_markdown()
|
||||||
|
|
@ -246,12 +221,6 @@ if __name__ == "__main__":
|
||||||
choices=[k.name.lower() for k in Kind],
|
choices=[k.name.lower() for k in Kind],
|
||||||
help="Filter plugins by kind (neovim, vim, misc)",
|
help="Filter plugins by kind (neovim, vim, misc)",
|
||||||
)
|
)
|
||||||
parser.add_argument(
|
|
||||||
"-s",
|
|
||||||
"--state",
|
|
||||||
choices=[s.name.lower() for s in State],
|
|
||||||
help="Filter plugins by state (new, old, unknown)",
|
|
||||||
)
|
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"-d",
|
"-d",
|
||||||
"--deprecation-warnings",
|
"--deprecation-warnings",
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue