From 3c822ac7807f3c9753e5c46be3223da578bf33b8 Mon Sep 17 00:00:00 2001 From: Dan Tong Date: Sat, 11 May 2024 10:57:52 +1200 Subject: [PATCH] feat(ui): add `open_split_vertical` option for splits opened (#387) Co-authored-by: Marc Jakobi --- CHANGELOG.md | 8 ++++++++ lua/rustaceanvim/commands/diagnostic.lua | 3 ++- lua/rustaceanvim/config/check.lua | 1 + lua/rustaceanvim/config/internal.lua | 5 +++++ 4 files changed, 16 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index dcba7d80..d84957dc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,14 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [Unreleased] + +### Added + +- Config: Open vertical splits from floating windows with + `tools.float_win_config.open_split = 'vertical'`. + Thanks [@dwtong](https://github.com/dwtong)! + ## [4.22.10] - 2024-05-04 ### Fixed diff --git a/lua/rustaceanvim/commands/diagnostic.lua b/lua/rustaceanvim/commands/diagnostic.lua index 9409aa9c..d5b5a39e 100644 --- a/lua/rustaceanvim/commands/diagnostic.lua +++ b/lua/rustaceanvim/commands/diagnostic.lua @@ -27,7 +27,8 @@ local function set_open_split_keymap(bufnr, winnr, lines) _window_state.latest_scratch_buf_id = vim.api.nvim_create_buf(false, true) -- not listed and scratch -- split the window to create a new buffer and set it to our window - ui.split(false, _window_state.latest_scratch_buf_id) + local vsplit = config.tools.float_win_config.open_split == 'vertical' + ui.split(vsplit, _window_state.latest_scratch_buf_id) -- set filetype to rust for syntax highlighting vim.bo[_window_state.latest_scratch_buf_id].filetype = 'rust' diff --git a/lua/rustaceanvim/config/check.lua b/lua/rustaceanvim/config/check.lua index 6a6eef74..6ba776ed 100644 --- a/lua/rustaceanvim/config/check.lua +++ b/lua/rustaceanvim/config/check.lua @@ -61,6 +61,7 @@ function M.validate(cfg) max_height = { float_win_config.max_height, 'number', true }, max_width = { float_win_config.max_width, 'number', true }, auto_focus = { float_win_config.auto_focus, 'boolean' }, + open_split = { float_win_config.open_split, 'string' }, }) if not ok then return false, err diff --git a/lua/rustaceanvim/config/internal.lua b/lua/rustaceanvim/config/internal.lua index ae44397e..3e132590 100644 --- a/lua/rustaceanvim/config/internal.lua +++ b/lua/rustaceanvim/config/internal.lua @@ -168,6 +168,11 @@ local RustaceanDefaultConfig = { --- default: false ---@type boolean auto_focus = false, + + --- whether splits opened from floating preview are vertical + --- default: false + ---@type 'horizontal' | 'vertical' + open_split = 'horizontal', }, --- settings for showing the crate graph based on graphviz and the dot