diff --git a/nvim/colors/dotfiles.vim b/nvim/colors/dotfiles.vim index f6dcc2b..4c137f3 100644 --- a/nvim/colors/dotfiles.vim +++ b/nvim/colors/dotfiles.vim @@ -375,8 +375,9 @@ " }}} " Python {{{ - hi! link pythonBuiltinType Type - hi! link pythonExClass Type + hi! link pythonClass Type + hi! link pythonBuiltinType pythonClass + hi! link pythonExClass pythonClass hi! link pythonBuiltinObj pythonFunction hi! link pythonClassVar Variable " }}} diff --git a/nvim/dotfiles/plugins-list.vim b/nvim/dotfiles/plugins-list.vim index d425f92..e64ce85 100644 --- a/nvim/dotfiles/plugins-list.vim +++ b/nvim/dotfiles/plugins-list.vim @@ -14,7 +14,11 @@ endif Plug 'Raimondi/delimitMate' Plug 'tpope/vim-repeat' - Plug 'tpope/vim-commentary' + " if g:vim_ide + Plug 'tomtom/tcomment_vim' + " else + " Plug 'tpope/vim-commentary' + " endif Plug 'tpope/vim-surround' Plug 'Yggdroot/indentLine' Plug 'idbrii/detectindent' diff --git a/nvim/plugin/editing.vim b/nvim/plugin/editing.vim index fc11f3a..d53d96a 100644 --- a/nvim/plugin/editing.vim +++ b/nvim/plugin/editing.vim @@ -233,6 +233,18 @@ set commentstring=//%s noremap s s noremap S S + " Remove the mappings that I won't use + let g:tcomment_maps = 0 + + nmap gc TComment_gc + nmap gcc TComment_gcc + nmap gC TComment_gcb + " The default block commenting mapping refuses to work on a single line, as + " a workaround I give it another empty one to work with. + nmap gCC m'o''TComment_gcb+ + xnoremap gc :TCommentMaybeInline + xnoremap gC :TCommentBlock + " }}} diff --git a/scripts/leveldb-dump b/scripts/leveldb-dump index 90e7964..f1d273e 100755 --- a/scripts/leveldb-dump +++ b/scripts/leveldb-dump @@ -8,36 +8,42 @@ from sys import stdout import base64 parser = argparse.ArgumentParser() -parser.add_argument( - "--encode", - "-e", - choices=["utf8", "base16", "base32", "base64", "base85"], - default="utf8", -) +encoding_names = ["utf8", "base16", "base32", "base64", "base85"] +parser.add_argument("--encoding", "-e", choices=encoding_names, default="utf8") +parser.add_argument("--key-encoding", choices=encoding_names, default=None) +parser.add_argument("--value-encoding", choices=encoding_names, default=None) parser.add_argument("db_path", type=Path) cli_args = parser.parse_args() -def bytes_to_json(b: bytes) -> Union[str, list[int]]: - if cli_args.encode == "utf8": +def bytes_to_json(b: bytes, encoding: str) -> Union[str, list[int]]: + if encoding == "utf8": try: return b.decode("utf8") except UnicodeDecodeError: return list(b) - elif cli_args.encode == "base16": + elif encoding == "base16": return base64.b16encode(b).decode("ascii") - elif cli_args.encode == "base32": + elif encoding == "base32": return base64.b32encode(b).decode("ascii") - elif cli_args.encode == "base64": + elif encoding == "base64": return base64.b64encode(b).decode("ascii") - elif cli_args.encode == "base85": + elif encoding == "base85": return base64.b85encode(b).decode("ascii") else: assert False +key_encoding: str = cli_args.key_encoding or cli_args.encoding +value_encoding: str = cli_args.value_encoding or cli_args.encoding db = plyvel.DB(str(cli_args.db_path), create_if_missing=False) with db.iterator() as iterator: for key, value in iterator: - json.dump({"key": bytes_to_json(key), "value": bytes_to_json(value)}, stdout) + json.dump( + { + "key": bytes_to_json(key, key_encoding), + "value": bytes_to_json(value, value_encoding), + }, + stdout, + ) stdout.write("\n")