feat(query): add cache for get_query (#879)

* added cached to get_query

* added reload function

* fixed message

* added autocommand to reload cache on bufwrite for query file

* pass filename to autocommand v:lua fn

* removed comment

* added metatable

* fixed loop

* Update lua/nvim-treesitter/query.lua

Co-authored-by: Thomas Vigouroux <tomvig38@gmail.com>

* Update lua/nvim-treesitter/query.lua

Co-authored-by: Thomas Vigouroux <tomvig38@gmail.com>

* added do ... end to local query_cache

* made line shorter

Co-authored-by: Thomas Vigouroux <tomvig38@gmail.com>
This commit is contained in:
oberblastmeister 2021-01-28 13:56:55 -05:00 committed by GitHub
parent 12181e236e
commit 64ffea57f4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 68 additions and 13 deletions

View file

@ -5,6 +5,9 @@ if exists('g:loaded_nvim_treesitter')
endif
augroup NvimTreesitter
" on every query file write we want to set an autocommand that will reload the cache
autocmd FileType query
\ autocmd! NvimTreesitter BufWritePost <buffer> call v:lua.require('nvim-treesitter.query').reload_file_cache_on_write(expand('%:p'))
augroup END
let g:loaded_nvim_treesitter = 1