Browse Source

add black as a formatter and format stuff with it

main
Brian Hicks 2 years ago
parent
commit
72b581f474
  1. 18
      dotfiles/kakoune.nix
  2. 4
      occasional-scripts/chapters.py
  3. 8
      occasional-scripts/flashcardify.py
  4. 3
      shell.nix

18
dotfiles/kakoune.nix

@ -146,6 +146,24 @@ in {
option = ".*.hs";
}
# Python
{
name = "WinCreate";
option = ".*.py";
commands = ''
evaluate-commands %sh{
if which black > /dev/null; then
echo 'set-option buffer formatcmd "black - --quiet --fast"'
fi
}
'';
}
{
commands = "format";
name = "BufWritePre";
option = ".*.py";
}
# Indents
{
name = "WinCreate";

4
occasional-scripts/chapters.py

@ -3,7 +3,7 @@ from __future__ import print_function, unicode_literals
import argparse
parser = argparse.ArgumentParser()
parser.add_argument('num_chapters', type=int)
parser.add_argument("num_chapters", type=int)
args = parser.parse_args()
task_templates = [
@ -12,6 +12,6 @@ task_templates = [
"make flashcards for chapter {}",
]
for i in range(1, args.num_chapters+1):
for i in range(1, args.num_chapters + 1):
for template in task_templates:
print(template.format(i))

8
occasional-scripts/flashcardify.py

@ -3,12 +3,12 @@ import sys
import argparse
parser = argparse.ArgumentParser()
parser.add_argument('--name', default=None)
parser.add_argument("--name", default=None)
args = parser.parse_args()
for line in sys.stdin.read().split('\n'):
out = line.strip('- ').split('|')
for line in sys.stdin.read().split("\n"):
out = line.strip("- ").split("|")
if args.name is not None:
out.append(args.name)
print('\t'.join(out))
print("\t".join(out))

3
shell.nix

@ -10,6 +10,9 @@ stdenv.mkDerivation {
## meta-information for managing dotfiles
niv.niv
## formatting
python3Packages.black
## sample projects
# elm
# elmPackages.elm

Loading…
Cancel
Save