vimPlugins: Automatically sort vim-plugin-names.

Python's `sorted` method works a little differently than `sort` in the
handling of dashes.
This commit is contained in:
ryneeverett 2020-03-24 19:00:31 +00:00
parent cffb6cb637
commit b886ad90e7
3 changed files with 26 additions and 25 deletions

View File

@ -11,7 +11,6 @@ let
# TL;DR # TL;DR
# * Add your plugin to ./vim-plugin-names # * Add your plugin to ./vim-plugin-names
# * sort -udf ./vim-plugin-names > sorted && mv sorted vim-plugin-names
# * run ./update.py # * run ./update.py
# #
# If additional modifications to the build process are required, # If additional modifications to the build process are required,

View File

@ -9,7 +9,6 @@
# $ nix run nixpkgs.python3Packages.flake8 -c flake8 --ignore E501,E265 update.py # $ nix run nixpkgs.python3Packages.flake8 -c flake8 --ignore E501,E265 update.py
import argparse import argparse
import fileinput
import functools import functools
import http import http
import json import json
@ -124,7 +123,7 @@ class Repo:
new_owner, new_name = ( new_owner, new_name = (
urllib.parse.urlsplit(response_url).path.strip("/").split("/")[:2] urllib.parse.urlsplit(response_url).path.strip("/").split("/")[:2]
) )
end_line = f" as {self.alias}\n" if self.alias else "\n" end_line = "\n" if self.alias is None else f" as {self.alias}\n"
plugin_line = "{owner}/{name}" + end_line plugin_line = "{owner}/{name}" + end_line
old_plugin = plugin_line.format(owner=self.owner, name=self.name) old_plugin = plugin_line.format(owner=self.owner, name=self.name)
@ -416,11 +415,12 @@ in lib.fix' (lib.extends overrides packages)
print(f"updated {outfile}") print(f"updated {outfile}")
def update_redirects(input_file: Path, output_file: Path, redirects: dict): def rewrite_input(input_file: Path, output_file: Path, redirects: dict):
with fileinput.input(input_file, inplace=True) as f: with open(input_file, "r") as f:
for line in f: lines = f.readlines()
line = " ".join(line.split())
print(redirects.get(line, line), end="") if redirects:
lines = [redirects.get(line, line) for line in lines]
print( print(
f"""\ f"""\
Redirects have been detected and {input_file} has been updated. Please take the Redirects have been detected and {input_file} has been updated. Please take the
@ -430,17 +430,20 @@ following steps:
git commit -m "vimPlugins: Update" git commit -m "vimPlugins: Update"
2. If any of the plugin names were changed, throw an error in aliases.nix: 2. If any of the plugin names were changed, throw an error in aliases.nix:
<oldName> = deprecateName "<oldName>" "<newName>"; # backwards compat, added YYYY-MM-DD <oldName> = deprecateName "<oldName>" "<newName>"; # backwards compat, added YYYY-MM-DD
3. Make sure the updated {input_file} is still correctly sorted: 3. Run this script again so these changes will be reflected in the
sort -udf ./vim-plugin-names > sorted && mv sorted vim-plugin-names
4. Run this script again so these changes will be reflected in the
generated expressions: generated expressions:
./update.py ./update.py
5. Commit {input_file} along with aliases and generated expressions: 4. Commit {input_file} along with aliases and generated expressions:
git add {output_file} {input_file} aliases.nix git add {output_file} {input_file} aliases.nix
git commit -m "vimPlugins: Update redirects" git commit -m "vimPlugins: Update redirects"
""" """
) )
lines = sorted(lines, key=str.casefold)
with open(input_file, "w") as f:
f.writelines(lines)
def parse_args(): def parse_args():
parser = argparse.ArgumentParser( parser = argparse.ArgumentParser(
@ -488,8 +491,7 @@ def main() -> None:
generate_nix(plugins, args.outfile) generate_nix(plugins, args.outfile)
if redirects: rewrite_input(args.input_file, args.outfile, redirects)
update_redirects(args.input_file, args.outfile, redirects)
if __name__ == "__main__": if __name__ == "__main__":

View File

@ -55,8 +55,8 @@ cocopon/iceberg.vim
cohama/lexima.vim cohama/lexima.vim
ctjhoa/spacevim ctjhoa/spacevim
ctrlpvim/ctrlp.vim ctrlpvim/ctrlp.vim
dag/vim2hs
dag/vim-fish dag/vim-fish
dag/vim2hs
dannyob/quickfixstatus dannyob/quickfixstatus
darfink/starsearch.vim darfink/starsearch.vim
dart-lang/dart-vim-plugin dart-lang/dart-vim-plugin
@ -315,8 +315,8 @@ neoclide/coc-neco
neoclide/coc-pairs neoclide/coc-pairs
neoclide/coc-prettier neoclide/coc-prettier
neoclide/coc-python neoclide/coc-python
neoclide/coc-rls
neoclide/coc-r-lsp neoclide/coc-r-lsp
neoclide/coc-rls
neoclide/coc-smartf neoclide/coc-smartf
neoclide/coc-snippets neoclide/coc-snippets
neoclide/coc-solargraph neoclide/coc-solargraph
@ -334,10 +334,10 @@ neoclide/denite-extra
neoclide/denite-git neoclide/denite-git
neoclide/vim-easygit neoclide/vim-easygit
neomake/neomake neomake/neomake
neovim/nvim-lsp
neovim/nvimdev.nvim
neovimhaskell/haskell-vim neovimhaskell/haskell-vim
neovimhaskell/nvim-hs.vim neovimhaskell/nvim-hs.vim
neovim/nvimdev.nvim
neovim/nvim-lsp
neutaaaaan/iosvkem neutaaaaan/iosvkem
nfnty/vim-nftables nfnty/vim-nftables
nicoe/deoplete-khard nicoe/deoplete-khard
@ -505,16 +505,14 @@ Valodim/deoplete-notmuch
vhda/verilog_systemverilog.vim vhda/verilog_systemverilog.vim
vim-airline/vim-airline vim-airline/vim-airline
vim-airline/vim-airline-themes vim-airline/vim-airline-themes
vimlab/split-term.vim
vimoutliner/vimoutliner
vim-pandoc/vim-pandoc vim-pandoc/vim-pandoc
vim-pandoc/vim-pandoc-after vim-pandoc/vim-pandoc-after
vim-pandoc/vim-pandoc-syntax vim-pandoc/vim-pandoc-syntax
vim-ruby/vim-ruby vim-ruby/vim-ruby
vim-scripts/a.vim
vim-scripts/align vim-scripts/align
vim-scripts/argtextobj.vim vim-scripts/argtextobj.vim
vim-scripts/autoload_cscope.vim vim-scripts/autoload_cscope.vim
vim-scripts/a.vim
vim-scripts/bats.vim vim-scripts/bats.vim
vim-scripts/changeColorScheme.vim vim-scripts/changeColorScheme.vim
vim-scripts/Colour-Sampler-Pack vim-scripts/Colour-Sampler-Pack
@ -538,6 +536,8 @@ vim-scripts/wombat256.vim
vim-scripts/YankRing.vim vim-scripts/YankRing.vim
vim-syntastic/syntastic vim-syntastic/syntastic
vim-utils/vim-husk vim-utils/vim-husk
vimlab/split-term.vim
vimoutliner/vimoutliner
vimwiki/vimwiki vimwiki/vimwiki
vito-c/jq.vim vito-c/jq.vim
vmchale/dhall-vim vmchale/dhall-vim