mirror of
https://github.com/NotAShelf/nvf.git
synced 2024-11-30 00:26:45 +00:00
Compare commits
10 commits
bf54ca3cb2
...
af9f09762a
Author | SHA1 | Date | |
---|---|---|---|
|
af9f09762a | ||
|
e57ef1db64 | ||
|
6ef34511b1 | ||
|
d3ff60bd4c | ||
|
850465faba | ||
|
02676d4224 | ||
|
5e6677fb1a | ||
|
a4f03076bf | ||
|
347a04b62e | ||
|
834aee6cce |
11 changed files with 175 additions and 75 deletions
|
@ -20,6 +20,7 @@ custom plugins that you might have added to your configuration.
|
||||||
|
|
||||||
```{=include=} sections
|
```{=include=} sections
|
||||||
custom-plugins/configuring.md
|
custom-plugins/configuring.md
|
||||||
custom-plugins/new-method.md
|
custom-plugins/lazy-method.md
|
||||||
custom-plugins/old-method.md
|
custom-plugins/non-lazy-method.md
|
||||||
|
custom-plugins/legacy-method.md
|
||||||
```
|
```
|
||||||
|
|
|
@ -1,12 +1,32 @@
|
||||||
# Configuring {#sec-configuring-plugins}
|
# Configuring {#sec-configuring-plugins}
|
||||||
|
|
||||||
Just making the plugin to your Neovim configuration available might not always
|
Just making the plugin to your Neovim configuration available might not always be enough. In that
|
||||||
be enough. In that case, you can write custom lua config using either
|
case, you can write custom lua config using either `config.vim.lazy.plugins.*.setupOpts`
|
||||||
`config.vim.extraPlugins` (which has the `setup` field) or
|
`config.vim.extraPlugins.*.setup` or `config.vim.luaConfigRC`.
|
||||||
`config.vim.luaConfigRC`. The first option uses an attribute set, which maps DAG
|
|
||||||
section names to a custom type, which has the fields `package`, `after`,
|
The first option uses an extended version of `lz.n`'s PluginSpec. `setupModule` and `setupOpt` can
|
||||||
`setup`. They allow you to set the package of the plugin, the sections its setup
|
be used if the plugin uses a `require('module').setup(...)` pattern. Otherwise, the `before` and
|
||||||
code should be after (note that the `extraPlugins` option has its own DAG
|
`after` hooks should do what you need.
|
||||||
|
|
||||||
|
```nix
|
||||||
|
{
|
||||||
|
config.vim.lazy.plugins = {
|
||||||
|
aerial-nvim = {
|
||||||
|
# ^^^^^^^^^ this name should match the package.pname or package.name
|
||||||
|
package = aerial-nvim;
|
||||||
|
|
||||||
|
setupModule = "aerial";
|
||||||
|
setupOpts = {option_name = false;};
|
||||||
|
|
||||||
|
after = "print('aerial loaded')";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
The second option uses an attribute set, which maps DAG section names to a custom type, which has
|
||||||
|
the fields `package`, `after`, `setup`. They allow you to set the package of the plugin, the
|
||||||
|
sections its setup code should be after (note that the `extraPlugins` option has its own DAG
|
||||||
scope), and the its setup code respectively. For example:
|
scope), and the its setup code respectively. For example:
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
|
@ -24,7 +44,7 @@ config.vim.extraPlugins = with pkgs.vimPlugins; {
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
The second option also uses an attribute set, but this one is resolved as a DAG
|
The third option also uses an attribute set, but this one is resolved as a DAG
|
||||||
directly. The attribute names denote the section names, and the values lua code.
|
directly. The attribute names denote the section names, and the values lua code.
|
||||||
For example:
|
For example:
|
||||||
|
|
||||||
|
|
40
docs/manual/configuring/custom-plugins/lazy-method.md
Normal file
40
docs/manual/configuring/custom-plugins/lazy-method.md
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
# Lazy Method {#sec-lazy-method}
|
||||||
|
|
||||||
|
As of version **0.7**, we exposed an API for configuring lazy-loaded plugins via
|
||||||
|
`lz.n` and `lzn-auto-require`.
|
||||||
|
|
||||||
|
```nix
|
||||||
|
{
|
||||||
|
config.vim.lazy.plugins = {
|
||||||
|
aerial = {
|
||||||
|
package = pkgs.vimPlugins.aerial-nvim;
|
||||||
|
setupModule = aerial;
|
||||||
|
setupOpts = {
|
||||||
|
option_name = true;
|
||||||
|
};
|
||||||
|
after = ''
|
||||||
|
-- custom lua code to run after plugin is loaded
|
||||||
|
print('aerial loaded')
|
||||||
|
'';
|
||||||
|
|
||||||
|
# Explicitly mark plugin as lazy. You don't need this if you define one of
|
||||||
|
# the trigger "events" below
|
||||||
|
lazy = true;
|
||||||
|
|
||||||
|
# load on command
|
||||||
|
cmd = ["AerialOpen"];
|
||||||
|
|
||||||
|
# load on event
|
||||||
|
event = ["BufEnter"];
|
||||||
|
|
||||||
|
# load on keymap
|
||||||
|
keys = [
|
||||||
|
{
|
||||||
|
key = "<leader>a";
|
||||||
|
action = ":AerialToggle<CR>";
|
||||||
|
}
|
||||||
|
];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
```
|
|
@ -1,4 +1,4 @@
|
||||||
# Old Method {#sec-old-method}
|
# Legacy Method {#sec-legacy-method}
|
||||||
|
|
||||||
Prior to version 0.5, the method of adding new plugins was adding the plugin
|
Prior to version 0.5, the method of adding new plugins was adding the plugin
|
||||||
package to `vim.startPlugins` and add its configuration as a DAG under one of
|
package to `vim.startPlugins` and add its configuration as a DAG under one of
|
|
@ -1,4 +1,4 @@
|
||||||
# New Method {#sec-new-method}
|
# Non-lazy Method {#sec-non-lazy-method}
|
||||||
|
|
||||||
As of version **0.5**, we have a more extensive API for configuring plugins,
|
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
|
under `vim.extraPlugins`. Instead of using DAGs exposed by the library, you may
|
|
@ -12,9 +12,9 @@ entries in nvf:
|
||||||
2. `globalsScript` - used to set globals defined in `vim.globals`
|
2. `globalsScript` - used to set globals defined in `vim.globals`
|
||||||
3. `basic` - used to set basic configuration options
|
3. `basic` - used to set basic configuration options
|
||||||
4. `optionsScript` - used to set options defined in `vim.o`
|
4. `optionsScript` - used to set options defined in `vim.o`
|
||||||
5. `theme` (this is simply placed before `pluginConfigs`, meaning that
|
5. `theme` (this is simply placed before `pluginConfigs` and `lazyConfigs`, meaning that
|
||||||
surrounding entries don't depend on it) - used to set up the theme, which has
|
surrounding entries don't depend on it) - used to set up the theme, which has to be done before
|
||||||
to be done before other plugins
|
other plugins
|
||||||
6. `lazyConfigs` - `lz.n` and `lzn-auto-require` configs. If `vim.lazy.enable`
|
6. `lazyConfigs` - `lz.n` and `lzn-auto-require` configs. If `vim.lazy.enable`
|
||||||
is false, this will contain each plugin's config instead.
|
is false, this will contain each plugin's config instead.
|
||||||
7. `pluginConfigs` - the result of the nested `vim.pluginRC` (internal option,
|
7. `pluginConfigs` - the result of the nested `vim.pluginRC` (internal option,
|
||||||
|
|
|
@ -11,8 +11,6 @@
|
||||||
inherit (self.options.vim.comments.comment-nvim) mappings;
|
inherit (self.options.vim.comments.comment-nvim) mappings;
|
||||||
in {
|
in {
|
||||||
config = mkIf cfg.enable {
|
config = mkIf cfg.enable {
|
||||||
vim.startPlugins = ["comment-nvim"];
|
|
||||||
|
|
||||||
vim.lazy.plugins.comment-nvim = {
|
vim.lazy.plugins.comment-nvim = {
|
||||||
package = "comment-nvim";
|
package = "comment-nvim";
|
||||||
setupModule = "Comment";
|
setupModule = "Comment";
|
||||||
|
|
|
@ -41,13 +41,13 @@ in {
|
||||||
package = "nvim-cmp";
|
package = "nvim-cmp";
|
||||||
after = ''
|
after = ''
|
||||||
${optionalString luasnipEnable "local luasnip = require('luasnip')"}
|
${optionalString luasnipEnable "local luasnip = require('luasnip')"}
|
||||||
require("lz.n").trigger_load("cmp-path")
|
|
||||||
local cmp = require("cmp")
|
local cmp = require("cmp")
|
||||||
cmp.setup(${toLuaObject cfg.setupOpts})
|
cmp.setup(${toLuaObject cfg.setupOpts})
|
||||||
|
|
||||||
${concatStringsSep "\n" (map
|
${optionalString config.vim.lazy.enable
|
||||||
|
(concatStringsSep "\n" (map
|
||||||
(package: "require('lz.n').trigger_load(${toLuaObject (getPluginName package)})")
|
(package: "require('lz.n').trigger_load(${toLuaObject (getPluginName package)})")
|
||||||
cfg.sourcePlugins)}
|
cfg.sourcePlugins))}
|
||||||
'';
|
'';
|
||||||
|
|
||||||
event = ["InsertEnter" "CmdlineEnter"];
|
event = ["InsertEnter" "CmdlineEnter"];
|
||||||
|
@ -74,10 +74,9 @@ in {
|
||||||
};
|
};
|
||||||
|
|
||||||
formatting.format = cfg.format;
|
formatting.format = cfg.format;
|
||||||
};
|
|
||||||
|
|
||||||
# `cmp` and `luasnip` are defined above, in the `nvim-cmp` section
|
# `cmp` and `luasnip` are defined above, in the `nvim-cmp` section
|
||||||
setupOpts.mapping = {
|
mapping = {
|
||||||
${mappings.complete} = mkLuaInline "cmp.mapping.complete()";
|
${mappings.complete} = mkLuaInline "cmp.mapping.complete()";
|
||||||
${mappings.close} = mkLuaInline "cmp.mapping.abort()";
|
${mappings.close} = mkLuaInline "cmp.mapping.abort()";
|
||||||
${mappings.scrollDocsUp} = mkLuaInline "cmp.mapping.scroll_docs(-4)";
|
${mappings.scrollDocsUp} = mkLuaInline "cmp.mapping.scroll_docs(-4)";
|
||||||
|
@ -122,4 +121,5 @@ in {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -116,7 +116,60 @@ in {
|
||||||
end
|
end
|
||||||
|
|
||||||
local capabilities = vim.lsp.protocol.make_client_capabilities()
|
local capabilities = vim.lsp.protocol.make_client_capabilities()
|
||||||
-- ${optionalString usingNvimCmp "capabilities = require('cmp_nvim_lsp').default_capabilities()"}
|
${optionalString usingNvimCmp ''
|
||||||
|
-- HACK: copied from cmp-nvim-lsp. If we ever lazy load lspconfig we
|
||||||
|
-- should re-evaluate whether we can just use `default_capabilities`
|
||||||
|
capabilities = {
|
||||||
|
textDocument = {
|
||||||
|
completion = {
|
||||||
|
dynamicRegistration = false,
|
||||||
|
completionItem = {
|
||||||
|
snippetSupport = true,
|
||||||
|
commitCharactersSupport = true,
|
||||||
|
deprecatedSupport = true,
|
||||||
|
preselectSupport = true,
|
||||||
|
tagSupport = {
|
||||||
|
valueSet = {
|
||||||
|
1, -- Deprecated
|
||||||
|
}
|
||||||
|
},
|
||||||
|
insertReplaceSupport = true,
|
||||||
|
resolveSupport = {
|
||||||
|
properties = {
|
||||||
|
"documentation",
|
||||||
|
"detail",
|
||||||
|
"additionalTextEdits",
|
||||||
|
"sortText",
|
||||||
|
"filterText",
|
||||||
|
"insertText",
|
||||||
|
"textEdit",
|
||||||
|
"insertTextFormat",
|
||||||
|
"insertTextMode",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
insertTextModeSupport = {
|
||||||
|
valueSet = {
|
||||||
|
1, -- asIs
|
||||||
|
2, -- adjustIndentation
|
||||||
|
}
|
||||||
|
},
|
||||||
|
labelDetailsSupport = true,
|
||||||
|
},
|
||||||
|
contextSupport = true,
|
||||||
|
insertTextMode = 1,
|
||||||
|
completionList = {
|
||||||
|
itemDefaults = {
|
||||||
|
'commitCharacters',
|
||||||
|
'editRange',
|
||||||
|
'insertTextFormat',
|
||||||
|
'insertTextMode',
|
||||||
|
'data',
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
''}
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -66,7 +66,7 @@ in {
|
||||||
config = mkIf cfg.enable {
|
config = mkIf cfg.enable {
|
||||||
vim = {
|
vim = {
|
||||||
startPlugins = [cfg.name];
|
startPlugins = [cfg.name];
|
||||||
luaConfigRC.theme = entryBefore ["pluginConfigs"] ''
|
luaConfigRC.theme = entryBefore ["pluginConfigs" "lazyConfigs"] ''
|
||||||
${cfg.extraConfig}
|
${cfg.extraConfig}
|
||||||
${supportedThemes.${cfg.name}.setup {inherit (cfg) style transparent base16-colors;}}
|
${supportedThemes.${cfg.name}.setup {inherit (cfg) style transparent base16-colors;}}
|
||||||
'';
|
'';
|
||||||
|
|
|
@ -11,7 +11,6 @@
|
||||||
inherit (lib.nvim.dag) entryBefore entryAfter;
|
inherit (lib.nvim.dag) entryBefore entryAfter;
|
||||||
|
|
||||||
cfg = config.vim.treesitter;
|
cfg = config.vim.treesitter;
|
||||||
usingNvimCmp = config.vim.autocomplete.nvim-cmp.enable;
|
|
||||||
|
|
||||||
self = import ./treesitter.nix {inherit pkgs lib;};
|
self = import ./treesitter.nix {inherit pkgs lib;};
|
||||||
mappingDefinitions = self.options.vim.treesitter.mappings;
|
mappingDefinitions = self.options.vim.treesitter.mappings;
|
||||||
|
@ -21,17 +20,6 @@ in {
|
||||||
vim = {
|
vim = {
|
||||||
startPlugins = ["nvim-treesitter"];
|
startPlugins = ["nvim-treesitter"];
|
||||||
|
|
||||||
lazy.plugins = {
|
|
||||||
cmp-treesitter = mkIf usingNvimCmp {
|
|
||||||
package = "cmp-treesitter";
|
|
||||||
after = ''
|
|
||||||
local path = vim.fn.globpath(vim.o.packpath, 'pack/*/opt/cmp-treesitter')
|
|
||||||
require("rtp_nvim").source_after_plugin_dir(path)
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
nvim-cmp.after = mkIf usingNvimCmp "require('lz.n').trigger_load('cmp-treesitter')";
|
|
||||||
};
|
|
||||||
|
|
||||||
autocomplete.nvim-cmp = {
|
autocomplete.nvim-cmp = {
|
||||||
sources = {treesitter = "[Treesitter]";};
|
sources = {treesitter = "[Treesitter]";};
|
||||||
sourcePlugins = ["cmp-treesitter"];
|
sourcePlugins = ["cmp-treesitter"];
|
||||||
|
|
Loading…
Reference in a new issue