From d3c9b65252ab1fa532811fee0212f68b50b30601 Mon Sep 17 00:00:00 2001 From: Subeet Kumar Dutta <34621179+SubeetKD@users.noreply.github.com> Date: Sun, 6 Sep 2020 01:19:01 +0530 Subject: [PATCH] added preview for files which spaces in names. (#35) TODO: Still need to do better escaping. --- lua/telescope/previewers.lua | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/lua/telescope/previewers.lua b/lua/telescope/previewers.lua index 6df7f78..2978e03 100644 --- a/lua/telescope/previewers.lua +++ b/lua/telescope/previewers.lua @@ -140,10 +140,10 @@ previewers.vim_buffer_or_bat = defaulter(function(_) local file_name = vim.split(value, ":")[1] - log.trace("Previewing File: %s", file_name) + log.trace("Previewing File: '%s'", file_name) -- vim.fn.termopen( - -- string.format("bat --color=always --style=grid %s"), + -- string.format("bat --color=always --style=grid '%s'"), -- vim.fn.fnamemodify(file_name, ":p") local bufnr = vim.fn.bufadd(file_name) @@ -159,7 +159,7 @@ previewers.vim_buffer_or_bat = defaulter(function(_) vim.api.nvim_win_set_option(status.preview_win, 'signcolumn', 'no') vim.api.nvim_win_set_option(status.preview_win, 'foldlevel', 100) else - vim.api.nvim_buf_set_lines(status.preview_bufnr, 0, -1, false, vim.fn.systemlist(string.format('bat %s', file_name))) + vim.api.nvim_buf_set_lines(status.preview_bufnr, 0, -1, false, vim.fn.systemlist(string.format('bat "%s"', file_name))) end end, } @@ -168,9 +168,9 @@ end, {}) previewers.cat = defaulter(function(opts) return previewers.new { setup = function() - local command_string = "cat %s" + local command_string = "cat '%s'" if 1 == vim.fn.executable("bat") then - command_string = "bat %s --style=grid --paging=always" + command_string = "bat '%s' --style=grid --paging=always" end return { @@ -203,9 +203,9 @@ end, {}) previewers.vimgrep = defaulter(function(_) return previewers.new { setup = function() - local command_string = "cat %s" + local command_string = "cat '%s'" if vim.fn.executable("bat") then - command_string = "bat %s --highlight-line %s -r %s:%s" .. bat_options + command_string = "bat '%s' --highlight-line '%s' -r '%s':'%s'" .. bat_options end return { @@ -244,9 +244,9 @@ end, {}) previewers.qflist = defaulter(function(_) return previewers.new { setup = function() - local command_string = "cat %s" + local command_string = "cat '%s'" if vim.fn.executable("bat") then - command_string = "bat %s --highlight-line %s -r %s:%s" .. bat_options + command_string = "bat '%s' --highlight-line '%s' -r '%s':'%s'" .. bat_options end return {