From 637a6ee11d8af7abf8feac688c9a0bde46e36473 Mon Sep 17 00:00:00 2001 From: alemi Date: Sun, 15 Sep 2024 12:39:50 +0200 Subject: [PATCH] fix: if not given, default to current buffer --- lua/codemp/buffers.lua | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lua/codemp/buffers.lua b/lua/codemp/buffers.lua index 5be3de7..440452f 100644 --- a/lua/codemp/buffers.lua +++ b/lua/codemp/buffers.lua @@ -10,7 +10,7 @@ local user_buffer_name = {} local ticks = {} ---@param name string name of buffer to attach to ----@param buffer integer buffer to use for attaching (will clear content) +---@param buffer? integer buffer to use for attaching (will clear content) ---@param content? string if provided, set this content after attaching ---@param nowait? boolean skip waiting for initial content sync ---@return BufferController @@ -18,6 +18,11 @@ local function attach(name, buffer, content, nowait) if buffer_id_map[name] ~= nil then error("already attached to buffer " .. name) end + + if buffer == nil then + buffer = vim.api.nvim_get_current_buf() + end + vim.api.nvim_set_option_value('fileformat', 'unix', { buf = buffer }) vim.api.nvim_buf_set_name(buffer, name) local controller = session.workspace:attach_buffer(name):await()