merge main into breadcrumbs

This commit is contained in:
raf 2023-07-28 16:00:40 +03:00
commit d96d885fdd
No known key found for this signature in database
GPG key ID: 02D1DD3FA08B6B29
20 changed files with 205 additions and 63 deletions

View file

@ -193,12 +193,14 @@ in {
local cmp = require'cmp'
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 = {
-- 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)

View file

@ -158,6 +158,27 @@ in {
description = "List of plugins to optionally load";
};
extraPlugins = mkOption {
type = types.attrsOf nvim.types.extraPluginType;
default = {};
description = ''
List of plugins and related config.
Note that these are setup after builtin plugins.
'';
example = literalExpression ''
with pkgs.vimPlugins; {
aerial = {
package = aerial-nvim;
setup = "require('aerial').setup {}";
};
harpoon = {
package = harpoon;
setup = "require('harpoon').setup {}";
after = ["aerial"];
};
}'';
};
globals = mkOption {
default = {};
description = "Set containing global variable values";
@ -297,6 +318,7 @@ in {
result;
in {
vim = {
startPlugins = map (x: x.package) (attrValues cfg.extraPlugins);
configRC = {
globalsScript = nvim.dag.entryAnywhere (concatStringsSep "\n" globalsScript);
@ -314,6 +336,27 @@ in {
in
nvim.dag.entryAfter ["globalsScript"] luaConfig;
extraPluginConfigs = let
mkSection = r: ''
-- SECTION: ${r.name}
${r.data}
'';
mapResult = r: (wrapLuaConfig (concatStringsSep "\n" (map mkSection r)));
extraPluginsDag = mapAttrs (_: {
after,
setup,
...
}:
nvim.dag.entryAfter after setup)
cfg.extraPlugins;
pluginConfig = resolveDag {
name = "extra plugins config";
dag = extraPluginsDag;
inherit mapResult;
};
in
nvim.dag.entryAfter ["luaScript"] pluginConfig;
# This is probably not the right way to set the config. I'm not sure how it should look like.
mappings = let
maps = [

View file

@ -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}"
}
''}
})
'';
};
}

View file

@ -16,6 +16,13 @@ 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 = '${config.vim.ui.borders.globalStyle}'
''
}
'';
}
{

View file

@ -39,7 +39,11 @@ in {
vim.luaConfigRC.lspsage = nvim.dag.entryAnywhere ''
-- Enable lspsaga
local saga = require 'lspsaga'
saga.init_lsp_saga()
saga.init_lsp_saga({
${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 ''
local codewindow = require('codewindow')
codewindow.setup({
exclude_filetypes = { 'NvimTree', 'orgagenda'},
exclude_filetypes = { 'NvimTree', 'orgagenda', 'Alpha'},
})
'';
};

View file

@ -0,0 +1,43 @@
{
config,
lib,
...
}: let
inherit (lib) mkOption mkEnableOption types;
cfg = config.vim.ui.borders;
defaultStyles = ["none" "single" "double" "rounded"];
in {
options.vim.ui.borders = {
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";
};
};
}

View file

@ -0,0 +1,5 @@
_: {
imports = [
./borders.nix
];
}

View file

@ -66,7 +66,7 @@ in {
lsp = {
auto_attach = ${boolToString nb.lsp.autoAttach},
preference = nil, -- TODO: convert list to lua table if not null
-- preference = nil, -- TODO: convert list to lua table if not null
},
source_buffer = {

View file

@ -7,5 +7,6 @@ _: {
./colorizer
./illuminate
./breadcrumbs
./borders
];
}

View file

@ -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 = ${boolToString (config.vim.ui.borders.enable)}, -- add a border to hover docs and signature help
},
format = {

View file

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