mirror of
https://github.com/neovim/neovim.git
synced 2026-06-15 16:23:48 +00:00
feat(pos): create a cursor position by using the current of a window
Problem: `vim.pos.cursor(vim.api.nvim_get_current_buf(win), vim.api.nvim_win_get_cursor(win))` is too verbose to create a cursor position of a window, but it is a common use case. Solution: Overload `vim.pos.cursor()`, so that it accepts `win` as an argument when `pos` is omitted.
This commit is contained in:
@@ -51,7 +51,7 @@ local function ctx_is_valid(ctx)
|
||||
return false
|
||||
end
|
||||
|
||||
local cur_pos = vim.pos.cursor(bufnr, api.nvim_win_get_cursor(0))
|
||||
local cur_pos = vim.pos.cursor(0)
|
||||
local pos = vim.pos.lsp(bufnr, p, enc)
|
||||
return cur_pos == pos
|
||||
end
|
||||
@@ -222,7 +222,7 @@ local function get_locations(method, context, opts)
|
||||
)
|
||||
end
|
||||
|
||||
local pos = opts.pos or vim.pos.cursor(0, api.nvim_win_get_cursor(0))
|
||||
local pos = opts.pos or vim.pos.cursor(0)
|
||||
local buf = pos.buf
|
||||
|
||||
local clients = lsp.get_clients({ method = method, bufnr = buf })
|
||||
|
||||
Reference in New Issue
Block a user