Skip to content

Commit

Permalink
Added functionality to view and navigate loclist
Browse files Browse the repository at this point in the history
  • Loading branch information
singalhimanshu committed Sep 2, 2020
1 parent c11a661 commit c76d832
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
12 changes: 11 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,11 @@ require('telescope.builtin').live_grep()
-- Use builtin LSP to request references under cursor. Fuzzy find over results.
require('telescope.builtin').lsp_references()

-- Convert currently quickfixlist to telescope
-- convert currently quickfixlist to telescope
require('telescope.builtin').quickfix()

-- convert currently loclist to telescope
require('telescope.builtin').loclist()
```

### Example
Expand Down Expand Up @@ -91,6 +94,13 @@ require'telescope.builtin'.quickfix{
}
```

```lua
require'telescope.builtin'.loclist{
-- see picker for additional options
prompt = 'loclist'
}
```

```lua
require'telescope.builtin'.grep_string{
-- See Picker for additional options
Expand Down
22 changes: 22 additions & 0 deletions lua/telescope/builtin.lua
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,28 @@ builtin.quickfix = function(opts)
}):find()
end

builtin.loclist = function(opts)
local locations = vim.fn.getloclist(0)
local filename = vim.api.nvim_buf_get_name(0)

for _, value in pairs(locations) do
value.filename = filename
end

local results = utils.quickfix_items_to_entries(locations)

if vim.tbl_isempty(results) then
return
end

pickers.new(opts, {
prompt = 'Loclist',
finder = finders.new_table(results),
previewer = previewers.qflist,
sorter = sorters.get_norcalli_sorter(),
}):find()
end

builtin.grep_string = function(opts)
opts = opts or {}

Expand Down

0 comments on commit c76d832

Please sign in to comment.