aboutsummaryrefslogtreecommitdiff
path: root/runtime
diff options
context:
space:
mode:
Diffstat (limited to 'runtime')
-rw-r--r--runtime/doc/change.txt8
-rw-r--r--runtime/doc/index.txt2
-rw-r--r--runtime/doc/lsp.txt22
-rw-r--r--runtime/lua/vim/lsp.lua2
-rw-r--r--runtime/lua/vim/lsp/util.lua56
5 files changed, 72 insertions, 18 deletions
diff --git a/runtime/doc/change.txt b/runtime/doc/change.txt
index b2e910a834..924401be74 100644
--- a/runtime/doc/change.txt
+++ b/runtime/doc/change.txt
@@ -1091,6 +1091,11 @@ inside of strings can change! Also see 'softtabstop' option. >
Using the mouse only works when 'mouse' contains 'n'
or 'a'.
+["x]zp or *zp* *zP*
+["x]zP Like "p" and "P", except without adding trailing spaces
+ when pasting a block. Thus the inserted text will not
+ always be a rectangle.
+
You can use these commands to copy text from one place to another. Do this
by first getting the text into a register with a yank, delete or change
command, then inserting the register contents with a put command. You can
@@ -1130,6 +1135,9 @@ a register, a paste on a visual selected area will paste that single line on
each of the selected lines (thus replacing the blockwise selected region by a
block of the pasted line).
+Use |zP|/|zp| to paste a blockwise yanked register without appending trailing
+spaces.
+
*blockwise-register*
If you use a blockwise Visual mode command to get the text into the register,
the block of text will be inserted before ("P") or after ("p") the cursor
diff --git a/runtime/doc/index.txt b/runtime/doc/index.txt
index e7d891bc33..17258f896d 100644
--- a/runtime/doc/index.txt
+++ b/runtime/doc/index.txt
@@ -851,6 +851,8 @@ tag char note action in Normal mode ~
|zm| zm subtract one from 'foldlevel'
|zn| zn reset 'foldenable'
|zo| zo open fold
+|zp| zp paste in block-mode without trailing spaces
+|zP| zP paste in block-mode without trailing spaces
|zr| zr add one to 'foldlevel'
|zs| zs when 'wrap' off scroll horizontally to
position the cursor at the start (left
diff --git a/runtime/doc/lsp.txt b/runtime/doc/lsp.txt
index d5e8db4dd7..3b8a9d94fe 100644
--- a/runtime/doc/lsp.txt
+++ b/runtime/doc/lsp.txt
@@ -1886,6 +1886,28 @@ open_floating_preview({contents}, {syntax}, {opts})
{contents} table of lines to show in window
{syntax} string of syntax to set for opened buffer
{opts} dictionary with optional fields
+ • height of floating window
+ • width of floating window
+ • wrap boolean enable wrapping of long lines
+ (defaults to true)
+ • wrap_at character to wrap at for computing
+ height when wrap is enabled
+ • max_width maximal width of floating window
+ • max_height maximal height of floating window
+ • pad_left number of columns to pad contents
+ at left
+ • pad_right number of columns to pad contents
+ at right
+ • pad_top number of lines to pad contents at
+ top
+ • 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
Return: ~
bufnr,winnr buffer and window number of the newly created
diff --git a/runtime/lua/vim/lsp.lua b/runtime/lua/vim/lsp.lua
index 93ec9ed624..5a606188dd 100644
--- a/runtime/lua/vim/lsp.lua
+++ b/runtime/lua/vim/lsp.lua
@@ -1421,7 +1421,7 @@ function lsp.omnifunc(findstart, base)
local items = {}
lsp.buf_request(bufnr, 'textDocument/completion', params, function(err, _, result)
- if err or not result then return end
+ if err or not result or vim.fn.mode() ~= "i" then return end
local matches = util.text_document_completion_list_to_complete_items(result, prefix)
-- TODO(ashkan): is this the best way to do this?
vim.list_extend(items, matches)
diff --git a/runtime/lua/vim/lsp/util.lua b/runtime/lua/vim/lsp/util.lua
index e16b02fa6c..a986bd6f81 100644
--- a/runtime/lua/vim/lsp/util.lua
+++ b/runtime/lua/vim/lsp/util.lua
@@ -44,10 +44,30 @@ local function get_border_size(opts)
height = 2
width = 2
else
- height = height + vim.fn.strdisplaywidth(border[2][1]) -- top
- height = height + vim.fn.strdisplaywidth(border[6][1]) -- bottom
- width = width + vim.fn.strdisplaywidth(border[4][1]) -- right
- width = width + vim.fn.strdisplaywidth(border[8][1]) -- left
+ local function border_width(id)
+ if type(border[id]) == "table" then
+ -- border specified as a table of <character, highlight group>
+ return vim.fn.strdisplaywidth(border[id][1])
+ elseif type(border[id]) == "string" then
+ -- border specified as a list of border characters
+ return vim.fn.strdisplaywidth(border[id])
+ end
+ error("floating preview border is not correct. Please refer to the docs |vim.api.nvim_open_win()|" .. vim.inspect(border))
+ end
+ local function border_height(id)
+ if type(border[id]) == "table" then
+ -- border specified as a table of <character, highlight group>
+ return #border[id][1] > 0 and 1 or 0
+ elseif type(border[id]) == "string" then
+ -- border specified as a list of border characters
+ return #border[id] > 0 and 1 or 0
+ end
+ error("floating preview border is not correct. Please refer to the docs |vim.api.nvim_open_win()|" .. vim.inspect(border))
+ end
+ height = height + border_height(2) -- top
+ height = height + border_height(6) -- bottom
+ width = width + border_width(4) -- right
+ width = width + border_width(8) -- left
end
return { height = height, width = width }
@@ -915,6 +935,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',
@@ -1304,18 +1325,19 @@ end
--@param contents table of lines to show in window
--@param syntax string of syntax to set for opened buffer
--@param opts dictionary with optional fields
--- - height of floating window
--- - width of floating window
--- - wrap boolean enable wrapping of long lines (defaults to true)
--- - wrap_at character to wrap at for computing height when wrap is enabled
--- - max_width maximal width of floating window
--- - max_height maximal height of floating window
--- - pad_left number of columns to pad contents at left
--- - pad_right number of columns to pad contents at right
--- - pad_top number of lines to pad contents at top
--- - 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
+--- - height of floating window
+--- - width of floating window
+--- - wrap boolean enable wrapping of long lines (defaults to true)
+--- - wrap_at character to wrap at for computing height when wrap is enabled
+--- - max_width maximal width of floating window
+--- - max_height maximal height of floating window
+--- - pad_left number of columns to pad contents at left
+--- - pad_right number of columns to pad contents at right
+--- - pad_top number of lines to pad contents at top
+--- - 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 +1354,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