-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
331 additions
and
128 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
local config = {} | ||
|
||
--- Default telescope options: | ||
---@eval return MiniDoc.afterlines_to_code(MiniDoc.current.eval_section) | ||
config.opts = { | ||
-- Enable/Disable debug messages (is put in ~/.cache/nvim/agrolens.log) | ||
debug = false, | ||
|
||
-- Some tree-sitter plugins uses hidden buffers | ||
-- and we can enable those to if we want | ||
include_hidden_buffers = false, | ||
|
||
-- Make sure the query only runs on | ||
-- same filetype as the current one | ||
same_type = true, | ||
|
||
-- Match a given string or object | ||
-- Example `:Telescope agrolens query=callings buffers=all same_type=false match=name,object` | ||
-- this will query all callings but only those who match the word on the cursor | ||
match = nil, | ||
|
||
-- Disable displaying indententations in telescope | ||
disable_indentation = false, | ||
|
||
-- Alias can be used to join several queries into a single name | ||
-- Example: `aliases = { yamllist = "docker-compose,github-workflow-steps"}` | ||
aliases = {}, | ||
|
||
-- Several internal functions can also be overwritten | ||
-- | ||
-- Default entry maker | ||
-- entry_maker = agrolens.entry_maker | ||
-- | ||
-- Default way of finding current directory | ||
-- cwd = opts.cwd and vim.fn.expand(opts.cwd) or vim.uv.cwd() | ||
-- | ||
-- Default previewer | ||
-- previewer = conf.grep_previewer(opts) | ||
-- | ||
-- Default sorting | ||
-- sorter = conf.generic_sorter(opts) | ||
|
||
-- Default enable devicons | ||
disable_devicons = false, | ||
|
||
-- display length | ||
display_width = 150, | ||
|
||
-- force long path name even when only a single buffer | ||
force_long_filepath = false, | ||
} | ||
--minidoc_afterlines_end | ||
|
||
return config |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
local fzf = {} | ||
local core = require("agrolens.core") | ||
|
||
local contents = {} | ||
|
||
local fzf_lua = require("fzf-lua") | ||
local builtin = require("fzf-lua.previewer.builtin") | ||
local fzfpreview = builtin.buffer_or_file:extend() | ||
|
||
function fzfpreview:new(o, opts, fzf_win) | ||
fzfpreview.super.new(self, o, opts, fzf_win) | ||
setmetatable(self, fzfpreview) | ||
return self | ||
end | ||
|
||
function fzfpreview.parse_entry(_, entry_str) | ||
if entry_str == "" then | ||
return {} | ||
end | ||
|
||
local entry = contents[entry_str] | ||
return { | ||
path = entry.filename, | ||
line = entry.lnum or 1, | ||
col = 1, | ||
} | ||
end | ||
|
||
fzf.run = function(args) | ||
local opts = {} | ||
local cfg = require("agrolens.config").opts | ||
|
||
opts = core.sanitize_opts(opts, cfg, args) | ||
|
||
opts.cwd = opts.cwd and vim.fn.expand(opts.cwd) or vim.uv.cwd() | ||
opts = core.get_buffers(opts) | ||
|
||
if opts.jump then | ||
local jumplist = core.generate_jump_list(opts) | ||
local curline = vim.api.nvim_win_get_cursor(0)[1] | ||
|
||
if opts.jump == "next" then | ||
core.jump_next(curline, jumplist) | ||
elseif opts.jump == "prev" then | ||
core.jump_prev(curline, jumplist) | ||
end | ||
else | ||
fzf_lua.fzf_exec(function(fzf_cb) | ||
local results = core.get_captures(opts) | ||
for _, b in ipairs(results) do | ||
local fname = b.relfilename | ||
|
||
if opts.force_long_filepath ~= true then | ||
fname = vim.fs.basename(b.filename) | ||
end | ||
|
||
local key = fname .. ":" .. b.lnum .. ":" .. b.line | ||
contents[key] = b | ||
fzf_cb(key) | ||
end | ||
fzf_cb() | ||
end, { | ||
previewer = fzfpreview, | ||
prompt = "Agrolens> ", | ||
actions = { | ||
["enter"] = { | ||
fn = function(selected) | ||
local entry = contents[selected[1]] | ||
|
||
core.jump_to_buffer_line( | ||
entry.bufnr, | ||
entry.lnum, | ||
entry.col | ||
) | ||
end, | ||
silent = true, | ||
}, | ||
}, | ||
}) | ||
end | ||
end | ||
|
||
return fzf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.