From cf48beb8e6ef51930c64fc1b9a0a9dbcfbe9d0fc Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Sun, 23 Jul 2023 18:26:38 +0300 Subject: [PATCH 1/7] feat: make visible borders optional --- modules/completion/nvim-cmp/config.nix | 5 +++-- modules/lsp/lspconfig/config.nix | 5 +++++ modules/ui/borders/borders.nix | 9 +++++++++ modules/ui/borders/default.nix | 5 +++++ modules/ui/default.nix | 1 + 5 files changed, 23 insertions(+), 2 deletions(-) create mode 100644 modules/ui/borders/borders.nix create mode 100644 modules/ui/borders/default.nix diff --git a/modules/completion/nvim-cmp/config.nix b/modules/completion/nvim-cmp/config.nix index 72c9a1a..8ad7336 100644 --- a/modules/completion/nvim-cmp/config.nix +++ b/modules/completion/nvim-cmp/config.nix @@ -200,12 +200,13 @@ in { local cmp = require'cmp' cmp.setup({ + ${optionalString (config.vim.ui.borders.enable) '' + -- explicitly enabled by setting ui.borders.enable = true window = { - -- TODO: at some point, those need to be optional - -- but first nvim cmp module needs to be detached from "cfg.autocomplete" completion = cmp.config.window.bordered(), documentation = cmp.config.window.bordered(), }, + ''} snippet = { expand = function(args) diff --git a/modules/lsp/lspconfig/config.nix b/modules/lsp/lspconfig/config.nix index 70485be..cdcadc8 100644 --- a/modules/lsp/lspconfig/config.nix +++ b/modules/lsp/lspconfig/config.nix @@ -16,6 +16,11 @@ in { vim.luaConfigRC.lspconfig = nvim.dag.entryAfter ["lsp-setup"] '' local lspconfig = require('lspconfig') + + ${ + # TODO: make border style configurable + optionalString (config.vim.ui.borders.enable) "require('lspconfig.ui.windows').default_options.border = 'single'" + } ''; } { diff --git a/modules/ui/borders/borders.nix b/modules/ui/borders/borders.nix new file mode 100644 index 0000000..b11d2cd --- /dev/null +++ b/modules/ui/borders/borders.nix @@ -0,0 +1,9 @@ +{lib, ...}: let + inherit (lib) mkEnableOption mkOption; +in { + options.vim.ui.borders = { + enable = mkEnableOption "visible borders for most windows"; + + # TODO: make per-plugin borders configurable + }; +} diff --git a/modules/ui/borders/default.nix b/modules/ui/borders/default.nix new file mode 100644 index 0000000..526ac4e --- /dev/null +++ b/modules/ui/borders/default.nix @@ -0,0 +1,5 @@ +_: { + imports = [ + ./borders.nix + ]; +} diff --git a/modules/ui/default.nix b/modules/ui/default.nix index 980a04a..757dd46 100644 --- a/modules/ui/default.nix +++ b/modules/ui/default.nix @@ -6,5 +6,6 @@ _: { ./smartcolumn ./colorizer ./illuminate + ./borders ]; } From d461cd903beaf5a571af21a7d0986eee7b09532e Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Sun, 23 Jul 2023 22:36:19 +0300 Subject: [PATCH 2/7] feat: add borders to lspsaga windows --- modules/lsp/lspsaga/config.nix | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/modules/lsp/lspsaga/config.nix b/modules/lsp/lspsaga/config.nix index 3b7ea26..8f84f1d 100644 --- a/modules/lsp/lspsaga/config.nix +++ b/modules/lsp/lspsaga/config.nix @@ -39,7 +39,9 @@ in { vim.luaConfigRC.lspsage = nvim.dag.entryAnywhere '' -- Enable lspsaga local saga = require 'lspsaga' - saga.init_lsp_saga() + saga.init_lsp_saga({ + border_style = 'single', + }) ''; }; } From 0951114a291aee9d42eb53d92cca95999d1fac11 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Sun, 23 Jul 2023 18:26:38 +0300 Subject: [PATCH 3/7] feat: make visible borders optional --- modules/completion/nvim-cmp/config.nix | 5 +++-- modules/lsp/lspconfig/config.nix | 5 +++++ modules/ui/borders/borders.nix | 9 +++++++++ modules/ui/borders/default.nix | 5 +++++ modules/ui/default.nix | 1 + 5 files changed, 23 insertions(+), 2 deletions(-) create mode 100644 modules/ui/borders/borders.nix create mode 100644 modules/ui/borders/default.nix diff --git a/modules/completion/nvim-cmp/config.nix b/modules/completion/nvim-cmp/config.nix index e49fdb9..0d6bd2c 100644 --- a/modules/completion/nvim-cmp/config.nix +++ b/modules/completion/nvim-cmp/config.nix @@ -192,12 +192,13 @@ in { local cmp = require'cmp' cmp.setup({ + ${optionalString (config.vim.ui.borders.enable) '' + -- explicitly enabled by setting ui.borders.enable = true window = { - -- TODO: at some point, those need to be optional - -- but first nvim cmp module needs to be detached from "cfg.autocomplete" completion = cmp.config.window.bordered(), documentation = cmp.config.window.bordered(), }, + ''} snippet = { expand = function(args) diff --git a/modules/lsp/lspconfig/config.nix b/modules/lsp/lspconfig/config.nix index 70485be..cdcadc8 100644 --- a/modules/lsp/lspconfig/config.nix +++ b/modules/lsp/lspconfig/config.nix @@ -16,6 +16,11 @@ in { vim.luaConfigRC.lspconfig = nvim.dag.entryAfter ["lsp-setup"] '' local lspconfig = require('lspconfig') + + ${ + # TODO: make border style configurable + optionalString (config.vim.ui.borders.enable) "require('lspconfig.ui.windows').default_options.border = 'single'" + } ''; } { diff --git a/modules/ui/borders/borders.nix b/modules/ui/borders/borders.nix new file mode 100644 index 0000000..b11d2cd --- /dev/null +++ b/modules/ui/borders/borders.nix @@ -0,0 +1,9 @@ +{lib, ...}: let + inherit (lib) mkEnableOption mkOption; +in { + options.vim.ui.borders = { + enable = mkEnableOption "visible borders for most windows"; + + # TODO: make per-plugin borders configurable + }; +} diff --git a/modules/ui/borders/default.nix b/modules/ui/borders/default.nix new file mode 100644 index 0000000..526ac4e --- /dev/null +++ b/modules/ui/borders/default.nix @@ -0,0 +1,5 @@ +_: { + imports = [ + ./borders.nix + ]; +} diff --git a/modules/ui/default.nix b/modules/ui/default.nix index 980a04a..757dd46 100644 --- a/modules/ui/default.nix +++ b/modules/ui/default.nix @@ -6,5 +6,6 @@ _: { ./smartcolumn ./colorizer ./illuminate + ./borders ]; } From b9e0f20e3963e094e346a3569337c6c26fe5f7bb Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Sun, 23 Jul 2023 22:36:19 +0300 Subject: [PATCH 4/7] feat: add borders to lspsaga windows --- modules/lsp/lspsaga/config.nix | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/modules/lsp/lspsaga/config.nix b/modules/lsp/lspsaga/config.nix index 3b7ea26..8f84f1d 100644 --- a/modules/lsp/lspsaga/config.nix +++ b/modules/lsp/lspsaga/config.nix @@ -39,7 +39,9 @@ in { vim.luaConfigRC.lspsage = nvim.dag.entryAnywhere '' -- Enable lspsaga local saga = require 'lspsaga' - saga.init_lsp_saga() + saga.init_lsp_saga({ + border_style = 'single', + }) ''; }; } From 0667f1f9361b75b4fc76136a94699ce39774468f Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Tue, 25 Jul 2023 22:16:20 +0300 Subject: [PATCH 5/7] dev: add missing hover window borders via noice.nvim --- configuration.nix | 1 + modules/ui/borders/borders.nix | 8 ++++++-- modules/ui/noice/config.nix | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/configuration.nix b/configuration.nix index a38a2da..ce9b442 100644 --- a/configuration.nix +++ b/configuration.nix @@ -185,6 +185,7 @@ inputs: let }; vim.ui = { + borders.enable = true; noice.enable = true; colorizer.enable = true; modes-nvim.enable = false; # the theme looks terrible with catppuccin diff --git a/modules/ui/borders/borders.nix b/modules/ui/borders/borders.nix index b11d2cd..f1fbd3c 100644 --- a/modules/ui/borders/borders.nix +++ b/modules/ui/borders/borders.nix @@ -1,8 +1,12 @@ {lib, ...}: let - inherit (lib) mkEnableOption mkOption; + inherit (lib) mkEnableOption mkOption types; in { options.vim.ui.borders = { - enable = mkEnableOption "visible borders for most windows"; + enable = mkOption { + type = types.bool; + default = true; + description = "visible borders for most windows"; + }; # TODO: make per-plugin borders configurable }; diff --git a/modules/ui/noice/config.nix b/modules/ui/noice/config.nix index 705256b..a2e3008 100644 --- a/modules/ui/noice/config.nix +++ b/modules/ui/noice/config.nix @@ -32,7 +32,7 @@ in { command_palette = true, -- position the cmdline and popupmenu together long_message_to_split = true, -- long messages will be sent to a split inc_rename = false, -- enables an input dialog for inc-rename.nvim - lsp_doc_border = false, -- add a border to hover docs and signature help + lsp_doc_border = ${builtins.toString (config.vim.ui.borders.enable)}, -- add a border to hover docs and signature help }, format = { From cc1f1b2ed87f2c85155b3a33c3efff567ef04c31 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Wed, 26 Jul 2023 10:27:57 +0300 Subject: [PATCH 6/7] feat: per-plugin border styles defaults to the value of globalStyle, can be overriden --- modules/completion/nvim-cmp/config.nix | 1 + modules/lsp/lsp-signature/config.nix | 9 ++++- modules/lsp/lspconfig/config.nix | 4 ++- modules/lsp/lspsaga/config.nix | 4 ++- modules/minimap/codewindow/config.nix | 2 +- modules/ui/borders/borders.nix | 42 ++++++++++++++++++---- modules/utility/binds/which-key/config.nix | 8 ++++- 7 files changed, 59 insertions(+), 11 deletions(-) diff --git a/modules/completion/nvim-cmp/config.nix b/modules/completion/nvim-cmp/config.nix index 0d6bd2c..afbf39e 100644 --- a/modules/completion/nvim-cmp/config.nix +++ b/modules/completion/nvim-cmp/config.nix @@ -194,6 +194,7 @@ in { cmp.setup({ ${optionalString (config.vim.ui.borders.enable) '' -- explicitly enabled by setting ui.borders.enable = true + -- TODO: try to get nvim-cmp to follow global border style window = { completion = cmp.config.window.bordered(), documentation = cmp.config.window.bordered(), diff --git a/modules/lsp/lsp-signature/config.nix b/modules/lsp/lsp-signature/config.nix index 738dcb5..1e73476 100644 --- a/modules/lsp/lsp-signature/config.nix +++ b/modules/lsp/lsp-signature/config.nix @@ -14,7 +14,14 @@ in { vim.luaConfigRC.lsp-signature = nvim.dag.entryAnywhere '' -- Enable lsp signature viewer - require("lsp_signature").setup() + require("lsp_signature").setup({ + ${optionalString (config.vim.ui.borders.plugins.lsp-signature.enable) '' + bind = true, -- This is mandatory, otherwise border config won't get registered. + handler_opts = { + border = "${config.vim.ui.borders.plugins.lsp-signature.style}" + } + ''} + }) ''; }; } diff --git a/modules/lsp/lspconfig/config.nix b/modules/lsp/lspconfig/config.nix index cdcadc8..e9d7b3c 100644 --- a/modules/lsp/lspconfig/config.nix +++ b/modules/lsp/lspconfig/config.nix @@ -19,7 +19,9 @@ in { ${ # TODO: make border style configurable - optionalString (config.vim.ui.borders.enable) "require('lspconfig.ui.windows').default_options.border = 'single'" + optionalString (config.vim.ui.borders.enable) '' + require('lspconfig.ui.windows').default_options.border = '${config.vim.ui.borders.globalStyle}' + '' } ''; } diff --git a/modules/lsp/lspsaga/config.nix b/modules/lsp/lspsaga/config.nix index 8f84f1d..74b91fc 100644 --- a/modules/lsp/lspsaga/config.nix +++ b/modules/lsp/lspsaga/config.nix @@ -40,7 +40,9 @@ in { -- Enable lspsaga local saga = require 'lspsaga' saga.init_lsp_saga({ - border_style = 'single', + ${optionalString (config.vim.ui.borders.plugins.lspsaga.enable) '' + border_style = '${config.vim.ui.borders.plugins.lspsaga.style}', + ''} }) ''; }; diff --git a/modules/minimap/codewindow/config.nix b/modules/minimap/codewindow/config.nix index 1025e63..ac82829 100644 --- a/modules/minimap/codewindow/config.nix +++ b/modules/minimap/codewindow/config.nix @@ -27,7 +27,7 @@ in { vim.luaConfigRC.codewindow = nvim.dag.entryAnywhere '' local codewindow = require('codewindow') codewindow.setup({ - exclude_filetypes = { 'NvimTree', 'orgagenda'}, + exclude_filetypes = { 'NvimTree', 'orgagenda', 'Alpha'}, }) ''; }; diff --git a/modules/ui/borders/borders.nix b/modules/ui/borders/borders.nix index f1fbd3c..179de44 100644 --- a/modules/ui/borders/borders.nix +++ b/modules/ui/borders/borders.nix @@ -1,13 +1,43 @@ -{lib, ...}: let - inherit (lib) mkEnableOption mkOption types; +{ + config, + lib, + ... +}: let + inherit (lib) mkOption mkEnableOption types; + + cfg = config.vim.ui.borders; + + defaultStyles = ["none" "single" "double" "rounded"]; in { options.vim.ui.borders = { - enable = mkOption { - type = types.bool; - default = true; - description = "visible borders for most windows"; + enable = mkEnableOption "visible borders for most windows"; + + globalStyle = mkOption { + type = types.enum defaultStyles; + default = "rounded"; + description = '' + global border style to use + ''; }; # TODO: make per-plugin borders configurable + plugins = let + mkPluginStyleOption = name: { + enable = mkEnableOption "whether to enable borders for the ${name} plugin" // {default = cfg.enable;}; + + style = mkOption { + type = types.enum (defaultStyles ++ lib.optionals (name != "which-key") ["shadow"]); + default = cfg.globalStyle; + description = "border style to use for the ${name} plugin"; + }; + }; + in { + # despite not having it listed in example configuration, which-key does support the rounded type + # additionall, it supports a "shadow" type that is similar to none but is of higher contrast + which-key = mkPluginStyleOption "which-key"; + lspsaga = mkPluginStyleOption "lspsaga"; + nvim-cmp = mkPluginStyleOption "nvim-cmp"; + lsp-signature = mkPluginStyleOption "lsp-signature"; + }; }; } diff --git a/modules/utility/binds/which-key/config.nix b/modules/utility/binds/which-key/config.nix index a5c1569..8b0fa6c 100644 --- a/modules/utility/binds/which-key/config.nix +++ b/modules/utility/binds/which-key/config.nix @@ -18,7 +18,13 @@ in { [""] = "SPACE", [""] = "RETURN", [""] = "TAB", - } + }, + + ${lib.optionalString (config.vim.ui.borders.plugins.which-key.enable) '' + window = { + border = "${config.vim.ui.borders.plugins.which-key.style}", + }, + ''} }) wk.register({ From 107cea4f20e69b4c3535d77d696d4e6476b32382 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Wed, 26 Jul 2023 15:12:32 +0300 Subject: [PATCH 7/7] fix: (toString false) producing an empty line --- modules/ui/noice/config.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/ui/noice/config.nix b/modules/ui/noice/config.nix index a2e3008..d12ebf0 100644 --- a/modules/ui/noice/config.nix +++ b/modules/ui/noice/config.nix @@ -32,7 +32,7 @@ in { command_palette = true, -- position the cmdline and popupmenu together long_message_to_split = true, -- long messages will be sent to a split inc_rename = false, -- enables an input dialog for inc-rename.nvim - lsp_doc_border = ${builtins.toString (config.vim.ui.borders.enable)}, -- add a border to hover docs and signature help + lsp_doc_border = ${boolToString (config.vim.ui.borders.enable)}, -- add a border to hover docs and signature help }, format = {