mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
Merge pull request #4558 from justinmk/filetype
defaults: Enable syntax/filetype for real.
This commit is contained in:
commit
4eb58273cd
@ -31,9 +31,7 @@ these differences.
|
|||||||
2. Defaults *nvim-defaults*
|
2. Defaults *nvim-defaults*
|
||||||
|
|
||||||
- Syntax highlighting is enabled by default
|
- Syntax highlighting is enabled by default
|
||||||
- Filetype-related plugins and scripts are enabled by default
|
- ":filetype plugin indent on" is enabled by default
|
||||||
Note: these defaults can be disabled with the "-u NONE" command line
|
|
||||||
argument. |-u|
|
|
||||||
|
|
||||||
- 'autoindent' is set by default
|
- 'autoindent' is set by default
|
||||||
- 'autoread' is set by default
|
- 'autoread' is set by default
|
||||||
|
@ -335,7 +335,7 @@ int main(int argc, char **argv)
|
|||||||
source_startup_scripts(¶ms);
|
source_startup_scripts(¶ms);
|
||||||
|
|
||||||
// If using the runtime (-u is not NONE), enable syntax & filetype plugins.
|
// If using the runtime (-u is not NONE), enable syntax & filetype plugins.
|
||||||
if (params.use_vimrc != NULL && strcmp(params.use_vimrc, "NONE") != 0) {
|
if (params.use_vimrc == NULL || strcmp(params.use_vimrc, "NONE") != 0) {
|
||||||
// Does ":filetype plugin indent on".
|
// Does ":filetype plugin indent on".
|
||||||
filetype_maybe_enable();
|
filetype_maybe_enable();
|
||||||
// Sources syntax/syntax.vim, which calls `:filetype on`.
|
// Sources syntax/syntax.vim, which calls `:filetype on`.
|
||||||
|
85
test/functional/options/defaults_spec.lua
Normal file
85
test/functional/options/defaults_spec.lua
Normal file
@ -0,0 +1,85 @@
|
|||||||
|
local helpers = require('test.functional.helpers')
|
||||||
|
local Screen = require('test.functional.ui.screen')
|
||||||
|
local clear, feed = helpers.clear, helpers.feed
|
||||||
|
local eval, eq, neq = helpers.eval, helpers.eq, helpers.neq
|
||||||
|
local execute, source, expect = helpers.execute, helpers.source, helpers.expect
|
||||||
|
|
||||||
|
local function init_session(...)
|
||||||
|
local args = { helpers.nvim_prog, '-i', 'NONE', '--embed',
|
||||||
|
'--cmd', 'set shortmess+=I background=light noswapfile noautoindent',
|
||||||
|
'--cmd', 'set laststatus=1 undodir=. directory=. viewdir=. backupdir=.'
|
||||||
|
}
|
||||||
|
for _, v in ipairs({...}) do
|
||||||
|
table.insert(args, v)
|
||||||
|
end
|
||||||
|
helpers.set_session(helpers.spawn(args))
|
||||||
|
end
|
||||||
|
|
||||||
|
describe('startup defaults', function()
|
||||||
|
before_each(function()
|
||||||
|
clear()
|
||||||
|
end)
|
||||||
|
|
||||||
|
describe(':filetype', function()
|
||||||
|
local function expect_filetype(expected)
|
||||||
|
local screen = Screen.new(48, 4)
|
||||||
|
screen:attach()
|
||||||
|
execute('filetype')
|
||||||
|
screen:expect([[
|
||||||
|
^ |
|
||||||
|
~ |
|
||||||
|
~ |
|
||||||
|
]]..expected
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
it('enabled by `-u NORC`', function()
|
||||||
|
init_session('-u', 'NORC')
|
||||||
|
expect_filetype(
|
||||||
|
'filetype detection:ON plugin:ON indent:ON |')
|
||||||
|
end)
|
||||||
|
|
||||||
|
it('disabled by `-u NONE`', function()
|
||||||
|
init_session('-u', 'NONE')
|
||||||
|
expect_filetype(
|
||||||
|
'filetype detection:OFF plugin:OFF indent:OFF |')
|
||||||
|
end)
|
||||||
|
|
||||||
|
it('overridden by early `filetype on`', function()
|
||||||
|
init_session('-u', 'NORC', '--cmd', 'filetype on')
|
||||||
|
expect_filetype(
|
||||||
|
'filetype detection:ON plugin:OFF indent:OFF |')
|
||||||
|
end)
|
||||||
|
|
||||||
|
it('overridden by early `filetype plugin on`', function()
|
||||||
|
init_session('-u', 'NORC', '--cmd', 'filetype plugin on')
|
||||||
|
expect_filetype(
|
||||||
|
'filetype detection:ON plugin:ON indent:OFF |')
|
||||||
|
end)
|
||||||
|
|
||||||
|
it('overridden by early `filetype indent on`', function()
|
||||||
|
init_session('-u', 'NORC', '--cmd', 'filetype indent on')
|
||||||
|
expect_filetype(
|
||||||
|
'filetype detection:ON plugin:OFF indent:ON |')
|
||||||
|
end)
|
||||||
|
end)
|
||||||
|
|
||||||
|
describe('syntax', function()
|
||||||
|
it('enabled by `-u NORC`', function()
|
||||||
|
init_session('-u', 'NORC')
|
||||||
|
eq(1, eval('g:syntax_on'))
|
||||||
|
end)
|
||||||
|
|
||||||
|
it('disabled by `-u NONE`', function()
|
||||||
|
init_session('-u', 'NONE')
|
||||||
|
eq(0, eval('exists("g:syntax_on")'))
|
||||||
|
end)
|
||||||
|
|
||||||
|
it('overridden by early `syntax off`', function()
|
||||||
|
init_session('-u', 'NORC', '--cmd', 'syntax off')
|
||||||
|
eq(0, eval('exists("g:syntax_on")'))
|
||||||
|
end)
|
||||||
|
end)
|
||||||
|
end)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user