diff options
| author | Steven Sojka <Steven.Sojka@tdameritrade.com> | 2020-06-12 14:11:37 -0500 |
|---|---|---|
| committer | Steven Sojka <steelsojka@gmail.com> | 2020-06-14 05:58:09 -0500 |
| commit | 44108fe03e5c2cb761090c4abf8e7164225bf62f (patch) | |
| tree | a32dbd2f9c5ef73222d848a849f0c1185669c05b /lua | |
| parent | Merge pull request #77 from TravonteD/76-syntax-update (diff) | |
| download | nvim-treesitter-44108fe03e5c2cb761090c4abf8e7164225bf62f.tar nvim-treesitter-44108fe03e5c2cb761090c4abf8e7164225bf62f.tar.gz nvim-treesitter-44108fe03e5c2cb761090c4abf8e7164225bf62f.tar.bz2 nvim-treesitter-44108fe03e5c2cb761090c4abf8e7164225bf62f.tar.lz nvim-treesitter-44108fe03e5c2cb761090c4abf8e7164225bf62f.tar.xz nvim-treesitter-44108fe03e5c2cb761090c4abf8e7164225bf62f.tar.zst nvim-treesitter-44108fe03e5c2cb761090c4abf8e7164225bf62f.zip | |
feat(queries): allow for user overrides
Diffstat (limited to 'lua')
| -rw-r--r-- | lua/nvim-treesitter/query.lua | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/lua/nvim-treesitter/query.lua b/lua/nvim-treesitter/query.lua index 644c33933..b914e5d7d 100644 --- a/lua/nvim-treesitter/query.lua +++ b/lua/nvim-treesitter/query.lua @@ -3,14 +3,21 @@ local ts = vim.treesitter local M = {} -local function read_query_file(fname) - return table.concat(vim.fn.readfile(fname), '\n') +local function read_query_files(filenames) + local contents = {} + + for _,filename in ipairs(filenames) do + vim.list_extend(contents, vim.fn.readfile(filename)) + end + + return table.concat(contents, '\n') end function M.get_query(ft, query_name) - local query_files = api.nvim_get_runtime_file(string.format('queries/%s/%s.scm', ft, query_name), false) + local query_files = api.nvim_get_runtime_file(string.format('queries/%s/%s.scm', ft, query_name), true) + if #query_files > 0 then - return ts.parse_query(ft, read_query_file(query_files[1])) + return ts.parse_query(ft, read_query_files(query_files)) end end |
