vmux.vim 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. set shell=powershell " Default Windows shell is cmd.exe
  2. set mouse=a " mouse on
  3. " Default directory
  4. cd ~
  5. set autochdir
  6. let s:prefix="<C-a>" " <prefix>
  7. let s:vmuxExit='<C-\><C-n>'
  8. " Use system clipboard
  9. set clipboard=unnamed
  10. " --- FUNCTIONS ---
  11. function Bind(key, ...)
  12. exe join(['tnoremap <silent>', s:prefix . a:key, s:vmuxExit, join(a:000, ' ')], ' ')
  13. exe join(['nnoremap <silent>', s:prefix . a:key, s:vmuxExit, join(a:000, ' ')], ' ')
  14. endfunction
  15. command! -nargs=+ -bar Bind :call Bind(<f-args>)
  16. function GoToTab(index)
  17. if a:index == tabpagenr()
  18. startinsert
  19. elseif a:index <= tabpagenr("$")
  20. call feedkeys(a:index . "gt")
  21. else
  22. echo "Can't find window: " . a:index
  23. startinsert
  24. endif
  25. endfunction
  26. function ModeName()
  27. let modes = {
  28. \ '__' : '------',
  29. \ 'n' : 'NORMAL',
  30. \ 'no' : 'OP PENDING',
  31. \ 'nov': 'OP PENDING CHAR',
  32. \ 'noV': 'OP PENDING LINE',
  33. \ 'no': 'OP PENDING BLOCK',
  34. \ 'niI': 'INSERT (NORMAL)',
  35. \ 'niR': 'REPLACE (NORMAL)',
  36. \ 'niV': 'V REPLACE (NORMAL)',
  37. \ 'v' : 'VISUAL',
  38. \ 'V' : 'VISUAL-LINE',
  39. \ '' : 'VISUAL-BLOCK',
  40. \ 's' : 'SELECT',
  41. \ 'S' : 'SELECT-LINE',
  42. \ '' : 'SELECT-BLOCK',
  43. \ 'i' : '',
  44. \ 'ic' : 'INSERT COMPL GENERIC',
  45. \ 'ix' : 'INSERT COMPL',
  46. \ 'R' : 'REPLACE',
  47. \ 'Rc' : 'REPLACE COMP GENERIC',
  48. \ 'Rv' : 'V REPLACE',
  49. \ 'Rx' : 'REPLACE COMP',
  50. \ 'c' : 'COMMAND',
  51. \ 'cv' : 'VIM EX',
  52. \ 'ce' : 'EX',
  53. \ 'r' : 'PROMPT',
  54. \ 'rm' : 'MORE PROMPT',
  55. \ 'r?' : 'CONFIRM',
  56. \ '!' : 'SHELL',
  57. \ 't' : '',
  58. \ 'multi' : 'MULTI',
  59. \ }
  60. return modes[mode()]
  61. endfunction
  62. " --- BINDINGS ---
  63. Bind % :vnew +term<Enter> " split window vertical
  64. Bind \" :new +term<Enter> " split window horizontal
  65. Bind x :q!<Enter> " close pane
  66. Bind X :qa!<Enter> " exit
  67. Bind [ " swich to normal mode
  68. Bind c :tabnew +term<Enter> " create tab
  69. Bind n gt " next tab
  70. Bind p gT " previos tab
  71. Bind : :call feedkeys(':')<Enter> " command mode
  72. " Window moving <prefix>h
  73. Bind j <C-w>j
  74. Bind h <C-w>h
  75. Bind H <C-w>H
  76. Bind J <C-w>J
  77. Bind k <C-w>k
  78. Bind K <C-w>K
  79. Bind l <C-w>l
  80. Bind L <C-w>L
  81. " Tab moving <prefix>1
  82. Bind 1 :call GoToTab(1)<Enter>
  83. Bind 2 :call GoToTab(2)<Enter>
  84. Bind 3 :call GoToTab(3)<Enter>
  85. Bind 4 :call GoToTab(4)<Enter>
  86. Bind 5 :call GoToTab(5)<Enter>
  87. Bind 6 :call GoToTab(6)<Enter>
  88. Bind 7 :call GoToTab(7)<Enter>
  89. Bind 8 :call GoToTab(8)<Enter>
  90. Bind 9 :call GoToTab(9)<Enter>
  91. Bind 0 :call GoToTab(10)<Enter>
  92. " --- AUTOCOMMANDS ---
  93. " Launch terminal on startup
  94. au VimEnter * term
  95. " Enter terminal mode automatically
  96. au BufWinEnter,WinEnter term://* startinsert
  97. " Close the window if the terminal is finished
  98. au TermClose * :q! | startinsert
  99. " --- UI ---
  100. " Transparent window borders
  101. hi VertSplit cterm=NONE
  102. " Hide UI
  103. set noshowmode
  104. set noruler
  105. set showtabline=0
  106. set noshowcmd
  107. " Statusline
  108. set laststatus=3 " single statusline
  109. set statusline= " reset statusline
  110. set statusline+=[%{tabpagenr()}/%{tabpagenr('$')}] " tab-number and count of tabs
  111. set statusline+=\ %{ModeName()} " current mode (not INSERT and TERMINAL)
  112. set statusline+=%= " float: right
  113. set statusline+=%{strftime('%R\ %d-%m-%Y')}\ " date and time
  114. " Transparent background for statusline
  115. hi StatusLine ctermbg=0 cterm=NONE
  116. " Start insert on startup
  117. startinsert