setup.vim 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  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 diffopt=internal,filler,closeoff,inline:simple
  7. set directory^=.
  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 shelltemp
  23. set sidescroll=0
  24. set tags=./tags,tags
  25. set undodir^=.
  26. set wildoptions=
  27. set startofline
  28. set sessionoptions+=options
  29. set viewoptions+=options
  30. set switchbuf=
  31. if has('win32')
  32. set isfname+=:
  33. endif
  34. if g:testname !~ 'test_mapping.vim$'
  35. " Make "Q" switch to Ex mode.
  36. " This does not work for all tests as Nvim only supports Vim Ex mode.
  37. nnoremap Q gQ<Cmd>call<SID>ExStart()<CR>
  38. endif
  39. endif
  40. " Common preparations for running tests.
  41. " Only load this once.
  42. if exists('s:did_load')
  43. finish
  44. endif
  45. let s:did_load = 1
  46. func s:ExStart()
  47. call feedkeys($"\<Cmd>call{expand('<SID>')}ExMayEnd()\<CR>")
  48. endfunc
  49. func s:ExMayEnd()
  50. " When :normal runs out of characters in Vim, the behavior is different in
  51. " normal Ex mode vs. Vim Ex mode.
  52. " - In normal Ex mode, "\n" is used.
  53. " - In Vim Ex mode, Ctrl-C is used.
  54. " Nvim only supports Vim Ex mode, so emulate the normal Ex mode behavior.
  55. if state('m') == '' && mode(1) == 'cv' && getcharstr(1) == "\<C-C>"
  56. call feedkeys("\n")
  57. endif
  58. endfunc
  59. " Clear Nvim default user commands, mappings and menus.
  60. comclear
  61. mapclear
  62. mapclear!
  63. aunmenu *
  64. tlunmenu *
  65. autocmd! nvim.popupmenu
  66. " Undo the 'grepprg' and 'grepformat' setting in _defaults.lua.
  67. set grepprg& grepformat&
  68. " Prevent Nvim log from writing to stderr.
  69. let $NVIM_LOG_FILE = exists($NVIM_LOG_FILE) ? $NVIM_LOG_FILE : 'Xnvim.log'
  70. " Make sure 'runtimepath' and 'packpath' does not include $HOME.
  71. set rtp=$VIM/vimfiles,$VIMRUNTIME,$VIM/vimfiles/after
  72. let &packpath = &rtp
  73. " Avoid storing shell history.
  74. let $HISTFILE = ""
  75. " Use default shell on Windows to avoid segfault, caused by TUI
  76. if has('win32')
  77. let $SHELL = ''
  78. let $TERM = ''
  79. let &shell = empty($COMSPEC) ? exepath('cmd.exe') : $COMSPEC
  80. set shellcmdflag=/s/c shellxquote=\" shellredir=>%s\ 2>&1
  81. let &shellpipe = &shellredir
  82. endif
  83. " Detect user modules for language providers
  84. let $PYTHONUSERBASE = $HOME . '/.local'
  85. if executable('gem')
  86. let $GEM_PATH = system('gem env gempath')
  87. endif
  88. " Have current $HOME available as $ORIGHOME. $HOME is used for option
  89. " defaults before we get here, and test_mksession checks that.
  90. let $ORIGHOME = $HOME
  91. if !exists('$XDG_CONFIG_HOME')
  92. let $XDG_CONFIG_HOME = $HOME .. '/.config'
  93. endif
  94. " Make sure $HOME does not get read or written.
  95. let $HOME = expand(getcwd() . '/XfakeHOME')
  96. if !isdirectory($HOME)
  97. call mkdir($HOME)
  98. endif
  99. " Use Vim's default color scheme
  100. colorscheme vim