Cleanup previous PR

This commit is contained in:
Kovid Goyal
2022-06-06 17:19:52 +05:30
parent fc217dafba
commit 79f7954048
7 changed files with 47 additions and 27 deletions

View File

@@ -48,10 +48,17 @@ opt('replace_tab_by', '\\x20\\x20\\x20\\x20',
long_text='The string to replace tabs with. Default is to use four spaces.'
)
opt('ignore_paths', '',
option_type='pattern_list',
long_text='''List of patterns that are matched against directory and file
names and ignored when directories are compared.
opt('+ignore_name', '',
option_type='store_multiple',
add_to_default=False,
long_text='''
A glob pattern that is matched against only the filename of files and directories. Matching
files and directories are ignored when scanning the filesystem to look for files to diff.
Can be specified multiple times to use multiple patterns. For example::
ignore_name .git
ignore_name *~
ignore_name *.pyc
''',
)

View File

@@ -1,7 +1,7 @@
# generated by gen-config.py DO NOT edit
import typing
from kittens.diff.options.utils import parse_map, pattern_list, syntax_aliases
from kittens.diff.options.utils import parse_map, store_multiple, syntax_aliases
from kitty.conf.utils import merge_dicts, positive_int, python_string, to_color, to_color_or_none
@@ -37,6 +37,10 @@ class Parser:
def hunk_margin_bg(self, val: str, ans: typing.Dict[str, typing.Any]) -> None:
ans['hunk_margin_bg'] = to_color(val)
def ignore_name(self, val: str, ans: typing.Dict[str, typing.Any]) -> None:
for k, v in store_multiple(val, ans["ignore_name"]):
ans["ignore_name"][k] = v
def margin_bg(self, val: str, ans: typing.Dict[str, typing.Any]) -> None:
ans['margin_bg'] = to_color(val)
@@ -86,12 +90,10 @@ class Parser:
for k in parse_map(val):
ans['map'].append(k)
def ignore_paths(self, val: str, ans: typing.Dict[str, typing.Any]):
ans['ignore_paths'] = pattern_list(val)
def create_result_dict() -> typing.Dict[str, typing.Any]:
return {
'ignore_name': {},
'map': [],
}

View File

@@ -20,7 +20,7 @@ option_names = ( # {{{
'highlight_removed_bg',
'hunk_bg',
'hunk_margin_bg',
'ignore_paths',
'ignore_name',
'map',
'margin_bg',
'margin_fg',
@@ -50,7 +50,6 @@ class Options:
highlight_removed_bg: Color = Color(253, 184, 192)
hunk_bg: Color = Color(241, 248, 255)
hunk_margin_bg: Color = Color(219, 237, 255)
ignore_paths: typing.Tuple[str, ...] = ()
margin_bg: Color = Color(250, 251, 252)
margin_fg: Color = Color(170, 170, 170)
margin_filler_bg: typing.Optional[kitty.fast_data_types.Color] = None
@@ -66,6 +65,7 @@ class Options:
syntax_aliases: typing.Dict[str, str] = {'pyj': 'py', 'pyi': 'py', 'recipe': 'py'}
title_bg: Color = Color(255, 255, 255)
title_fg: Color = Color(0, 0, 0)
ignore_name: typing.Dict[str, str] = {}
map: typing.List[typing.Tuple[kitty.types.ParsedShortcut, kitty.conf.utils.KeyAction]] = []
key_definitions: KittensKeyMap = {}
config_paths: typing.Tuple[str, ...] = ()
@@ -118,6 +118,7 @@ class Options:
defaults = Options()
defaults.ignore_name = {}
defaults.map = [
# quit
(ParsedShortcut(mods=0, key_name='q'), KeyAction('quit')), # noqa

View File

@@ -3,8 +3,7 @@
# License: GPLv3 Copyright: 2021, Kovid Goyal <kovid at kovidgoyal.net>
import shlex
from typing import Any, Dict, Iterable, List, Tuple, Union
from typing import Any, Container, Dict, Iterable, Tuple, Union
from kitty.conf.utils import (
KeyFuncWrapper, KittensKeyDefinition, parse_kittens_key
@@ -59,8 +58,10 @@ def syntax_aliases(raw: str) -> Dict[str, str]:
return ans
def pattern_list(raw: str) -> Tuple[str, ...]:
return tuple(shlex.split(raw, comments=True))
def store_multiple(val: str, current_val: Container[str]) -> Iterable[Tuple[str, str]]:
val = val.strip()
if val not in current_val:
yield val, val
def parse_map(val: str) -> Iterable[KittensKeyDefinition]: