summaryrefslogtreecommitdiff
path: root/lua/telescope/previewers.lua
diff options
context:
space:
mode:
authorSimon Hauser <Simon-Hauser@outlook.de>2020-11-23 16:11:46 +0100
committerGitHub <noreply@github.com>2020-11-23 10:11:46 -0500
commit863328a96d81d4b93bcfaa0038d429ea24880b0b (patch)
tree4560fcbb47d2c084711d228f70ab58983182d874 /lua/telescope/previewers.lua
parent2ac0582c06d8a52a42907dde106983e44ae989ef (diff)
feat: Buffers rework (indicators and sorting) (#208)
Diffstat (limited to 'lua/telescope/previewers.lua')
-rw-r--r--lua/telescope/previewers.lua34
1 files changed, 4 insertions, 30 deletions
diff --git a/lua/telescope/previewers.lua b/lua/telescope/previewers.lua
index 01d8793..ee98f1c 100644
--- a/lua/telescope/previewers.lua
+++ b/lua/telescope/previewers.lua
@@ -356,53 +356,27 @@ previewers.vim_buffer = defaulter(function(_)
end,
preview_fn = function(self, entry, status)
- -- TODO: Consider using path here? Might not work otherwise.
- local filename = entry.filename
-
- if filename == nil then
- filename = entry.path
- end
+ local bufnr = tonumber(entry.bufnr)
- if filename == nil then
- local value = entry.value
- filename = vim.split(value, ":")[1]
- end
-
- if filename == nil then
- return
- end
-
- log.info("Previewing File:", filename)
-
- local bufnr = vim.fn.bufnr(filename)
- if bufnr == -1 then
- -- TODO: Is this the best way to load the buffer?... I'm not sure tbh
- bufnr = vim.fn.bufadd(filename)
+ if not vim.api.nvim_buf_is_loaded(bufnr) then
vim.fn.bufload(bufnr)
-
- vim.cmd([[doautocmd filetypedetect BufRead ]] .. filename)
end
self.state.last_set_bufnr = bufnr
- -- TODO: We should probably call something like this because we're not always getting highlight and all that stuff.
- -- api.nvim_command('doautocmd filetypedetect BufRead ' .. vim.fn.fnameescape(filename))
vim.api.nvim_win_set_buf(status.preview_win, bufnr)
vim.api.nvim_win_set_option(status.preview_win, 'wrap', false)
vim.api.nvim_win_set_option(status.preview_win, 'winhl', 'Normal:Normal')
- -- vim.api.nvim_win_set_option(preview_win, 'winblend', 20)
vim.api.nvim_win_set_option(status.preview_win, 'signcolumn', 'no')
vim.api.nvim_win_set_option(status.preview_win, 'foldlevel', 100)
-
if entry.lnum then
vim.api.nvim_buf_add_highlight(bufnr, previewer_ns, "Visual", entry.lnum - 1, 0, -1)
- vim.api.nvim_win_set_option(status.preview_win, 'scrolloff', 10)
+ vim.api.nvim_win_set_option(status.preview_win, 'scrolloff', 999)
vim.api.nvim_win_set_cursor(status.preview_win, {entry.lnum, 0})
-- print("LNUM:", entry.lnum)
end
- vim.api.nvim_win_set_option(status.preview_win, 'scrolloff', 999)
- log.info("Previewed bufnr", bufnr)
+ self.state.hl_win = status.preview_win
end,
}
end, {})