Skip to content

feat: split_height設定オプションを追加#21

Merged
Cassin01 merged 1 commit into
mainfrom
add-split-height-config
Jan 21, 2026
Merged

feat: split_height設定オプションを追加#21
Cassin01 merged 1 commit into
mainfrom
add-split-height-config

Conversation

@Cassin01
Copy link
Copy Markdown
Owner

Summary

  • メモを水平分割ウィンドウで開く際の高さをsplit_heightオプションで設定可能に
  • デフォルト値は15行
  • nilを設定した場合は高さ設定をスキップ(Neovimのデフォルト動作)

Usage

require("sm").setup({
  split_height = 10  -- カスタム高さ
})

Test plan

  • make test - 全テスト通過
  • Neovimで手動確認: メモ作成/開く時に指定した高さで分割されること

🤖 Generated with Claude Code

メモを水平分割ウィンドウで開く際の高さを設定可能に。
デフォルト値は15行。
Copilot AI review requested due to automatic review settings January 21, 2026 05:00
@Cassin01 Cassin01 merged commit 5cec628 into main Jan 21, 2026
5 checks passed
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

This PR adds a new split_height configuration option that allows users to control the height of the horizontal split window when opening memos. The default value is 15 lines, and setting it to nil will use Neovim's default split behavior.

Changes:

  • Added split_height configuration option with default value of 15
  • Modified open_in_split function to apply the configured height when opening memos
  • Added test coverage for the new configuration option

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
fnl/sm/config.fnl Added split_height default configuration value
fnl/sm/memo.fnl Implemented window height setting based on split_height config
fnl/sm/memo_test.fnl Added test to verify split_height functionality
lua/sm/config.lua Auto-generated Lua from Fennel source
lua/sm/memo.lua Auto-generated Lua from Fennel source
lua/sm/memo_test.lua Auto-generated Lua from Fennel source

Comment thread fnl/sm/memo_test.fnl
Comment on lines +113 to +158
;; Test split_height config sets window height
(do
;; Clear package.loaded for fresh mocks
(tset package.loaded :sm.config nil)
(tset package.loaded :sm.git nil)
(tset package.loaded :sm.memo nil)

;; Track nvim_win_set_height calls
(var set_height_calls [])
(when (not _G.vim.api)
(set _G.vim.api {}))
(tset _G.vim.api :nvim_win_set_height
(fn [win height]
(table.insert set_height_calls {:win win :height height})))

;; Mock config with split_height
(tset package.loaded :sm.config
{:get (fn []
{:split_height 15
:copilot_integration false
:date_format "%Y%m%d_%H%M%S"
:template ["---" "# %title%" ""]})
:get_memos_dir (fn [] "/tmp/test-memos")})

;; Mock other dependencies
(tset package.loaded :sm.git {:get_repo_tag (fn [] nil) :is_git_repo (fn [] false)})
(tset package.loaded :sm.state {:set_last_edited (fn []) :add_recent (fn []) :load (fn [] {})})

;; Mock vim functions needed by open_in_split
(tset _G.vim.fn :bufadd (fn [filepath] 1))
(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 [] {})}))
(tset _G.vim :cmd (fn [cmd] nil))
(tset _G.vim.api :nvim_win_set_buf (fn [win buf] nil))

;; Re-require memo with mocks
(local M3 (require :sm.memo))

;; Call open_in_split
(M3.open_in_split "/tmp/test-memos/test.md")

;; Verify nvim_win_set_height was called with correct value
(assert (= (length set_height_calls) 1) "split_height: nvim_win_set_height called once")
(assert (= (. set_height_calls 1 :height) 15) "split_height: height set to config value"))
Copy link

Copilot AI Jan 21, 2026

Choose a reason for hiding this comment

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

The test only covers the case where split_height is set to 15. According to the PR description, setting split_height to nil should skip the height setting and use Neovim's default behavior. A test case should be added to verify that nvim_win_set_height is NOT called when split_height is nil.

Copilot uses AI. Check for mistakes.
Comment thread fnl/sm/config.fnl
: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
:split_height 15 ; height for horizontal split window
Copy link

Copilot AI Jan 21, 2026

Choose a reason for hiding this comment

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

The new split_height configuration option is not documented in README.md. The configuration table in the Options section (around line 119-127) should include an entry for split_height explaining its purpose, default value (15), and that it can be set to nil to use Neovim's default behavior.

Suggested change
:split_height 15 ; height for horizontal split window
:split_height 15 ; height for horizontal split window (set to nil to use Neovim's default behavior)

Copilot uses AI. Check for mistakes.
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