setup.vim 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. if exists('s:did_load')
  2. " Align Nvim defaults to Vim.
  3. set commentstring=/*\ %s\ */
  4. set complete=.,w,b,u,t,i
  5. set define=^\\s*#\\s*define
  6. set directory^=.
  7. set diffopt=internal,filler,closeoff
  8. set display=
  9. set fillchars=vert:\|,foldsep:\|,fold:-
  10. set formatoptions=tcq
  11. set fsync
  12. set include=^\\s*#\\s*include
  13. set laststatus=1
  14. set listchars=eol:$
  15. set joinspaces
  16. set jumpoptions=
  17. set mousemodel=extend
  18. set nohidden nosmarttab noautoindent noautoread noruler noshowcmd
  19. set nohlsearch noincsearch
  20. set nrformats=bin,octal,hex
  21. set shortmess=filnxtToOS
  22. set sidescroll=0
  23. set tags=./tags,tags
  24. set undodir^=.
  25. set wildoptions=
  26. set startofline
  27. set sessionoptions+=options
  28. set viewoptions+=options
  29. set switchbuf=
  30. if has('win32')
  31. set isfname+=:
  32. endif
  33. if g:testname !~ 'test_mapping.vim$'
  34. " Make "Q" switch to Ex mode.
  35. " This does not work for all tests as Nvim only supports Vim Ex mode.
  36. nnoremap Q gQ<Cmd>call<SID>ExStart()<CR>
  37. endif
  38. endif
  39. " Common preparations for running tests.
  40. " Only load this once.
  41. if exists('s:did_load')
  42. finish
  43. endif
  44. let s:did_load = 1
  45. func s:ExStart()
  46. call feedkeys($"\<Cmd>call{expand('<SID>')}ExMayEnd()\<CR>")
  47. endfunc
  48. func s:ExMayEnd()
  49. " When :normal runs out of characters in Vim, the behavior is different in
  50. " normal Ex mode vs. Vim Ex mode.
  51. " - In normal Ex mode, "\n" is used.
  52. " - In Vim Ex mode, Ctrl-C is used.
  53. " Nvim only supports Vim Ex mode, so emulate the normal Ex mode behavior.
  54. if state('m') == '' && mode(1) == 'cv' && getcharstr(1) == "\<C-C>"
  55. call feedkeys("\n")
  56. endif
  57. endfunc
  58. " Clear Nvim default user commands, mappings and menus.
  59. comclear
  60. mapclear
  61. mapclear!
  62. aunmenu *
  63. tlunmenu *
  64. autocmd! nvim.popupmenu
  65. " Undo the 'grepprg' and 'grepformat' setting in _defaults.lua.
  66. set grepprg& grepformat&
  67. " roughly equivalent to test_setmouse() in Vim
  68. func Ntest_setmouse(row, col)
  69. call nvim_input_mouse('move', '', '', 0, a:row - 1, a:col - 1)
  70. if state('m') == ''
  71. call getchar(0)
  72. endif
  73. endfunc
  74. " roughly equivalent to term_wait() in Vim
  75. func Nterm_wait(buf, time = 10)
  76. execute $'sleep {a:time}m'
  77. endfunc
  78. " Prevent Nvim log from writing to stderr.
  79. let $NVIM_LOG_FILE = exists($NVIM_LOG_FILE) ? $NVIM_LOG_FILE : 'Xnvim.log'
  80. " Make sure 'runtimepath' and 'packpath' does not include $HOME.
  81. set rtp=$VIM/vimfiles,$VIMRUNTIME,$VIM/vimfiles/after
  82. let &packpath = &rtp
  83. " Avoid storing shell history.
  84. let $HISTFILE = ""
  85. " Use default shell on Windows to avoid segfault, caused by TUI
  86. if has('win32')
  87. let $SHELL = ''
  88. let $TERM = ''
  89. let &shell = empty($COMSPEC) ? exepath('cmd.exe') : $COMSPEC
  90. set shellcmdflag=/s/c shellxquote=\" shellredir=>%s\ 2>&1
  91. let &shellpipe = &shellredir
  92. endif
  93. " Detect user modules for language providers
  94. let $PYTHONUSERBASE = $HOME . '/.local'
  95. if executable('gem')
  96. let $GEM_PATH = system('gem env gempath')
  97. endif
  98. " Make sure $HOME does not get read or written.
  99. let $HOME = expand(getcwd() . '/XfakeHOME')
  100. if !isdirectory($HOME)
  101. call mkdir($HOME)
  102. endif
  103. " Use Vim's default color scheme
  104. colorscheme vim