mirror of
https://github.com/NotAShelf/nvf.git
synced 2025-11-05 13:12:21 +00:00
Compare commits
4 commits
f661c388ee
...
18c17b7b8d
| Author | SHA1 | Date | |
|---|---|---|---|
|
18c17b7b8d |
|||
|
76becd77e0 |
|||
|
|
8c7fdc0f5d |
||
|
787678dd73 |
5 changed files with 111 additions and 13 deletions
|
|
@ -19,13 +19,12 @@ indent_style = space
|
|||
indent_size = 2
|
||||
tab_width = 2
|
||||
|
||||
[*.{diff,patch}]
|
||||
[*.{diff,patch,lock}]
|
||||
end_of_line = unset
|
||||
insert_final_newline = unset
|
||||
trim_trailing_whitespace = unset
|
||||
|
||||
[*.lock]
|
||||
indent_size = unset
|
||||
|
||||
[npins/sources.json]
|
||||
insert_final_newline = unset
|
||||
indent_style = unset
|
||||
indent_size = unset
|
||||
trim_trailing_whitespace = unset
|
||||
|
|
|
|||
|
|
@ -352,6 +352,7 @@
|
|||
|
||||
[rrvsh](https://github.com/rrvsh):
|
||||
|
||||
- Add custom snippet support to `vim.snippets.luasnip`
|
||||
- Fix namespace of python-lsp-server by changing it to python3Packages
|
||||
|
||||
[Noah765](https://github.com/Noah765):
|
||||
|
|
|
|||
12
flake.lock
generated
12
flake.lock
generated
|
|
@ -58,11 +58,11 @@
|
|||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1749796250,
|
||||
"narHash": "sha256-oxvVAFUO9husnRk6XZcLFLjLWL9z0pW25Fk6kVKwt1c=",
|
||||
"lastModified": 1750047244,
|
||||
"narHash": "sha256-vluLARrk4485npdyHOj8XKr0yk6H22pNf+KVRNL+i/Y=",
|
||||
"owner": "oxalica",
|
||||
"repo": "nil",
|
||||
"rev": "9e4cccb088440c20703d62db9de8d5ae06d4a449",
|
||||
"rev": "870a4b1b5f12004832206703ac15aa85c42c247b",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
|
@ -73,11 +73,11 @@
|
|||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1749743618,
|
||||
"narHash": "sha256-ibsz06u1jlWyH7YURnRhLQn38Tuc5zwknr00suFjvfA=",
|
||||
"lastModified": 1750215678,
|
||||
"narHash": "sha256-Rc/ytpamXRf6z8UA2SGa4aaWxUXRbX2MAWIu2C8M+ok=",
|
||||
"owner": "nixos",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "8d6cdc7756817e0c4b24567271634a44bcf80752",
|
||||
"rev": "5395fb3ab3f97b9b7abca147249fa2e8ed27b192",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
|
|
|||
|
|
@ -1,11 +1,48 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}: let
|
||||
inherit (lib.modules) mkIf;
|
||||
|
||||
inherit (lib.lists) replicate;
|
||||
inherit
|
||||
(lib.strings)
|
||||
optionalString
|
||||
removeSuffix
|
||||
concatStrings
|
||||
stringAsChars
|
||||
concatMapStringsSep
|
||||
;
|
||||
inherit (lib.attrsets) mapAttrsToList;
|
||||
inherit (pkgs) writeTextFile;
|
||||
cfg = config.vim.snippets.luasnip;
|
||||
# LuaSnip freaks out if the indentation is wrong in snippets
|
||||
indent = n: s: let
|
||||
indentString = concatStrings (replicate n " ");
|
||||
sep = "\n" + indentString;
|
||||
in
|
||||
indentString
|
||||
+ stringAsChars (c:
|
||||
if c == "\n"
|
||||
then sep
|
||||
else c) (removeSuffix "\n" s);
|
||||
customSnipmateSnippetFiles =
|
||||
mapAttrsToList (
|
||||
name: value:
|
||||
writeTextFile {
|
||||
name = "${name}.snippets";
|
||||
text =
|
||||
concatMapStringsSep "\n" (x: ''
|
||||
snippet ${x.trigger} ${x.description}
|
||||
${indent 2 x.body}
|
||||
'')
|
||||
value;
|
||||
destination = "/snippets/${name}.snippets";
|
||||
}
|
||||
)
|
||||
cfg.customSnippets.snipmate;
|
||||
in {
|
||||
config = mkIf cfg.enable {
|
||||
vim = {
|
||||
|
|
@ -19,11 +56,16 @@ in {
|
|||
|
||||
after = cfg.loaders;
|
||||
};
|
||||
startPlugins = cfg.providers;
|
||||
startPlugins = cfg.providers ++ customSnipmateSnippetFiles;
|
||||
autocomplete.nvim-cmp = mkIf config.vim.autocomplete.nvim-cmp.enable {
|
||||
sources = {luasnip = "[LuaSnip]";};
|
||||
sourcePlugins = ["cmp-luasnip"];
|
||||
};
|
||||
snippets.luasnip.loaders = ''
|
||||
${optionalString (
|
||||
cfg.customSnippets.snipmate != {}
|
||||
) "require('luasnip.loaders.from_snipmate').lazy_load()"}
|
||||
'';
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{lib, ...}: let
|
||||
inherit (lib.options) mkEnableOption mkOption literalExpression literalMD;
|
||||
inherit (lib.types) listOf lines;
|
||||
inherit (lib.types) listOf lines submodule str attrsOf;
|
||||
inherit (lib.nvim.types) pluginType mkPluginSetupOption;
|
||||
in {
|
||||
options.vim.snippets.luasnip = {
|
||||
|
|
@ -36,5 +36,61 @@ in {
|
|||
setupOpts = mkPluginSetupOption "LuaSnip" {
|
||||
enable_autosnippets = mkEnableOption "autosnippets";
|
||||
};
|
||||
|
||||
customSnippets.snipmate = mkOption {
|
||||
type = attrsOf (
|
||||
listOf (submodule {
|
||||
options = {
|
||||
trigger = mkOption {
|
||||
type = str;
|
||||
description = ''
|
||||
The trigger used to activate this snippet.
|
||||
'';
|
||||
};
|
||||
description = mkOption {
|
||||
type = str;
|
||||
default = "";
|
||||
description = ''
|
||||
The description shown for this snippet.
|
||||
'';
|
||||
};
|
||||
body = mkOption {
|
||||
type = str;
|
||||
description = ''
|
||||
[LuaSnip Documentation]: https://github.com/L3MON4D3/LuaSnip#add-snippets
|
||||
The body of the snippet in SnipMate format (see [LuaSnip Documentation]).
|
||||
'';
|
||||
};
|
||||
};
|
||||
})
|
||||
);
|
||||
default = {};
|
||||
example = ''
|
||||
{
|
||||
all = [
|
||||
{
|
||||
trigger = "if";
|
||||
body = "if $1 else $2";
|
||||
}
|
||||
];
|
||||
nix = [
|
||||
{
|
||||
trigger = "mkOption";
|
||||
body = '''
|
||||
mkOption {
|
||||
type = $1;
|
||||
default = $2;
|
||||
description = $3;
|
||||
example = $4;
|
||||
}
|
||||
''';
|
||||
}
|
||||
];
|
||||
}
|
||||
'';
|
||||
description = ''
|
||||
A list containing custom snippets in the SnipMate format to be loaded by LuaSnip.
|
||||
'';
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue