feat: make buffer work much better

This commit is contained in:
TJ DeVries
2020-09-11 15:28:32 -04:00
parent a9404201a9
commit f47f1dc037
4 changed files with 27 additions and 7 deletions
+15
View File
@@ -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