diff options
| author | Mike <Mike325@users.noreply.github.com> | 2021-01-05 13:11:36 -0600 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-01-05 20:11:36 +0100 |
| commit | d2ba51c6caab17147ec476a25668a61a4d6259c9 (patch) | |
| tree | e7e352b91fd880eac6acce9b2bcc91b3e8710106 /lua | |
| parent | f750159203077b00cecdd9f68c254aa70d10f879 (diff) | |
fix: handle directories in windows with dir (term_previewer) (#395)
Diffstat (limited to 'lua')
| -rw-r--r-- | lua/telescope/previewers/term_previewer.lua | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/lua/telescope/previewers/term_previewer.lua b/lua/telescope/previewers/term_previewer.lua index 666d06a..c09d6a3 100644 --- a/lua/telescope/previewers/term_previewer.lua +++ b/lua/telescope/previewers/term_previewer.lua @@ -33,9 +33,14 @@ local get_file_stat = function(filename) return vim.loop.fs_stat(vim.fn.expand(filename)) or {} end +local function list_dir(dirname) + local qdir = add_quotes .. vim.fn.expand(dirname) .. add_quotes + return vim.fn.has('win32') == 1 and {'cmd.exe', '/c', 'dir', qdir} or { 'ls', '-la', qdir} +end + local bat_maker = function(filename, lnum, start, finish) if get_file_stat(filename).type == 'directory' then - return { 'ls', '-la', vim.fn.expand(filename) } + return list_dir(filename) end local command = {"bat"} @@ -68,7 +73,7 @@ end local cat_maker = function(filename, _, start, _) if get_file_stat(filename).type == 'directory' then - return { 'ls', '-la', add_quotes .. vim.fn.expand(filename) .. add_quotes } + return list_dir(filename) end if 1 == vim.fn.executable('file') then |
