mirror of
https://github.com/NotAShelf/neovim-flake.git
synced 2024-11-09 22:55:58 +01:00
Compare commits
20 commits
115d38e48e
...
2ba09617bb
Author | SHA1 | Date | |
---|---|---|---|
2ba09617bb | |||
6563ad45f3 | |||
d0ca3f8a4c | |||
bba0ba92a6 | |||
694012dbd8 | |||
616c00ab46 | |||
c8d38872ab | |||
e8035c42f4 | |||
5246cf50de | |||
2941092470 | |||
92c94fda20 | |||
103941e270 | |||
feb7cd731e | |||
ad9d0c6cdb | |||
5e12c2315a | |||
5e08ed42e7 | |||
49b705b6aa | |||
b614dc6b41 | |||
7fd653b4d8 | |||
495e7620d2 |
20 changed files with 677 additions and 206 deletions
|
@ -132,9 +132,8 @@ inputs: let
|
|||
};
|
||||
|
||||
filetree = {
|
||||
nvimTree = {
|
||||
enable = true;
|
||||
};
|
||||
nvimTree.enable = false;
|
||||
neo-tree.enable = true;
|
||||
};
|
||||
|
||||
tabline = {
|
||||
|
|
77
flake.lock
77
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": {
|
||||
|
@ -931,14 +931,30 @@
|
|||
"type": "github"
|
||||
}
|
||||
},
|
||||
"plugin-neo-tree-nvim": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1713050882,
|
||||
"narHash": "sha256-cZwOVpdMT0NCtp6Ha592QA2RzKVS6LhXXcjfDBCQ+0k=",
|
||||
"owner": "nvim-neo-tree",
|
||||
"repo": "neo-tree.nvim",
|
||||
"rev": "22e566aeb075c94f670f34077e05ba95190dfb4a",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nvim-neo-tree",
|
||||
"repo": "neo-tree.nvim",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"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 +1191,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 +1319,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 +1335,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": {
|
||||
|
@ -1851,6 +1867,7 @@
|
|||
"plugin-mind-nvim": "plugin-mind-nvim",
|
||||
"plugin-minimap-vim": "plugin-minimap-vim",
|
||||
"plugin-modes-nvim": "plugin-modes-nvim",
|
||||
"plugin-neo-tree-nvim": "plugin-neo-tree-nvim",
|
||||
"plugin-neocord": "plugin-neocord",
|
||||
"plugin-neodev-nvim": "plugin-neodev-nvim",
|
||||
"plugin-noice-nvim": "plugin-noice-nvim",
|
||||
|
@ -2111,11 +2128,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": {
|
||||
|
|
|
@ -223,6 +223,11 @@
|
|||
flake = false;
|
||||
};
|
||||
|
||||
plugin-neo-tree-nvim = {
|
||||
url = "github:nvim-neo-tree/neo-tree.nvim";
|
||||
flake = false;
|
||||
};
|
||||
|
||||
# Tablines
|
||||
plugin-nvim-bufferline-lua = {
|
||||
url = "github:akinsho/nvim-bufferline.lua";
|
||||
|
|
|
@ -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;
|
||||
}
|
|
@ -49,7 +49,7 @@ in {
|
|||
|
||||
syntaxHighlighting = mkOption {
|
||||
type = bool;
|
||||
default = true;
|
||||
default = !config.vim.treesitter.highlight.enable;
|
||||
description = "Enable syntax highlighting";
|
||||
};
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
{
|
||||
imports = [
|
||||
./nvimtree
|
||||
./neo-tree
|
||||
];
|
||||
}
|
||||
|
|
28
modules/plugins/filetree/neo-tree/config.nix
Normal file
28
modules/plugins/filetree/neo-tree/config.nix
Normal file
|
@ -0,0 +1,28 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (lib.modules) mkIf;
|
||||
inherit (lib.nvim.dag) entryAnywhere;
|
||||
inherit (lib.nvim.lua) toLuaObject;
|
||||
|
||||
cfg = config.vim.filetree.neo-tree;
|
||||
in {
|
||||
config = mkIf cfg.enable {
|
||||
vim = {
|
||||
startPlugins = [
|
||||
# dependencies
|
||||
"plenary-nvim" # commons library
|
||||
"image-nvim" # optional for image previews
|
||||
"nui-nvim" # ui library
|
||||
# neotree
|
||||
"neo-tree-nvim"
|
||||
];
|
||||
|
||||
luaConfigRC.neo-tree = entryAnywhere ''
|
||||
require("neo-tree").setup(${toLuaObject cfg.setupOpts})
|
||||
'';
|
||||
};
|
||||
};
|
||||
}
|
6
modules/plugins/filetree/neo-tree/default.nix
Normal file
6
modules/plugins/filetree/neo-tree/default.nix
Normal file
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
imports = [
|
||||
./config.nix
|
||||
./neo-tree.nix
|
||||
];
|
||||
}
|
155
modules/plugins/filetree/neo-tree/neo-tree.nix
Normal file
155
modules/plugins/filetree/neo-tree/neo-tree.nix
Normal file
|
@ -0,0 +1,155 @@
|
|||
{lib, ...}: let
|
||||
inherit (lib.types) bool str int submodule enum either listOf;
|
||||
inherit (lib.options) mkOption mkEnableOption literalExpression;
|
||||
inherit (lib.nvim.types) mkPluginSetupOption;
|
||||
in {
|
||||
options.vim.filetree.neo-tree = {
|
||||
enable = mkEnableOption "filetree via neo-tree.nvim";
|
||||
|
||||
# Permalink:
|
||||
# https://github.com/nvim-neo-tree/neo-tree.nvim/blob/22e566aeb075c94f670f34077e05ba95190dfb4a/lua/neo-tree/defaults.lua
|
||||
setupOpts = mkPluginSetupOption "neo-tree" {
|
||||
add_blank_line_at_top = mkOption {
|
||||
type = bool;
|
||||
default = false;
|
||||
description = ''
|
||||
Whether to add a blank line at the top of the tree
|
||||
'';
|
||||
};
|
||||
|
||||
auto_clean_after_session_restore = mkOption {
|
||||
type = bool;
|
||||
default = false;
|
||||
description = ''
|
||||
Whether to automatically clean up broken neo-tree buffers
|
||||
saved in sessions
|
||||
'';
|
||||
};
|
||||
|
||||
default_source = mkOption {
|
||||
type = str;
|
||||
default = "filesystem";
|
||||
description = ''
|
||||
You can choose a specific source.
|
||||
|
||||
`last` here which indicates the last used source
|
||||
'';
|
||||
};
|
||||
|
||||
enable_diagnostics = mkEnableOption "diagnostics" // {default = true;};
|
||||
enable_git_status = mkEnableOption "git status" // {default = true;};
|
||||
enable_modified_markers = mkEnableOption "markers for files with unsaved changes." // {default = true;};
|
||||
enable_opened_markers =
|
||||
mkEnableOption ''
|
||||
tracking of opened files.
|
||||
|
||||
Required for `components.name.highlight_opened_files`
|
||||
''
|
||||
// {default = true;};
|
||||
|
||||
enable_refresh_on_write =
|
||||
mkEnableOption ''
|
||||
Refresh the tree when a file is written.
|
||||
|
||||
Only used if `use_libuv_file_watcher` is false.
|
||||
''
|
||||
// {default = true;};
|
||||
|
||||
enable_cursor_hijack = mkEnableOption ''
|
||||
cursor hijacking.
|
||||
|
||||
If enabled neotree will keep the cursor on the first letter of the filename when moving in the tree
|
||||
'';
|
||||
|
||||
git_status_async = mkEnableOption ''
|
||||
async git status.
|
||||
|
||||
This will make the git status check async and will not block the UI.
|
||||
'';
|
||||
|
||||
/*
|
||||
git_status_async_options = mkOption {
|
||||
description = "These options are for people with VERY large git repos";
|
||||
type = submodule {
|
||||
batch_size = mkOption {
|
||||
type = int;
|
||||
default = 1000;
|
||||
description = "How many lines of git status results to process at a time";
|
||||
};
|
||||
|
||||
batch_delay = mkOption {
|
||||
type = int;
|
||||
default = 10;
|
||||
description = "Delay, in ms, between batches. Spreads out the workload to let other processes run";
|
||||
};
|
||||
|
||||
max_lines = mkOption {
|
||||
type = int;
|
||||
default = 10000;
|
||||
description = ''
|
||||
How many lines of git status results to process.
|
||||
|
||||
Anything after this will be dropped. Anything before this will be used.
|
||||
The last items to be processed are the untracked files.
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
*/
|
||||
|
||||
hide_root_node = mkOption {
|
||||
type = bool;
|
||||
default = false;
|
||||
description = ''
|
||||
Whether to hide the root node of the tree
|
||||
'';
|
||||
};
|
||||
|
||||
retain_hidden_root_indent = mkOption {
|
||||
type = bool;
|
||||
default = false;
|
||||
description = ''
|
||||
Whether to retain the indent of the hidden root node
|
||||
|
||||
IF the root node is hidden, keep the indentation anyhow.
|
||||
This is needed if you use expanders because they render in the indent.
|
||||
'';
|
||||
};
|
||||
|
||||
log_level = mkOption {
|
||||
type = enum ["trace" "debug" "info" "warn" "error" "fatal"];
|
||||
default = "info";
|
||||
description = "Log level for the plugin.";
|
||||
};
|
||||
|
||||
log_to_file = mkOption {
|
||||
type = either bool str;
|
||||
default = false;
|
||||
example = literalExpression "/tmp/neo-tree.log";
|
||||
description = ''
|
||||
Must be either a boolean or a path to your log file.
|
||||
|
||||
Use :NeoTreeLogs to show the file
|
||||
'';
|
||||
};
|
||||
|
||||
open_files_in_last_window = mkOption {
|
||||
type = bool;
|
||||
default = true;
|
||||
description = ''
|
||||
Whether to open files in the last window
|
||||
|
||||
If disabled, neo-tree will open files in top left window
|
||||
'';
|
||||
};
|
||||
|
||||
open_files_do_not_replace_types = mkOption {
|
||||
type = listOf str;
|
||||
default = ["terminal" "Trouble" "qf" "edgy"];
|
||||
description = ''
|
||||
A list of filetypes that should not be replaced when opening a file
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
_: {
|
||||
{
|
||||
imports = [
|
||||
./config.nix
|
||||
./nvimtree.nix
|
||||
|
|
|
@ -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.
|
||||
|
@ -35,28 +39,51 @@ in {
|
|||
|
||||
# For some reason treesitter highlighting does not work on start if this is set before syntax on
|
||||
configRC.treesitter-fold = mkIf cfg.fold (entryBefore ["basic"] ''
|
||||
" This is required by treesitter-context to handle folds
|
||||
set foldmethod=expr
|
||||
set foldexpr=nvim_treesitter#foldexpr()
|
||||
|
||||
" This is optional, but is set rather as a sane default.
|
||||
" If unset, opened files will be folded by automatically as
|
||||
" the files are opened
|
||||
set nofoldenable
|
||||
'');
|
||||
|
||||
luaConfigRC.treesitter = entryAnywhere ''
|
||||
require'nvim-treesitter.configs'.setup {
|
||||
highlight = {
|
||||
enable = true,
|
||||
disable = {},
|
||||
},
|
||||
|
||||
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 = ${toLuaObject cfg.indent.enable},
|
||||
disable = ${toLuaObject cfg.indent.disable},
|
||||
},
|
||||
|
||||
-- Highlight module for Treesitter
|
||||
highlight = {
|
||||
enable = ${toLuaObject cfg.highlight.enable},
|
||||
disable = ${toLuaObject cfg.highlight.disable},
|
||||
additional_vim_regex_highlighting = ${toLuaObject cfg.highlight.additionalVimRegexHighlighting},
|
||||
},
|
||||
|
||||
-- Indentation module for Treesitter
|
||||
-- Keymaps are set to false here as they are
|
||||
-- handled by `vim.maps` entries calling lua
|
||||
-- functions achieving the same functionality.
|
||||
incremental_selection = {
|
||||
enable = true,
|
||||
enable = ${toLuaObject cfg.incrementalSelection.enable},
|
||||
disable = ${toLuaObject cfg.incrementalSelection.disable},
|
||||
keymaps = {
|
||||
init_selection = false,
|
||||
node_incremental = false,
|
||||
scope_incremental = false,
|
||||
node_decremental = false,
|
||||
|
||||
},
|
||||
},
|
||||
}
|
||||
|
|
|
@ -1,89 +0,0 @@
|
|||
{
|
||||
config,
|
||||
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;
|
||||
};
|
||||
|
||||
minWindowHeight = mkOption {
|
||||
description = "Minimum editor window height to enable context. Values <= 0 mean no limit.";
|
||||
type = int;
|
||||
default = 0;
|
||||
};
|
||||
|
||||
lineNumbers = mkOption {
|
||||
description = "";
|
||||
type = bool;
|
||||
default = true;
|
||||
};
|
||||
|
||||
multilineThreshold = mkOption {
|
||||
description = "Maximum number of lines to collapse for a single context line.";
|
||||
type = int;
|
||||
default = 20;
|
||||
};
|
||||
|
||||
trimScope = mkOption {
|
||||
description = "Which context lines to discard if [](#opt-vim.treesitter.context.maxLines) is exceeded.";
|
||||
type = enum ["inner" "outer"];
|
||||
default = "outer";
|
||||
};
|
||||
|
||||
mode = mkOption {
|
||||
description = "Line used to calculate context.";
|
||||
type = enum ["cursor" "topline"];
|
||||
default = "cursor";
|
||||
};
|
||||
|
||||
separator = mkOption {
|
||||
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;
|
||||
};
|
||||
};
|
||||
|
||||
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},
|
||||
}
|
||||
'';
|
||||
};
|
||||
}
|
|
@ -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 literalExpression;
|
||||
inherit (lib.types) listOf package str either bool;
|
||||
inherit (lib.nvim.binds) mkMappingOption;
|
||||
inherit (lib.types) listOf package;
|
||||
inherit (lib.nvim.types) luaInline;
|
||||
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,152 @@ 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.
|
||||
'';
|
||||
};
|
||||
|
||||
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
|
||||
:::
|
||||
'';
|
||||
};
|
||||
|
||||
indent = {
|
||||
enable = mkEnableOption "indentation with treesitter" // {default = true;};
|
||||
disable = mkOption {
|
||||
type = either (listOf str) luaInline;
|
||||
default = [];
|
||||
example = literalExpression ''["c" "rust"]'';
|
||||
|
||||
description = ''
|
||||
List of treesitter grammars to disable indentation for.
|
||||
|
||||
This option can be either a list, in which case it will be
|
||||
converted to a Lua table containing grammars to disable
|
||||
indentation 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.
|
||||
:::
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
highlight = {
|
||||
enable = mkEnableOption "highlighting with treesitter" // {default = true;};
|
||||
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.
|
||||
:::
|
||||
'';
|
||||
};
|
||||
|
||||
additionalVimRegexHighlighting = mkOption {
|
||||
type = either bool (listOf str);
|
||||
default = false;
|
||||
description = ''
|
||||
Takes either a boolean or a list of languages.
|
||||
|
||||
Setting this to true will run `:h syntax` and tree-sitter at the same time.
|
||||
You may this to `true` if you depend on 'syntax' being enabled (like for
|
||||
indentation).
|
||||
|
||||
::: {.note}
|
||||
Using this option may slow down your editor, and you may see some duplicate
|
||||
highlights.
|
||||
:::
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
incrementalSelection = {
|
||||
enable = mkEnableOption "incremental selection with treesitter" // {default = true;};
|
||||
disable = mkOption {
|
||||
type = either (listOf str) luaInline;
|
||||
default = [];
|
||||
example = literalExpression ''["c" "rust" ]'';
|
||||
|
||||
description = ''
|
||||
List of treesitter grammars to disable incremental selection
|
||||
for.
|
||||
|
||||
This option can be either a list, in which case it will be
|
||||
converted to a Lua table containing grammars to disable
|
||||
indentation 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.
|
||||
:::
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
24
modules/plugins/treesitter/ts-context/config.nix
Normal file
24
modules/plugins/treesitter/ts-context/config.nix
Normal file
|
@ -0,0 +1,24 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (lib.modules) mkIf;
|
||||
inherit (lib.nvim.lua) toLuaObject;
|
||||
inherit (lib.nvim.dag) entryAfter;
|
||||
|
||||
inherit (config.vim) treesitter;
|
||||
cfg = treesitter.context;
|
||||
in {
|
||||
config = mkIf (treesitter.enable && cfg.enable) {
|
||||
vim = {
|
||||
startPlugins = ["nvim-treesitter-context"];
|
||||
|
||||
# set up treesitter-context after Treesitter. The ordering
|
||||
# should not matter, but there is no harm in doing this
|
||||
luaConfigRC.treesitter-context = entryAfter ["treesitter"] ''
|
||||
require("treesitter-context").setup(${toLuaObject cfg.setupOpts})
|
||||
'';
|
||||
};
|
||||
};
|
||||
}
|
94
modules/plugins/treesitter/ts-context/context.nix
Normal file
94
modules/plugins/treesitter/ts-context/context.nix
Normal file
|
@ -0,0 +1,94 @@
|
|||
{lib, ...}: let
|
||||
inherit (lib.options) mkOption mkEnableOption;
|
||||
inherit (lib.types) int bool str nullOr enum;
|
||||
inherit (lib.nvim.types) mkPluginSetupOption;
|
||||
inherit (lib.nvim.config) batchRenameOptions;
|
||||
migrationTable = {
|
||||
maxLines = "max_lines";
|
||||
minWindowHeight = "min_window_height";
|
||||
lineNumbers = "line_numbers";
|
||||
multilineThreshold = "multiline_threshold";
|
||||
trimScope = "trim_scope";
|
||||
mode = "mode";
|
||||
seperator = "separator";
|
||||
zindex = "z_index";
|
||||
};
|
||||
|
||||
renamedSetupOpts =
|
||||
batchRenameOptions
|
||||
["vim" "treesitter" "context"]
|
||||
["vim" "treesitter" "context" "setupOpts"]
|
||||
migrationTable;
|
||||
in {
|
||||
imports = renamedSetupOpts;
|
||||
options.vim.treesitter.context = {
|
||||
enable = mkEnableOption "context of current buffer contents [nvim-treesitter-context] ";
|
||||
|
||||
setupOpts = mkPluginSetupOption "treesitter-context" {
|
||||
max_lines = mkOption {
|
||||
type = int;
|
||||
default = 0;
|
||||
description = ''
|
||||
How many lines the window should span.
|
||||
|
||||
Values >= 0 mean there will be no limit.
|
||||
'';
|
||||
};
|
||||
|
||||
min_window_height = mkOption {
|
||||
type = int;
|
||||
default = 0;
|
||||
description = ''
|
||||
Minimum editor window height to enable context.
|
||||
|
||||
Values >= 0 mean there will be no limit.
|
||||
'';
|
||||
};
|
||||
|
||||
line_numbers = mkOption {
|
||||
type = bool;
|
||||
default = true;
|
||||
description = "Whether to display line numbers in current context";
|
||||
};
|
||||
|
||||
multiline_threshold = mkOption {
|
||||
type = int;
|
||||
default = 20;
|
||||
description = "Maximum number of lines to collapse for a single context line.";
|
||||
};
|
||||
|
||||
trim_scope = mkOption {
|
||||
type = enum ["inner" "outer"];
|
||||
default = "outer";
|
||||
description = ''
|
||||
Which context lines to discard if
|
||||
[](#opt-vim.treesitter.context.setupOpts.max_lines) is exceeded.
|
||||
'';
|
||||
};
|
||||
|
||||
mode = mkOption {
|
||||
type = enum ["cursor" "topline"];
|
||||
default = "cursor";
|
||||
description = "Line used to calculate context.";
|
||||
};
|
||||
|
||||
separator = mkOption {
|
||||
type = nullOr str;
|
||||
default = "-";
|
||||
description = ''
|
||||
Separator between context and content. This option 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.
|
||||
'';
|
||||
};
|
||||
|
||||
zindex = mkOption {
|
||||
type = int;
|
||||
default = 20;
|
||||
description = "The Z-index of the context window.";
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
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,27 +1,37 @@
|
|||
{
|
||||
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 = [
|
||||
vim = {
|
||||
startPlugins = [
|
||||
"noice-nvim"
|
||||
"nui-nvim"
|
||||
];
|
||||
|
||||
vim.luaConfigRC.noice-nvim = entryAnywhere ''
|
||||
treesitter.grammars = optionals tscfg.addDefaultGrammars defaultGrammars;
|
||||
|
||||
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,
|
||||
${optionalString (cmptype == "nvim-cmp") "[\"cmp.entry.get_documentation\"] = true,"}
|
||||
},
|
||||
|
||||
signature = {
|
||||
|
@ -29,6 +39,13 @@ in {
|
|||
},
|
||||
},
|
||||
|
||||
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
|
||||
|
@ -50,7 +67,7 @@ in {
|
|||
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
|
||||
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
|
||||
|
@ -72,4 +89,5 @@ in {
|
|||
})
|
||||
'';
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue