From f47f1dc03712bf49bf278e103e5196a09c5a6210 Mon Sep 17 00:00:00 2001 From: TJ DeVries Date: Fri, 11 Sep 2020 15:28:32 -0400 Subject: feat: make buffer work much better --- lua/telescope/make_entry.lua | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'lua/telescope/make_entry.lua') diff --git a/lua/telescope/make_entry.lua b/lua/telescope/make_entry.lua index b595ffc..35fef98 100644 --- a/lua/telescope/make_entry.lua +++ b/lua/telescope/make_entry.lua @@ -180,10 +180,23 @@ function make_entry.gen_from_quickfix(opts) end function make_entry.gen_from_buffer(opts) + local get_position = function(entry) + local tabpage_wins = vim.api.nvim_tabpage_list_wins(0) + for k, v in ipairs(tabpage_wins) do + if entry == vim.api.nvim_win_get_buf(v) then + return vim.api.nvim_win_get_cursor(v) + end + end + + return {} + end + return function(entry) local bufnr_str = tostring(entry) local bufname = vim.api.nvim_buf_get_name(entry) + local position = get_position(entry) + if '' == bufname then return nil end @@ -197,6 +210,8 @@ function make_entry.gen_from_buffer(opts) bufnr = entry, filename = bufname, + + lnum = position[1] or 1, } end end -- cgit v1.2.3