Skip to content

Commit

Permalink
Merge pull request #34 from desdic/20240112apidoc
Browse files Browse the repository at this point in the history
fix: fix documentation and change treesitter api to vim.treesitter
  • Loading branch information
desdic committed Jan 12, 2024
2 parents a2f1509 + 0365768 commit a30a0e3
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ Some file formats just doesn't fit into the category labels so custom ones have

## Custom queries

You can place your custom queries in `~/.config/nvim/queries` you can load them just as with the build-in queries. So adding `myspecial.scm` as `~/.config/nvim/queries/c/myspecial.scm` enables you to run
You can place your custom queries in `~/.config/nvim/queries` you can load them just as with the build-in queries. So adding `myspecial` as `~/.config/nvim/queries/c/agrolens.myspecial.scm` enables you to run

```
:Telescope agrolens query=myspecial
Expand Down
6 changes: 3 additions & 3 deletions doc/agrolens.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Agrolens is an extention for telescope that runs pre-defined (or custom)
tree-sitter queries on a buffer (or all buffers) and gives a quick
view via telescope.

Usage~
Usage ~
Using Lazy plugin manager

{
Expand Down Expand Up @@ -68,10 +68,10 @@ Default options when generation a query:
`agrolens.generate`({opts})
Generate treesitter query

Parameters~
Parameters ~
{opts} `(table)` Options for generating query.

Usage~
Usage ~
`require('agrolens').generate({})`


Expand Down
6 changes: 2 additions & 4 deletions lua/telescope/_extensions/agrolenslib.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ local finders = require("telescope.finders")
local make_entry = require("telescope.make_entry")
local actions = require("telescope.actions")
local conf = require("telescope.config").values
local queries = require("nvim-treesitter.query")
local ppath = require("plenary.path")
local plenary = require("plenary")
local utils = require("telescope._extensions.utils")
Expand Down Expand Up @@ -138,9 +137,8 @@ agrolens._add_entries = function(
local root = trees[1]:root()

for _, capture_name in ipairs(capture_names) do
local okgetq, iter_query =
pcall(queries.get_query, filetype, "agrolens." .. capture_name)
if okgetq and iter_query then
local iter_query = vim.treesitter.query.get(filetype, "agrolens." .. capture_name)
if iter_query then
for _, matches, _ in iter_query:iter_matches(root, bufnr) do
local entry = agrolens._create_entry(
filename,
Expand Down

0 comments on commit a30a0e3

Please sign in to comment.