mirror of
https://github.com/neovim/neovim.git
synced 2024-12-29 14:41:06 -07:00
39d70fcafd
This is the first PR featuring a conversion of an upstream vim9script file into a Lua file. The generated file can be found in `runtime/autoload/ccomplete.vim` in the vim repository. Below is a limited history of the changes of that file at the time of conversion. ``` ❯ git log --format=oneline runtime/autoload/ccomplete.vim c4573eb12dba6a062af28ee0b8938d1521934ce4 Update runtime files a4d131d11052cafcc5baad2273ef48e0dd4d09c5 Update runtime files 4466ad6baa22485abb1147aca3340cced4778a66 Update runtime files d1caa941d876181aae0ebebc6ea954045bf0da24 Update runtime files 20aac6c1126988339611576d425965a25a777658 Update runtime files. 30b658179962cc3c9f0a98f071b36b09a36c2b94 Updated runtime files. b6b046b281fac168a78b3eafdea9274bef06882f Updated runtime files. 00a927d62b68a3523cb1c4f9aa3f7683345c8182 Updated runtime files. 8c8de839325eda0bed68917d18179d2003b344d1 (tag: v7.2a) updated for version 7.2a ... ``` The file runtime/lua/_vim9script.lua only needs to be updated when vim9jit is updated (for any bug fixes or new features, like implementing class and interface, the latest in vim9script). Further PRs will improve the DX of generated the converted lua and tracking which files in the neovim's code base have been generated.
62 lines
2.1 KiB
Lua
62 lines
2.1 KiB
Lua
local helpers = require('test.functional.helpers')(after_each)
|
|
local clear = helpers.clear
|
|
local command = helpers.command
|
|
local eq = helpers.eq
|
|
local eval = helpers.eval
|
|
local feed = helpers.feed
|
|
local write_file = helpers.write_file
|
|
|
|
describe('ccomplete#Complete', function()
|
|
setup(function()
|
|
-- Realistic tags generated from neovim source tree using `ctags -R *`
|
|
write_file(
|
|
'Xtags',
|
|
[[
|
|
augroup_del src/nvim/autocmd.c /^void augroup_del(char *name, bool stupid_legacy_mode)$/;" f typeref:typename:void
|
|
augroup_exists src/nvim/autocmd.c /^bool augroup_exists(const char *name)$/;" f typeref:typename:bool
|
|
augroup_find src/nvim/autocmd.c /^int augroup_find(const char *name)$/;" f typeref:typename:int
|
|
aupat_get_buflocal_nr src/nvim/autocmd.c /^int aupat_get_buflocal_nr(char *pat, int patlen)$/;" f typeref:typename:int
|
|
aupat_is_buflocal src/nvim/autocmd.c /^bool aupat_is_buflocal(char *pat, int patlen)$/;" f typeref:typename:bool
|
|
expand_get_augroup_name src/nvim/autocmd.c /^char *expand_get_augroup_name(expand_T *xp, int idx)$/;" f typeref:typename:char *
|
|
expand_get_event_name src/nvim/autocmd.c /^char *expand_get_event_name(expand_T *xp, int idx)$/;" f typeref:typename:char *
|
|
]]
|
|
)
|
|
end)
|
|
|
|
before_each(function()
|
|
clear()
|
|
command('set tags=Xtags')
|
|
end)
|
|
|
|
teardown(function()
|
|
os.remove('Xtags')
|
|
end)
|
|
|
|
it('can complete from Xtags', function()
|
|
local completed = eval('ccomplete#Complete(0, "a")')
|
|
eq(5, #completed)
|
|
eq('augroup_del(', completed[1].word)
|
|
eq('f', completed[1].kind)
|
|
|
|
local aupat = eval('ccomplete#Complete(0, "aupat")')
|
|
eq(2, #aupat)
|
|
eq('aupat_get_buflocal_nr(', aupat[1].word)
|
|
eq('f', aupat[1].kind)
|
|
end)
|
|
|
|
it('does not error when returning no matches', function()
|
|
local completed = eval('ccomplete#Complete(0, "doesnotmatch")')
|
|
eq({}, completed)
|
|
end)
|
|
|
|
it('can find the beginning of a word for C', function()
|
|
command('set filetype=c')
|
|
feed('i int something = augroup')
|
|
local result = eval('ccomplete#Complete(1, "")')
|
|
eq(#' int something = ', result)
|
|
|
|
local completed = eval('ccomplete#Complete(0, "augroup")')
|
|
eq(3, #completed)
|
|
end)
|
|
end)
|