aboutsummaryrefslogtreecommitdiff
path: root/test/functional
diff options
context:
space:
mode:
Diffstat (limited to 'test/functional')
-rw-r--r--test/functional/api/vim_spec.lua43
-rw-r--r--test/functional/api/window_spec.lua4
-rw-r--r--test/functional/fixtures/autoload/Test104.vim1
-rw-r--r--test/functional/helpers.lua94
-rw-r--r--test/functional/job/job_spec.lua11
-rw-r--r--test/functional/legacy/004_bufenter_with_modelines_spec.lua4
-rw-r--r--test/functional/legacy/005_bufleave_delete_buffer.lua71
-rw-r--r--test/functional/legacy/025_jump_tag_hidden_spec.lua50
-rw-r--r--test/functional/legacy/026_execute_while_if_spec.lua66
-rw-r--r--test/functional/legacy/033_lisp_indent_spec.lua73
-rw-r--r--test/functional/legacy/043_magic_settings_spec.lua61
-rw-r--r--test/functional/legacy/051_highlight_spec.lua70
-rw-r--r--test/functional/legacy/066_visual_block_tab_spec.lua64
-rw-r--r--test/functional/legacy/067_augroup_exists_spec.lua46
-rw-r--r--test/functional/legacy/075_maparg_spec.lua58
-rw-r--r--test/functional/legacy/101_hlsearch_spec.lua63
-rw-r--r--test/functional/legacy/104_let_assignment.lua54
-rw-r--r--test/functional/legacy/105_filename_modifiers_spec.lua81
-rw-r--r--test/functional/runtime/autoload/remote/define_spec.lua (renamed from test/functional/runtime/autoload/rpc/define_spec.lua)26
-rw-r--r--test/functional/shell/viml_system_spec.lua7
20 files changed, 883 insertions, 64 deletions
diff --git a/test/functional/api/vim_spec.lua b/test/functional/api/vim_spec.lua
index abf9c9efcd..f34df8cefb 100644
--- a/test/functional/api/vim_spec.lua
+++ b/test/functional/api/vim_spec.lua
@@ -1,6 +1,6 @@
-- Sanity checks for vim_* API calls via msgpack-rpc
local helpers = require('test.functional.helpers')
-local clear, nvim, eq, ok = helpers.clear, helpers.nvim, helpers.eq, helpers.ok
+local clear, nvim, eq, neq, ok = helpers.clear, helpers.nvim, helpers.eq, helpers.neq, helpers.ok
describe('vim_* functions', function()
@@ -106,6 +106,47 @@ describe('vim_* functions', function()
end)
end)
+ describe('replace_termcodes', function()
+ it('escapes K_SPECIAL as K_SPECIAL KS_SPECIAL KE_FILLER', function()
+ eq(helpers.nvim('replace_termcodes', '\x80', true, true, true), '\x80\xfeX')
+ end)
+
+ it('leaves non K_SPECIAL string unchanged', function()
+ eq(helpers.nvim('replace_termcodes', 'abc', true, true, true), 'abc')
+ end)
+
+ it('converts <expressions>', function()
+ eq(helpers.nvim('replace_termcodes', '<Leader>', true, true, true), '\\')
+ end)
+ end)
+
+ describe('feedkeys', function()
+ it('CSI escaping', function()
+ local function on_setup()
+ -- notice the special char(…) \xe2\80\xa6
+ nvim('feedkeys', ':let x1="…"\n', '', true)
+
+ -- Both replace_termcodes and feedkeys escape \x80
+ local inp = helpers.nvim('replace_termcodes', ':let x2="…"<CR>', true, true, true)
+ nvim('feedkeys', inp, '', true)
+
+ -- Disabling CSI escaping in feedkeys
+ inp = helpers.nvim('replace_termcodes', ':let x3="…"<CR>', true, true, true)
+ nvim('feedkeys', inp, '', false)
+
+ helpers.stop()
+ end
+
+ -- spin the loop a bit
+ helpers.run(nil, nil, on_setup)
+
+ eq(nvim('get_var', 'x1'), '…')
+ -- Because of the double escaping this is neq
+ neq(nvim('get_var', 'x2'), '…')
+ eq(nvim('get_var', 'x3'), '…')
+ end)
+ end)
+
it('can throw exceptions', function()
local status, err = pcall(nvim, 'get_option', 'invalid-option')
eq(false, status)
diff --git a/test/functional/api/window_spec.lua b/test/functional/api/window_spec.lua
index 4c867d2f5d..f3ac90de21 100644
--- a/test/functional/api/window_spec.lua
+++ b/test/functional/api/window_spec.lua
@@ -104,7 +104,7 @@ describe('window_* functions', function()
nvim('set_current_window', nvim('get_windows')[2])
nvim('command', 'split')
eq(window('get_height', nvim('get_windows')[2]),
- window('get_height', nvim('get_windows')[1]) / 2)
+ math.floor(window('get_height', nvim('get_windows')[1]) / 2))
window('set_height', nvim('get_windows')[2], 2)
eq(2, window('get_height', nvim('get_windows')[2]))
end)
@@ -118,7 +118,7 @@ describe('window_* functions', function()
nvim('set_current_window', nvim('get_windows')[2])
nvim('command', 'vsplit')
eq(window('get_width', nvim('get_windows')[2]),
- window('get_width', nvim('get_windows')[1]) / 2)
+ math.floor(window('get_width', nvim('get_windows')[1]) / 2))
window('set_width', nvim('get_windows')[2], 2)
eq(2, window('get_width', nvim('get_windows')[2]))
end)
diff --git a/test/functional/fixtures/autoload/Test104.vim b/test/functional/fixtures/autoload/Test104.vim
new file mode 100644
index 0000000000..d1e0e17a3b
--- /dev/null
+++ b/test/functional/fixtures/autoload/Test104.vim
@@ -0,0 +1 @@
+let Test104#numvar = 123
diff --git a/test/functional/helpers.lua b/test/functional/helpers.lua
index 6c3f5190c9..b758817b41 100644
--- a/test/functional/helpers.lua
+++ b/test/functional/helpers.lua
@@ -6,23 +6,33 @@ local Session = require('nvim.session')
local nvim_prog = os.getenv('NVIM_PROG') or 'build/bin/nvim'
local nvim_argv = {nvim_prog, '-u', 'NONE', '-i', 'NONE', '-N', '--embed'}
+local prepend_argv
if os.getenv('VALGRIND') then
local log_file = os.getenv('VALGRIND_LOG') or 'valgrind-%p.log'
- local valgrind_argv = {'valgrind', '-q', '--tool=memcheck',
- '--leak-check=yes', '--track-origins=yes',
- '--show-possibly-lost=no',
- '--suppressions=.valgrind.supp',
- '--log-file='..log_file}
- if os.getenv('VALGRIND_GDB') then
- table.insert(valgrind_argv, '--vgdb=yes')
- table.insert(valgrind_argv, '--vgdb-error=0')
+ prepend_argv = {'valgrind', '-q', '--tool=memcheck',
+ '--leak-check=yes', '--track-origins=yes',
+ '--show-possibly-lost=no',
+ '--suppressions=.valgrind.supp',
+ '--log-file='..log_file}
+ if os.getenv('GDB') then
+ table.insert(prepend_argv, '--vgdb=yes')
+ table.insert(prepend_argv, '--vgdb-error=0')
end
- local len = #valgrind_argv
+elseif os.getenv('GDB') then
+ local gdbserver_port = '7777'
+ if os.getenv('GDBSERVER_PORT') then
+ gdbserver_port = os.getenv('GDBSERVER_PORT')
+ end
+ prepend_argv = {'gdbserver', 'localhost:'..gdbserver_port}
+end
+
+if prepend_argv then
+ local len = #prepend_argv
for i = 1, #nvim_argv do
- valgrind_argv[i + len] = nvim_argv[i]
+ prepend_argv[i + len] = nvim_argv[i]
end
- nvim_argv = valgrind_argv
+ nvim_argv = prepend_argv
end
local session, loop_running, loop_stopped, last_error
@@ -42,7 +52,6 @@ local function request(method, ...)
if not loop_stopped then
-- Except when the loop has been stopped by a notification triggered
-- by the initial request, for example.
- session:request('vim_eval', '1')
end
return rv
end
@@ -99,25 +108,20 @@ local function nvim_eval(expr)
return request('vim_eval', expr)
end
-local function nvim_feed(input, mode)
- mode = mode or ''
- request('vim_feedkeys', input, mode)
-end
-
-local function buffer_slice(start, stop, buffer_idx)
- local include_end = false
- if not stop then
- stop = -1
- include_end = true
+local function nvim_feed(input)
+ while #input > 0 do
+ local written = request('vim_input', input)
+ input = input:sub(written + 1)
end
- local buffer = request('vim_get_buffers')[buffer_idx or 1]
- local slice = request('buffer_get_line_slice', buffer, start or 0, stop,
- true, include_end)
- return table.concat(slice, '\n')
end
local function nvim_replace_termcodes(input)
- return request('vim_replace_termcodes', input, false, true, true)
+ -- small hack to stop <C-@> from being replaced by the internal
+ -- representation(which is different and won't work for vim_input)
+ local temp_replacement = 'CCCCCCCCC@@@@@@@@@@'
+ input = input:gsub('<[Cc][-]@>', temp_replacement)
+ local rv = request('vim_replace_termcodes', input, false, true, true)
+ return rv:gsub(temp_replacement, '\000')
end
local function dedent(str)
@@ -150,13 +154,14 @@ end
local function rawfeed(...)
for _, v in ipairs({...}) do
- nvim_feed(dedent(v), 'nt')
+ nvim_feed(dedent(v))
end
end
local function clear()
if session then
session:request('vim_command', 'qa!')
+ session._async_session._msgpack_stream._loop:exit()
end
local loop = Loop.new()
local msgpack_stream = MsgpackStream.new(loop)
@@ -166,22 +171,32 @@ local function clear()
end
local function insert(...)
- nvim_feed('i', 'nt')
+ nvim_feed('i')
rawfeed(...)
- nvim_feed(nvim_replace_termcodes('<ESC>'), 'nt')
+ nvim_feed(nvim_replace_termcodes('<ESC>'))
end
local function execute(...)
for _, v in ipairs({...}) do
if v:sub(1, 1) ~= '/' then
-- not a search command, prefix with colon
- nvim_feed(':', 'nt')
+ nvim_feed(':')
end
- nvim_feed(v, 'nt')
- nvim_feed(nvim_replace_termcodes('<CR>'), 'nt')
+ nvim_feed(v)
+ nvim_feed(nvim_replace_termcodes('<CR>'))
end
end
+local function source(code)
+ local tmpname = os.tmpname()
+ local tmpfile = io.open(tmpname, "w")
+ tmpfile:write(code)
+ tmpfile:flush()
+ tmpfile:close()
+ nvim_command('source '..tmpname)
+ os.remove(tmpname)
+end
+
local function eq(expected, actual)
return assert.are.same(expected, actual)
end
@@ -190,10 +205,6 @@ local function neq(expected, actual)
return assert.are_not.same(expected, actual)
end
-local function expect(contents, first, last, buffer_index)
- return eq(dedent(contents), buffer_slice(first, last, buffer_index))
-end
-
local function ok(expr)
assert.is_true(expr)
end
@@ -223,6 +234,10 @@ local function curbuf(method, ...)
end
local function curbuf_contents()
+ -- Before inspecting the buffer, execute 'vim_eval' to wait until all
+ -- previously sent keys are processed(vim_eval is a deferred function, and
+ -- only processed after all input)
+ session:request('vim_eval', '1')
return table.concat(curbuf('get_line_slice', 0, -1, true, true), '\n')
end
@@ -242,11 +257,16 @@ local function curtab(method, ...)
return tabpage(method, tab, ...)
end
+local function expect(contents)
+ return eq(dedent(contents), curbuf_contents())
+end
+
clear()
return {
clear = clear,
dedent = dedent,
+ source = source,
rawfeed = rawfeed,
insert = insert,
feed = feed,
diff --git a/test/functional/job/job_spec.lua b/test/functional/job/job_spec.lua
index 85a1e92e38..07ca0c0058 100644
--- a/test/functional/job/job_spec.lua
+++ b/test/functional/job/job_spec.lua
@@ -37,7 +37,7 @@ describe('jobs', function()
end)
it('allows interactive commands', function()
- nvim('command', notify_str('v:job_data[1]', 'v:job_data[2]'))
+ nvim('command', notify_str('v:job_data[1]', 'get(v:job_data, 2)'))
nvim('command', "let j = jobstart('xxx', 'cat', ['-'])")
neq(0, eval('j'))
nvim('command', 'call jobsend(j, "abc\\n")')
@@ -46,9 +46,8 @@ describe('jobs', function()
eq({'notification', 'stdout', {{'123', 'xyz'}}}, next_message())
nvim('command', 'call jobsend(j, [123, "xyz"])')
eq({'notification', 'stdout', {{'123', 'xyz'}}}, next_message())
- nvim('command', notify_str('v:job_data[1])'))
nvim('command', "call jobstop(j)")
- eq({'notification', 'exit', {}}, next_message())
+ eq({'notification', 'exit', {0}}, next_message())
end)
it('preserves NULs', function()
@@ -59,9 +58,10 @@ describe('jobs', function()
file:close()
-- v:job_data preserves NULs.
- nvim('command', notify_str('v:job_data[1]', 'v:job_data[2]'))
+ nvim('command', notify_str('v:job_data[1]', 'get(v:job_data, 2)'))
nvim('command', "let j = jobstart('xxx', 'cat', ['"..filename.."'])")
eq({'notification', 'stdout', {{'abc\ndef'}}}, next_message())
+ eq({'notification', 'exit', {0}}, next_message())
os.remove(filename)
-- jobsend() preserves NULs.
@@ -72,12 +72,13 @@ describe('jobs', function()
end)
it('will hold data if it does not end in a newline', function()
- nvim('command', notify_str('v:job_data[1]', 'v:job_data[2]'))
+ nvim('command', notify_str('v:job_data[1]', 'get(v:job_data, 2)'))
nvim('command', "let j = jobstart('xxx', 'cat', ['-'])")
nvim('command', 'call jobsend(j, "abc\\nxyz")')
eq({'notification', 'stdout', {{'abc'}}}, next_message())
nvim('command', "call jobstop(j)")
eq({'notification', 'stdout', {{'xyz'}}}, next_message())
+ eq({'notification', 'exit', {0}}, next_message())
end)
it('will not allow jobsend/stop on a non-existent job', function()
diff --git a/test/functional/legacy/004_bufenter_with_modelines_spec.lua b/test/functional/legacy/004_bufenter_with_modelines_spec.lua
index f1222700a7..6f009b52dd 100644
--- a/test/functional/legacy/004_bufenter_with_modelines_spec.lua
+++ b/test/functional/legacy/004_bufenter_with_modelines_spec.lua
@@ -31,7 +31,7 @@ describe('BufEnter with modelines', function()
execute('sp Xxx')
-- Append text with autoindent to this file
- feed('G?this is a<Esc>')
+ feed('G?this is a<CR>')
feed('othis should be auto-indented<Esc>')
-- Go to Xxx, no autocmd anymore
@@ -39,7 +39,7 @@ describe('BufEnter with modelines', function()
execute('buf Xxx')
-- Append text without autoindent to Xxx
- feed('G?this is a<Esc>')
+ feed('G?this is a<CR>')
feed('othis should be in column 1<Esc>')
execute('wq')
diff --git a/test/functional/legacy/005_bufleave_delete_buffer.lua b/test/functional/legacy/005_bufleave_delete_buffer.lua
new file mode 100644
index 0000000000..e8459ad4a7
--- /dev/null
+++ b/test/functional/legacy/005_bufleave_delete_buffer.lua
@@ -0,0 +1,71 @@
+-- Test for autocommand that deletes the current buffer on BufLeave event.
+-- Also test deleting the last buffer, should give a new, empty buffer.
+
+local helpers = require('test.functional.helpers')
+local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert
+local execute, expect = helpers.execute, helpers.expect
+
+describe('test5', function()
+ setup(clear)
+
+ it('is working', function()
+ insert([[
+ start of test file Xxx
+ vim: set noai :
+ this is a test
+ this is a test
+ this is a test
+ this is a test
+ end of test file Xxx]])
+
+ execute('w! Xxx0')
+ execute('au BufLeave Xxx bwipe')
+ execute('/start of')
+
+ -- Write test file Xxx.
+ execute('.,/end of/w! Xxx')
+
+ -- Split to Xxx.
+ execute('sp Xxx')
+
+ -- Delete buffer Xxx, now we're back here.
+ execute('bwipe')
+ feed('G?this is a<cr>')
+ feed('othis is some more text<esc>')
+
+ -- Append some text to this file.
+
+ -- Write current file contents.
+ execute('?start?,$yank A')
+
+ -- Delete alternate buffer.
+ execute('bwipe test.out')
+ execute('au bufleave test5.in bwipe')
+
+ -- Delete current buffer, get an empty one.
+ execute('bwipe!')
+ feed('ithis is another test line<esc>:yank A<cr>')
+
+ -- Output results
+ execute('%d')
+ execute('0put a')
+ execute('1d | $d')
+
+ -- Assert buffer contents.
+ expect([[
+ start of test file Xxx
+ vim: set noai :
+ this is a test
+ this is a test
+ this is a test
+ this is a test
+ this is some more text
+ end of test file Xxx
+ this is another test line]])
+ end)
+
+ teardown(function()
+ os.remove('Xxx')
+ os.remove('Xxx0')
+ end)
+end)
diff --git a/test/functional/legacy/025_jump_tag_hidden_spec.lua b/test/functional/legacy/025_jump_tag_hidden_spec.lua
new file mode 100644
index 0000000000..bd434c013c
--- /dev/null
+++ b/test/functional/legacy/025_jump_tag_hidden_spec.lua
@@ -0,0 +1,50 @@
+-- Test for jumping to a tag with 'hidden' set, with symbolic link in path of tag.
+-- This only works for Unix, because of the symbolic link.
+
+local helpers = require('test.functional.helpers')
+local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert
+local execute, expect = helpers.execute, helpers.expect
+
+describe('jump to a tag with hidden set', function()
+ setup(clear)
+
+ it('is working', function()
+ insert([[
+ tags line:
+ SECTION_OFF /test25.dir/Xxx /^#define SECTION_OFF 3$/
+
+ /*tx.c*/
+ #define SECTION_OFF 3
+ #define NUM_SECTIONS 3
+
+ SECTION_OFF]])
+
+ execute('w! Xxx')
+ execute('set hidden')
+
+ -- Create a link from test25.dir to the current directory.
+ execute('!rm -f test25.dir')
+ execute('!ln -s . test25.dir')
+
+ -- Create tags.text, with the current directory name inserted.
+ execute('/tags line')
+ execute('r !pwd')
+ feed('d$/test<cr>')
+ feed('hP:.w! tags.test<cr>')
+
+ -- Try jumping to a tag in the current file, but with a path that contains a
+ -- symbolic link. When wrong, this will give the ATTENTION message. The next
+ -- space will then be eaten by hit-return, instead of moving the cursor to 'd'.
+ execute('set tags=tags.test')
+ feed('G<C-]> x:yank a<cr>')
+ execute('!rm -f Xxx test25.dir tags.test')
+
+ -- Put @a and remove empty line
+ execute('%d')
+ execute('0put a')
+ execute('$d')
+
+ -- Assert buffer contents.
+ expect("#efine SECTION_OFF 3")
+ end)
+end)
diff --git a/test/functional/legacy/026_execute_while_if_spec.lua b/test/functional/legacy/026_execute_while_if_spec.lua
new file mode 100644
index 0000000000..9acbf76673
--- /dev/null
+++ b/test/functional/legacy/026_execute_while_if_spec.lua
@@ -0,0 +1,66 @@
+-- Test for :execute, :while and :if
+
+local helpers = require('test.functional.helpers')
+local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert
+local execute, expect = helpers.execute, helpers.expect
+local source = helpers.source
+
+describe(':execute, :while and :if', function()
+ setup(clear)
+
+ it('is working', function()
+ source([[
+ let i = 0
+ while i < 12
+ let i = i + 1
+ if has("ebcdic")
+ execute "normal o" . i . "\047"
+ else
+ execute "normal o" . i . "\033"
+ endif
+ if i % 2
+ normal Ax
+ if i == 9
+ break
+ endif
+ if i == 5
+ continue
+ else
+ let j = 9
+ while j > 0
+ if has("ebcdic")
+ execute "normal" j . "a" . j . "\x27"
+ else
+ execute "normal" j . "a" . j . "\x1b"
+ endif
+ let j = j - 1
+ endwhile
+ endif
+ endif
+ if i == 9
+ if has("ebcdic")
+ execute "normal Az\047"
+ else
+ execute "normal Az\033"
+ endif
+ endif
+ endwhile
+ unlet i j
+ ]])
+
+ -- Remove empty line
+ execute('1d')
+
+ -- Assert buffer contents.
+ expect([[
+ 1x999999999888888887777777666666555554444333221
+ 2
+ 3x999999999888888887777777666666555554444333221
+ 4
+ 5x
+ 6
+ 7x999999999888888887777777666666555554444333221
+ 8
+ 9x]])
+ end)
+end)
diff --git a/test/functional/legacy/033_lisp_indent_spec.lua b/test/functional/legacy/033_lisp_indent_spec.lua
new file mode 100644
index 0000000000..3ee248815d
--- /dev/null
+++ b/test/functional/legacy/033_lisp_indent_spec.lua
@@ -0,0 +1,73 @@
+-- vim: set foldmethod=marker foldmarker=[[,]] :
+-- Test for 'lisp'
+-- If the lisp feature is not enabled, this will fail!
+
+local helpers = require('test.functional.helpers')
+local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert
+local execute, expect = helpers.execute, helpers.expect
+
+describe('lisp indent', function()
+ setup(clear)
+
+ it('is working', function()
+ insert([[
+ (defun html-file (base)
+ (format nil "~(~A~).html" base))
+
+ (defmacro page (name title &rest body)
+ (let ((ti (gensym)))
+ `(with-open-file (*standard-output*
+ (html-file ,name)
+ :direction :output
+ :if-exists :supersede)
+ (let ((,ti ,title))
+ (as title ,ti)
+ (with center
+ (as h2 (string-upcase ,ti)))
+ (brs 3)
+ ,@body))))
+
+ ;;; Utilities for generating links
+
+ (defmacro with-link (dest &rest body)
+ `(progn
+ (format t "<a href=\"~A\">" (html-file ,dest))
+ ,@body
+ (princ "</a>")))]])
+
+ execute('set lisp expandtab')
+ execute('/^(defun')
+ feed('=G:/^(defun/,$yank A<cr>')
+
+ -- Put @a and clean empty line
+ execute('%d')
+ execute('0put a')
+ execute('$d')
+
+ -- Assert buffer contents.
+ expect([[
+ (defun html-file (base)
+ (format nil "~(~A~).html" base))
+
+ (defmacro page (name title &rest body)
+ (let ((ti (gensym)))
+ `(with-open-file (*standard-output*
+ (html-file ,name)
+ :direction :output
+ :if-exists :supersede)
+ (let ((,ti ,title))
+ (as title ,ti)
+ (with center
+ (as h2 (string-upcase ,ti)))
+ (brs 3)
+ ,@body))))
+
+ ;;; Utilities for generating links
+
+ (defmacro with-link (dest &rest body)
+ `(progn
+ (format t "<a href=\"~A\">" (html-file ,dest))
+ ,@body
+ (princ "</a>")))]])
+ end)
+end)
diff --git a/test/functional/legacy/043_magic_settings_spec.lua b/test/functional/legacy/043_magic_settings_spec.lua
new file mode 100644
index 0000000000..ccef298cdd
--- /dev/null
+++ b/test/functional/legacy/043_magic_settings_spec.lua
@@ -0,0 +1,61 @@
+-- vim: set foldmethod=marker foldmarker=[[,]] :
+-- Tests for regexp with various magic settings.
+
+local helpers = require('test.functional.helpers')
+local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert
+local execute, expect = helpers.execute, helpers.expect
+
+describe('regexp with magic settings', function()
+ setup(clear)
+
+ it('is working', function()
+ insert([[
+ 1 a aa abb abbccc
+ 2 d dd dee deefff
+ 3 g gg ghh ghhiii
+ 4 j jj jkk jkklll
+ 5 m mm mnn mnnooo
+ 6 x ^aa$ x
+ 7 (a)(b) abbaa
+ 8 axx [ab]xx
+ 9 foobar
+ ]])
+
+ execute('set nocompatible viminfo+=nviminfo')
+ execute('/^1')
+ execute([[/a*b\{2}c\+/e]])
+ feed([[x/\Md\*e\{2}f\+/e<cr>]])
+ feed('x:set nomagic<cr>')
+ execute([[/g\*h\{2}i\+/e]])
+ feed([[x/\mj*k\{2}l\+/e<cr>]])
+ feed([[x/\vm*n{2}o+/e<cr>]])
+ feed([[x/\V^aa$<cr>]])
+ feed('x:set magic<cr>')
+ execute([[/\v(a)(b)\2\1\1/e]])
+ feed([[x/\V[ab]\(\[xy]\)\1<cr>]])
+ feed('x:$<cr>')
+ execute('set undolevels=100')
+ feed('dv?bar?<cr>')
+ feed('Yup:<cr>')
+ execute('?^1?,$yank A')
+
+ -- Put @a and clean empty line
+ execute('%d')
+ execute('0put a')
+ execute('$d')
+
+ -- Assert buffer contents.
+ expect([[
+ 1 a aa abb abbcc
+ 2 d dd dee deeff
+ 3 g gg ghh ghhii
+ 4 j jj jkk jkkll
+ 5 m mm mnn mnnoo
+ 6 x aa$ x
+ 7 (a)(b) abba
+ 8 axx ab]xx
+ 9 foobar
+ 9 foo
+ ]])
+ end)
+end)
diff --git a/test/functional/legacy/051_highlight_spec.lua b/test/functional/legacy/051_highlight_spec.lua
new file mode 100644
index 0000000000..f35b70f93f
--- /dev/null
+++ b/test/functional/legacy/051_highlight_spec.lua
@@ -0,0 +1,70 @@
+-- vim: set foldmethod=marker foldmarker=[[,]] :
+-- Tests for ":highlight".
+
+local helpers = require('test.functional.helpers')
+local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert
+local execute, expect = helpers.execute, helpers.expect
+
+describe(':highlight', function()
+ setup(clear)
+
+ it('is working', function()
+ -- Basic test if ":highlight" doesn't crash
+ execute('highlight')
+ execute('hi Search')
+
+ -- Test setting colors.
+ -- Test clearing one color and all doesn't generate error or warning
+ execute('hi NewGroup term=bold cterm=italic ctermfg=DarkBlue ctermbg=Grey gui= guifg=#00ff00 guibg=Cyan')
+ execute('hi Group2 term= cterm=')
+ execute('hi Group3 term=underline cterm=bold')
+ execute('redir! @a')
+ execute('hi NewGroup')
+ execute('hi Group2')
+ execute('hi Group3')
+ execute('hi clear NewGroup')
+ execute('hi NewGroup')
+ execute('hi Group2')
+ execute('hi Group2 NONE')
+ execute('hi Group2')
+ execute('hi clear')
+ execute('hi Group3')
+ execute([[hi Crash term='asdf]])
+ execute('redir END')
+
+ -- Filter ctermfg and ctermbg, the numbers depend on the terminal
+ execute('0put a')
+ execute([[%s/ctermfg=\d*/ctermfg=2/]])
+ execute([[%s/ctermbg=\d*/ctermbg=3/]])
+
+ -- Filter out possibly translated error message
+ execute('%s/E475: [^:]*:/E475:/')
+
+ -- Fix the fileformat
+ execute('set ff&')
+ execute('$d')
+
+ -- Assert buffer contents.
+ expect([[
+
+
+ NewGroup xxx term=bold cterm=italic ctermfg=2 ctermbg=3
+
+ Group2 xxx cleared
+
+ Group3 xxx term=underline cterm=bold
+
+
+ NewGroup xxx cleared
+
+ Group2 xxx cleared
+
+
+ Group2 xxx cleared
+
+
+ Group3 xxx cleared
+
+ E475: term='asdf]])
+ end)
+end)
diff --git a/test/functional/legacy/066_visual_block_tab_spec.lua b/test/functional/legacy/066_visual_block_tab_spec.lua
new file mode 100644
index 0000000000..cd283e6746
--- /dev/null
+++ b/test/functional/legacy/066_visual_block_tab_spec.lua
@@ -0,0 +1,64 @@
+-- vim: set foldmethod=marker foldmarker=[[,]] :
+-- Test for visual block shift and tab characters.
+
+local helpers = require('test.functional.helpers')
+local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert
+local execute, expect = helpers.execute, helpers.expect
+
+describe('visual block shift and tab characters', function()
+ setup(clear)
+
+ it('is working', function()
+ insert([[
+ one two three
+ one two three
+ one two three
+ one two three
+ one two three
+
+ abcdefghijklmnopqrstuvwxyz
+ abcdefghijklmnopqrstuvwxyz
+ abcdefghijklmnopqrstuvwxyz
+ abcdefghijklmnopqrstuvwxyz
+ abcdefghijklmnopqrstuvwxyz]])
+
+ feed('gg')
+ feed([[fe<C-v>4jR<esc>ugvr1:'<,'>yank A<cr>]])
+ execute('/^abcdefgh')
+ feed('<C-v>4jI <esc>j<<11|D')
+ feed('j7|a <esc>')
+ feed('j7|a <esc>')
+ feed('j7|a <esc>4k13|<C-v>4j<')
+ execute('$-5,$yank A')
+ execute([[$-4,$s/\s\+//g]])
+ feed('<C-v>4kI <esc>j<<')
+ feed('j7|a <esc>')
+ feed('j7|a <esc>')
+ feed('j7|a <esc>4k13|<C-v>4j3<')
+ execute('$-4,$yank A')
+
+ -- Put @a and clean empty lines
+ execute('%d')
+ execute('0put a')
+ execute('$d')
+
+ -- Assert buffer contents.
+ expect([[
+ on1 two three
+ on1 two three
+ on1 two three
+ on1 two three
+ on1 two three
+
+ abcdefghijklmnopqrstuvwxyz
+ abcdefghij
+ abc defghijklmnopqrstuvwxyz
+ abc defghijklmnopqrstuvwxyz
+ abc defghijklmnopqrstuvwxyz
+ abcdefghijklmnopqrstuvwxyz
+ abcdefghij
+ abc defghijklmnopqrstuvwxyz
+ abc defghijklmnopqrstuvwxyz
+ abc defghijklmnopqrstuvwxyz]])
+ end)
+end)
diff --git a/test/functional/legacy/067_augroup_exists_spec.lua b/test/functional/legacy/067_augroup_exists_spec.lua
new file mode 100644
index 0000000000..6d89ad6d55
--- /dev/null
+++ b/test/functional/legacy/067_augroup_exists_spec.lua
@@ -0,0 +1,46 @@
+-- Test that groups and patterns are tested correctly when calling exists() for
+-- autocommands.
+
+local helpers = require('test.functional.helpers')
+local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert
+local execute, expect = helpers.execute, helpers.expect
+
+describe('augroup when calling exists()', function()
+ setup(clear)
+
+ it('is working', function()
+ execute('let results=[]')
+ execute('call add(results, "##BufEnter: " . exists("##BufEnter"))')
+ execute('call add(results, "#BufEnter: " . exists("#BufEnter"))')
+ execute('au BufEnter * let g:entered=1')
+ execute('call add(results, "#BufEnter: " . exists("#BufEnter"))')
+ execute('call add(results, "#auexists#BufEnter: " . exists("#auexists#BufEnter"))')
+ execute('augroup auexists', 'au BufEnter * let g:entered=1', 'augroup END')
+ execute('call add(results, "#auexists#BufEnter: " . exists("#auexists#BufEnter"))')
+ execute('call add(results, "#BufEnter#*.test: " . exists("#BufEnter#*.test"))')
+ execute('au BufEnter *.test let g:entered=1')
+ execute('call add(results, "#BufEnter#*.test: " . exists("#BufEnter#*.test"))')
+ execute('edit testfile.test')
+ execute('call add(results, "#BufEnter#<buffer>: " . exists("#BufEnter#<buffer>"))')
+ execute('au BufEnter <buffer> let g:entered=1')
+ execute('call add(results, "#BufEnter#<buffer>: " . exists("#BufEnter#<buffer>"))')
+ execute('edit testfile2.test')
+ execute('call add(results, "#BufEnter#<buffer>: " . exists("#BufEnter#<buffer>"))')
+ execute('bf')
+ execute('call append(0, results)')
+ execute('$d')
+
+ -- Assert buffer contents.
+ expect([[
+ ##BufEnter: 1
+ #BufEnter: 0
+ #BufEnter: 1
+ #auexists#BufEnter: 0
+ #auexists#BufEnter: 1
+ #BufEnter#*.test: 0
+ #BufEnter#*.test: 1
+ #BufEnter#<buffer>: 0
+ #BufEnter#<buffer>: 1
+ #BufEnter#<buffer>: 0]])
+ end)
+end)
diff --git a/test/functional/legacy/075_maparg_spec.lua b/test/functional/legacy/075_maparg_spec.lua
new file mode 100644
index 0000000000..dac8940314
--- /dev/null
+++ b/test/functional/legacy/075_maparg_spec.lua
@@ -0,0 +1,58 @@
+-- Tests for maparg().
+-- Also test utf8 map with a 0x80 byte.
+
+local helpers = require('test.functional.helpers')
+local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert
+local execute, expect = helpers.execute, helpers.expect
+
+describe('maparg()', function()
+ setup(clear)
+
+ it('is working', function()
+ execute('set cpo-=<')
+ execute('set encoding=utf8')
+
+ -- Test maparg() with a string result
+ execute('map foo<C-V> is<F4>foo')
+ execute('vnoremap <script> <buffer> <expr> <silent> bar isbar')
+ execute([[call append('$', maparg('foo<C-V>'))]])
+ execute([[call append('$', string(maparg('foo<C-V>', '', 0, 1)))]])
+ execute([[call append('$', string(maparg('bar', '', 0, 1)))]])
+ execute('map <buffer> <nowait> foo bar')
+ execute([[call append('$', string(maparg('foo', '', 0, 1)))]])
+ execute('map abc x<char-114>x')
+ execute([[call append('$', maparg('abc'))]])
+ execute('map abc y<S-char-114>y')
+ execute([[call append('$', maparg('abc'))]])
+ feed('Go<esc>:<cr>')
+
+ -- Outside of the range, minimum
+ execute('inoremap <Char-0x1040> a')
+ execute([[execute "normal a\u1040\<Esc>"]])
+
+ -- Inside of the range, minimum
+ execute('inoremap <Char-0x103f> b')
+ execute([[execute "normal a\u103f\<Esc>"]])
+
+ -- Inside of the range, maximum
+ execute('inoremap <Char-0xf03f> c')
+ execute([[execute "normal a\uf03f\<Esc>"]])
+
+ -- Outside of the range, maximum
+ execute('inoremap <Char-0xf040> d')
+ execute([[execute "normal a\uf040\<Esc>"]])
+
+ -- Remove empty line
+ execute('1d')
+
+ -- Assert buffer contents.
+ expect([[
+ is<F4>foo
+ {'silent': 0, 'noremap': 0, 'lhs': 'foo<C-V>', 'mode': ' ', 'nowait': 0, 'expr': 0, 'sid': 0, 'rhs': 'is<F4>foo', 'buffer': 0}
+ {'silent': 1, 'noremap': 1, 'lhs': 'bar', 'mode': 'v', 'nowait': 0, 'expr': 1, 'sid': 0, 'rhs': 'isbar', 'buffer': 1}
+ {'silent': 0, 'noremap': 0, 'lhs': 'foo', 'mode': ' ', 'nowait': 1, 'expr': 0, 'sid': 0, 'rhs': 'bar', 'buffer': 1}
+ xrx
+ yRy
+ abcd]])
+ end)
+end)
diff --git a/test/functional/legacy/101_hlsearch_spec.lua b/test/functional/legacy/101_hlsearch_spec.lua
new file mode 100644
index 0000000000..3c44f02edb
--- /dev/null
+++ b/test/functional/legacy/101_hlsearch_spec.lua
@@ -0,0 +1,63 @@
+-- Test for v:hlsearch
+
+local helpers = require('test.functional.helpers')
+local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert
+local execute, expect = helpers.execute, helpers.expect
+local eval = helpers.eval
+
+describe('v:hlsearch', function()
+ setup(clear)
+
+ it('is working', function()
+ -- Last abc: Q
+ execute('new')
+ execute([[call setline(1, repeat(['aaa'], 10))]])
+ execute('set hlsearch nolazyredraw')
+ execute('let r=[]')
+ execute('command -nargs=0 -bar AddR :call add(r, [screenattr(1, 1), v:hlsearch])')
+ execute('/aaa')
+ execute('AddR')
+ execute('nohlsearch')
+ execute('AddR')
+ execute('let v:hlsearch=1')
+ execute('AddR')
+ execute('let v:hlsearch=0')
+ execute('AddR')
+ execute('set hlsearch')
+ execute('AddR')
+ execute('let v:hlsearch=0')
+ execute('AddR')
+ feed('n:AddR<cr>')
+ execute('let v:hlsearch=0')
+ execute('AddR')
+ execute('/')
+ execute('AddR')
+ execute('let r1=r[0][0]')
+
+ -- I guess it is not guaranteed that screenattr outputs always the same character
+ execute([[call map(r, 'v:val[1].":".(v:val[0]==r1?"highlighted":"not highlighted")')]])
+ execute('try')
+ execute(' let v:hlsearch=[]')
+ execute('catch')
+ execute([[ call add(r, matchstr(v:exception,'^Vim(let):E\d\+:'))]])
+ execute('endtry')
+ execute('bwipeout!')
+ execute('$put=r')
+ execute('call garbagecollect(1)')
+ execute('call getchar()')
+ execute('1d', '1d')
+
+ -- Assert buffer contents.
+ expect([[
+ 1:highlighted
+ 0:not highlighted
+ 1:highlighted
+ 0:not highlighted
+ 1:highlighted
+ 0:not highlighted
+ 1:highlighted
+ 0:not highlighted
+ 1:highlighted
+ Vim(let):E706:]])
+ end)
+end)
diff --git a/test/functional/legacy/104_let_assignment.lua b/test/functional/legacy/104_let_assignment.lua
new file mode 100644
index 0000000000..a2431da835
--- /dev/null
+++ b/test/functional/legacy/104_let_assignment.lua
@@ -0,0 +1,54 @@
+-- Tests for :let.
+
+local helpers = require('test.functional.helpers')
+local clear, source = helpers.clear, helpers.source
+local execute, expect = helpers.execute, helpers.expect
+
+describe(':let', function()
+ setup(clear)
+
+ it('is working', function()
+ execute('set runtimepath+=test/functional/fixtures')
+
+ -- Test to not autoload when assigning. It causes internal error.
+ source([[
+ try
+ let Test104#numvar = function('tr')
+ $put ='OK: ' . string(Test104#numvar)
+ catch
+ $put ='FAIL: ' . v:exception
+ endtry
+ let a = 1
+ let b = 2
+ for letargs in ['a b', '{0 == 1 ? "a" : "b"}', '{0 == 1 ? "a" : "b"} a', 'a {0 == 1 ? "a" : "b"}']
+ try
+ redir => messages
+ execute 'let' letargs
+ redir END
+ $put ='OK:'
+ $put =split(substitute(messages, '\n', '\0 ', 'g'), '\n')
+ catch
+ $put ='FAIL: ' . v:exception
+ redir END
+ endtry
+ endfor]])
+
+ -- Remove empty line
+ execute('1d')
+
+ -- Assert buffer contents.
+ expect([[
+ OK: function('tr')
+ OK:
+ a #1
+ b #2
+ OK:
+ b #2
+ OK:
+ b #2
+ a #1
+ OK:
+ a #1
+ b #2]])
+ end)
+end)
diff --git a/test/functional/legacy/105_filename_modifiers_spec.lua b/test/functional/legacy/105_filename_modifiers_spec.lua
new file mode 100644
index 0000000000..3b417a88eb
--- /dev/null
+++ b/test/functional/legacy/105_filename_modifiers_spec.lua
@@ -0,0 +1,81 @@
+-- Test filename modifiers.
+
+local helpers = require('test.functional.helpers')
+local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert
+local execute, expect = helpers.execute, helpers.expect
+
+describe('filename modifiers', function()
+ setup(clear)
+
+ it('is working', function()
+ local tmpdir = helpers.nvim('eval', 'resolve("/tmp")')
+
+ execute('cd ' .. tmpdir)
+ execute([=[set shell=sh]=])
+ execute([=[set shellslash]=])
+ execute([=[let tab="\t"]=])
+ execute([=[command -nargs=1 Put :let expr=<q-args> | $put =expr.tab.strtrans(string(eval(expr)))]=])
+ execute([=[let $HOME=fnamemodify('.', ':p:h:h:h')]=])
+ execute([=[Put fnamemodify('.', ':p' )[-1:]]=])
+ execute([=[Put fnamemodify('.', ':p:h' )[-1:]]=])
+ execute([=[Put fnamemodify('test.out', ':p' )[-1:]]=])
+ execute([=[Put fnamemodify('test.out', ':.' )]=])
+ execute([=[Put fnamemodify('../testdir/a', ':.' )]=])
+ execute([=[Put fnamemodify('test.out', ':~' )]=])
+ execute([=[Put fnamemodify('../testdir/a', ':~' )]=])
+ execute([=[Put fnamemodify('../testdir/a', ':t' )]=])
+ execute([=[Put fnamemodify('.', ':p:t' )]=])
+ execute([=[Put fnamemodify('test.out', ':p:t' )]=])
+ execute([=[Put fnamemodify('test.out', ':p:e' )]=])
+ execute([=[Put fnamemodify('test.out', ':p:t:e' )]=])
+ execute([=[Put fnamemodify('abc.fb2.tar.gz', ':r' )]=])
+ execute([=[Put fnamemodify('abc.fb2.tar.gz', ':r:r' )]=])
+ execute([=[Put fnamemodify('abc.fb2.tar.gz', ':r:r:r' )]=])
+ execute([=[Put substitute(fnamemodify('abc.fb2.tar.gz', ':p:r:r'), '.*\(nvim/testdir/.*\)', '\1', '')]=])
+ execute([=[Put fnamemodify('abc.fb2.tar.gz', ':e' )]=])
+ execute([=[Put fnamemodify('abc.fb2.tar.gz', ':e:e' )]=])
+ execute([=[Put fnamemodify('abc.fb2.tar.gz', ':e:e:e' )]=])
+ execute([=[Put fnamemodify('abc.fb2.tar.gz', ':e:e:e:e')]=])
+ execute([=[Put fnamemodify('abc.fb2.tar.gz', ':e:e:r' )]=])
+ execute([=[Put fnamemodify('abc def', ':S' )]=])
+ execute([=[Put fnamemodify('abc" "def', ':S' )]=])
+ execute([=[Put fnamemodify('abc"%"def', ':S' )]=])
+ execute([=[Put fnamemodify('abc'' ''def', ':S' )]=])
+ execute([=[Put fnamemodify('abc''%''def', ':S' )]=])
+ execute([=[Put fnamemodify("abc\ndef", ':S' )]=])
+ execute([=[set shell=tcsh]=])
+ execute([=[Put fnamemodify("abc\ndef", ':S' )]=])
+ execute([=[1 delete _]=])
+
+ -- Assert buffer contents.
+ expect([=[
+ fnamemodify('.', ':p' )[-1:] '/'
+ fnamemodify('.', ':p:h' )[-1:] 'p'
+ fnamemodify('test.out', ':p' )[-1:] 't'
+ fnamemodify('test.out', ':.' ) 'test.out'
+ fnamemodify('../testdir/a', ':.' ) '../testdir/a'
+ fnamemodify('test.out', ':~' ) 'test.out'
+ fnamemodify('../testdir/a', ':~' ) '../testdir/a'
+ fnamemodify('../testdir/a', ':t' ) 'a'
+ fnamemodify('.', ':p:t' ) ''
+ fnamemodify('test.out', ':p:t' ) 'test.out'
+ fnamemodify('test.out', ':p:e' ) 'out'
+ fnamemodify('test.out', ':p:t:e' ) 'out'
+ fnamemodify('abc.fb2.tar.gz', ':r' ) 'abc.fb2.tar'
+ fnamemodify('abc.fb2.tar.gz', ':r:r' ) 'abc.fb2'
+ fnamemodify('abc.fb2.tar.gz', ':r:r:r' ) 'abc'
+ substitute(fnamemodify('abc.fb2.tar.gz', ':p:r:r'), '.*\(nvim/testdir/.*\)', '\1', '') ']=] .. tmpdir .. [=[/abc.fb2'
+ fnamemodify('abc.fb2.tar.gz', ':e' ) 'gz'
+ fnamemodify('abc.fb2.tar.gz', ':e:e' ) 'tar.gz'
+ fnamemodify('abc.fb2.tar.gz', ':e:e:e' ) 'fb2.tar.gz'
+ fnamemodify('abc.fb2.tar.gz', ':e:e:e:e') 'fb2.tar.gz'
+ fnamemodify('abc.fb2.tar.gz', ':e:e:r' ) 'tar'
+ fnamemodify('abc def', ':S' ) '''abc def'''
+ fnamemodify('abc" "def', ':S' ) '''abc" "def'''
+ fnamemodify('abc"%"def', ':S' ) '''abc"%"def'''
+ fnamemodify('abc'' ''def', ':S' ) '''abc''\'''' ''\''''def'''
+ fnamemodify('abc''%''def', ':S' ) '''abc''\''''%''\''''def'''
+ fnamemodify("abc\ndef", ':S' ) '''abc^@def'''
+ fnamemodify("abc\ndef", ':S' ) '''abc\^@def''']=])
+ end)
+end)
diff --git a/test/functional/runtime/autoload/rpc/define_spec.lua b/test/functional/runtime/autoload/remote/define_spec.lua
index a85ba4d37b..53da47243c 100644
--- a/test/functional/runtime/autoload/rpc/define_spec.lua
+++ b/test/functional/runtime/autoload/remote/define_spec.lua
@@ -346,20 +346,20 @@ local function host()
end
local function register()
- eval('rpc#host#Register("busted", '..channel()..')')
+ eval('remote#host#Register("busted", '..channel()..')')
end
-command_specs_for('rpc#define#CommandOnChannel', true, channel)
-command_specs_for('rpc#define#CommandOnChannel', false, channel)
-command_specs_for('rpc#define#CommandOnHost', true, host, register)
-command_specs_for('rpc#define#CommandOnHost', false, host, register)
+command_specs_for('remote#define#CommandOnChannel', true, channel)
+command_specs_for('remote#define#CommandOnChannel', false, channel)
+command_specs_for('remote#define#CommandOnHost', true, host, register)
+command_specs_for('remote#define#CommandOnHost', false, host, register)
-autocmd_specs_for('rpc#define#AutocmdOnChannel', true, channel)
-autocmd_specs_for('rpc#define#AutocmdOnChannel', false, channel)
-autocmd_specs_for('rpc#define#AutocmdOnHost', true, host, register)
-autocmd_specs_for('rpc#define#AutocmdOnHost', false, host, register)
+autocmd_specs_for('remote#define#AutocmdOnChannel', true, channel)
+autocmd_specs_for('remote#define#AutocmdOnChannel', false, channel)
+autocmd_specs_for('remote#define#AutocmdOnHost', true, host, register)
+autocmd_specs_for('remote#define#AutocmdOnHost', false, host, register)
-function_specs_for('rpc#define#FunctionOnChannel', true, channel)
-function_specs_for('rpc#define#FunctionOnChannel', false, channel)
-function_specs_for('rpc#define#FunctionOnHost', true, host, register)
-function_specs_for('rpc#define#FunctionOnHost', false, host, register)
+function_specs_for('remote#define#FunctionOnChannel', true, channel)
+function_specs_for('remote#define#FunctionOnChannel', false, channel)
+function_specs_for('remote#define#FunctionOnHost', true, host, register)
+function_specs_for('remote#define#FunctionOnHost', false, host, register)
diff --git a/test/functional/shell/viml_system_spec.lua b/test/functional/shell/viml_system_spec.lua
index 91e115aedf..8d212c1375 100644
--- a/test/functional/shell/viml_system_spec.lua
+++ b/test/functional/shell/viml_system_spec.lua
@@ -10,6 +10,7 @@ local eq, clear, eval, feed, nvim =
local function create_file_with_nuls(name)
return function()
feed('ipart1<C-V>000part2<C-V>000part3<ESC>:w '..name..'<CR>')
+ eval('1') -- wait for the file to be created
end
end
@@ -21,11 +22,9 @@ end
-- Some tests require the xclip program and a x server.
local xclip = nil
-do
+do
if os.getenv('DISPLAY') then
- local proc = io.popen('which xclip')
- xclip = proc:read()
- proc:close()
+ xclip = (os.execute('command -v xclip > /dev/null 2>&1') == 0)
end
end