Revert "NvChad Updater | Chadrc Fixes | Cleanup and Formatting | Misc (#288)"
This reverts commit 36cb57ecce
.
This commit is contained in:
parent
36cb57ecce
commit
aa8df57cae
12 changed files with 197 additions and 389 deletions
|
@ -10,7 +10,7 @@ M.term_picker = function(opts)
|
|||
pickers = require "telescope.pickers"
|
||||
finders = require "telescope.finders"
|
||||
previewers = require "telescope.previewers"
|
||||
|
||||
|
||||
make_entry = require "telescope.make_entry"
|
||||
actions = require "telescope.actions"
|
||||
action_state = require "telescope.actions.state"
|
||||
|
@ -19,25 +19,26 @@ M.term_picker = function(opts)
|
|||
else
|
||||
error "Cannot find telescope!"
|
||||
end
|
||||
|
||||
|
||||
local filter = vim.tbl_filter
|
||||
|
||||
|
||||
local local_utils = require "utils"
|
||||
|
||||
-- buffer number and name
|
||||
local bufnr = vim.api.nvim_get_current_buf()
|
||||
local bufname = vim.api.nvim_buf_get_name(bufnr)
|
||||
|
||||
|
||||
local bufnrs = filter(function(b)
|
||||
local present_type, type = pcall(function()
|
||||
return vim.api.nvim_buf_get_var(b, "term_type")
|
||||
end)
|
||||
|
||||
|
||||
if not present_type then
|
||||
-- let's only terms that we created
|
||||
return false
|
||||
end
|
||||
|
||||
|
||||
|
||||
-- if 1 ~= vim.fn.buflisted(b) then
|
||||
-- return false
|
||||
-- end
|
||||
|
@ -58,22 +59,22 @@ M.term_picker = function(opts)
|
|||
return vim.fn.getbufinfo(a)[1].lastused > vim.fn.getbufinfo(b)[1].lastused
|
||||
end)
|
||||
end
|
||||
|
||||
|
||||
local buffers = {}
|
||||
local default_selection_idx = 1
|
||||
for _, bufnr in ipairs(bufnrs) do
|
||||
local flag = bufnr == vim.fn.bufnr "" and "%" or (bufnr == vim.fn.bufnr "#" and "#" or " ")
|
||||
|
||||
|
||||
if opts.sort_lastused and not opts.ignore_current_buffer and flag == "#" then
|
||||
default_selection_idx = 2
|
||||
end
|
||||
|
||||
|
||||
local element = {
|
||||
bufnr = bufnr,
|
||||
flag = flag,
|
||||
info = vim.fn.getbufinfo(bufnr)[1],
|
||||
}
|
||||
|
||||
|
||||
if opts.sort_lastused and (flag == "#" or flag == "%") then
|
||||
local idx = ((buffers[1] ~= nil and buffers[1].flag == "%") and 2 or 1)
|
||||
table.insert(buffers, idx, element)
|
||||
|
@ -81,12 +82,12 @@ M.term_picker = function(opts)
|
|||
table.insert(buffers, element)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
if not opts.bufnr_width then
|
||||
local max_bufnr = math.max(unpack(bufnrs))
|
||||
opts.bufnr_width = #tostring(max_bufnr)
|
||||
end
|
||||
|
||||
|
||||
pickers.new(opts, {
|
||||
prompt_title = "Terminal buffers",
|
||||
finder = finders.new_table {
|
||||
|
@ -102,24 +103,24 @@ M.term_picker = function(opts)
|
|||
actions.close(prompt_bufnr)
|
||||
|
||||
local buf = entry.bufnr
|
||||
|
||||
|
||||
local chad_term, type = pcall(function()
|
||||
return vim.api.nvim_buf_get_var(buf, "term_type")
|
||||
end)
|
||||
|
||||
return vim.api.nvim_buf_get_var(buf, "term_type")
|
||||
end)
|
||||
|
||||
-- TODO buffer checks/error detection (make sure we do get a buf)
|
||||
|
||||
if chad_term then
|
||||
if type == "wind" then
|
||||
-- swtich to term buff & show in bufferline
|
||||
vim.cmd(string.format("b %d | setlocal bl", buf))
|
||||
vim.cmd(string.format('b %d | setlocal bl', buf))
|
||||
-- vim.cmd('startinsert') TODO fix this
|
||||
elseif type == "vert" then
|
||||
vim.cmd(string.format("vsp #%d", buf))
|
||||
vim.cmd(string.format('vsp #%d', buf))
|
||||
-- vim.cmd('startinsert') TODO fix this
|
||||
elseif type == "hori" then
|
||||
-- TODO change 15 to a chad config var number
|
||||
vim.cmd(string.format("15 sp #%d ", buf))
|
||||
vim.cmd(string.format('15 sp #%d ', buf))
|
||||
-- vim.cmd('startinsert') TODO fix this
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue