diff options
author | shadmansaleh <shadmansaleh3@gmail.com> | 2021-06-01 13:33:07 +0600 |
---|---|---|
committer | shadmansaleh <shadmansaleh3@gmail.com> | 2021-06-01 17:23:35 +0600 |
commit | 0bd34cb4ec301abeb751f8d3be1d3b644a009355 (patch) | |
tree | e67c2a5f0ee629bac2f8dd70ca911aed518e9596 /runtime/lua/vim/lsp/util.lua | |
parent | 27c616d688c73c406726c949a3b664f52d4e4f04 (diff) | |
download | rneovim-0bd34cb4ec301abeb751f8d3be1d3b644a009355.tar.gz rneovim-0bd34cb4ec301abeb751f8d3be1d3b644a009355.tar.bz2 rneovim-0bd34cb4ec301abeb751f8d3be1d3b644a009355.zip |
feat(lsp): Make focusability of lsp float configurable
This pr allows the user to specify whether `lsp.utils.open_floating_preview`
is focusable via the `opts` parameter. Defaults to true.
It can be configured by setting the focusable key inside opts parameter:
```lua
vim.lsp.util.open_floating_preview(contents, syntax, {focusable = false})
```
Diffstat (limited to 'runtime/lua/vim/lsp/util.lua')
-rw-r--r-- | runtime/lua/vim/lsp/util.lua | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/runtime/lua/vim/lsp/util.lua b/runtime/lua/vim/lsp/util.lua index e16b02fa6c..04f99112bf 100644 --- a/runtime/lua/vim/lsp/util.lua +++ b/runtime/lua/vim/lsp/util.lua @@ -915,6 +915,7 @@ function M.make_floating_popup_options(width, height, opts) anchor = anchor, col = col + (opts.offset_x or 0), height = height, + focusable = opts.focusable, relative = 'cursor', row = row + (opts.offset_y or 0), style = 'minimal', @@ -1316,6 +1317,7 @@ end -- - pad_bottom number of lines to pad contents at bottom -- - focus_id if a popup with this id is opened, then focus it -- - close_events list of events that closes the floating window +-- - focusable (boolean, default true): Make float focusable --@returns bufnr,winnr buffer and window number of the newly created floating ---preview window function M.open_floating_preview(contents, syntax, opts) @@ -1332,7 +1334,7 @@ function M.open_floating_preview(contents, syntax, opts) local bufnr = api.nvim_get_current_buf() -- check if this popup is focusable and we need to focus - if opts.focus_id then + if opts.focus_id and opts.focusable ~= false then -- Go back to previous window if we are in a focusable one local current_winnr = api.nvim_get_current_win() if npcall(api.nvim_win_get_var, current_winnr, opts.focus_id) then |