mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-21 16:39:00 +02:00
luasnip: init plugin (#56)
* luasnip: init plugin Also added support for paths in `toLuaObject` * luasnip: more flexible types * luasnip: changed options to be more flexible * luasnip: added example * luasnip: added package option
This commit is contained in:
parent
1a89cd2107
commit
cba9cca52b
3 changed files with 102 additions and 0 deletions
|
@ -32,6 +32,8 @@
|
||||||
|
|
||||||
./pluginmanagers/packer.nix
|
./pluginmanagers/packer.nix
|
||||||
|
|
||||||
|
./snippets/luasnip
|
||||||
|
|
||||||
./statuslines/airline.nix
|
./statuslines/airline.nix
|
||||||
./statuslines/lightline.nix
|
./statuslines/lightline.nix
|
||||||
./statuslines/lualine.nix
|
./statuslines/lualine.nix
|
||||||
|
|
|
@ -23,6 +23,8 @@ rec {
|
||||||
else if builtins.isString args then
|
else if builtins.isString args then
|
||||||
# This should be enough!
|
# This should be enough!
|
||||||
escapeShellArg args
|
escapeShellArg args
|
||||||
|
else if builtins.isPath args then
|
||||||
|
escapeShellArg args
|
||||||
else if builtins.isBool args then
|
else if builtins.isBool args then
|
||||||
"${ boolToString args }"
|
"${ boolToString args }"
|
||||||
else if builtins.isFloat args then
|
else if builtins.isFloat args then
|
||||||
|
|
98
plugins/snippets/luasnip/default.nix
Normal file
98
plugins/snippets/luasnip/default.nix
Normal file
|
@ -0,0 +1,98 @@
|
||||||
|
{ pkgs, config, lib, ... }:
|
||||||
|
with lib;
|
||||||
|
let
|
||||||
|
cfg = config.plugins.luasnip;
|
||||||
|
helpers = import ../../helpers.nix { lib = lib; };
|
||||||
|
in
|
||||||
|
{
|
||||||
|
options.plugins.luasnip = {
|
||||||
|
enable = mkEnableOption "Enable luasnip";
|
||||||
|
|
||||||
|
package = mkOption {
|
||||||
|
default = pkgs.vimPlugins.luasnip;
|
||||||
|
type = types.package;
|
||||||
|
};
|
||||||
|
|
||||||
|
fromVscode = mkOption {
|
||||||
|
default = [ ];
|
||||||
|
example = ''
|
||||||
|
[
|
||||||
|
{}
|
||||||
|
{
|
||||||
|
paths = ./path/to/snippets;
|
||||||
|
}
|
||||||
|
]
|
||||||
|
# generates:
|
||||||
|
#
|
||||||
|
# require("luasnip.loaders.from_vscode").lazy_load({})
|
||||||
|
# require("luasnip.loaders.from_vscode").lazy_load({['paths'] = {'/nix/store/.../path/to/snippets'}})
|
||||||
|
#
|
||||||
|
'';
|
||||||
|
type = types.listOf (types.submodule {
|
||||||
|
options = {
|
||||||
|
lazyLoad = mkOption {
|
||||||
|
type = types.bool;
|
||||||
|
default = true;
|
||||||
|
description = ''
|
||||||
|
Whether or not to lazy load the snippets
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
# TODO: add option to also include the default runtimepath
|
||||||
|
paths = mkOption {
|
||||||
|
default = null;
|
||||||
|
type = with types; nullOr (oneOf
|
||||||
|
[
|
||||||
|
str
|
||||||
|
path
|
||||||
|
helpers.rawType
|
||||||
|
(listOf (oneOf
|
||||||
|
[
|
||||||
|
str
|
||||||
|
path
|
||||||
|
helpers.rawType
|
||||||
|
]))
|
||||||
|
]);
|
||||||
|
};
|
||||||
|
|
||||||
|
exclude = mkOption {
|
||||||
|
type = types.nullOr (types.listOf types.str);
|
||||||
|
default = null;
|
||||||
|
description = ''
|
||||||
|
List of languages to exclude, by default is empty.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
include = mkOption {
|
||||||
|
type = types.nullOr (types.listOf types.str);
|
||||||
|
default = null;
|
||||||
|
description = ''
|
||||||
|
List of languages to include, by default is not set.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
# TODO: add support for snipmate
|
||||||
|
# TODO: add support for lua
|
||||||
|
};
|
||||||
|
|
||||||
|
config =
|
||||||
|
let
|
||||||
|
|
||||||
|
fromVscodeLoaders = lists.map
|
||||||
|
(loader:
|
||||||
|
let
|
||||||
|
options = attrsets.getAttrs [ "paths" "exclude" "include" ] loader;
|
||||||
|
in
|
||||||
|
''
|
||||||
|
require("luasnip.loaders.from_vscode").${optionalString loader.lazyLoad "lazy_"}load(${helpers.toLuaObject options})
|
||||||
|
'')
|
||||||
|
cfg.fromVscode;
|
||||||
|
in
|
||||||
|
mkIf cfg.enable {
|
||||||
|
extraPlugins = [ cfg.package ];
|
||||||
|
extraConfigLua = concatStringsSep "\n" fromVscodeLoaders;
|
||||||
|
};
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue