aboutsummaryrefslogtreecommitdiff
path: root/runtime/lua/vim/pos.lua
Commit message (Collapse)AuthorAge
* fix(lua): enable param-type-mismatch diagnosticLewis Russell2026-09-28
| | | | | | | | | Problem: Argument type mismatches are excluded from EmmyLua checks. Solution: Correct runtime annotations and calls, document local checker workarounds, and enable the diagnostic. AI-assisted
* refactor(pos): only get current buf once #41905Eman Resu2026-09-14
| | | | This check is already performed by M.new() - there's no need to do it multiple times.
* build: enable more EmmyLua checksLewis Russell2026-09-08
| | | | | | | | | | | | | | | | - call-non-callable - missing-fields - redefined-label - redefined-local - undefined-field - unreachable-code Promote redefined-local and unreachable-code to warnings. Fix DOS line-ending handling for multiline semantic tokens, and support intersection types in the help parser. AI-assisted
* feat(pos): mutable vim.Pos, vim.Range fields #41318Olivia Kinnear2026-08-23
| | | Allow plugins to set the human-readable fields.
* feat(pos): vim.pos.cursor() without args returns curwin pos #40975Olivia Kinnear2026-07-28
|
* feat(api): optional params after `opts` #40720Justin M. Keyes2026-07-13
| | | | | | | | | | | | | | | | | | | | Problem: After 25439dad7e2b, `opts` is optional, but not params that follow it. Solution: - Update `gen_api_dispatch.lua`, docs, tests. - Enhance the `nvim_get_api_info()` api-metadata to include a boolean flag indicating whether a parameter is optional: ``` [type, name, optional] ``` Note: Currently, optional params are assumed to be Dict/Array. Since we don't yet have any use-cases of optional params following `opts`, the build just checks this assumption and we can deal with it later if we ever care to: nvim_get_hl: optional param "foo" has type "Integer" but (currently) we assume Dict/Array
* feat(pos)!: match return value of `to_cursor()` with parameters of `cursor()`Yi Ming2026-06-08
| | | | | | | | | | | Problem: - `pos.cursor()` receives a table contains `row` and `col` as arguments, but `pos:to_cursor` returns `row` and `col` directly without wrapping them in a table. - `pos.mark()`/`pos:to_mark` can already handle unpacked `row` `col`. Solution: Make `pos:to_cursor()` return a `row` and `col` in a table.
* feat(pos): create a cursor position by using the current of a windowYi Ming2026-06-08
| | | | | | | | | | 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.
* docs: misc, options, pos/rangeJustin M. Keyes2026-05-30
|
* refactor(pos,range): add missing validators and improve the docsYi Ming2026-05-20
| | | | | | | | | | | Problem: Our documentation is incomplete or inconsistent in several ways: - Some public APIs lack corresponding validators. - Some public APIs lack usage examples. - The meaning of some return values or parameters is not clearly explained. Solution: Add the missing validators, examples, and clarifications.
* refactor(pos,range): extract `vim.pos._util`Yi Ming2026-05-20
| | | | | | | | | | | Problem: - To share logic, creating a `vim.Range` currently creates two `vim.Pos` values as intermediates, which causes unnecessary table allocations. - `pos.lua` and `range.lua` contain some overlapping logic. Solution: Add `vim.pos._util`, a module for handling positions represented directly by `row` and `col`.
* feat(pos,range)!: remove `range.cursor()` and `range:to_cursor()`,Yi Ming2026-05-20
| | | | | | | | | | | | | Problem: - A window can only have one cursor, ranges selected by the cursor are typically obtained by marks like ">" and "<", instead of calling get_cursor() twice. - `vim.Range` is described as end-exclusive, but the current `range.cursor()`/`range:to_cursor()` are end-inclusive. - Conversion between `vim.Range` and mark-indexed range can be done by `range.mark()`/`range:to_mark()` Solution: Remove `range.cursor()` and `range:to_cursor()`,
* feat(pos,range): pos:to_mark(), pos.mark(), range:to_mark(), range.mark()Yi Ming2026-05-18
| | | | | | | | | Problem: Ranges represented by marks are usually end-inclusive, but the range utilities we provided are end-exclusive. Solution: Add pos:to_mark(), pos.mark(), range:to_mark(), and range.mark().
* refactor(pos): move `get_lines` from `lsp.util` to `pos`Yi Ming2026-05-16
|
* fix(pos): precisely handle positions at the end of the fileYi Ming2026-05-16
|
* feat(pos): pos:to_offset(), pos.offset() #39564Yi Ming2026-05-06
| | | | | | | | | | | | | | | | | | | Problem: For a given position, it is not easy to compare which of several other positions is closest to it. Solution: Add support for converting `vim.Pos` to a buffer byte offset. This allows for sorting, e.g: ```lua table.sort(positions, function(pos1, pos2) return pos1:to_offset() < pos2:to_offset() end ``` Or a binary search, e.g: ```lua vim.list.bisect(positions, pos, { key = function(pos) return pos:to_offset() end }) ```
* perf(vim.pos): use numeric index internally #39447Yi Ming2026-04-27
|
* feat(vim.pos): accept buf=0 for current buf #39414Luis Calle2026-04-26
|
* feat(docs): render class dot members as module functionsYi Ming2026-04-16
| | | | AI-assisted: Codex
* revert: "docs: vim.range, vim.pos #38869"Yi Ming2026-04-15
| | | | This reverts commit c530fd8e752607f57b83854b74b029eabe8d57c6.
* docs: vim.posJustin M. Keyes2026-04-12
|
* docs: vim.range, vim.pos #38869Luis Calle2026-04-08
| | | | | | | Problem: `vim.Range` and `vim.Pos` have signature mismatches on the docs of some functions. Solution: Split the "module" functions from the "class" functions (just like it's done in other modules like `vim.version`) and regenerate the docs.
* feat(vim.pos)!: require `buf` param on vim.pos, vim.range #38665Luis Calle2026-04-06
| | | | | | | Problem: `buf` is optional even though its needed to perform conversions and the ordering of `(buf, row, col)` is not consistent. Solution: make `buf` mandatory on `vim.range` and `vim.pos` and enforce the `buf, row, col` ordering
* perf(vim.pos): use `nvim_buf_line_count` instead of fetching all lines #38686Luis Calle2026-04-01
|
* docs: misc #38532Justin M. Keyes2026-03-29
| | | | | | | | | Close #38431 Close #38521 Close #38530 Co-authored-by: tayheau <thopsore@pasteur.fr> Co-authored-by: zeertzjq <zeertzjq@outlook.com> Co-authored-by: Olivia Kinnear <git@superatomic.dev>
* feat: extend vim.Pos, vim.Range #36397Luis Calle2026-03-29
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Problem: Using nested `vim.Pos` objects to represent each `vim.Range` object requires 3 tables for each `vim.Range`, which may be undesirable in performance critical code. Using key-value tables performs worse than using array-like tables (lists). Solution: Use array-like indices for the internal fields of both `vim.Pos` and `vim.Range` objects. Use a metatable to allow users to access them like if they were key-value tables. --- Problem: The `vim.Pos` conversion interface for `extmark` indexing does not take into account the difference in how a position on top of a newline is represented in `vim.Pos` and `extmark`. - `vim.Pos`: for a newline at the end of row `n`, `row` takes the value `n + 1` and `col` takes the value `0`. - `extmark`: for a newline at the end of for `n`, `row` takes the value `n` and `col` takes the value `#row_text`. Solution: Handle this in the `extmark` interface. --- Problem: Not all `to_xxx` interfaces have wrapping objects like `to_lsp`. Solution: Return unwrapped values in `to_xxx` interfaces where it makes sense. Accept unwrapped values in "from" interfaces where it makes sense. --- Problem: `start` and `end` positions have different semantics, so they can't be compared. `vim.Range` relies on comparing the `end` and `start` of two ranges to decide which one is greater, which doesn't work as expected because this of the different semantics. For example, for the ranges: local a = { start = { row = 0, col = 22, }, end_ = { row = 0, col = 24, }, } local b = { start = { row = 0, col = 17, }, end_ = { row = 0, col = 22, }, } in this code: local foo, bar = "foo", "bar" -- |---||-| -- b a The range `b` is smaller than the range `a`, but the current implementation compares `b._end` (`col = 22`) and `a.start` (`col = 22`) and concludes that, since `b.col` is not smaller than `a.col`, `b` should be greater than `a`. Solution: - Use a `to_inclusive_pos` to normalize end positions inside of `vim.Range` whenever a comparison between a start and an end position is necessary.
* Merge #33972 feat(lsp): textDocument/inlineCompletionJustin M. Keyes2025-08-24
|\
| * fix(lua): disable `strict_indexing` when converting LSP positionsYi Ming2025-08-24
| |
| * feat(lua): conversion between extmark positionsYi Ming2025-08-24
| |
| * feat(lua): conversion between cursor positionsYi Ming2025-08-24
| |
| * docs(lua): mark `vim.Pos.Optional` as optionalYi Ming2025-08-24
| |
* | docs: misc #35459Justin M. Keyes2025-08-24
|/
* feat(lua): conversion between vim and lsp position/rangeYi Ming2025-08-17
|
* feat(lua): `vim.pos`/`vim.range`Yi Ming2025-08-17