nix-community.nixvim/plugins/by-name/lspkind/default.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

63 lines
1.7 KiB
Nix
Raw Normal View History

2022-11-10 18:22:45 +00:00
{
lib,
helpers,
config,
...
}:
let
inherit (lib) types;
in
lib.nixvim.plugins.mkNeovimPlugin {
name = "lspkind";
packPathName = "lspkind.nvim";
package = "lspkind-nvim";
maintainers = [ lib.maintainers.saygo-png ];
description = "VS Code-like pictograms for Neovim LSP completion items.";
general: add package options (#127) * barbar: package option * Base16: package option * gruvbox: package option * nord: package option * one: package option * onedark: package option * tokyonight: package option * nvim-cmp: package option * coq: package option * lspkind: package option * helpers: added package option to mkPlugin * fugitive: package option * gitgutter: package option * gitsigns: package option * neogit: package option * ledger: package option * nix: package option * plantuml-syntax: package option * treesitter-context: package option + formatting * treesitter-refactor: package option + formatting * treesitter: package option * zig: package option * null-ls: package option * null-ls/servers: package option * lsp-lines: package option * lspsaga: package option * trouble: package option * luasnip: added description for package option * airline: package option * lightline: package option * lualine: package option * telescope: package option * telescope/frecency: package option * telescope/fzf-native: package option * telescope/media-files: package option * comment-nvim: package option * vim-commentary: package option * dashboard: package option * easyescape: package option * emmet: package option * endwise: package option * floaterm: package option * goyo: package option * intellitab: package option * mark-radar: package option * notify: package option * nvim-autopairs: package option * nvim-tree: package option * project-nvim: package option * specs: package option * startify: package option * surround: package option * undotree: package option
2023-01-19 10:45:15 +00:00
# The plugin does not call setup when integrating with cmp, so it has to be conditional.
callSetup = false;
2022-11-10 18:22:45 +00:00
# TODO: introduced 2025-07-16: remove after 25.11
inherit (import ./deprecations.nix lib) deprecateExtraOptions optionsRenamedToSettings;
2022-11-10 18:22:45 +00:00
extraOptions = {
cmp = {
enable = lib.mkOption {
type = types.bool;
default = true;
description = "Integrate with nvim-cmp";
};
2022-11-10 18:22:45 +00:00
after = helpers.mkNullOrOption types.str "Function to run after calculating the formatting. function(entry, vim_item, kind)";
2022-11-10 18:22:45 +00:00
};
2024-05-05 19:39:35 +02:00
};
2022-11-10 18:22:45 +00:00
extraConfig = cfg: {
assertions = lib.nixvim.mkAssertions "plugins.lspkind" {
assertion = cfg.cmp.enable -> config.plugins.cmp.enable;
message = ''
Cmp integration (cmp.enable) is enabled but the cmp plugin is not.
2022-11-10 18:22:45 +00:00
'';
};
plugins.lspkind.luaConfig.content = lib.mkIf (!cfg.cmp.enable) ''
require('lspkind').init(${lib.nixvim.toLuaObject cfg.settings})
'';
plugins.cmp.settings.formatting.format = lib.mkIf cfg.cmp.enable (
if cfg.cmp.after != null then
''
function(entry, vim_item)
local kind = require('lspkind').cmp_format(${lib.nixvim.toLuaObject cfg.settings})(entry, vim_item)
return (${cfg.cmp.after})(entry, vim_item, kind)
end
''
else
''
require('lspkind').cmp_format(${lib.nixvim.toLuaObject cfg.settings})
''
);
};
2022-11-10 18:22:45 +00:00
}