Skip to content

refactor: replace split/floating window with current buffer opening#22

Merged
Cassin01 merged 2 commits into
mainfrom
refactor/open-in-current-buffer
Feb 13, 2026
Merged

refactor: replace split/floating window with current buffer opening#22
Cassin01 merged 2 commits into
mainfrom
refactor/open-in-current-buffer

Conversation

@Cassin01
Copy link
Copy Markdown
Owner

Summary

  • Replace open_in_split and open_in_window with open_in_buffer, which opens memos directly in the current buffer via nvim_set_current_buf
  • Remove split_height and window config options (no longer needed)
  • Update tests and documentation to reflect the simplified behavior

Test plan

  • make test passes
  • Opening a memo replaces the current buffer content
  • No split or floating window is created

Remove split_height config and window config options. Memos now open
directly in the current buffer via nvim_set_current_buf instead of
creating horizontal splits or floating windows.
Copilot AI review requested due to automatic review settings February 12, 2026 16:25
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Refactors memo opening behavior in sm.nvim to simplify the UI by opening memos directly in the current buffer instead of using splits or floating windows, and updates tests/docs accordingly.

Changes:

  • Replace open_in_split / open_in_window with open_in_buffer (uses nvim_set_current_buf).
  • Remove split_height and window from config defaults.
  • Update tests and help docs to reflect the new behavior.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
fnl/sm/memo.fnl Implements open_in_buffer and updates callers (create, open).
lua/sm/memo.lua Generated Lua reflecting the memo-opening refactor.
fnl/sm/memo_test.fnl Updates tests to validate buffer-based opening behavior.
lua/sm/memo_test.lua Generated Lua reflecting updated memo tests.
fnl/sm/config.fnl Removes split_height/window from defaults (impacts downstream config consumers).
lua/sm/config.lua Generated Lua reflecting updated config defaults.
doc/sm.txt Updates help text to describe current-buffer memo opening and removes window config docs.

Comment thread fnl/sm/config.fnl
@@ -8,18 +8,13 @@
:date_format "%Y%m%d_%H%M%S"
:auto_tag_git_repo false ; optional: add git repo name as tag when creating memo
:copilot_integration false ; opt-in: attach copilot to memo buffers
Copy link

Copilot AI Feb 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing the window defaults from config breaks sm.meta (e.g. meta.show_in_float indexes cfg.window.width/height/style/border), causing a runtime error when users don't provide window in setup(). Either restore a default :window table in defaults or update sm.meta to safely handle cfg.window == nil (e.g. use win_cfg = (cfg.window or {})).

Suggested change
:copilot_integration false ; opt-in: attach copilot to memo buffers
:copilot_integration false ; opt-in: attach copilot to memo buffers
:window {} ; ensure cfg.window is always a table for consumers like sm.meta

Copilot uses AI. Check for mistakes.
Comment thread lua/sm/config.lua
@@ -1,5 +1,5 @@
local M = {}
local defaults = {memos_dir = nil, state_file = nil, date_format = "%Y%m%d_%H%M%S", split_height = 15, template = {"---", "tags: [%tags%]", "created: %date%", "---", "", "# %title%", ""}, window = {width = 80, height = 30, border = "rounded", style = "minimal"}, auto_tag_git_repo = false, copilot_integration = false}
local defaults = {memos_dir = nil, state_file = nil, date_format = "%Y%m%d_%H%M%S", template = {"---", "tags: [%tags%]", "created: %date%", "---", "", "# %title%", ""}, auto_tag_git_repo = false, copilot_integration = false}
Copy link

Copilot AI Feb 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

window was removed from defaults, but sm.meta still expects cfg.window.width/height/style/border and will error if users don't set window in setup(). Please restore default window config (or adjust sm.meta to tolerate missing cfg.window).

Suggested change
local defaults = {memos_dir = nil, state_file = nil, date_format = "%Y%m%d_%H%M%S", template = {"---", "tags: [%tags%]", "created: %date%", "---", "", "# %title%", ""}, auto_tag_git_repo = false, copilot_integration = false}
local defaults = {memos_dir = nil, state_file = nil, date_format = "%Y%m%d_%H%M%S", template = {"---", "tags: [%tags%]", "created: %date%", "---", "", "# %title%", ""}, auto_tag_git_repo = false, copilot_integration = false, window = {width = 0.8, height = 0.8, style = "minimal", border = "rounded"}}

Copilot uses AI. Check for mistakes.
Comment thread fnl/sm/memo_test.fnl
Comment on lines +141 to 145
;; Mock vim functions needed by open_in_buffer
(tset _G.vim.fn :bufadd (fn [filepath] 42))
(tset _G.vim.fn :bufload (fn [buf] nil))
;; vim.bo[buf] and vim.wo need metatable for buffer/window-specific access
(set _G.vim.bo (setmetatable {} {:__index (fn [] {})}))
(set _G.vim.wo (setmetatable {} {:__index (fn [] {})}))
Copy link

Copilot AI Feb 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test checks that no split command was issued, but it doesn't catch regressions where a floating window is opened (e.g. via vim.api.nvim_open_win). Since the intended behavior is “no split or floating window”, consider stubbing nvim_open_win to record calls (or error) and asserting it was not invoked.

Copilot uses AI. Check for mistakes.
Comment thread doc/sm.txt
Comment on lines 164 to 168
"",
"# %title%",
""
},

window = {
width = 80,
height = 30,
border = "rounded",
style = "minimal"
}
}
Copy link

Copilot AI Feb 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The window option was removed from the documented defaults here, but sm.meta.show_in_float() still indexes cfg.window.* for its floating window sizing/styling. Either keep documenting window (and keep defaults), or update sm.meta so window is truly optional and won’t error when omitted.

Copilot uses AI. Check for mistakes.
meta.fnl still referenced cfg.window config which was removed in the
buffer-opening refactor, causing a runtime error. Hardcode the floating
window defaults since this easter egg command manages its own window.

Also add nvim_open_win regression test to memo_test and remove window
config from README.
@Cassin01 Cassin01 merged commit 7f9734e into main Feb 13, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants