1
0
Fork 0
mirror of https://github.com/NotAShelf/neovim-flake.git synced 2024-12-26 15:29:47 +01:00

feat: per-plugin border styles

defaults to the value of globalStyle, can be overriden
This commit is contained in:
NotAShelf 2023-07-26 10:27:57 +03:00
parent 0667f1f936
commit cc1f1b2ed8
No known key found for this signature in database
GPG key ID: 02D1DD3FA08B6B29
7 changed files with 59 additions and 11 deletions
modules
completion/nvim-cmp
lsp
lsp-signature
lspconfig
lspsaga
minimap/codewindow
ui/borders
utility/binds/which-key

View file

@ -194,6 +194,7 @@ in {
cmp.setup({ cmp.setup({
${optionalString (config.vim.ui.borders.enable) '' ${optionalString (config.vim.ui.borders.enable) ''
-- explicitly enabled by setting ui.borders.enable = true -- explicitly enabled by setting ui.borders.enable = true
-- TODO: try to get nvim-cmp to follow global border style
window = { window = {
completion = cmp.config.window.bordered(), completion = cmp.config.window.bordered(),
documentation = cmp.config.window.bordered(), documentation = cmp.config.window.bordered(),

View file

@ -14,7 +14,14 @@ in {
vim.luaConfigRC.lsp-signature = nvim.dag.entryAnywhere '' vim.luaConfigRC.lsp-signature = nvim.dag.entryAnywhere ''
-- Enable lsp signature viewer -- 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}"
}
''}
})
''; '';
}; };
} }

View file

@ -19,7 +19,9 @@ in {
${ ${
# TODO: make border style configurable # 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}'
''
} }
''; '';
} }

View file

@ -40,7 +40,9 @@ in {
-- Enable lspsaga -- Enable lspsaga
local saga = require 'lspsaga' local saga = require 'lspsaga'
saga.init_lsp_saga({ saga.init_lsp_saga({
border_style = 'single', ${optionalString (config.vim.ui.borders.plugins.lspsaga.enable) ''
border_style = '${config.vim.ui.borders.plugins.lspsaga.style}',
''}
}) })
''; '';
}; };

View file

@ -27,7 +27,7 @@ in {
vim.luaConfigRC.codewindow = nvim.dag.entryAnywhere '' vim.luaConfigRC.codewindow = nvim.dag.entryAnywhere ''
local codewindow = require('codewindow') local codewindow = require('codewindow')
codewindow.setup({ codewindow.setup({
exclude_filetypes = { 'NvimTree', 'orgagenda'}, exclude_filetypes = { 'NvimTree', 'orgagenda', 'Alpha'},
}) })
''; '';
}; };

View file

@ -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 { in {
options.vim.ui.borders = { options.vim.ui.borders = {
enable = mkOption { enable = mkEnableOption "visible borders for most windows";
type = types.bool;
default = true; globalStyle = mkOption {
description = "visible borders for most windows"; type = types.enum defaultStyles;
default = "rounded";
description = ''
global border style to use
'';
}; };
# TODO: make per-plugin borders configurable # 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";
};
}; };
} }

View file

@ -18,7 +18,13 @@ in {
["<leader>"] = "SPACE", ["<leader>"] = "SPACE",
["<cr>"] = "RETURN", ["<cr>"] = "RETURN",
["<tab>"] = "TAB", ["<tab>"] = "TAB",
} },
${lib.optionalString (config.vim.ui.borders.plugins.which-key.enable) ''
window = {
border = "${config.vim.ui.borders.plugins.which-key.style}",
},
''}
}) })
wk.register({ wk.register({