diff options
| author | Lewis Russell <lewis6991@gmail.com> | 2022-04-21 10:48:47 +0100 |
|---|---|---|
| committer | Lewis Russell <me@lewisr.dev> | 2022-09-12 11:49:51 +0100 |
| commit | 2eaf18826988f921ddb39e4a2e7d23d95bb0e52a (patch) | |
| tree | 4d4d76fd369b82f7a0ab26725f9c24cef13e6250 /lua/nvim-treesitter/query.lua | |
| parent | 2bc82e814bbe25eb4b69e6d002c0e55573d726d4 (diff) | |
fix(fold): don't include whitespace end regions
Some languages that are difficult to parse via Treesitter may
incorrectly include whitespace lines at the end of regions. This can
makes the calculated folds sub-optimal.
To recitfy, use a custom directive (trim), to calculate the range with
the trailing whitespace lines removed. Note this only works if the
region end column is 0.
Also added folds for Make.
Diffstat (limited to 'lua/nvim-treesitter/query.lua')
| -rw-r--r-- | lua/nvim-treesitter/query.lua | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/lua/nvim-treesitter/query.lua b/lua/nvim-treesitter/query.lua index bad1c27e..aeaa683b 100644 --- a/lua/nvim-treesitter/query.lua +++ b/lua/nvim-treesitter/query.lua @@ -209,7 +209,7 @@ function M.iter_prepared_matches(query, qnode, bufnr, start_row, end_row) local matches = query:iter_matches(qnode, bufnr, start_row, end_row) local function iterator() - local pattern, match = matches() + local pattern, match, metadata = matches() if pattern ~= nil then local prepared_match = {} @@ -219,6 +219,8 @@ function M.iter_prepared_matches(query, qnode, bufnr, start_row, end_row) if name ~= nil then local path = split(name .. ".node") insert_to_path(prepared_match, path, node) + local metadata_path = split(name .. ".metadata") + insert_to_path(prepared_match, metadata_path, metadata[id]) end end |
