diff options
author | Lewis Russell <lewis6991@gmail.com> | 2023-03-11 17:11:02 +0000 |
---|---|---|
committer | Lewis Russell <lewis6991@gmail.com> | 2023-03-20 10:06:32 +0000 |
commit | e5641df6d3fc3bb6c3c55593b6152082bfc561b6 (patch) | |
tree | 9354e0f324c274ba9aaae31ddb2269b1a6a54268 /test/functional/api/vim_spec.lua | |
parent | e1db0e35e4d5859b96e6aff882df62d6c714b569 (diff) | |
download | rneovim-e5641df6d3fc3bb6c3c55593b6152082bfc561b6.tar.gz rneovim-e5641df6d3fc3bb6c3c55593b6152082bfc561b6.tar.bz2 rneovim-e5641df6d3fc3bb6c3c55593b6152082bfc561b6.zip |
feat: add `vim.filetype.get_option()`
Diffstat (limited to 'test/functional/api/vim_spec.lua')
-rw-r--r-- | test/functional/api/vim_spec.lua | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/test/functional/api/vim_spec.lua b/test/functional/api/vim_spec.lua index 2af041c706..ff1bfef591 100644 --- a/test/functional/api/vim_spec.lua +++ b/test/functional/api/vim_spec.lua @@ -1518,6 +1518,31 @@ describe('API', function() nvim('get_option_value', 'filetype', {buf = buf}) eq({1, 9}, nvim('win_get_cursor', win)) end) + + it('can get default option values for filetypes', function() + command('filetype plugin on') + for ft, opts in pairs { + lua = { commentstring = '-- %s' }, + vim = { commentstring = '"%s' }, + man = { tagfunc = 'v:lua.require\'man\'.goto_tag' }, + xml = { formatexpr = 'xmlformat#Format()' } + } do + for option, value in pairs(opts) do + eq(value, nvim('get_option_value', option, { filetype = ft })) + end + end + + command'au FileType lua setlocal commentstring=NEW\\ %s' + + eq('NEW %s', nvim('get_option_value', 'commentstring', { filetype = 'lua' })) + end) + + it('errors for bad FileType autocmds', function() + command'au FileType lua setlocal commentstring=BAD' + eq([[FileType Autocommands for "lua": Vim(setlocal):E537: 'commentstring' must be empty or contain %s: commentstring=BAD]], + pcall_err(nvim, 'get_option_value', 'commentstring', { filetype = 'lua' })) + end) + end) describe('nvim_{get,set}_current_buf, nvim_list_bufs', function() |