[nvim] use Yapf with a modified config for formatting
This commit is contained in:
parent
2c6193a487
commit
74e978d78e
|
@ -32,8 +32,7 @@ selection_bg = base16_colors[0x2]
|
||||||
selection_fg = fg
|
selection_fg = fg
|
||||||
|
|
||||||
ansi_colors = [
|
ansi_colors = [
|
||||||
base16_colors[int(i, 16)]
|
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()
|
||||||
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]
|
link_color = ansi_colors[0xC]
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
import _theme as theme
|
import _theme as theme
|
||||||
|
|
||||||
|
|
||||||
print(
|
print(
|
||||||
"""\
|
"""\
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
@ -13,7 +14,7 @@ print(
|
||||||
|
|
||||||
|
|
||||||
def print_color(key_name, color):
|
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(
|
print(
|
||||||
"""\
|
"""\
|
||||||
<key>{} Color</key>
|
<key>{} Color</key>
|
||||||
|
@ -27,9 +28,7 @@ def print_color(key_name, color):
|
||||||
<key>Blue Component</key>
|
<key>Blue Component</key>
|
||||||
<real>{}</real>
|
<real>{}</real>
|
||||||
</dict>\
|
</dict>\
|
||||||
""".format(
|
""".format(key_name, r, g, b)
|
||||||
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("Ansi " + str(index), color)
|
||||||
print_color("Link", theme.link_color)
|
print_color("Link", theme.link_color)
|
||||||
|
|
||||||
print(
|
print("""\
|
||||||
"""\
|
|
||||||
</dict>
|
</dict>
|
||||||
</plist>\
|
</plist>\
|
||||||
"""
|
""")
|
||||||
)
|
|
||||||
|
|
|
@ -7,8 +7,6 @@ with open(os.path.join(os.path.dirname(__file__), "prismjs-theme-src.css")) as f
|
||||||
css_src = f.read()
|
css_src = f.read()
|
||||||
|
|
||||||
for var_name, color in theme.css_variables.items():
|
for var_name, color in theme.css_variables.items():
|
||||||
css_src = css_src.replace(
|
css_src = css_src.replace("var(--{}{})".format(theme.css_variables_prefix, var_name), color)
|
||||||
"var(--{}{})".format(theme.css_variables_prefix, var_name), color
|
|
||||||
)
|
|
||||||
|
|
||||||
print(css_src)
|
print(css_src)
|
||||||
|
|
|
@ -8,11 +8,4 @@ import _theme as theme
|
||||||
# 0,0,0,0,170,170,170,170,85,85,85,85,255,255,255,255
|
# 0,0,0,0,170,170,170,170,85,85,85,85,255,255,255,255
|
||||||
|
|
||||||
for i in range(3):
|
for i in range(3):
|
||||||
print(
|
print(",".join([str(int(color[2 * i + 1:2 * i + 3], 16)) for color in theme.ansi_colors[:16]]))
|
||||||
",".join(
|
|
||||||
[
|
|
||||||
str(int(color[2 * i + 1 : 2 * i + 3], 16))
|
|
||||||
for color in theme.ansi_colors[:16]
|
|
||||||
]
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
import _theme as theme
|
import _theme as theme
|
||||||
|
|
||||||
|
|
||||||
print(":root {")
|
print(":root {")
|
||||||
for var_name, color in theme.css_variables.items():
|
for var_name, color in theme.css_variables.items():
|
||||||
print(" --{}{}: {};".format(theme.css_variables_prefix, var_name, color))
|
print(" --{}{}: {};".format(theme.css_variables_prefix, var_name, color))
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
import _theme as theme
|
import _theme as theme
|
||||||
|
|
||||||
|
|
||||||
print("let dotfiles_colorscheme_name = '{}'".format(theme.name))
|
print("let dotfiles_colorscheme_name = '{}'".format(theme.name))
|
||||||
print("let dotfiles_colorscheme_base16_name = '{}'".format(theme.base16_name))
|
print("let dotfiles_colorscheme_base16_name = '{}'".format(theme.base16_name))
|
||||||
print("let dotfiles_colorscheme_base16_colors = [")
|
print("let dotfiles_colorscheme_base16_colors = [")
|
||||||
|
|
|
@ -25,11 +25,7 @@ colors = {
|
||||||
|
|
||||||
for color_brightness in [False, True]:
|
for color_brightness in [False, True]:
|
||||||
for color_index, color_name in enumerate(ANSI_COLOR_NAMES):
|
for color_index, color_name in enumerate(ANSI_COLOR_NAMES):
|
||||||
color = theme.ansi_colors[
|
color = theme.ansi_colors[color_index + int(color_brightness) * len(ANSI_COLOR_NAMES)]
|
||||||
color_index + int(color_brightness) * len(ANSI_COLOR_NAMES)
|
colors["terminal.ansi" + ("Bright" if color_brightness else "") + color_name] = color
|
||||||
]
|
|
||||||
colors[
|
|
||||||
"terminal.ansi" + ("Bright" if color_brightness else "") + color_name
|
|
||||||
] = color
|
|
||||||
|
|
||||||
print(json.dumps(colors, ensure_ascii=False, indent=2))
|
print(json.dumps(colors, ensure_ascii=False, indent=2))
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
import _theme as theme
|
import _theme as theme
|
||||||
|
|
||||||
|
|
||||||
print("[Scheme]")
|
print("[Scheme]")
|
||||||
print("Name=dmitmel's dotfiles colorscheme")
|
print("Name=dmitmel's dotfiles colorscheme")
|
||||||
print("ColorForeground={}".format(theme.fg))
|
print("ColorForeground={}".format(theme.fg))
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
|
|
||||||
import _theme as theme
|
import _theme as theme
|
||||||
|
|
||||||
|
|
||||||
for attr in [
|
for attr in [
|
||||||
"bg",
|
"bg",
|
||||||
"fg",
|
"fg",
|
||||||
|
|
|
@ -1,12 +1,24 @@
|
||||||
let g:coc_global_extensions += ['coc-pyright']
|
let g:coc_global_extensions += ['coc-pyright']
|
||||||
let g:coc_filetypes += ['python']
|
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.autocomplete.showAdvancedMembers'] = v:false
|
||||||
let g:coc_user_config['python'] = {
|
let g:coc_user_config['python'] = {
|
||||||
\ 'formatting': { 'provider': 'black' },
|
\ 'formatting': {
|
||||||
|
\ 'provider': 'yapf',
|
||||||
|
\ 'yapfArgs': ['--style=' . simplify(g:nvim_dotfiles_dir.'/../python/yapf.ini')]
|
||||||
|
\ },
|
||||||
\ 'linting': {
|
\ 'linting': {
|
||||||
\ 'pylintEnabled': v:false,
|
\ 'pylintEnabled': v:false,
|
||||||
\ 'flake8Enabled': v:true,
|
\ 'flake8Enabled': v:true,
|
||||||
\ 'flake8Args': ['--ignore', 'E501'],
|
\ 'flake8Args': ['--ignore=' . join(s:ignored_errors, ',')],
|
||||||
\ },
|
\ },
|
||||||
\ }
|
\ }
|
||||||
|
|
|
@ -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
|
|
@ -4,7 +4,6 @@ import subprocess
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Iterable, NoReturn
|
from typing import Iterable, NoReturn
|
||||||
|
|
||||||
|
|
||||||
if os.name == "posix":
|
if os.name == "posix":
|
||||||
DOTFILES_CONFIG_DIR: Path = Path.home() / ".config" / "dotfiles"
|
DOTFILES_CONFIG_DIR: Path = Path.home() / ".config" / "dotfiles"
|
||||||
DOTFILES_CACHE_DIR: Path = Path.home() / ".cache" / "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))
|
raise Exception("platform '{}' is not supported!".format(sys.platform))
|
||||||
|
|
||||||
|
|
||||||
def run_chooser(
|
def run_chooser(choices: Iterable[str], prompt: str = None, async_read: bool = False) -> int:
|
||||||
choices: Iterable[str], prompt: str = None, async_read: bool = False
|
|
||||||
) -> int:
|
|
||||||
supports_result_index = True
|
supports_result_index = True
|
||||||
if os.isatty(sys.stderr.fileno()):
|
if os.isatty(sys.stderr.fileno()):
|
||||||
process_args = [
|
process_args = [
|
||||||
|
@ -38,9 +35,7 @@ def run_chooser(
|
||||||
else:
|
else:
|
||||||
platform_not_supported_error()
|
platform_not_supported_error()
|
||||||
|
|
||||||
chooser_process = subprocess.Popen(
|
chooser_process = subprocess.Popen(process_args, stdin=subprocess.PIPE, stdout=subprocess.PIPE)
|
||||||
process_args, stdin=subprocess.PIPE, stdout=subprocess.PIPE
|
|
||||||
)
|
|
||||||
|
|
||||||
with chooser_process.stdin as pipe:
|
with chooser_process.stdin as pipe:
|
||||||
for index, choice in enumerate(choices):
|
for index, choice in enumerate(choices):
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
from colorama import Fore, Style, ansi
|
from colorama import Fore, Style, ansi
|
||||||
|
|
||||||
|
|
||||||
COLORS = [ansi.code_to_chars(30 + color_index) for color_index in range(0, 8)]
|
COLORS = [ansi.code_to_chars(30 + color_index) for color_index in range(0, 8)]
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,7 @@ import re
|
||||||
from colors import COLORS, Style
|
from colors import COLORS, Style
|
||||||
from system_info import get_system_info
|
from system_info import get_system_info
|
||||||
|
|
||||||
|
|
||||||
print("")
|
print("")
|
||||||
|
|
||||||
logo_lines, info_lines = get_system_info()
|
logo_lines, info_lines = get_system_info()
|
||||||
|
|
|
@ -94,9 +94,7 @@ def _get_users():
|
||||||
terminals = users[name]
|
terminals = users[name]
|
||||||
|
|
||||||
colored_name = bright_colored(name, Fore.BLUE)
|
colored_name = bright_colored(name, Fore.BLUE)
|
||||||
colored_terminals = [
|
colored_terminals = [colored(str(term), Style.DIM, Fore.WHITE) for term in terminals]
|
||||||
colored(str(term), Style.DIM, Fore.WHITE) for term in terminals
|
|
||||||
]
|
|
||||||
|
|
||||||
terminals_str = ", ".join(colored_terminals)
|
terminals_str = ", ".join(colored_terminals)
|
||||||
if len(colored_terminals) > 1:
|
if len(colored_terminals) > 1:
|
||||||
|
@ -140,14 +138,12 @@ def _get_disks():
|
||||||
continue
|
continue
|
||||||
|
|
||||||
usage = psutil.disk_usage(disk.mountpoint)
|
usage = psutil.disk_usage(disk.mountpoint)
|
||||||
result.append(
|
result.append((
|
||||||
(
|
disk.mountpoint,
|
||||||
disk.mountpoint,
|
humanize_bytes(usage.used),
|
||||||
humanize_bytes(usage.used),
|
humanize_bytes(usage.total),
|
||||||
humanize_bytes(usage.total),
|
colorize_percent(usage.percent, warning=70, critical=85),
|
||||||
colorize_percent(usage.percent, warning=70, critical=85),
|
))
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue