-
-
Notifications
You must be signed in to change notification settings - Fork 46
StackView: Allow scaling of StackView window #91
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,11 +1,22 @@ | ||
| local cs = require("cscope") | ||
| local tree = require("cscope.stack_view.tree") | ||
| local hl = require("cscope.stack_view.hl") | ||
| local log = require("cscope_maps.utils.log") | ||
| local utils = require("cscope_maps.utils") | ||
| local M = {} | ||
|
|
||
| -- Size presets for stack view window | ||
| -- width: fraction of screen width (0.85 = 85% of screen width) | ||
| -- height: fraction of screen height (0.8 = 80% of screen height) | ||
| -- Add more presets here as needed (e.g., "small", "medium") | ||
| local size_presets = { | ||
| default = { width = 0.85, height = 0.8 }, | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. make height=0.7 to match prev config
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should we rename default to medium? we can keep "medium" in default opts |
||
| large = { width = 0.95, height = 0.95 }, | ||
| } | ||
|
|
||
| M.opts = { | ||
| tree_hl = true, -- toggle tree highlighting | ||
| size = "default", -- "default" or "large" | ||
| } | ||
|
|
||
| -- m() | ||
|
|
@@ -144,14 +155,16 @@ M.set_autocmds = function() | |
| }) | ||
| end | ||
|
|
||
| M.buf_open = function() | ||
| M.buf_open = function(width_scale, height_scale) | ||
| local vim_height = vim.o.lines | ||
| local vim_width = vim.o.columns | ||
|
|
||
| local width = math.floor(vim_width * 0.8 / 2 + 3 / 2) | ||
| local height = math.floor(vim_height * 0.7) | ||
| local col = vim_width * 0.1 - 1 | ||
| local row = vim_height * 0.15 | ||
| local w_scale = width_scale | ||
| local h_scale = height_scale | ||
| local width = math.floor(vim_width * w_scale * 0.5) | ||
| local height = math.floor(vim_height * h_scale) | ||
| local col = vim_width * (1 - w_scale) * 0.5 | ||
| local row = vim_height * (1 - h_scale) * 0.5 | ||
|
|
||
| M.save_last_window() | ||
|
|
||
|
|
@@ -163,7 +176,7 @@ M.buf_open = function() | |
| title_pos = "center", | ||
| width = width, | ||
| height = height, | ||
| col = col + 1 + width, | ||
| col = col + width + 1, | ||
| row = row, | ||
| style = "minimal", | ||
| focusable = false, | ||
|
|
@@ -180,7 +193,7 @@ M.buf_open = function() | |
| title_pos = "center", | ||
| width = width, | ||
| height = height, | ||
| col = col - 1, | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. don't remove this. i like the gap :) |
||
| col = col, | ||
| row = row, | ||
| style = "minimal", | ||
| focusable = false, | ||
|
|
@@ -236,7 +249,8 @@ M.buf_open_and_update = function() | |
| end | ||
|
|
||
| if not M.cache.win_opened then | ||
| M.buf_open() | ||
| local preset = size_presets[M.opts.size] | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. access this inside buf_open instead of passing as argument |
||
| M.buf_open(preset.width, preset.height) | ||
| end | ||
|
|
||
| -- print(vim.inspect(root)) | ||
|
|
@@ -470,6 +484,11 @@ end | |
|
|
||
| M.setup = function(opts) | ||
| M.opts = vim.tbl_deep_extend("force", M.opts, opts) | ||
| -- Validate size preset (fall back to "default" if invalid) | ||
| if not size_presets[M.opts.size] then | ||
| log.warn(string.format('Invalid stack_view size "%s", using "default"', M.opts.size)) | ||
| M.opts.size = "default" | ||
| end | ||
| M.set_user_cmd() | ||
| end | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
move it below opts