[nvim] use Yapf with a modified config for formatting

This commit is contained in:
Dmytro Meleshko 2021-04-26 10:07:31 +03:00
parent 2c6193a487
commit 74e978d78e
15 changed files with 47 additions and 49 deletions

View File

@ -32,8 +32,7 @@ selection_bg = base16_colors[0x2]
selection_fg = fg
ansi_colors = [
base16_colors[int(i, 16)]
for i in "0 8 B A D E C 5 3 8 B A D E C 7 9 F 1 2 4 6".split()
base16_colors[int(i, 16)] for i in "0 8 B A D E C 5 3 8 B A D E C 7 9 F 1 2 4 6".split()
]
link_color = ansi_colors[0xC]

View File

@ -2,6 +2,7 @@
import _theme as theme
print(
"""\
<?xml version="1.0" encoding="UTF-8"?>
@ -13,7 +14,7 @@ print(
def print_color(key_name, color):
r, g, b = [float(int(color[2 * i + 1 : 2 * i + 3], 16)) / 255 for i in range(3)]
r, g, b = [float(int(color[2 * i + 1:2 * i + 3], 16)) / 255 for i in range(3)]
print(
"""\
<key>{} Color</key>
@ -27,9 +28,7 @@ def print_color(key_name, color):
<key>Blue Component</key>
<real>{}</real>
</dict>\
""".format(
key_name, r, g, b
)
""".format(key_name, r, g, b)
)
@ -44,9 +43,7 @@ for index, color in enumerate(theme.ansi_colors[:16]):
print_color("Ansi " + str(index), color)
print_color("Link", theme.link_color)
print(
"""\
print("""\
</dict>
</plist>\
"""
)
""")

View File

@ -7,8 +7,6 @@ with open(os.path.join(os.path.dirname(__file__), "prismjs-theme-src.css")) as f
css_src = f.read()
for var_name, color in theme.css_variables.items():
css_src = css_src.replace(
"var(--{}{})".format(theme.css_variables_prefix, var_name), color
)
css_src = css_src.replace("var(--{}{})".format(theme.css_variables_prefix, var_name), color)
print(css_src)

View File

@ -8,11 +8,4 @@ import _theme as theme
# 0,0,0,0,170,170,170,170,85,85,85,85,255,255,255,255
for i in range(3):
print(
",".join(
[
str(int(color[2 * i + 1 : 2 * i + 3], 16))
for color in theme.ansi_colors[:16]
]
)
)
print(",".join([str(int(color[2 * i + 1:2 * i + 3], 16)) for color in theme.ansi_colors[:16]]))

View File

@ -2,6 +2,7 @@
import _theme as theme
print(":root {")
for var_name, color in theme.css_variables.items():
print(" --{}{}: {};".format(theme.css_variables_prefix, var_name, color))

View File

@ -2,6 +2,7 @@
import _theme as theme
print("let dotfiles_colorscheme_name = '{}'".format(theme.name))
print("let dotfiles_colorscheme_base16_name = '{}'".format(theme.base16_name))
print("let dotfiles_colorscheme_base16_colors = [")

View File

