-
-
Notifications
You must be signed in to change notification settings - Fork 297
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
plugins/lazydev: init #2774
Merged
Merged
plugins/lazydev: init #2774
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,167 @@ | ||
{ config, lib, ... }: | ||
let | ||
inherit (lib) types; | ||
inherit (lib.nixvim) | ||
defaultNullOpts | ||
literalLua | ||
mkNullOrOption' | ||
nestedLiteralLua | ||
; | ||
in | ||
lib.nixvim.plugins.mkNeovimPlugin { | ||
name = "lazydev"; | ||
packPathName = "lazydev.nvim"; | ||
package = "lazydev-nvim"; | ||
|
||
maintainers = [ lib.maintainers.HeitorAugustoLN ]; | ||
|
||
description = '' | ||
### lazydev.nvim as a blink.cmp source | ||
|
||
```nix | ||
{ | ||
plugins = { | ||
lazydev.enable = true; | ||
|
||
blink-cmp.settings = { | ||
sources.providers = { | ||
lazydev = { | ||
name = "LazyDev"; | ||
module = "lazydev.integrations.blink"; | ||
# make lazydev completions top priority (see `:h blink.cmp`) | ||
score_offset = 100; | ||
}; | ||
}; | ||
}; | ||
}; | ||
} | ||
``` | ||
''; | ||
|
||
settingsOptions = | ||
let | ||
libraryType = types.submodule { | ||
freeformType = with types; attrsOf anything; | ||
options = { | ||
files = mkNullOrOption' { | ||
type = with types; listOf str; | ||
example = [ "xmake.lua" ]; | ||
description = "A list of files that triggers the library to be loaded when required."; | ||
}; | ||
mods = mkNullOrOption' { | ||
type = with types; listOf str; | ||
example = [ "wezterm" ]; | ||
description = "A list of modules that triggers the library to be loaded when required."; | ||
}; | ||
path = lib.mkOption { | ||
type = types.str; | ||
example = "~/projects/my-awesome-lib"; | ||
description = "The path to the library."; | ||
}; | ||
words = mkNullOrOption' { | ||
type = with types; listOf str; | ||
example = [ | ||
"wezterm" | ||
"LazyVim" | ||
]; | ||
description = "A list of words that triggers the library to be loaded."; | ||
}; | ||
}; | ||
}; | ||
in | ||
{ | ||
enabled = | ||
defaultNullOpts.mkBool | ||
(literalLua '' | ||
function(root_dir) | ||
return vim.g.lazydev_enabled == nil and true or vim.g.lazydev_enabled | ||
end | ||
'') | ||
'' | ||
Whether lazydev.nvim is enabled. | ||
''; | ||
|
||
integrations = { | ||
cmp = defaultNullOpts.mkBool true '' | ||
Whether lazydev.nvim should integrate with nvim-cmp. | ||
|
||
Adds a completion source for: | ||
- `require "modname"` | ||
- `---@module "modname"` | ||
''; | ||
|
||
coq = defaultNullOpts.mkBool false '' | ||
Whether lazydev.nvim should integrate with coq.nvim. | ||
|
||
Adds a completion source for: | ||
- `require "modname"` | ||
- `---@module "modname"` | ||
''; | ||
|
||
lspconfig = defaultNullOpts.mkBool true '' | ||
Whether lazydev.nvim should integrate with nvim-lspconfig. | ||
|
||
Fixes lspconfig's workspace management for LuaLS. | ||
Only create a new workspace if the buffer is not part | ||
of an existing workspace or one of its libraries. | ||
''; | ||
}; | ||
|
||
library = defaultNullOpts.mkListOf (with types; either str libraryType) [ ] '' | ||
A list of libraries for lazydev.nvim. | ||
''; | ||
|
||
runtime = defaultNullOpts.mkStr (literalLua "vim.env.VIMRUNTIME") '' | ||
The runtime path of the current Neovim instance. | ||
''; | ||
}; | ||
|
||
settingsExample = { | ||
enabled = nestedLiteralLua '' | ||
function(root_dir) | ||
return vim.g.lazydev_enabled == nil and true or vim.g.lazydev_enabled | ||
end | ||
''; | ||
library = [ | ||
"~/projects/my-awesome-lib" | ||
"lazy.nvim" | ||
"LazyVim" | ||
{ | ||
path = "LazyVim"; | ||
words = [ "LazyVim" ]; | ||
} | ||
]; | ||
runtime = nestedLiteralLua "vim.env.VIMRUNTIME"; | ||
}; | ||
|
||
extraConfig = cfg: { | ||
warnings = | ||
lib.optionals | ||
( | ||
builtins.isBool cfg.settings.integrations.cmp | ||
&& !config.plugins.cmp.enable | ||
&& cfg.settings.integrations.cmp | ||
) | ||
[ "Nixvim(plugins.lazydev): you have enabled nvim-cmp integration but plugins.cmp is not enabled." ] | ||
++ | ||
lib.optionals | ||
( | ||
builtins.isBool cfg.settings.integrations.lspconfig | ||
&& !config.plugins.lsp.enable | ||
&& cfg.settings.integrations.lspconfig | ||
) | ||
[ | ||
"Nixvim(plugins.lazydev): you have enabled lspconfig integration but plugins.lsp is not enabled." | ||
] | ||
++ | ||
lib.optionals | ||
( | ||
builtins.isBool cfg.settings.integrations.coq | ||
&& !config.plugins.coq-nvim.enable | ||
&& cfg.settings.integrations.coq | ||
) | ||
[ | ||
"Nixvim(plugins.lazydev): you have enabled coq integration but plugins.coq-nvim is not enabled." | ||
]; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
{ | ||
empty = { | ||
plugins.lazydev.enable = true; | ||
}; | ||
|
||
defaults = { | ||
plugins = { | ||
cmp.enable = true; | ||
|
||
lazydev = { | ||
enable = true; | ||
|
||
settings = { | ||
enabled.__raw = '' | ||
function(root_dir) | ||
return vim.g.lazydev_enabled == nil and true or vim.g.lazydev_enabled | ||
end | ||
''; | ||
integrations = { | ||
lspconfig = true; | ||
cmp = true; | ||
coq = false; | ||
}; | ||
library.__raw = "{}"; | ||
runtime.__raw = "vim.env.VIMRUNTIME"; | ||
}; | ||
}; | ||
|
||
lsp.enable = true; | ||
}; | ||
}; | ||
|
||
example = { | ||
plugins.lazydev = { | ||
enable = true; | ||
|
||
settings = { | ||
enabled.__raw = '' | ||
function(root_dir) | ||
return vim.g.lazydev_enabled == nil and true or vim.g.lazydev_enabled | ||
end | ||
''; | ||
library = [ | ||
"~/projects/my-awesome-lib" | ||
"lazy.nvim" | ||
"LazyVim" | ||
{ | ||
path = "LazyVim"; | ||
words = [ "LazyVim" ]; | ||
} | ||
]; | ||
runtime.__raw = "vim.env.VIMRUNTIME"; | ||
}; | ||
}; | ||
}; | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we (mostly) put a space there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At least on blink-cmp there is not:
nixvim/plugins/by-name/blink-cmp/default.nix
Line 45 in 0ebc64a
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know which formatting we prefer, but we're definitely not very consistent about it currently! 🙈
I'll hold my hands up to contributing some of the inconsistency on this, too.
If we really want to be consistent, we probably need some systematic method of achieving that...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes...