diff options
| author | TJ DeVries <devries.timothyj@gmail.com> | 2020-10-08 21:07:25 -0400 |
|---|---|---|
| committer | TJ DeVries <devries.timothyj@gmail.com> | 2020-10-08 21:07:25 -0400 |
| commit | fa17b37dad05a2928ee64bb53a8be8a36ee2de14 (patch) | |
| tree | ce1dad003ea3617cbbf30c92d1d69cfeeaf7813e /lua | |
| parent | 0b35057a0cd995ff419693d94e75b81ee331d3a5 (diff) | |
fix: Do not wrap lines and allow scrolling in ranged options
Diffstat (limited to 'lua')
| -rw-r--r-- | lua/telescope/previewers.lua | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/lua/telescope/previewers.lua b/lua/telescope/previewers.lua index f57a0d6..e605c24 100644 --- a/lua/telescope/previewers.lua +++ b/lua/telescope/previewers.lua @@ -18,6 +18,8 @@ Previewer.__index = Previewer -- TODO: Should play with these some more, ty @clason local bat_options = {"--style=plain", "--color=always", "--paging=always"} +local has_less = (vim.fn.executable('less') == 1) + local bat_maker = function(filename, lnum, start, finish) local command = {"bat"} @@ -25,8 +27,16 @@ local bat_maker = function(filename, lnum, start, finish) table.insert(command, { "--highlight-line", lnum}) end - if start and finish then - table.insert(command, { "-r", string.format("%s:%s", start, finish) }) + if has_less then + if start then + table.insert(command, {"--pager", string.format("less -S +%s", start)}) + else + table.insert(command, {"--pager", "less -S"}) + end + else + if start and finish then + table.insert(command, { "-r", string.format("%s:%s", start, finish) }) + end end return flatten { |
