Guest User

Untitled

a guest
Aug 15th, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.48 KB | None | 0 0
  1. # vim: set filetype=python :
  2.  
  3. import shutil
  4. import neovim
  5. import os
  6. import platform
  7. from pathlib import Path
  8.  
  9. xontrib load vox vox_tabcomplete coreutils
  10.  
  11. $IGNOREEOF = True
  12. $INDENT = " " * 4
  13. $AUTO_PUSHD = True
  14. $HISTCONTROL = set("ignoredups")
  15. $INTENSIFY_COLORS_ON_WIN=False
  16. $AUTO_CD = True
  17.  
  18. # inputs
  19. $UPDATE_COMPLETIONS_ON_KEYPRESS = False
  20. $CASE_SENSITIVE_COMPLETIONS = False
  21. $COMPLETIONS_CONFIRM = True
  22. $VI_MODE = False
  23. $XONSH_AUTOPAIR = True
  24.  
  25. # show error trace
  26. $XONSH_SHOW_TRACEBACK = True
  27.  
  28. if shutil.which("nvim"):
  29. aliases["vim"] = "nvim"
  30. $VISUAL="nvim"
  31. $EDITOR="nvim"
  32. elif shutil.which("vim"):
  33. $VISUAL="vim"
  34. $EDITOR="vim"
  35.  
  36. if platform.system() == "Windows":
  37. # WSL's bash is too slow and not usable on windows
  38. if "bash" in __xonsh_completers__:
  39. completer remove bash
  40.  
  41. if "NVIM_LISTEN_ADDRESS" in ${...}:
  42. print("nvim: ", $NVIM_LISTEN_ADDRESS)
  43. nvim = neovim.attach("socket", path=$NVIM_LISTEN_ADDRESS)
  44.  
  45. def _tab_open(args, stdin=None, stdout=None, stderr=None):
  46. if len(args) != 1:
  47. stderr.write("argument requires 1.\nUsage: tabopen <filename>\n")
  48. return 2
  49. vim_cwd = Path(nvim.eval("getcwd()")).resolve()
  50. target = Path.cwd() / args[0]
  51. try:
  52. filename = vim_cwd.relative_to(target)
  53. except ValueError:
  54. filename = target
  55. nvim.command("tabnew " + str(filename))
  56. print("tab opened")
  57. return 0
  58.  
  59. aliases["tabopen"] = _tab_open
  60. aliases["tabnew"] = _tab_open
Add Comment
Please, Sign In to add comment