mirror of
https://github.com/NotAShelf/neovim-flake.git
synced 2024-11-09 14:45:58 +01:00
Merge e8035c42f4
into 4b868d0de6
This commit is contained in:
commit
e3cd5328ec
11 changed files with 305 additions and 148 deletions
60
flake.lock
60
flake.lock
|
@ -131,11 +131,11 @@
|
|||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1713714899,
|
||||
"narHash": "sha256-+z/XjO3QJs5rLE5UOf015gdVauVRQd2vZtsFkaXBq2Y=",
|
||||
"lastModified": 1713895582,
|
||||
"narHash": "sha256-cfh1hi+6muQMbi9acOlju3V1gl8BEaZBXBR9jQfQi4U=",
|
||||
"owner": "nixos",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "6143fc5eeb9c4f00163267708e26191d1e918932",
|
||||
"rev": "572af610f6151fd41c212f897c71f7056e3fb518",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
@ -502,11 +502,11 @@
|
|||
"plugin-crates-nvim": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1713017448,
|
||||
"narHash": "sha256-rRm7xXt5+u76ylWhLYXwjDqxWQL8epfjnTHLv7M+Lc8=",
|
||||
"lastModified": 1713995074,
|
||||
"narHash": "sha256-09+mBhh5hAXENPzrvwNNQEyM7ZtuPYAWrtAG/pzBOV8=",
|
||||
"owner": "Saecki",
|
||||
"repo": "crates.nvim",
|
||||
"rev": "786d12a70c9b91fa2d0d102bb07df02be0db31a1",
|
||||
"rev": "f00e11e8282b94f2a2e938d32712c99f0e0bdeb4",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
@ -566,11 +566,11 @@
|
|||
"plugin-dressing-nvim": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1710299803,
|
||||
"narHash": "sha256-9AwOFTRvhWFo7USgoFYfceiojZM62IXPpBs8CnSqc18=",
|
||||
"lastModified": 1713925216,
|
||||
"narHash": "sha256-46r7X8CNuMgSB9X1jFLTQAiiBVqszkBP6DPlo6nBAxI=",
|
||||
"owner": "stevearc",
|
||||
"repo": "dressing.nvim",
|
||||
"rev": "18e5beb3845f085b6a33c24112b37988f3f93c06",
|
||||
"rev": "5162edb1442a729a885c45455a07e9a89058be2f",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
@ -646,11 +646,11 @@
|
|||
"plugin-gesture-nvim": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1713827672,
|
||||
"narHash": "sha256-YsE4mqM5hBsv4uaCYEpqcA6ZhVKgWWQ4/oHVVdX+vnA=",
|
||||
"lastModified": 1713872849,
|
||||
"narHash": "sha256-npryXJ92l65gOGltTd3jE3fdhiEgqbxCdK5w/C/BQV0=",
|
||||
"owner": "notomo",
|
||||
"repo": "gesture.nvim",
|
||||
"rev": "547f9b50b87e2ec40e72465fc2f975bb6b6232ff",
|
||||
"rev": "47175ed2741ba46fe7f14d6ee37ebbc5b9614c5a",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
@ -758,11 +758,11 @@
|
|||
"plugin-image-nvim": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1713467683,
|
||||
"narHash": "sha256-qSGtiBl94RJMffoxXEV74fNcmrYcKtfPc3Aw65tzuDM=",
|
||||
"lastModified": 1713989303,
|
||||
"narHash": "sha256-UBrusfIYWURI1Auo3XayswA8NXgZhqwazg6wmmgWygA=",
|
||||
"owner": "3rd",
|
||||
"repo": "image.nvim",
|
||||
"rev": "301de7919b2c0378cb7a782663f67abbcb198b17",
|
||||
"rev": "2d4b479c59fd70cc26f63d48b5cd76a44dda8873",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
@ -934,11 +934,11 @@
|
|||
"plugin-neocord": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1713646638,
|
||||
"narHash": "sha256-lcARsc0JxnzYbucRP0pY/bRMsSfm4P4Cpc5A6EoY3Lc=",
|
||||
"lastModified": 1713923379,
|
||||
"narHash": "sha256-oVWdnQlgXIMzMiybMq7yR/WfEW+Fm5RmhWx0RWprlfQ=",
|
||||
"owner": "IogaMaster",
|
||||
"repo": "neocord",
|
||||
"rev": "014e78cff9f1fc7b3b46ec67fdca68a91a9b7c65",
|
||||
"rev": "aa7a58023166533da83ca7b11c0d2569e45d7381",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
@ -1175,11 +1175,11 @@
|
|||
"plugin-nvim-lspconfig": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1713863504,
|
||||
"narHash": "sha256-q82z4V3718/XvrCB9zRL5VwMFgkt3KS5olICSV0UUHo=",
|
||||
"lastModified": 1713908193,
|
||||
"narHash": "sha256-VdIoInJj2u49WHN4+WX0kNHdbXgh0AqIPU+OAiUaBck=",
|
||||
"owner": "neovim",
|
||||
"repo": "nvim-lspconfig",
|
||||
"rev": "ee3d635692451bc3ef0e5d4b30ea2fbfdeefc373",
|
||||
"rev": "cfa386fc4027e847156ee16141ea1f4c0bc2f0a4",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
@ -1303,11 +1303,11 @@
|
|||
"plugin-nvim-tree-lua": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1713668329,
|
||||
"narHash": "sha256-QEvHQcEAGkm5UKVLc1DYvEqs5/JFNrkEFKHFZpe5ZDE=",
|
||||
"lastModified": 1713946472,
|
||||
"narHash": "sha256-iD8c/dXt/UcTYDK8/zkTkFW/1Ial8ulCUWojjyXpG8k=",
|
||||
"owner": "nvim-tree",
|
||||
"repo": "nvim-tree.lua",
|
||||
"rev": "ae8e46e8fabb32fa3ae5319383ea2c8763f14caa",
|
||||
"rev": "62008e5cf2e8745c9d23bb599ef642963131057e",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
@ -1319,11 +1319,11 @@
|
|||
"plugin-nvim-treesitter-context": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1713520917,
|
||||
"narHash": "sha256-AT49dDlwPaV41O+rcUCzzdra8moIg4iDAIhZJb6j0zE=",
|
||||
"lastModified": 1713984790,
|
||||
"narHash": "sha256-QAudKglQGDRJKrsEcMSjbrxTgQRXO60ZcfOvEnPLUoE=",
|
||||
"owner": "nvim-treesitter",
|
||||
"repo": "nvim-treesitter-context",
|
||||
"rev": "ba4289ad345ececd335a9cdd7b9616fd0bb6be92",
|
||||
"rev": "4fe0a54e86859744968e1a5c7867b49c86855774",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
@ -2111,11 +2111,11 @@
|
|||
"nixpkgs": "nixpkgs_4"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1713745451,
|
||||
"narHash": "sha256-j5/bimg/wI14yTDUXZcSQRosV1LIOYuxYkZjvVJC/yg=",
|
||||
"lastModified": 1713960597,
|
||||
"narHash": "sha256-WAryNIrMfZ48iZSTh8hcHIX9vwh78LMFUtewgY7kp1Y=",
|
||||
"owner": "mitchellh",
|
||||
"repo": "zig-overlay",
|
||||
"rev": "2c86c36e7fe65faac08bdf85d041cf7b798f8ee8",
|
||||
"rev": "71894accd2dd096f5a84166a628b1f075311aafe",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
binds = import ./binds.nix {inherit lib;};
|
||||
dag = import ./dag.nix {inherit lib;};
|
||||
languages = import ./languages.nix {inherit lib;};
|
||||
lists = import ./lists.nix {inherit lib;};
|
||||
lua = import ./lua.nix {inherit lib;};
|
||||
vim = import ./vim.nix;
|
||||
}
|
||||
|
|
34
lib/lists.nix
Normal file
34
lib/lists.nix
Normal file
|
@ -0,0 +1,34 @@
|
|||
{lib}: let
|
||||
inherit (lib.lists) elem all;
|
||||
in {
|
||||
/*
|
||||
Checks if all values are present in the list.
|
||||
|
||||
Type:
|
||||
listContainsValues :: { list :: [a], values :: [a] } -> Bool
|
||||
|
||||
Arguments:
|
||||
list - A list of elements.
|
||||
values - A list of values to check for presence in the list.
|
||||
|
||||
Returns:
|
||||
True if all values are present in the list, otherwise False.
|
||||
|
||||
Example:
|
||||
```nix
|
||||
listContainsValues { list = [1 2 3]; values = [2 3]; }
|
||||
=> True
|
||||
|
||||
listContainsValues { list = [1 2 3]; values = [2 4]; }
|
||||
=> False
|
||||
```
|
||||
*/
|
||||
listContainsValues = {
|
||||
list,
|
||||
values,
|
||||
}: let
|
||||
# Check if all values are present in the list
|
||||
containsValue = value: elem value list;
|
||||
in
|
||||
all containsValue values;
|
||||
}
|
|
@ -58,6 +58,7 @@
|
|||
gitsigns = true,
|
||||
telescope = true,
|
||||
treesitter = true,
|
||||
treesitter_context = true,
|
||||
ts_rainbow = true,
|
||||
fidget = true,
|
||||
alpha = true,
|
||||
|
|
|
@ -1,17 +1,20 @@
|
|||
{
|
||||
config,
|
||||
pkgs,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (lib.modules) mkIf mkMerge;
|
||||
inherit (lib.lists) optional;
|
||||
inherit (lib.lists) optional optionals;
|
||||
inherit (lib.trivial) boolToString;
|
||||
inherit (lib.nvim.binds) mkSetBinding addDescriptionsToMappings;
|
||||
inherit (lib.nvim.dag) entryBefore entryAnywhere;
|
||||
inherit (lib.nvim.lua) toLuaObject;
|
||||
inherit (lib.nvim.dag) entryBefore entryAfter;
|
||||
|
||||
cfg = config.vim.treesitter;
|
||||
usingNvimCmp = config.vim.autocomplete.enable && config.vim.autocomplete.type == "nvim-cmp";
|
||||
|
||||
self = import ./treesitter.nix {inherit lib;};
|
||||
self = import ./treesitter.nix {inherit pkgs lib;};
|
||||
mappingDefinitions = self.options.vim.treesitter.mappings;
|
||||
mappings = addDescriptionsToMappings cfg.mappings mappingDefinitions;
|
||||
in {
|
||||
|
@ -20,6 +23,7 @@ in {
|
|||
startPlugins = ["nvim-treesitter"] ++ optional usingNvimCmp "cmp-treesitter";
|
||||
|
||||
autocomplete.sources = {"treesitter" = "[Treesitter]";};
|
||||
treesitter.grammars = optionals cfg.addDefaultGrammars cfg.defaultGrammars;
|
||||
|
||||
maps = {
|
||||
# HACK: Using mkSetLuaBinding and putting the lua code does not work for some reason: It just selects the whole file.
|
||||
|
@ -40,18 +44,32 @@ in {
|
|||
set nofoldenable
|
||||
'');
|
||||
|
||||
luaConfigRC.treesitter = entryAnywhere ''
|
||||
require'nvim-treesitter.configs'.setup {
|
||||
highlight = {
|
||||
luaConfigRC.treesitter = entryAfter ["basic"] ''
|
||||
require('nvim-treesitter.configs').setup {
|
||||
-- Disable imperative treesitter options that would attempt to fetch
|
||||
-- grammars into the read-only Nix store. To add additional grammars here
|
||||
-- you must use the `config.vim.treesitter.grammars` option.
|
||||
auto_install = false,
|
||||
sync_install = false,
|
||||
ensure_installed = {},
|
||||
|
||||
-- Indentation module for Treesitter
|
||||
indent = {
|
||||
enable = true,
|
||||
disable = {},
|
||||
},
|
||||
|
||||
auto_install = false,
|
||||
ensure_installed = {},
|
||||
-- Highlight module for Treesitter
|
||||
highlight = {
|
||||
enable = ${boolToString cfg.highlight.enable},
|
||||
disable = ${toLuaObject cfg.highlight.disable},
|
||||
additional_vim_regex_highlighting = false,
|
||||
},
|
||||
|
||||
-- Indentation module for Treesitter
|
||||
incremental_selection = {
|
||||
enable = true,
|
||||
disable = {},
|
||||
keymaps = {
|
||||
init_selection = false,
|
||||
node_incremental = false,
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
{
|
||||
imports = [
|
||||
# treesitter extras
|
||||
./ts-context
|
||||
|
||||
./treesitter.nix
|
||||
./context.nix
|
||||
./config.nix
|
||||
];
|
||||
}
|
||||
|
|
|
@ -1,20 +1,15 @@
|
|||
{lib, ...}: let
|
||||
inherit (lib.options) mkOption mkEnableOption;
|
||||
{
|
||||
pkgs,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (lib.options) mkOption mkEnableOption literalMD;
|
||||
inherit (lib.types) listOf package str either bool;
|
||||
inherit (lib.nvim.binds) mkMappingOption;
|
||||
inherit (lib.types) listOf package;
|
||||
inherit (lib.nvim.types) luaInline mkGrammarOption;
|
||||
in {
|
||||
options.vim.treesitter = {
|
||||
enable = mkEnableOption "treesitter, also enabled automatically through language options";
|
||||
fold = mkEnableOption "fold with treesitter";
|
||||
autotagHtml = mkEnableOption "autoclose and rename html tag";
|
||||
grammars = mkOption {
|
||||
type = listOf package;
|
||||
default = [];
|
||||
description = ''
|
||||
List of treesitter grammars to install. For supported languages
|
||||
use the `vim.language.<lang>.treesitter` option
|
||||
'';
|
||||
};
|
||||
|
||||
mappings.incrementalSelection = {
|
||||
init = mkMappingOption "Init selection [treesitter]" "gnn";
|
||||
|
@ -22,5 +17,85 @@ in {
|
|||
incrementByScope = mkMappingOption "Increment selection by scope [treesitter]" "grc";
|
||||
decrementByNode = mkMappingOption "Decrement selection by node [treesitter]" "grm";
|
||||
};
|
||||
|
||||
fold = mkEnableOption "fold with treesitter";
|
||||
autotagHtml = mkEnableOption "autoclose and rename html tag";
|
||||
grammars = mkOption {
|
||||
type = listOf package;
|
||||
default = [];
|
||||
description = ''
|
||||
List of treesitter grammars to install.
|
||||
|
||||
For languages already supported by neovim-flake, you may
|
||||
use the {option}`vim.language.<lang>.treesitter` options, which
|
||||
will automatically add the required grammars to this.
|
||||
'';
|
||||
};
|
||||
|
||||
highlight = {
|
||||
enable = mkEnableOption "highlighting with treesitter";
|
||||
disable = mkOption {
|
||||
type = either (listOf str) luaInline;
|
||||
default = [];
|
||||
example = literalMD ''
|
||||
```lua
|
||||
-- Disable slow treesitter highlight for large files
|
||||
disable = function(lang, buf)
|
||||
local max_filesize = 1000 * 1024 -- 1MB
|
||||
local ok, stats = pcall(vim.loop.fs_stat, vim.api.nvim_buf_get_name(buf))
|
||||
if ok and stats and stats.size > max_filesize then
|
||||
return true
|
||||
end
|
||||
end
|
||||
```
|
||||
'';
|
||||
|
||||
description = ''
|
||||
List of treesitter grammars to disable highlighting for.
|
||||
|
||||
This option can be either a list, in which case it will be
|
||||
converted to a Lua table containing grammars to disable
|
||||
highlighting for, or a string containing a **lua function**
|
||||
that will be read as is.
|
||||
|
||||
::: {.warning}
|
||||
A comma will be added at the end of your function, so you
|
||||
do not need to add it yourself. Doing so will cause in
|
||||
syntax errors within your Neovim configuration.
|
||||
:::
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
addDefaultGrammars = mkOption {
|
||||
type = bool;
|
||||
default = true;
|
||||
description = ''
|
||||
Whether to add the default grammars to the list of grammars
|
||||
to install.
|
||||
This option is only relevant if treesitter has been enabled.
|
||||
'';
|
||||
};
|
||||
|
||||
defaultGrammars = mkOption {
|
||||
internal = true;
|
||||
readOnly = true;
|
||||
type = listOf package;
|
||||
default = with pkgs.vimPlugins.nvim-treesitter.builtGrammars; [c lua vim vimdoc query];
|
||||
description = ''
|
||||
A list of treesitter grammars that will be installed by default
|
||||
if treesitter has been enabled and {option}`vim.treeesitter.addDefaultGrammars`
|
||||
has been set to true.
|
||||
|
||||
::: {.note}
|
||||
Regardless of which language module options you enable, Neovim
|
||||
depends on those grammars to be enabled while treesitter is enabled.
|
||||
|
||||
This list cannot be modified, but if you would like to bring your own
|
||||
parsers instead of those provided here, you can set `addDefaultGrammars`
|
||||
to false
|
||||
:::
|
||||
'';
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
31
modules/plugins/treesitter/ts-context/config.nix
Normal file
31
modules/plugins/treesitter/ts-context/config.nix
Normal file
|
@ -0,0 +1,31 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (lib.modules) mkIf;
|
||||
inherit (lib.trivial) boolToString;
|
||||
inherit (lib.nvim.lua) nullString;
|
||||
inherit (lib.nvim.dag) entryAfter;
|
||||
|
||||
inherit (config.vim) treesitter;
|
||||
cfg = treesitter.context;
|
||||
in {
|
||||
config = mkIf (treesitter.enable && cfg.enable) {
|
||||
vim.startPlugins = ["nvim-treesitter-context"];
|
||||
|
||||
vim.luaConfigRC.treesitter-context = entryAfter ["treesitter"] ''
|
||||
require'treesitter-context'.setup {
|
||||
enable = true,
|
||||
max_lines = ${toString cfg.maxLines},
|
||||
min_window_height = ${toString cfg.minWindowHeight},
|
||||
line_numbers = ${boolToString cfg.lineNumbers},
|
||||
multiline_threshold = ${toString cfg.multilineThreshold},
|
||||
trim_scope = '${cfg.trimScope}',
|
||||
mode = '${cfg.mode}',
|
||||
separator = ${nullString cfg.separator},
|
||||
z_index = ${toString cfg.zindex},
|
||||
}
|
||||
'';
|
||||
};
|
||||
}
|
|
@ -1,89 +1,60 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
{lib, ...}: let
|
||||
inherit (lib.options) mkOption mkEnableOption;
|
||||
inherit (lib.types) int bool str nullOr enum;
|
||||
inherit (lib.modules) mkIf;
|
||||
inherit (lib.trivial) boolToString;
|
||||
inherit (lib.nvim.lua) nullString;
|
||||
inherit (lib.nvim.dag) entryAnywhere;
|
||||
|
||||
inherit (config.vim) treesitter;
|
||||
cfg = treesitter.context;
|
||||
in {
|
||||
options.vim.treesitter.context = {
|
||||
enable = mkEnableOption "context of current buffer contents [nvim-treesitter-context] ";
|
||||
|
||||
maxLines = mkOption {
|
||||
description = "How many lines the window should span. Values <=0 mean no limit.";
|
||||
type = int;
|
||||
default = 0;
|
||||
description = "How many lines the window should span. Values <=0 mean no limit.";
|
||||
};
|
||||
|
||||
minWindowHeight = mkOption {
|
||||
description = "Minimum editor window height to enable context. Values <= 0 mean no limit.";
|
||||
type = int;
|
||||
default = 0;
|
||||
description = "Minimum editor window height to enable context. Values <= 0 mean no limit.";
|
||||
};
|
||||
|
||||
lineNumbers = mkOption {
|
||||
description = "";
|
||||
type = bool;
|
||||
default = true;
|
||||
description = "";
|
||||
};
|
||||
|
||||
multilineThreshold = mkOption {
|
||||
description = "Maximum number of lines to collapse for a single context line.";
|
||||
type = int;
|
||||
default = 20;
|
||||
description = "Maximum number of lines to collapse for a single context line.";
|
||||
};
|
||||
|
||||
trimScope = mkOption {
|
||||
description = "Which context lines to discard if [](#opt-vim.treesitter.context.maxLines) is exceeded.";
|
||||
type = enum ["inner" "outer"];
|
||||
default = "outer";
|
||||
description = "Which context lines to discard if [](#opt-vim.treesitter.context.maxLines) is exceeded.";
|
||||
};
|
||||
|
||||
mode = mkOption {
|
||||
description = "Line used to calculate context.";
|
||||
type = enum ["cursor" "topline"];
|
||||
default = "cursor";
|
||||
description = "Line used to calculate context.";
|
||||
};
|
||||
|
||||
separator = mkOption {
|
||||
type = nullOr str;
|
||||
default = null;
|
||||
description = ''
|
||||
Separator between context and content. Should be a single character string, like '-'.
|
||||
|
||||
When separator is set, the context will only show up when there are at least 2 lines above cursorline.
|
||||
'';
|
||||
type = nullOr str;
|
||||
default = null;
|
||||
};
|
||||
|
||||
zindex = mkOption {
|
||||
description = "The Z-index of the context window.";
|
||||
type = int;
|
||||
default = 20;
|
||||
description = "The Z-index of the context window.";
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf (treesitter.enable && cfg.enable) {
|
||||
vim.startPlugins = ["nvim-treesitter-context"];
|
||||
|
||||
vim.luaConfigRC.treesitter-context = entryAnywhere ''
|
||||
require'treesitter-context'.setup {
|
||||
enable = true,
|
||||
max_lines = ${toString cfg.maxLines},
|
||||
min_window_height = ${toString cfg.minWindowHeight},
|
||||
line_numbers = ${boolToString cfg.lineNumbers},
|
||||
multiline_threshold = ${toString cfg.multilineThreshold},
|
||||
trim_scope = '${cfg.trimScope}',
|
||||
mode = '${cfg.mode}',
|
||||
separator = ${nullString cfg.separator},
|
||||
max_lines = ${toString cfg.zindex},
|
||||
}
|
||||
'';
|
||||
};
|
||||
}
|
6
modules/plugins/treesitter/ts-context/default.nix
Normal file
6
modules/plugins/treesitter/ts-context/default.nix
Normal file
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
imports = [
|
||||
./context.nix
|
||||
./config.nix
|
||||
];
|
||||
}
|
|
@ -1,75 +1,93 @@
|
|||
{
|
||||
config,
|
||||
pkgs,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (lib.modules) mkIf;
|
||||
inherit (lib.lists) optionals;
|
||||
inherit (lib.strings) optionalString;
|
||||
inherit (lib.trivial) boolToString;
|
||||
inherit (lib.nvim.dag) entryAnywhere;
|
||||
|
||||
cfg = config.vim.ui.noice;
|
||||
tscfg = config.vim.treesitter;
|
||||
cmptype = config.vim.autocomplete.type;
|
||||
|
||||
defaultGrammars = with pkgs.vimPlugins.nvim-treesitter.builtGrammars; [vim regex lua bash markdown];
|
||||
in {
|
||||
config = mkIf cfg.enable {
|
||||
vim.startPlugins = [
|
||||
"noice-nvim"
|
||||
"nui-nvim"
|
||||
];
|
||||
vim = {
|
||||
startPlugins = [
|
||||
"noice-nvim"
|
||||
"nui-nvim"
|
||||
];
|
||||
|
||||
vim.luaConfigRC.noice-nvim = entryAnywhere ''
|
||||
require("noice").setup({
|
||||
lsp = {
|
||||
override = {
|
||||
["vim.lsp.util.convert_input_to_markdown_lines"] = true,
|
||||
["vim.lsp.util.stylize_markdown"] = true,
|
||||
["cmp.entry.get_documentation"] = true,
|
||||
},
|
||||
treesitter.grammars = optionals tscfg.addDefaultGrammars defaultGrammars;
|
||||
|
||||
signature = {
|
||||
enabled = false, -- FIXME: enabling this file throws an error which I couldn't figure out
|
||||
},
|
||||
},
|
||||
|
||||
presets = {
|
||||
bottom_search = true, -- use a classic bottom cmdline for search
|
||||
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 = ${boolToString config.vim.ui.borders.enable}, -- add a border to hover docs and signature help
|
||||
},
|
||||
|
||||
format = {
|
||||
cmdline = { pattern = "^:", icon = "", lang = "vim" },
|
||||
search_down = { kind = "search", pattern = "^/", icon = " ", lang = "regex" },
|
||||
search_up = { kind = "search", pattern = "^%?", icon = " ", lang = "regex" },
|
||||
filter = { pattern = "^:%s*!", icon = "", lang = "bash" },
|
||||
lua = { pattern = "^:%s*lua%s+", icon = "", lang = "lua" },
|
||||
help = { pattern = "^:%s*he?l?p?%s+", icon = "" },
|
||||
input = {},
|
||||
},
|
||||
|
||||
messages = {
|
||||
-- NOTE: If you enable messages, then the cmdline is enabled automatically.
|
||||
-- This is a current Neovim limitation.
|
||||
enabled = false, -- enables the Noice messages UI
|
||||
view = "notify", -- default view for messages
|
||||
view_error = "notify", -- view for errors
|
||||
view_warn = "notify", -- view for warnings
|
||||
view_history = "messages", -- view for :messages
|
||||
view_search = "virtualtext", -- view for search count messages. Set to `false` to disable
|
||||
},
|
||||
|
||||
-- Hide written messages
|
||||
routes = {
|
||||
{
|
||||
filter = {
|
||||
event = "msg_show",
|
||||
kind = "",
|
||||
find = "written",
|
||||
luaConfigRC.noice-nvim = entryAnywhere ''
|
||||
require("noice").setup({
|
||||
lsp = {
|
||||
override = {
|
||||
["vim.lsp.util.convert_input_to_markdown_lines"] = true,
|
||||
["vim.lsp.util.stylize_markdown"] = true,
|
||||
${optionalString (cmptype == "nvim-cmp") "[\"cmp.entry.get_documentation\"] = true,"}
|
||||
},
|
||||
|
||||
signature = {
|
||||
enabled = false, -- FIXME: enabling this file throws an error which I couldn't figure out
|
||||
},
|
||||
opts = { skip = true },
|
||||
},
|
||||
},
|
||||
})
|
||||
'';
|
||||
|
||||
hover = {
|
||||
enabled = true,
|
||||
silent = false, -- set to true to not show a message if hover is not available
|
||||
view = nil, -- when nil, use defaults from documentation
|
||||
opts = {}, -- merged with defaults from documentation
|
||||
},
|
||||
|
||||
presets = {
|
||||
bottom_search = true, -- use a classic bottom cmdline for search
|
||||
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 = ${boolToString config.vim.ui.borders.enable}, -- add a border to hover docs and signature help
|
||||
},
|
||||
|
||||
format = {
|
||||
cmdline = { pattern = "^:", icon = "", lang = "vim" },
|
||||
search_down = { kind = "search", pattern = "^/", icon = " ", lang = "regex" },
|
||||
search_up = { kind = "search", pattern = "^%?", icon = " ", lang = "regex" },
|
||||
filter = { pattern = "^:%s*!", icon = "", lang = "bash" },
|
||||
lua = { pattern = "^:%s*lua%s+", icon = "", lang = "lua" },
|
||||
help = { pattern = "^:%s*he?l?p?%s+", icon = "" },
|
||||
input = {},
|
||||
},
|
||||
|
||||
messages = {
|
||||
-- NOTE: If you enable messages, then the cmdline is enabled automatically.
|
||||
-- This is a current Neovim limitation.
|
||||
enabled = true, -- enables the Noice messages UI
|
||||
view = "notify", -- default view for messages
|
||||
view_error = "notify", -- view for errors
|
||||
view_warn = "notify", -- view for warnings
|
||||
view_history = "messages", -- view for :messages
|
||||
view_search = "virtualtext", -- view for search count messages. Set to `false` to disable
|
||||
},
|
||||
|
||||
-- Hide written messages
|
||||
routes = {
|
||||
{
|
||||
filter = {
|
||||
event = "msg_show",
|
||||
kind = "",
|
||||
find = "written",
|
||||
},
|
||||
opts = { skip = true },
|
||||
},
|
||||
},
|
||||
})
|
||||
'';
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue