|
@@ -6,22 +6,34 @@
|
|
|
-- end
|
|
-- end
|
|
|
-- end,
|
|
-- end,
|
|
|
-- })
|
|
-- })
|
|
|
|
|
+local function close_all_buffers_but_current()
|
|
|
|
|
+ local current_buf = vim.api.nvim_get_current_buf()
|
|
|
|
|
+ local all_bufs = vim.api.nvim_list_bufs()
|
|
|
|
|
+
|
|
|
|
|
+ for _, buf in ipairs(all_bufs) do
|
|
|
|
|
+ if buf ~= current_buf then
|
|
|
|
|
+ vim.api.nvim_buf_delete(buf, {})
|
|
|
|
|
+ end
|
|
|
|
|
+ end
|
|
|
|
|
+end
|
|
|
|
|
|
|
|
local is_git_dir = function()
|
|
local is_git_dir = function()
|
|
|
- return os.execute('git rev-parse --is-inside-work-tree >> /dev/null 2>&1')
|
|
|
|
|
|
|
+ return os.execute("git rev-parse --is-inside-work-tree >> /dev/null 2>&1")
|
|
|
end
|
|
end
|
|
|
-vim.api.nvim_create_autocmd('VimEnter', {
|
|
|
|
|
- callback = function()
|
|
|
|
|
- local bufferPath = vim.fn.expand('%:p')
|
|
|
|
|
- if vim.fn.isdirectory(bufferPath) ~= 0 then
|
|
|
|
|
- local ts_builtin = require('telescope.builtin')
|
|
|
|
|
- vim.api.nvim_buf_delete(0, { force = true })
|
|
|
|
|
- if is_git_dir() == 0 then
|
|
|
|
|
- ts_builtin.git_files({ show_untracked = true })
|
|
|
|
|
- else
|
|
|
|
|
- ts_builtin.find_files()
|
|
|
|
|
- end
|
|
|
|
|
- end
|
|
|
|
|
- end,
|
|
|
|
|
|
|
+vim.api.nvim_create_autocmd("VimEnter", {
|
|
|
|
|
+ callback = function()
|
|
|
|
|
+ local bufferPath = vim.fn.expand("%:p")
|
|
|
|
|
+ if vim.fn.isdirectory(bufferPath) ~= 0 then
|
|
|
|
|
+ local ts_builtin = require("telescope.builtin")
|
|
|
|
|
+ -- close_all_buffers_but_current()
|
|
|
|
|
+ -- vim.api.nvim_buf_delete(0, { force = true })
|
|
|
|
|
+ vim.defer_fn(function()
|
|
|
|
|
+ if is_git_dir() == 0 then
|
|
|
|
|
+ ts_builtin.git_files({ show_untracked = true })
|
|
|
|
|
+ else
|
|
|
|
|
+ ts_builtin.find_files()
|
|
|
|
|
+ end
|
|
|
|
|
+ end, 10) -- 10ms delay
|
|
|
|
|
+ end
|
|
|
|
|
+ end,
|
|
|
})
|
|
})
|
|
|
-
|
|
|