From cc1f1b2ed87f2c85155b3a33c3efff567ef04c31 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Wed, 26 Jul 2023 10:27:57 +0300 Subject: [PATCH] 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 0d6bd2ca..afbf39e7 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 738dcb5e..1e734761 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 cdcadc84..e9d7b3c9 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 8f84f1dc..74b91fcb 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 1025e632..ac828293 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 f1fbd3cd..179de440 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 a5c15694..8b0fa6c6 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({