@ -25,11 +25,7 @@ colors = {
for color_brightness in [False, True]:
for color_index, color_name in enumerate(ANSI_COLOR_NAMES):
color = theme.ansi_colors[
color_index + int(color_brightness) * len(ANSI_COLOR_NAMES)
]
colors[
"terminal.ansi" + ("Bright" if color_brightness else "") + color_name
] = color
color = theme.ansi_colors[color_index + int(color_brightness) * len(ANSI_COLOR_NAMES)]
colors["terminal.ansi" + ("Bright" if color_brightness else "") + color_name] = color
print(json.dumps(colors, ensure_ascii=False, indent=2))

View File

@ -2,6 +2,7 @@
import _theme as theme
print("[Scheme]")
print("Name=dmitmel's dotfiles colorscheme")
print("ColorForeground={}".format(theme.fg))

View File

@ -2,7 +2,6 @@
import _theme as theme
for attr in [
"bg",
"fg",

View File

@ -1,12 +1,24 @@
let g:coc_global_extensions += ['coc-pyright']
let g:coc_filetypes += ['python']
" let g:coc_user_config['pyls.plugins.pycodestyle.ignore'] = ['E501']
let s:ignored_errors = []
" Indent is not a multiple of 4
let s:ignored_errors += ['E111']
" Indent is not a multiple of 4 for comments
let s:ignored_errors += ['E114']
" Line too long
let s:ignored_errors += ['E501']
" let g:coc_user_config['pyls.plugins.pycodestyle.ignore'] = s:ignored_errors
" let g:coc_user_config['python.autocomplete.showAdvancedMembers'] = v:false
let g:coc_user_config['python'] = {
\ 'formatting': { 'provider': 'black' },
\ 'formatting': {
\ 'provider': 'yapf',
\ 'yapfArgs': ['--style=' . simplify(g:nvim_dotfiles_dir.'/../python/yapf.ini')]
\ },
\ 'linting': {
\ 'pylintEnabled': v:false,
\ 'flake8Enabled': v:true,
\ 'flake8Args': ['--ignore', 'E501'],
\ 'flake8Args': ['--ignore=' . join(s:ignored_errors, ',')],
\ },
\ }

8
python/yapf.ini Normal file
View File

@ -0,0 +1,8 @@
[style]
based_on_style = google
column_limit = 99
indent_width = 4
blank_lines_between_top_level_imports_and_variables = 2
dedent_closing_brackets = true
coalesce_brackets = true
spaces_around_power_operator = true

View File

@ -4,7 +4,6 @@ import subprocess
from pathlib import Path
from typing import Iterable, NoReturn
if os.name == "posix":
DOTFILES_CONFIG_DIR: Path = Path.home() / ".config" / "dotfiles"
DOTFILES_CACHE_DIR: Path = Path.home() / ".cache" / "dotfiles"
@ -14,9 +13,7 @@ def platform_not_supported_error() -> NoReturn:
raise Exception("platform '{}' is not supported!".format(sys.platform))
def run_chooser(
choices: Iterable[str], prompt: str = None, async_read: bool = False
) -> int:
def run_chooser(choices: Iterable[str], prompt: str = None, async_read: bool = False) -> int:
supports_result_index = True
if os.isatty(sys.stderr.fileno()):
process_args = [
@ -38,9 +35,7 @@ def run_chooser(
else:
platform_not_supported_error()
chooser_process = subprocess.Popen(
process_args, stdin=subprocess.PIPE, stdout=subprocess.PIPE
)
chooser_process = subprocess.Popen(process_args, stdin=subprocess.PIPE, stdout=subprocess.PIPE)
with chooser_process.stdin as pipe:
for index, choice in enumerate(choices):

View File

@ -1,5 +1,6 @@
from colorama import Fore, Style, ansi
COLORS = [ansi.code_to_chars(30 + color_index) for color_index in range(0, 8)]

View File

@ -5,6 +5,7 @@ import re
from colors import COLORS, Style
from system_info import get_system_info
print("")
logo_lines, info_lines = get_system_info()

View File

@ -94,9 +94,7 @@ def _get_users():
terminals = users[name]
colored_name = bright_colored(name, Fore.BLUE)
colored_terminals = [
colored(str(term), Style.DIM, Fore.WHITE) for term in terminals
]
colored_terminals = [colored(str(term), Style.DIM, Fore.WHITE) for term in terminals]
terminals_str = ", ".join(colored_terminals)
if len(colored_terminals) > 1:
@ -140,14 +138,12 @@ def _get_disks():
continue
usage = psutil.disk_usage(disk.mountpoint)
result.append(
(
disk.mountpoint,
humanize_bytes(usage.used),
humanize_bytes(usage.total),
colorize_percent(usage.percent, warning=70, critical=85),
)
)
result.append((
disk.mountpoint,
humanize_bytes(usage.used),
humanize_bytes(usage.total),
colorize_percent(usage.percent, warning=70, critical=85),
))
return result