mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-20 16:15:43 +02:00
plugins/lsp-signature: init
This commit is contained in:
parent
13564727c5
commit
c32a43a862
2 changed files with 294 additions and 0 deletions
212
plugins/by-name/lsp-signature/default.nix
Normal file
212
plugins/by-name/lsp-signature/default.nix
Normal file
|
@ -0,0 +1,212 @@
|
|||
{ lib, helpers, ... }:
|
||||
let
|
||||
inherit (lib.nixvim) defaultNullOpts;
|
||||
in
|
||||
lib.nixvim.neovim-plugin.mkNeovimPlugin {
|
||||
name = "lsp-signature";
|
||||
originalName = "lsp_signature.nvim";
|
||||
package = "lsp_signature-nvim";
|
||||
luaName = "lsp_signature";
|
||||
|
||||
maintainers = [ lib.maintainers.wadsaek ];
|
||||
|
||||
settingsOptions = {
|
||||
debug = defaultNullOpts.mkBool false ''
|
||||
Whether to enable debug logging.
|
||||
'';
|
||||
|
||||
log_path =
|
||||
defaultNullOpts.mkStr
|
||||
(lib.nixvim.mkRaw # lua
|
||||
''
|
||||
vim.fn.stdpath("cache") .. "/lsp_signature.log"
|
||||
''
|
||||
)
|
||||
''
|
||||
Log directory for when debug is on.
|
||||
Default is `~/.cache/nvim/lsp_signature.log`.
|
||||
'';
|
||||
|
||||
verbose = defaultNullOpts.mkBool false ''
|
||||
Whether to show the debug line number.
|
||||
'';
|
||||
|
||||
bind = defaultNullOpts.mkBool true ''
|
||||
This is mandatory, otherwise border config won't get registered.
|
||||
If you want to hook lspsaga or other signature handler, please set to false.
|
||||
'';
|
||||
|
||||
doc_lines = defaultNullOpts.mkUnsignedInt 10 ''
|
||||
Will show two lines of comment/doc(if there are more than two lines in the doc, will be truncated).
|
||||
|
||||
Set to zero if you DO NOT want any API comments be shown.
|
||||
This setting only take effect in insert mode, it does not affect signature help in nornal mode.
|
||||
'';
|
||||
|
||||
max_height = defaultNullOpts.mkUnsignedInt 12 ''
|
||||
Maximum height of the signature floating_window.
|
||||
'';
|
||||
|
||||
max_width = defaultNullOpts.mkPositiveInt 80 ''
|
||||
Maximum height of the signature floating_window, line will be wrapped if it exceeds max_width.
|
||||
'';
|
||||
|
||||
wrap = defaultNullOpts.mkBool true ''
|
||||
Allow doc/signature text wrap inside floating_window, useful if your lsp return/sig is too long.
|
||||
'';
|
||||
|
||||
floating_window = defaultNullOpts.mkBool true ''
|
||||
Show hint in a floating window, set to false for virtual text only mode.
|
||||
'';
|
||||
|
||||
floating_window_above_cur_line = defaultNullOpts.mkBool true ''
|
||||
Whether to try to place the floating window above the current line when possible.
|
||||
|
||||
Note:
|
||||
Will set to true when fully tested, set to false will use whichever side has more space.
|
||||
This setting will be helpful if you do not want the PUM and floating win overlap.
|
||||
'';
|
||||
|
||||
floating_window_off_x = defaultNullOpts.mkStrLuaFnOr lib.types.int 1 ''
|
||||
Adjust the floating window's x position.
|
||||
'';
|
||||
|
||||
floating_window_off_y = defaultNullOpts.mkStrLuaFnOr lib.types.int 0 ''
|
||||
Adjust the floating window's y positin. e.g:
|
||||
- `-2` move window up 2 lines.
|
||||
- `2` move down 2 lines.
|
||||
'';
|
||||
|
||||
close_timeout = defaultNullOpts.mkUnsignedInt 4000 ''
|
||||
Close the floating window after ms when last parameter is entered.
|
||||
'';
|
||||
|
||||
fix_pos = defaultNullOpts.mkBool false ''
|
||||
If set to true, the floating window will not auto-close until all parameters are entered.
|
||||
'';
|
||||
|
||||
hint_enable = defaultNullOpts.mkBool true ''
|
||||
Whether to enable virtual hint.
|
||||
'';
|
||||
|
||||
hint_prefix = helpers.defaultNullOpts.mkNullable' {
|
||||
type = lib.types.anything;
|
||||
pluginDefault = "🐼 ";
|
||||
description = ''
|
||||
Panda for parameter.
|
||||
Note: for the terminal not support emoji, might crash.
|
||||
|
||||
Alternatively, you can provide a table with 3 icons.
|
||||
'';
|
||||
};
|
||||
|
||||
hint_scheme = defaultNullOpts.mkStr "String" "";
|
||||
hint_inline =
|
||||
defaultNullOpts.mkLuaFn # lua
|
||||
''
|
||||
function() return false end
|
||||
''
|
||||
''
|
||||
Should the hint be inline(nvim 0.10 only)?
|
||||
False by default.
|
||||
- Return `true` | `'inline'` to show hint inline.
|
||||
- Return `'eol'` to show hint at the end of line.
|
||||
- Return `false` to disable.
|
||||
- Return `'right_align'` to display hint right aligned in the current line.
|
||||
'';
|
||||
|
||||
hi_parameter = defaultNullOpts.mkStr "LspSignatureActiveParameter" ''
|
||||
How your parameter will be highlighted.
|
||||
'';
|
||||
|
||||
handler_opts =
|
||||
defaultNullOpts.mkAttributeSet
|
||||
{
|
||||
border = "rounded";
|
||||
}
|
||||
''
|
||||
`border` can be double, rounded, single, shadow, none or a lua table of borders.
|
||||
'';
|
||||
|
||||
always_trigger = defaultNullOpts.mkBool false ''
|
||||
Sometime show signature on new line or in middle of parameter can be confusing.
|
||||
'';
|
||||
|
||||
auto_close_after = defaultNullOpts.mkLua "nil" ''
|
||||
Autoclose signature float win after x seconds, disabled if `nil`.
|
||||
'';
|
||||
|
||||
extra_trigger_chars = defaultNullOpts.mkListOf lib.types.str [ ] ''
|
||||
Array of of extra characters that will trigger signature completion.
|
||||
'';
|
||||
|
||||
zindex = defaultNullOpts.mkInt 200 ''
|
||||
By default it will be on top of all floating windows.
|
||||
Set to <= 50 to send it to the bottom.
|
||||
'';
|
||||
|
||||
padding = defaultNullOpts.mkStr "" ''
|
||||
Character to pad on left and right of signature.
|
||||
'';
|
||||
|
||||
transparency = defaultNullOpts.mkStrLuaOr (lib.types.ints.between 1 100) "nil" ''
|
||||
Disabled by default, allow floating window transparent value 1~100.
|
||||
'';
|
||||
|
||||
shadow_blend = defaultNullOpts.mkInt 36 ''
|
||||
If you're using shadow as border, use this to set the opacity.
|
||||
'';
|
||||
|
||||
shadow_guibg = defaultNullOpts.mkStr "Green" ''
|
||||
If you're using shadow as border, use this to set the color.
|
||||
'';
|
||||
|
||||
time_interval = defaultNullOpts.mkInt 200 ''
|
||||
Timer check interval. Set to a lower value if you want to reduce latency.
|
||||
'';
|
||||
|
||||
toggle_key = defaultNullOpts.mkStr null ''
|
||||
Toggle signature on and off in insert mode.
|
||||
'';
|
||||
|
||||
toggle_flip_floatwin_setting = defaultNullOpts.mkStrLuaOr lib.types.bool false ''
|
||||
- `true`: toggle.
|
||||
- `floating_windows`: true|false setting after toggle key pressed.
|
||||
- `false`: `floating_window`'s setup will not change, `toggle_key` will pop up signature helper, but signature.
|
||||
|
||||
May not popup when typing, depending on floating_window setting.
|
||||
'';
|
||||
|
||||
select_signature_key = defaultNullOpts.mkStr null ''
|
||||
The keybind for cycling to next signature.
|
||||
'';
|
||||
|
||||
move_cursor_key = defaultNullOpts.mkStr null ''
|
||||
imap, use `nvim_set_current_win` to move cursor between current window and floating window.
|
||||
Once moved to floating window, you can use `<M-d>`, `<M-u>` to move cursor up and down.
|
||||
'';
|
||||
|
||||
# TODO: figure out the types
|
||||
keymaps = defaultNullOpts.mkListOf lib.types.anything [ ] ''
|
||||
Related to move_cursor_key.
|
||||
The keymaps inside floating window with arguements of bufnr.
|
||||
It can be a function that sets keymaps.
|
||||
`<M-d>` and `<M-u>` are default keymaps for moving the cursor up and down.
|
||||
'';
|
||||
};
|
||||
|
||||
settingsExample = {
|
||||
hint_prefix = {
|
||||
above = "↙ ";
|
||||
current = "← ";
|
||||
below = "↖ ";
|
||||
};
|
||||
extra_trigger_chars = [
|
||||
"("
|
||||
","
|
||||
];
|
||||
padding = " ";
|
||||
shadow_guibg = "#121315";
|
||||
toggle_key = "<M-x>";
|
||||
};
|
||||
}
|
82
tests/test-sources/plugins/by-name/lsp-signature/default.nix
Normal file
82
tests/test-sources/plugins/by-name/lsp-signature/default.nix
Normal file
|
@ -0,0 +1,82 @@
|
|||
{
|
||||
empty = {
|
||||
plugins.lsp-signature.enable = true;
|
||||
};
|
||||
|
||||
example = {
|
||||
plugins.lsp-signature = {
|
||||
enable = true;
|
||||
|
||||
settings = {
|
||||
debug = true;
|
||||
log_path = "~/.config/TestDirectory/lsp_signature.log";
|
||||
verbose = true;
|
||||
bind = true;
|
||||
doc_lines = 5;
|
||||
|
||||
max_height = 10;
|
||||
max_width = 45;
|
||||
wrap = false;
|
||||
floating_window = true;
|
||||
floating_window_above_cur_line = false;
|
||||
floating_window_off_x = "function() return 1 end";
|
||||
fix_pos = true;
|
||||
hint_inline = "function() return 'inline' end";
|
||||
handler_opts.border = "shadow";
|
||||
extra_trigger_chars = [ "$" ];
|
||||
|
||||
shadow_blend = 1;
|
||||
select_signature_key = "<C-c>";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
defaults = {
|
||||
plugins.lsp-signature = {
|
||||
enable = true;
|
||||
|
||||
settings = {
|
||||
debug = false;
|
||||
log_path = # lua
|
||||
''
|
||||
vim.fn.stdpath("cache") .. "/lsp_signature.log"
|
||||
'';
|
||||
verbose = false;
|
||||
bind = true;
|
||||
doc_lines = 10;
|
||||
max_height = 12;
|
||||
max_width = 80;
|
||||
wrap = true;
|
||||
floating_window = true;
|
||||
floating_window_above_cur_line = true;
|
||||
floating_window_off_x = 1;
|
||||
floating_window_off_y = 0;
|
||||
close_timeout = 4000;
|
||||
fix_pos = false;
|
||||
hint_enable = true;
|
||||
hint_prefix = "🐼 ";
|
||||
hint_scheme = "String";
|
||||
hint_inline = # lua
|
||||
''
|
||||
function() return false end
|
||||
'';
|
||||
hi_parameter = "LspSignatureActiveParameter";
|
||||
handler_opts.border = "rounded";
|
||||
always_trigger = false;
|
||||
auto_close_after = "nil";
|
||||
extra_trigger_chars = [ ];
|
||||
zindex = 200;
|
||||
padding = "";
|
||||
transparency = "nil";
|
||||
shadow_blend = 36;
|
||||
shadow_guibg = "Green";
|
||||
time_interval = 200;
|
||||
toggle_key = null;
|
||||
toggle_flip_floatwin_setting = false;
|
||||
select_signature_key = null;
|
||||
move_cursor_key = null;
|
||||
keymaps = [ ];
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue