nix-community.nixvim/plugins/languages/treesitter/treesitter-context.nix

89 lines
2.5 KiB
Nix
Raw Normal View History

{
lib,
helpers,
config,
pkgs,
...
}:
with lib; let
cfg = config.plugins.treesitter-context;
in {
options.plugins.treesitter-context =
helpers.extraOptionsOptions
// {
enable = mkEnableOption "nvim-treesitter-context";
package = helpers.mkPackageOption "nvim-treesitter-context" pkgs.vimPlugins.nvim-treesitter-context;
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
maxLines = helpers.defaultNullOpts.mkUnsignedInt 0 ''
How many lines the window should span. 0 means no limit.
'';
minWindowHeight = helpers.defaultNullOpts.mkUnsignedInt 0 ''
Minimum editor window height to enable context. 0 means no limit.
'';
lineNumbers = helpers.defaultNullOpts.mkBool true ''
Whether to show line numbers.
'';
multilineThreshold = helpers.defaultNullOpts.mkUnsignedInt 20 ''
Maximum number of lines to collapse for a single context line.
'';
trimScope = helpers.defaultNullOpts.mkEnumFirstDefault ["outer" "inner"] ''
Which context lines to discard if `maxLines` is exceeded.
'';
mode = helpers.defaultNullOpts.mkEnumFirstDefault ["cursor" "topline"] ''
Line used to calculate context.
'';
separator = helpers.mkNullOrOption types.str ''
Separator between context and content.
Should be a single character string, like "-".
When separator is set, the context will only show up when there are at least 2 lines above
cursorline.
'';
zindex = helpers.defaultNullOpts.mkUnsignedInt 20 ''
The Z-index of the context window.
'';
onAttach = helpers.mkNullOrOption types.str ''
The implementation of a lua function which takes an integer `buf` as parameter and returns a
boolean.
Return `false` to disable attaching.
'';
};
config = let
setupOptions = with cfg;
{
max_lines = maxLines;
min_window_height = minWindowHeight;
line_numbers = lineNumbers;
multiline_threshold = multilineThreshold;
trim_scope = trimScope;
inherit
mode
separator
zindex
;
on_attach = helpers.mkRaw onAttach;
}
// cfg.extraOptions;
in
mkIf cfg.enable {
warnings = mkIf (!config.plugins.treesitter.enable) [
"Nixvim: treesitter-context needs treesitter to function as intended"
];
extraPlugins = [cfg.package];
extraConfigLua = ''
require('treesitter-context').setup(${helpers.toLuaObject setupOptions})
'';
};
}