mirror of
https://github.com/NotAShelf/neovim-flake.git
synced 2024-11-09 14:45:58 +01:00
merge main into breadcrumbs
This commit is contained in:
commit
d96d885fdd
20 changed files with 205 additions and 63 deletions
|
@ -188,6 +188,7 @@ inputs: let
|
|||
};
|
||||
|
||||
vim.ui = {
|
||||
borders.enable = true;
|
||||
noice.enable = true;
|
||||
colorizer.enable = true;
|
||||
modes-nvim.enable = false; # the theme looks terrible with catppuccin
|
||||
|
|
|
@ -3,11 +3,42 @@
|
|||
|
||||
You can use custom plugins, before they are implemented in the flake.
|
||||
To add a plugin, you need to add it to your config's `config.vim.startPlugins` array.
|
||||
This is an example of adding the FrenzyExists/aquarium-vim plugin:
|
||||
|
||||
|
||||
=== New Method
|
||||
As of version 0.5, we have a more extensive API for configuring plugins, under `vim.extraPlugins`.
|
||||
|
||||
Instead of using DAGs exposed by the library, you may use the extra plugin module as follows:
|
||||
|
||||
[source,nix]
|
||||
----
|
||||
{
|
||||
config.vim.extraPlugins = with pkgs.vimPlugins; {
|
||||
aerial = {
|
||||
package = aerial-nvim;
|
||||
setup = ''
|
||||
require('aerial').setup {
|
||||
-- some lua configuration here
|
||||
}
|
||||
'';
|
||||
};
|
||||
|
||||
harpoon = {
|
||||
package = harpoon;
|
||||
setup = "require('harpoon').setup {}";
|
||||
after = ["aerial"];
|
||||
};
|
||||
};
|
||||
}
|
||||
----
|
||||
|
||||
=== Old Method
|
||||
Users who have not yet updated to 0.5, or prefer a more hands-on approach may use the old method where the load orderof the plugins is determined by DAGs.
|
||||
|
||||
[source,nix]
|
||||
----
|
||||
{
|
||||
# fetch plugin source from GitHub and add it to startPlugins
|
||||
config.vim.startPlugins = [
|
||||
(pkgs.fetchFromGitHub {
|
||||
owner = "FrenzyExists";
|
||||
|
|
|
@ -43,38 +43,4 @@ Then we should be able to use the given module. E.g.
|
|||
}
|
||||
----
|
||||
|
||||
=== Custom vim/neovim plugins
|
||||
|
||||
It is possible to add custom plugins to your configuration by using the `vim.startPlugins` option and the this flake's lua DAG library.
|
||||
|
||||
Start by adding it to startPlugins. This example uses nvim-surround, but the process will be similar for other plugins as well.
|
||||
|
||||
[source,nix]
|
||||
----
|
||||
{
|
||||
programs.neovim-flake = {
|
||||
enable = true;
|
||||
settings = {
|
||||
vim.startPlugins = [ pkgs.vimPlugins.nvim-surround ];
|
||||
};
|
||||
};
|
||||
}
|
||||
----
|
||||
|
||||
Followed by requiring the plugin, should it need one, in the lua DAG. Please note that you're able to name the DAG to however you want, the name will add a `--SECTION <name>` in the init.vim, under which it will be initialized. `lib.nvim.dag.entryAfter ["name"]` could also be used to initialize a plugin only after a previous plugin has beeni initialize
|
||||
Your final setup will likely look like this, where nvim-flake refers to your flake input or fetch.
|
||||
|
||||
[source,nix]
|
||||
----
|
||||
{
|
||||
programs.neovim-flake = {
|
||||
enable = true;
|
||||
settings = {
|
||||
vim.startPlugins = [ pkgs.vimPlugins.nvim-surround ];
|
||||
luaConfigRC.nvim-surround = nvim-flake.lib.nvim.dag.entryAnywhere '' # nvim-flake is a reference to the flake. Please change this accordingly to your config.
|
||||
require("nvim-surround").setup()
|
||||
'';
|
||||
};
|
||||
};
|
||||
}
|
||||
----
|
||||
|
|
|
@ -8,14 +8,18 @@
|
|||
|
||||
https://github.com/horriblename[horriblename]:
|
||||
|
||||
* Add transparency support for tokyonight theme.
|
||||
* Added transparency support for tokyonight theme.
|
||||
|
||||
* Fix bug where cmp's close and scrollDocs mappings wasn't working.
|
||||
* Fixed a bug where cmp's close and scrollDocs mappings wasn't working.
|
||||
|
||||
* Streamlined and simplified extra plugin API with the addition of <<opt-vim.extraPlugins>>.
|
||||
|
||||
https://github.com/amanse[amanse]:
|
||||
|
||||
* Add daily notes options for obsidian plugin
|
||||
* Added daily notes options for obsidian plugin.
|
||||
|
||||
https://github.com/notashelf[notashelf]:
|
||||
|
||||
* Add GitHub Copilot to completion sources
|
||||
* Added GitHub Copilot to completion sources.
|
||||
|
||||
* Added <<opt-vim.ui.borders>> for global and individual plugin border configuration.
|
||||
|
|
14
flake.lock
14
flake.lock
|
@ -855,17 +855,17 @@
|
|||
"nmd": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1680213367,
|
||||
"narHash": "sha256-NbSXxpFAK5IMcsQTK0vSGy099HExx3SEagqW4Lpc+X8=",
|
||||
"owner": "rycee",
|
||||
"lastModified": 1687627428,
|
||||
"narHash": "sha256-7zGfXuNS5RHqhpEdz2fwrtqvF86JRo5U1hrxZSYgcm8=",
|
||||
"owner": "~rycee",
|
||||
"repo": "nmd",
|
||||
"rev": "abb15317ebd17e5a0a7dd105e2ce52f2700185a8",
|
||||
"type": "gitlab"
|
||||
"rev": "824a380546b5d0d0eb701ff8cd5dbafb360750ff",
|
||||
"type": "sourcehut"
|
||||
},
|
||||
"original": {
|
||||
"owner": "rycee",
|
||||
"owner": "~rycee",
|
||||
"repo": "nmd",
|
||||
"type": "gitlab"
|
||||
"type": "sourcehut"
|
||||
}
|
||||
},
|
||||
"noice-nvim": {
|
||||
|
|
|
@ -58,7 +58,7 @@
|
|||
|
||||
# For generating documentation website
|
||||
nmd = {
|
||||
url = "gitlab:rycee/nmd";
|
||||
url = "sourcehut:~rycee/nmd";
|
||||
flake = false;
|
||||
};
|
||||
|
||||
|
|
|
@ -4,6 +4,6 @@
|
|||
typesLanguage = import ./languages.nix {inherit lib;};
|
||||
in {
|
||||
inherit (typesDag) dagOf;
|
||||
inherit (typesPlugin) pluginsOpt;
|
||||
inherit (typesPlugin) pluginsOpt extraPluginType;
|
||||
inherit (typesLanguage) diagnostics mkGrammarOption;
|
||||
}
|
||||
|
|
|
@ -92,15 +92,37 @@ with lib; let
|
|||
"copilot-cmp"
|
||||
];
|
||||
# You can either use the name of the plugin or a package.
|
||||
pluginsType = with types;
|
||||
listOf (
|
||||
pluginType = with types;
|
||||
nullOr (
|
||||
either
|
||||
(enum availablePlugins)
|
||||
package
|
||||
)
|
||||
(enum availablePlugins)
|
||||
);
|
||||
|
||||
pluginsType = types.listOf pluginType;
|
||||
|
||||
extraPluginType = with types;
|
||||
submodule {
|
||||
options = {
|
||||
package = mkOption {
|
||||
type = pluginType;
|
||||
};
|
||||
after = mkOption {
|
||||
type = listOf str;
|
||||
default = [];
|
||||
description = "Setup this plugin after the following ones.";
|
||||
};
|
||||
setup = mkOption {
|
||||
type = lines;
|
||||
default = "";
|
||||
description = "Lua code to run during setup.";
|
||||
example = "require('aerial').setup {}";
|
||||
};
|
||||
};
|
||||
};
|
||||
in {
|
||||
inherit extraPluginType;
|
||||
|
||||
pluginsOpt = {
|
||||
description,
|
||||
default ? [],
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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 = [
|
||||
|
|
|
@ -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}"
|
||||
}
|
||||
''}
|
||||
})
|
||||
'';
|
||||
};
|
||||
}
|
||||
|
|
|
@ -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}'
|
||||
''
|
||||
}
|
||||
'';
|
||||
}
|
||||
{
|
||||
|
|
|
@ -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}',
|
||||
''}
|
||||
})
|
||||
'';
|
||||
};
|
||||
}
|
||||
|
|
|
@ -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'},
|
||||
})
|
||||
'';
|
||||
};
|
||||
|
|
43
modules/ui/borders/borders.nix
Normal file
43
modules/ui/borders/borders.nix
Normal 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";
|
||||
};
|
||||
};
|
||||
}
|
5
modules/ui/borders/default.nix
Normal file
5
modules/ui/borders/default.nix
Normal file
|
@ -0,0 +1,5 @@
|
|||
_: {
|
||||
imports = [
|
||||
./borders.nix
|
||||
];
|
||||
}
|
|
@ -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 = {
|
||||
|
|
|
@ -7,5 +7,6 @@ _: {
|
|||
./colorizer
|
||||
./illuminate
|
||||
./breadcrumbs
|
||||
./borders
|
||||
];
|
||||
}
|
||||
|
|
|
@ -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 = {
|
||||
|
|
|
@ -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({
|
||||
|
|
Loading…
Reference in a new issue