Merge pull request #1499 from pyrox0/init-ui2

ui/ui2: init
This commit is contained in:
raf 2026-04-06 00:24:02 +03:00 committed by GitHub
commit 2945a9cc5f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 105 additions and 0 deletions

View file

@ -207,6 +207,8 @@
- Lazy-load `nvim-autopairs` plugin when using - Lazy-load `nvim-autopairs` plugin when using
`vim.autopairs.nvim-autopairs.enable` `vim.autopairs.nvim-autopairs.enable`
- Added support for neovim 0.12's `ui2` feature via `vim.ui.ui2`
[Machshev](https://github.com/machshev): [Machshev](https://github.com/machshev):
- Added `ruff` and `ty` LSP support for Python under `programs.python`. - Added `ruff` and `ty` LSP support for Python under `programs.python`.

View file

@ -12,5 +12,6 @@
./notifications ./notifications
./nvim-ufo ./nvim-ufo
./smartcolumn ./smartcolumn
./ui2
]; ];
} }

View file

@ -0,0 +1,19 @@
{
config,
lib,
...
}: let
inherit (lib.modules) mkIf;
inherit (lib.nvim.dag) entryAnywhere;
inherit (lib.nvim.lua) toLuaObject;
cfg = config.vim.ui.ui2;
in {
config = mkIf cfg.enable {
vim = {
luaConfigRC.ui2 = entryAnywhere ''
require('vim._core.ui2').enable(${toLuaObject (cfg.setupOpts // {enable = lib.mkForce true;})})
'';
};
};
}

View file

@ -0,0 +1,6 @@
{
imports = [
./config.nix
./ui2.nix
];
}

View file

@ -0,0 +1,77 @@
{lib, ...}: let
inherit (lib.options) mkEnableOption mkOption;
inherit
(lib.types)
nullOr
oneOf
enum
attrsOf
number
int
;
inherit (lib.nvim.types) mkPluginSetupOption;
# Top-level targets only accepts `cmd` and `msg`, which is shorter, so we define that one
# inline below. This is the accepted targets for ui2 messages when defining it as a table
# or an attrset in Nix.
msgTargetEnum = enum [
"cmd"
"msg"
"pager"
];
heightOption = target: default:
mkOption {
description = "Maximum height for the ${target} window";
type = number;
inherit default;
};
in {
options.vim.ui.ui2 = {
enable = mkEnableOption "the Neovim 0.12+ experimental built-in UI overhaul";
setupOpts = mkPluginSetupOption "ui2" {
msg = {
targets = mkOption {
description = ''
Default message target, either commandline or a separate window.
Can alternatively specify different targets for different kinds of messages as an attrset.
See [`:h ui-messages`](https://neovim.io/doc/user/api-ui-events/#ui-messages)
for the different message types you can use in this configration.
Separating the message types also allows sending to a 'pager' output.
'';
type = nullOr (oneOf [
(enum [
"cmd"
"msg"
])
(attrsOf msgTargetEnum)
]);
default = "cmd";
example = {
bufwrite = "cmd";
quickfix = "msg";
};
};
cmd = {
height = heightOption "cmdline" 0.5;
};
dialog = {
height = heightOption "dialog" 0.5;
};
msg = {
height = heightOption "msg" 0.5;
timeout = mkOption {
description = "Time a message is visible in the message window";
type = int;
default = 4000;
example = 1500;
};
};
pager = {
height = heightOption "pager" 1;
};
};
};
};
}