diff options
| author | Simon Hauser <Simon-Hauser@outlook.de> | 2021-01-03 20:27:23 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-01-03 20:27:23 +0100 |
| commit | 4691863f4358857a02d3b78049453f7a3abdfac9 (patch) | |
| tree | a809ecd6fea4e5bf70144d9bace275d0be348c7c /lua | |
| parent | 88ebcaab10681e9b12bbf1c38719ae3d48d81f4d (diff) | |
fix: termopen previewer for powershell (#382)
Diffstat (limited to 'lua')
| -rw-r--r-- | lua/telescope/make_entry.lua | 2 | ||||
| -rw-r--r-- | lua/telescope/previewers/term_previewer.lua | 11 |
2 files changed, 7 insertions, 6 deletions
diff --git a/lua/telescope/make_entry.lua b/lua/telescope/make_entry.lua index d653f9e..188a54d 100644 --- a/lua/telescope/make_entry.lua +++ b/lua/telescope/make_entry.lua @@ -532,7 +532,7 @@ function make_entry.gen_from_treesitter(opts) local make_display = function(entry) local msg = vim.api.nvim_buf_get_lines( bufnr, - entry.lnum - 1, + entry.lnum, entry.lnum, false )[1] or '' diff --git a/lua/telescope/previewers/term_previewer.lua b/lua/telescope/previewers/term_previewer.lua index 132cba0..666d06a 100644 --- a/lua/telescope/previewers/term_previewer.lua +++ b/lua/telescope/previewers/term_previewer.lua @@ -15,12 +15,12 @@ local previewers = {} -- 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) and conf.use_less -local termopen_env = vim.tbl_extend("force", { ['GIT_PAGER'] = (has_less and 'less' or '') }, conf.set_env) -- TODO(conni2461): Workaround for neovim/neovim#11751. Add only quotes when using else branch. local valuate_shell = function() local shell = vim.o.shell - if string.find(shell, 'powershell.exe') or string.find(shell, 'cmd.exe') then + if string.find(shell, 'powershell.exe') or string.find(shell, 'cmd.exe') or + string.find(shell, 'powershell') or string.find(shell, 'pwsh') then return '' else return "'" @@ -177,19 +177,20 @@ previewers.new_termopen_previewer = function(opts) local term_opts = { cwd = opts.cwd or vim.fn.getcwd(), - env = termopen_env + env = conf.set_env } -- TODO(conni2461): Workaround for neovim/neovim#11751. local get_cmd = function(st) local shell = vim.o.shell - if string.find(shell, 'powershell.exe') or string.find(shell, 'cmd.exe') then + if string.find(shell, 'powershell.exe') or string.find(shell, 'cmd.exe') or + string.find(shell, 'powershell') or string.find(shell, 'pwsh') then return opts.get_command(entry, st) else local env = {} local cmd = opts.get_command(entry, st) if not cmd then return end - for k, v in pairs(termopen_env) do + for k, v in pairs(conf.set_env) do table.insert(env, k .. '=' .. v) end return table.concat(env, ' ') .. ' ' .. table.concat(cmd, ' ') |
