diff options
| author | TJ DeVries <devries.timothyj@gmail.com> | 2020-09-05 07:34:38 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-09-05 07:34:38 -0400 |
| commit | c70d6e58a0ab09db1ee57aded0695d350db2dd83 (patch) | |
| tree | 7215ab223c65788c9218923f6c7ee0c61550991c /lua/telescope/actions.lua | |
| parent | 4abb5f7867fb087aa69bcd49d40537609a1e2e46 (diff) | |
feat: add buffer list (#30)
NOTE: Buffer entry sometimes uses unstyled window, and I can't figure out why.
* feat: add buffers
* fixup
Diffstat (limited to 'lua/telescope/actions.lua')
| -rw-r--r-- | lua/telescope/actions.lua | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/lua/telescope/actions.lua b/lua/telescope/actions.lua index dc864d1..1f70a41 100644 --- a/lua/telescope/actions.lua +++ b/lua/telescope/actions.lua @@ -34,6 +34,7 @@ function actions.get_selected_entry(prompt_bufnr) return actions.get_current_picker(prompt_bufnr):get_selection() end +-- TODO: It seems sometimes we get bad styling. local function goto_file_selection(prompt_bufnr, command) local picker = actions.get_current_picker(prompt_bufnr) local entry = actions.get_selected_entry(prompt_bufnr) @@ -68,15 +69,28 @@ local function goto_file_selection(prompt_bufnr, command) col = tonumber(sections[3]) end - vim.cmd(string.format([[bwipeout! %s]], prompt_bufnr)) + local preview_win = state.get_status(prompt_bufnr).preview_win + if preview_win then + a.nvim_win_set_config(preview_win, {style = ''}) + end + + actions.close(prompt_bufnr) - a.nvim_set_current_win(picker.original_win_id or 0) - vim.cmd(string.format(":%s %s", command, filename)) + local original_win_id = picker.original_win_id or 0 + local entry_bufnr = entry.bufnr - local bufnr = vim.api.nvim_get_current_buf() - a.nvim_buf_set_option(bufnr, 'buflisted', true) - if row and col then - a.nvim_win_set_cursor(0, {row, col}) + -- TODO: Sometimes we open something with missing line numbers and stuff... + a.nvim_set_current_win(original_win_id) + if entry_bufnr then + a.nvim_win_set_buf(original_win_id, entry_bufnr) + else + vim.cmd(string.format(":%s %s", command, filename)) + + local bufnr = vim.api.nvim_get_current_buf() + a.nvim_buf_set_option(bufnr, 'buflisted', true) + if row and col then + a.nvim_win_set_cursor(0, {row, col}) + end end vim.cmd [[stopinsert]] |
