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()