aboutsummaryrefslogtreecommitdiff
path: root/runtime/lua/vim/highlight.lua
Commit message (Collapse)AuthorAge
* refactor: rename vim.highlight => vim.hlJustin M. Keyes2024-10-21
| | | | | | | | | | | | Problem: - `vim.highlight` module does not follow `:help dev-name-common`, which documents the name for "highlight" as "hl". - Shorter names are usually preferred. Solution: Rename `vim.highlight` to `vim.hl`. This is not a breaking change until 2.0 (or maybe never).
* refactor: use `vim._with` where possibledundargoc2024-06-28
| | | | | This mostly means replacing `nvim_buf_call` and `nvim_win_call` with `vim._with`.
* feat: get/set namespace properties #28728altermo2024-06-07
| | | | ref https://github.com/neovim/neovim/pull/28432 ref https://github.com/neovim/neovim/issues/28469
* fix(lua): don't clamp -1 or v:maxcol in vim.highlight.range() (#29203)zeertzjq2024-06-05
|
* refactor(lua): rewrite vim.highlight.range() (#28986)zeertzjq2024-05-25
| | | | - Use getregionpos(). - Use a single extmark for non-blockwise selection.
* refactor(api): nvim_win_xx_ns are EXPERIMENTALJustin M. Keyes2024-05-12
| | | | | | | | | | | | | | | | | Problem: The nvim_win_xx_ns function family introduced in ba0370b1d718d473d0ef51c35d88b98ba220082b needs more bake-time. Currently it's narrowly defined for windows, but other scopes ("buffer") and features are likely in the future. Solution: - Rename the API with double-underscore to mark it as EXPERIMENTAL. TODO/FUTURE: - Rename and change the signature to support more than just "window" scope, and for other flexibility. - Open question: we could choose either: - "store scopes on namespaces", or - "store namespaces on scopes (w:/b:/…)"
* refactor(api): rename nvim_win_remove_nsJustin M. Keyes2024-05-12
| | | | | | | | Problem: nvim_win_remove_ns does not follow `help dev-naming` API naming conventions. Solution: Rename it.
* perf(extmarks): better track whether namespace has extmarks (#28615)zeertzjq2024-05-03
| | | | | | This avoids redraw when adding/removing an empty namespace for a window. This also avoids marktree traversal when clearing a namespace that has already been cleared, which is added as a benchmark.
* docs: misc #24163Justin M. Keyes2024-04-30
| | | | | | | | | | - Also delete old perl scripts which are not used since 8+ years ago. fix #23251 fix #27367 ref https://github.com/neovim/neovim/issues/2252#issuecomment-1902662577 Helped-by: Daniel Kongsgaard <dakongsgaard@gmail.com> Co-authored-by: Kevin Pham <keevan.pham@gmail.com>
* refactor(lua): type annotationsLewis Russell2024-03-16
|
* feat(docs): replace lua2dox.luaLewis Russell2024-02-27
| | | | | | | | | | | | | | | | | | | | | | | | | | Problem: The documentation flow (`gen_vimdoc.py`) has several issues: - it's not very versatile - depends on doxygen - doesn't work well with Lua code as it requires an awkward filter script to convert it into pseudo-C. - The intermediate XML files and filters makes it too much like a rube goldberg machine. Solution: Re-implement the flow using Lua, LPEG and treesitter. - `gen_vimdoc.py` is now replaced with `gen_vimdoc.lua` and replicates a portion of the logic. - `lua2dox.lua` is gone! - No more XML files. - Doxygen is now longer used and instead we now use: - LPEG for comment parsing (see `scripts/luacats_grammar.lua` and `scripts/cdoc_grammar.lua`). - LPEG for C parsing (see `scripts/cdoc_parser.lua`) - Lua patterns for Lua parsing (see `scripts/luacats_parser.lua`). - Treesitter for Markdown parsing (see `scripts/text_utils.lua`). - The generated `runtime/doc/*.mpack` files have been removed. - `scripts/gen_eval_files.lua` now instead uses `scripts/cdoc_parser.lua` directly. - Text wrapping is implemented in `scripts/text_utils.lua` and appears to produce more consistent results (the main contributer to the diff of this change).
* fix(lua): make highlight.on_yank use win-local highlight (#27349)altermo2024-02-22
| | | | | | | | Currently, highlight.on_yank() does buffer-local highlighting, this PR makes it window scoped. Also fix the problem that when yanking in a buffer, moving to another buffer, and yanking before the original buffer highlight disappears, the original buffer highlight won't disappear on timeout.
* docs: enforce "treesitter" spelling #27110Jongwook Choi2024-01-28
| | | It's the "tree-sitter" project, but "treesitter" in our code and docs.
* docs: replace <pre> with ``` (#25136)Gregory Anders2023-09-14
|
* feat(extmark): support proper multiline rangesbfredl2023-09-12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The removes the previous restriction that nvim_buf_set_extmark() could not be used to highlight arbitrary multi-line regions The problem can be summarized as follows: let's assume an extmark with a hl_group is placed covering the region (5,0) to (50,0) Now, consider what happens if nvim needs to redraw a window covering the lines 20-30. It needs to be able to ask the marktree what extmarks cover this region, even if they don't begin or end here. Therefore the marktree needs to be augmented with the information covers a point, not just what marks begin or end there. To do this, we augment each node with a field "intersect" which is a set the ids of the marks which overlap this node, but only if it is not part of the set of any parent. This ensures the number of nodes that need to be explicitly marked grows only logarithmically with the total number of explicitly nodes (and thus the number of of overlapping marks). Thus we can quickly iterate all marks which overlaps any query position by looking up what leaf node contains that position. Then we only need to consider all "start" marks within that leaf node, and the "intersect" set of that node and all its parents. Now, and the major source of complexity is that the tree restructuring operations (to ensure that each node has T-1 <= size <= 2*T-1) also need to update these sets. If a full inner node is split in two, one of the new parents might start to completely overlap some ranges and its ids will need to be moved from its children's sets to its own set. Similarly, if two undersized nodes gets joined into one, it might no longer completely overlap some ranges, and now the children which do needs to have the have the ids in its set instead. And then there are the pivots! Yes the pivot operations when a child gets moved from one parent to another.
* docs(lua): more improvements (#24387)Lewis Russell2023-07-18
| | | | | | | | | | | | | | | | | * docs(lua): teach lua2dox how to table * docs(lua): teach gen_vimdoc.py about local functions No more need to mark local functions with @private * docs(lua): mention @nodoc and @meta in dev-lua-doc * fixup! Co-authored-by: Justin M. Keyes <justinkz@gmail.com> --------- Co-authored-by: Justin M. Keyes <justinkz@gmail.com>
* docs(lua): change *lua-foo* -> *vim.foo*Lewis Russell2023-07-17
|
* docs(lua): move function docs to lua filesLewis Russell2023-07-17
|
* feat(lua): add hl priority opts on yank (#23509)marcoSven2023-05-06
| | | | | feat(lua): add hl priority opts on_yank Signed-off-by: marcoSven <me@marcosven.com>
* feat(lua): vim.region accepts getpos() arg (#22635)NAKAI Tsuyoshi2023-04-11
|
* refactor(highlight)!: remove deprecated functionsnullchilly2023-03-11
| | | | vim.highlight.create/link
* docs(highlight): fix type annotations (#22272)Jaehwang Jung2023-03-04
|
* feat(lsp): initial support for semantic token highlightingJohn Drouhard2022-12-08
| | | | | | * credit to @smolck and @theHamsta for their contributions in laying the groundwork for this feature and for their work on some of the helper utility functions and tests
* fix(docs): invalid :help links #20345Justin M. Keyes2022-09-25
| | | | | Fix those naughty single quotes. closes #20159
* refactor(lua): replace vim.cmd use with API calls (#19283)Raphael2022-07-09
| | | Signed-off-by: Raphael <glephunter@gmail.com>
* refactor(lua): reformat with stylua 0.14.0 (#19264)Christian Clason2022-07-07
| | | | * reformat Lua runtime to make lint CI pass * reduce max line length to 100
* fix(lua): stop pending highlight.on_yank timer, if any (#18824)Wsevolod2022-06-02
| | | | | When yanking another range while previous yank is still highlighted, the pending timer could clear the highlight almost immediately (especially when using larger `timeout`, i.e. 2000)
* chore: format runtime with styluaChristian Clason2022-05-09
|
* refactor(highlight)!: optional arguments for highlight.range as table (#17462)Christian Clason2022-02-21
| | | | | | | | | also update documentation BREAKING CHANGE: signature of highlight.range is now vim.highlight.range(bufnr, ns, hlgroup, start, finish, { regtype = regtype, inclusive = inclusive, priority = priority }) Co-authored-by: Gregory Anders <8965202+gpanders@users.noreply.github.com>
* feat: use nvim_buf_set_extmark for vim.highlight (#16963)Michael Lingelbach2022-01-15
| | | | | | | | | Closes https://github.com/neovim/neovim/issues/13647 This allows customizing the priority of the highlights. * Add default priority of 50 * Use priority of 200 for highlight on yank * use priority of 40 for highlight references (LSP)
* fix(lua): verify buffer in highlight.on_yank (#15482)notomo2021-08-26
| | | | | Resolve an issue with deferred clearing of highlight failing if the buffer is deleted before the timeout by checking whether the buffer is valid first.
* docs: make Lua docstrings consistent #15255Gregory Anders2021-08-22
| | | | | | | | | | | | The official developer documentation in in :h dev-lua-doc specifies to use "--@" for special/magic tokens. However, this format is not consistent with EmmyLua notation (used by some Lua language servers) nor with the C version of the magic docstring tokens which use three comment characters. Further, the code base is currently split between usage of "--@", "---@", and "--- @". In an effort to remain consistent, change all Lua magic tokens to use "---@" and update the developer documentation accordingly.
* lsp: vim.lsp.diagnostic (#12655)TJ DeVries2020-11-12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Breaking Changes: - Deprecated all `vim.lsp.util.{*diagnostics*}()` functions. - Instead, all functions must be found in vim.lsp.diagnostic - For now, they issue a warning ONCE per neovim session. In a "little while" we will remove them completely. - `vim.lsp.callbacks` has moved to `vim.lsp.handlers`. - For a "little while" we will just redirect `vim.lsp.callbacks` to `vim.lsp.handlers`. However, we will remove this at some point, so it is recommended that you change all of your references to `callbacks` into `handlers`. - This also means that for functions like |vim.lsp.start_client()| and similar, keyword style arguments have moved from "callbacks" to "handlers". Once again, these are currently being forward, but will cease to be forwarded in a "little while". - Changed the highlight groups for LspDiagnostic highlight as they were inconsistently named. - For more information, see |lsp-highlight-diagnostics| - Changed the sign group names as well, to be consistent with |lsp-highlight-diagnostics| General Enhancements: - Rewrote much of the getting started help document for lsp. It also provides a much nicer configuration strategy, so as to not recommend globally overwriting builtin neovim mappings. LSP Enhancements: - Introduced the concept of |lsp-handlers| which will allow much better customization for users without having to copy & paste entire files / functions / etc. Diagnostic Enhancements: - "goto next diagnostic" |vim.lsp.diagnostic.goto_next()| - "goto prev diagnostic" |vim.lsp.diagnostic.goto_prev()| - For each of the gotos, auto open diagnostics is available as a configuration option - Configurable diagnostic handling: - See |vim.lsp.diagnostic.on_publish_diagnostics()| - Delay display until after insert mode - Configure signs - Configure virtual text - Configure underline - Set the location list with the buffers diagnostics. - See |vim.lsp.diagnostic.set_loclist()| - Better performance for getting counts and line diagnostics - They are now cached on save, to enhance lookups. - Particularly useful for checking in statusline, etc. - Actual testing :) - See ./test/functional/plugin/lsp/diagnostic_spec.lua - Added `guisp` for underline highlighting NOTE: "a little while" means enough time to feel like most plugins and plugin authors have had a chance to refactor their code to use the updated calls. Then we will remove them completely. There is no need to keep them, because we don't have any released version of neovim that exposes these APIs. I'm trying to be nice to people following HEAD :) Co-authored: [Twitch Chat 2020](https://twitch.tv/teej_dv)
* fix(highlight): compare rows vs columns in range highlight check (#12852)Steven Sojka2020-09-05
|
* lua: add options to highlight.on_yank (#12549)Christian Clason2020-07-05
| | | | | NOTE: Configuration options have changed for highlight.on_yank. Check help for |:help highlight.on_yank()|
* lua: add vim.highlight.range (#12401)Christian Clason2020-05-31
|
* lua: Add highlight.on_yank (#12279)Christian Clason2020-05-18
* add lua function to highlight yanked region * extract namespace, better naming, default values * add default for event argument * free timer * factor out mark to position calculation * d'oh * make sure timer stops before callback (cf. luv example) * factor out timer, more documentation * fixup * validate function argument for schedule * fix block selection past eol * correct handling of multibyte characters * move arguments around, some cleanup * move utility functions to vim.lua * use anonymous namespaces, avoid local api * rename function * add test for schedule_fn * fix indent * turn hl-yank into proper (hightlight) module * factor out position-to-region function mark extraction now part of highlight.on_yank * rename schedule_fn to defer_fn * add test for vim.region * todo: handle double-width characters * remove debug printout * do not shadow arguments * defer also callable table * whitespace change * move highlight to vim/highlight.lua * add documentation * add @return documentation * test: add check before vim.defer fires * doc: fixup