1

Update generated nvim config

This commit is contained in:
2024-06-05 22:05:42 +02:00
parent 859ee3a2ba
commit 075fe5f587
1292 changed files with 152601 additions and 0 deletions

View File

@ -0,0 +1,24 @@
MYVIM ?= nvim --clean --headless
INMAKE := 1
export INMAKE
TESTS := $(wildcard test-*.vim)
TESTS := $(TESTS:.vim=)
TESTS_KPSEWHICH := test-kpsewhich-local-a test-kpsewhich-local-b
TESTS_ALL := $(TESTS) $(TESTS_KPSEWHICH)
.PHONY: test $(TESTS_ALL) test-cleanup
test: $(TESTS_ALL) test-cleanup
$(TESTS):
@$(MYVIM) -u $@.vim
$(TESTS_KPSEWHICH):
@cd $@ && $(MYVIM) -u test.vim
test-cleanup: $(TESTS_ALL)
@rm kpsewhich.json
@rm capture.json
@rm -f nvim_servernames.log

View File

@ -0,0 +1 @@
{"a": 1, "b": 2, "c": 3, "d": 4, "__validate": "cache_v2"}

View File

@ -0,0 +1,42 @@
set nocompatible
let &rtp = '../..,' . &rtp
filetype plugin on
nnoremap q :qall!<cr>
let g:vimtex_cache_root = '.'
" Test basic open and read
let s:cache = vimtex#cache#open('test-basic')
call assert_equal(1, s:cache.get('a'))
call assert_equal(4, s:cache.get('d'))
call assert_equal(0, s:cache.get('missing'))
call assert_true(s:cache.has('c'))
call vimtex#cache#close('test-basic')
" Similar, but now change default value
let s:cache = vimtex#cache#open('test-basic', {'default': {'key': 1}})
call s:cache.read()
let s:cache.persistent = 0
let s:current = s:cache.get('missing')
call assert_equal({'key': 1}, s:current)
let s:current.other = 1
let s:again = s:cache.get('missing')
call assert_equal(1, get(s:again, 'other'))
" Test create, set and overwrite - non persistent
let s:cache = vimtex#cache#open('test-new', {'persistent': 0})
call s:cache.set('a', 1)
call s:cache.set('b', 2)
call s:cache.set('c', 3)
call s:cache.set('d', 4)
call assert_equal(4, s:cache.get('d'))
call s:cache.set('d', 5)
call assert_equal(5, s:cache.get('d'))
call assert_true(!filereadable('test-new.json'))
call vimtex#test#finished()

View File

@ -0,0 +1,30 @@
set nocompatible
let &rtp = '../..,' . &rtp
filetype plugin on
nnoremap q :qall!<cr>
let g:vimtex_cache_root = '.'
" Clear global cache
let s:cache = vimtex#cache#open('test-clear')
call assert_equal('./test-clear.json', s:cache.path)
call s:cache.set('a', 1)
call assert_true(s:cache.has('a'))
call assert_true(filereadable(s:cache.path))
call s:cache.clear()
call assert_false(s:cache.has('a'))
call assert_false(filereadable(s:cache.path))
" Clear local cache
let b:vimtex = {'tex': '/foobar.tex'}
let s:cache = vimtex#cache#open('test-clear', {'local': 1})
call assert_equal('./test-clear%foobar.json', s:cache.path)
call s:cache.set('a', 1)
call assert_true(s:cache.has('a'))
call assert_true(filereadable(s:cache.path))
call s:cache.clear()
call assert_false(s:cache.has('a'))
call assert_false(filereadable(s:cache.path))
call vimtex#test#finished()

View File

@ -0,0 +1,19 @@
set nocompatible
let &rtp = '../..,' . &rtp
filetype plugin on
nnoremap q :qall!<cr>
let g:vimtex_cache_root = '.'
call writefile([], 'empty.json')
try
let s:cache = vimtex#cache#open('empty')
catch
call assert_report('Should not fail on empty cache file!')
finally
call delete('empty.json')
endtry
call vimtex#test#finished()

View File

@ -0,0 +1,17 @@
set nocompatible
set runtimepath^=../../../
filetype plugin indent on
nnoremap q :qall!<cr>
let g:vimtex_cache_root = '../.'
silent edit test.tex
call assert_equal(
\ 'test-kpsewhich-local-a/local.bib',
\ vimtex#paths#relative(
\ vimtex#kpsewhich#find('local.bib'),
\ expand('%:p:h:h')))
call vimtex#test#finished()

