robin/laufey
git clone https://git.robinwobin.dev/robin/laufey
f907614088
master
1-- Test if URLs are recognized as filenames by commands such as "gf". Here 2-- we'll use `expand("<cfile>")` since "gf" would need to open the file. 3 4local n =require ( 'test.functional.testnvim' )() 5local t =require ( 'test.testutil' ) 6 7local describe , it , setup =t . describe , t . it , t . setup 8local clear , feed , insert =n . clear , n . feed , n . insert 9local feed_command , expect =n . feed_command , n . expect 10 11describe ( 'filename recognition' , function () 12setup ( clear ) 13 14it ( 'is working' , function () 15-- insert some lines containing URLs 16insert ( [[ 17first test for URL://machine.name/tmp/vimtest2a and other text 18second test for URL://machine.name/tmp/vimtest2b. And other text 19third test for URL:\\machine.name\vimtest2c and other text 20fourth test for URL:\\machine.name\tmp\vimtest2d, and other text]] ) 21 22-- Go to the first URL and append it to the beginning 23feed_command ( '/^first' , '/tmp' , 'call append(0, expand("<cfile>"))' ) 24 25-- Repeat for the second URL 26-- this time, navigate to the word "URL" instead of "tmp" 27feed_command ( '/^second' , '/URL' , 'call append(1, expand("<cfile>"))' ) 28 29-- Repeat for the remaining URLs. This time, the 'isfname' option must be 30-- set to allow '\' in filenames 31feed_command ( 'set isf=@,48-57,/,.,-,_,+,,,$,:,~,\\' ) 32feed_command ( '/^third' , '/name' , 'call append(2, expand("<cfile>"))' ) 33feed_command ( '/^fourth' , '/URL' , 'call append(3, expand("<cfile>"))' ) 34 35-- Delete the initial text, which now starts at line 5 36feed ( '5GdG' ) 37 38-- The buffer should now contain: 39expect ( [[ 40URL://machine.name/tmp/vimtest2a 41URL://machine.name/tmp/vimtest2b 42URL:\\machine.name\vimtest2c 43URL:\\machine.name\tmp\vimtest2d]] ) 44end ) 45end )