Skip to content

Commit

Permalink
plugins/treesj: init
Browse files Browse the repository at this point in the history
Add support for treesj, a plugin that splits and joins blocks of code,
such as arrays and argument lists.

Remove package field

Co-authored-by: Gaétan Lepage <33058747+GaetanLepage@users.noreply.github.com>

Finish sentence with full stop

Co-authored-by: Gaétan Lepage <33058747+GaetanLepage@users.noreply.github.com>

Add a blank line between options

Co-authored-by: Gaétan Lepage <33058747+GaetanLepage@users.noreply.github.com>

Rename `opts` to `langs`

Shorten example settings

Add blanklines between option declarations

Add blank line between enable and settings

Co-authored-by: Gaétan Lepage <33058747+GaetanLepage@users.noreply.github.com>

Add blank line between enable and settings

Co-authored-by: Gaétan Lepage <33058747+GaetanLepage@users.noreply.github.com>

Use mkEnumFirstDefault instead of mkStr

Co-authored-by: Gaétan Lepage <33058747+GaetanLepage@users.noreply.github.com>

Use mkRaw instead of mkLuaFn

Co-authored-by: Gaétan Lepage <33058747+GaetanLepage@users.noreply.github.com>

Simplify langs option
  • Loading branch information
jolars authored and nix-infra-bot committed Jan 5, 2025
1 parent 974b1d2 commit 7896856
Show file tree
Hide file tree
Showing 2 changed files with 121 additions and 0 deletions.
57 changes: 57 additions & 0 deletions plugins/by-name/treesj/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
{ lib, ... }:
let
inherit (lib.nixvim) defaultNullOpts;
in
lib.nixvim.plugins.mkNeovimPlugin {
name = "treesj";

description = ''
A plugin for splitting/joining blocks of code like arrays,
hashes, statements, objects, dictionaries, etc.
'';

maintainers = [ lib.maintainers.jolars ];

settingsOptions = {
use_default_keymaps = defaultNullOpts.mkBool true ''
Use default keymaps (`<space>m`: toggle, `<space>j`: join, `<space>s`: split).
'';

check_syntax_error = defaultNullOpts.mkBool true ''
If true, then a node with syntax error will not be formatted.
'';

max_join_length = defaultNullOpts.mkUnsignedInt 120 ''
If true and the line after the join will be longer
than this value, the node will not be formatted.
'';

cursor_behavior = defaultNullOpts.mkEnumFirstDefault [ "hold" "start" "end" ] ''
Cursor behavior.
- `hold`: cursor follows the node/place on which it was called.
- `start`: cursor jumps to the first symbol of the node being formatted.
- `end`: cursor jumps to the last symbol of the node being formatted.
'';

notify = defaultNullOpts.mkBool true ''
Notify about possible problems or not.
'';

dot_repeat = defaultNullOpts.mkBool true ''
Use `dot` for repeat action.
'';

on_error = defaultNullOpts.mkRaw null ''
Callback for treesj error handler.
'';

langs = defaultNullOpts.mkAttrsOf lib.types.anything { } ''
Presets for languages.
'';
};

settingsExample = {
use_default_keymaps = false;
cursor_behavior = "start";
};
}
64 changes: 64 additions & 0 deletions tests/test-sources/plugins/by-name/treesj/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
{
empty = {
plugins.treesj.enable = true;
};

defaults = {
plugins.treesj = {
enable = true;

settings = {
use_default_keymaps = true;
check_syntax_error = true;
max_join_length = 120;
cursor_behavior = "hold";
notify = true;
dot_repeat = true;
on_error.__raw = "nil";
langs = { };
};
};
};

example = {
plugins.treesj = {
enable = true;

settings = {
cursor_behavior = "start";
max_join_length = 80;
dot_repeat = false;
langs = {
r = {
arguments.__raw = ''
require("treesj.langs.utils").set_preset_for_args({
both = {
separator = "comma",
},
split = {
recursive_ignore = { "subset" },
},
})
'';
parameters.__raw = ''
require("treesj.langs.utils").set_preset_for_args({
both = {
separator = "comma",
},
split = {
recursive_ignore = { "subset" },
},
})
'';
left_assignment = {
target_nodes = [
"arguments"
"parameters"
];
};
};
};
};
};
};
}

0 comments on commit 7896856

Please sign in to comment.