View File

@ -0,0 +1,17 @@
set nocompatible
set runtimepath^=../../../
filetype plugin indent on
nnoremap q :qall!<cr>
let g:vimtex_cache_root = '../.'
silent edit test.tex
call assert_equal(
\ 'test-kpsewhich-local-b/local.bib',
\ vimtex#paths#relative(
\ vimtex#kpsewhich#find('local.bib'),
\ expand('%:p:h:h')))
call vimtex#test#finished()

View File

@ -0,0 +1,28 @@
set nocompatible
let &rtp = '../..,' . &rtp
filetype plugin on
nnoremap q :qall!<cr>
let g:vimtex_cache_root = '.'
" Local caches
let s:cache1 = vimtex#cache#open('test-local', {'local': 1})
call assert_equal('./test-local.json', s:cache1.path)
call s:cache1.set('a', 1)
" Local caches (this is a new cache)
let b:vimtex = {'tex': '/foo.bar'}
let s:cache2 = vimtex#cache#open('test-local', {'local': 1})
call assert_equal('./test-local%foo.json', s:cache2.path)
call s:cache2.set('a', 2)
" The caches are not the same!
call vimtex#cache#write_all()
call assert_true(s:cache1.path !=# s:cache2.path)
" Clean up
call delete(s:cache1.path)
call delete(s:cache2.path)
call vimtex#test#finished()

View File

@ -0,0 +1,31 @@
set nocompatible
let &rtp = '../..,' . &rtp
filetype plugin on
nnoremap q :qall!<cr>
let g:vimtex_cache_root = '.'
" Create test files
let s:files = {
\ 'test-validate-pass.json': {'__validate': 1, 'a': 1},
\ 'test-validate-fail.json': {'__validate': 0, 'a': 1},
\}
for [s:file, s:content] in items(s:files)
call writefile([json_encode(s:content)], s:file)
endfor
let s:cache = vimtex#cache#open('test-validate-pass', {'validate': 1})
call assert_true(s:cache.has('a'))
let s:cache = vimtex#cache#open('test-validate-fail', {'validate': 1})
call assert_false(s:cache.has('a'))
" Clean up
for s:file in keys(s:files)
if filereadable(s:file) | call delete(s:file) | endif
endfor
call vimtex#test#finished()

View File

@ -0,0 +1,30 @@
set nocompatible
let &rtp = '../..,' . &rtp
filetype plugin on
nnoremap q :qall!<cr>
let g:vimtex_cache_root = '.'
function! SlowFunc(argument) abort
sleep 100m
return a:argument + 100
endfunction
let SlowFuncWrapped = vimtex#cache#wrap(
\ function('SlowFunc'), 'test-wrapper', {'persistent': 0})
" First call is slow
let s:time = reltime()
call assert_equal(101, SlowFuncWrapped(1))
call assert_inrange(0.09, 0.11, reltimefloat(reltime(s:time)))
" Second call is fast
let s:time = reltime()
call assert_equal(101, SlowFuncWrapped(1))
call assert_inrange(0.0, 0.01, reltimefloat(reltime(s:time)))
" We can also open the cache directly
let s:cache = vimtex#cache#open('test-wrapper')
call assert_true(s:cache.has(1))
call vimtex#test#finished()

View File

@ -0,0 +1,30 @@
set nocompatible
let &rtp = '../..,' . &rtp
filetype plugin on
nnoremap q :qall!<cr>
let g:vimtex_cache_root = '.'
call vimtex#log#set_silent()
if has('nvim')
let s:cache_name = 'test-write-error'
let s:cache_file = s:cache_name . '.json'
let s:cache = vimtex#cache#open(s:cache_name)
call s:cache.set('bad', "Usu<73>rio")
call s:cache.write()
let s:log = vimtex#log#get()
call assert_equal(1, len(s:log))
if len(s:log) > 0
call assert_equal(
\ printf('Could not encode cache "%s"', s:cache_name),
\ s:log[0].msg[0]
\)
endif
if filereadable(s:cache_file) | call delete(s:cache_file) | endif
endif
call vimtex#test#finished()