summaryrefslogtreecommitdiffstatshomepage
path: root/runtime/lua/vim/_editor.lua
AgeCommit message (Collapse)AuthorFiles
2024-04-23perf(lua): faster vim.deprecate() #28470Evgeni Chasnovski1
Problem: `vim.deprecate()` can be relatively significantly slower than the deprecated function in "Nvim" plugin. Solution: Optimize checks for "Nvim" plugin. This also results into not distinguishing "xxx-dev" and "xxx" versions when doing checks, which is essentially covered by the deprecation logic itself. With this rewrite I get the times from #28459: `{ 0.024827, 0.003797, 0.002024, 0.001774, 0.001703 }`. For quicker reference: - On current Nightly it is something like `{ 3.72243, 0.918169, 0.968143, 0.763256, 0.783424 }`. - On 0.9.5: `{ 0.002955, 0.000361, 0.000281, 0.000251, 0.00019 }`.
2024-04-18feat(lua): enable(enable:boolean, filter:table) #28374Justin M. Keyes1
Problem: We need to establish a pattern for `enable()`. Solution: - First `enable()` parameter is always `enable:boolean`. - Update `vim.diagnostic.enable()` - Update `vim.lsp.inlay_hint.enable()`. - It was not released yet, so no deprecation is needed. But to help HEAD users, it will show an informative error. - vim.deprecate(): - Improve message when the "removal version" is a *current or older* version.
2024-04-15fix(vim.ui): open() may wait indefinitely #28325Justin M. Keyes1
Problem: vim.ui.open "locks up" Nvim if the spawned process does not terminate. #27986 Solution: - Change `vim.ui.open()`: - Do not call `wait()`. - Return a `SystemObj`. The caller can decide if it wants to `wait()`. - Change `gx` to `wait()` only a short time. - Allows `gx` to show a message if the command fails, without the risk of waiting forever.
2024-03-31feat(lua): pass keys before mapping to vim.on_key() callback (#28098)zeertzjq1
Keys before mapping (i.e. typed keys) are passed as the second argument.
2024-03-10docs(editorconfig): move to sourceLewis Russell1
2024-03-09docs: support inline markdownLewis Russell1
- Tags are now created with `[tag]()` - References are now created with `[tag]` - Code spans are no longer wrapped
2024-03-09feat!: remove deprecated functionsdundargoc1
2024-03-06refactor(types): more fixesLewis Russell1
2024-03-01docs: improve/add documentation of Lua typesLewis Russell1
- Added `@inlinedoc` so single use Lua types can be inlined into the functions docs. E.g. ```lua --- @class myopts --- @inlinedoc --- --- Documentation for some field --- @field somefield integer --- @param opts myOpts function foo(opts) end ``` Will be rendered as ``` foo(opts) Parameters: - {opts} (table) Object with the fields: - somefield (integer) Documentation for some field ``` - Marked many classes with with `@nodoc` or `(private)`. We can eventually introduce these when we want to.
2024-02-27feat(docs): replace lua2dox.luaLewis Russell1
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).
2024-02-12docs: correct on_key docs (#27429)altermo1
2024-01-23test: typing for screen.luaLewis Russell1
Very rough buts resolves most diagnostic errors and should provide some useful hovers.
2024-01-19fix(vim.deprecate): show deprecation warning in devel versions as wellJongwook Choi1
Problem: On devel(nightly) versions, deprecation warnings for hard-deprecated features are not being displayed. E.g., - to be removed in: 0.11 - hard-deprecation since 0.10 - soft-deprecation since 0.9 then 0.10-nightly (0.10.0-dev) versions as well as 0.10.0 (stable) should display the deprecation warning message. Solution: Improve the code and logic on `vim.deprecate()`, and improve test cases with mocked `vim.version()`.
2024-01-17feat: add __call typing for vim.inspect()Lewis Russell1
2024-01-11fix(doc): improve doc generation of types using lpegLewis Russell1
Added a lpeg grammar for LuaCATS and use it in lua2dox.lua
2023-12-30refactor: fix luals warningsdundargoc1
2023-12-27refactor: use vim.deprecate on all deprecated functionsdundargoc1
2023-12-25feat(vim.deprecate): only issue warning if neovim version is high enoughdundargoc1
As specified by MAINTAIN.md, features should be soft deprecated at first (meaning no warnings) to give people a chance to adjust. The problem with this approach is that deprecating a feature becomes harder than usual as during the soft deprecation period you need to remember not to issue a warning, and during the hard deprecation period you need to remember to start issuing a warning. This behavior is only enforced if the `plugin` parameter is `nil` as plugins may not want this specific behavior.
2023-12-14feat(lsp): more annotationsLewis Russell1
2023-11-27fix(lua): disallow vim.wait() in fast contextsLewis Russell1
`vim.wait()` cannot be called in a fast callback since the main loop cannot be run in that context as it is not reentrant Fixes #26122
2023-11-21fix(vim.region): handle multibyte inclusive selection properly (#26129)zeertzjq1
2023-11-08refactor: move defaults into separate module (#25929)Gregory Anders1
Move default mappings and autocommands into a separate module and add comments and docstrings to document each of the defaults.
2023-11-07fix(lua): correct return value for on_key with no arguments (#25911)altermo1
2023-11-03docs: small fixes (#25831)dundargoc1
Co-authored-by: Peter Aronoff <peter@aronoff.org>
2023-10-21feat(lsp): add snippet API (#25301)Maria José Solano1
2023-10-06fix(lua): vim.region on linewise selection #25467Aayush Ojha1
fixes #18155
2023-10-04feat: ignore swapfile for running Nvim processes #25336Justin M. Keyes1
Problem: The swapfile "E325: ATTENTION" dialog is displayed when editing a file already open in another (running) Nvim. Usually this behavior is annoying and irrelevant: - "Recover" and the other options ("Open readonly", "Quit", "Abort") are almost never wanted. - swapfiles are less relevant for "multi-Nvim" since 'autoread' is enabled by default. - Even less relevant if user enables 'autowrite'. Solution: Define a default SwapExists handler which does the following: 1. If the swapfile is owned by a running Nvim process, automatically chooses "(E)dit anyway" (caveat: this creates a new, extra swapfile, which is mostly harmless and ignored except by `:recover` or `nvim -r`. 2. Shows a 1-line "ignoring swapfile..." message. 3. Users can disable the default SwapExists handler via `autocmd! nvim_swapfile`.
2023-09-24docs: do not use deprecated functions #25334Maria José Solano1
2023-09-22docs: clarify vim.schedule_wrap behaviourOliver Marriott1
- Remove the usage of the term "defer" to avoid confusion with `vim.defer_fn`, which also calls `vim.schedule_wrap` internally. - Explicitly state that `vim.schedule_wrap` returns a function in the text. - Mention that arguments are passed along. - Include a usage example. - Rename param to `fn`.
2023-09-20feat(lua): add vim.func._memoizeLewis Russell1
Memoizes a function, using a custom function to hash the arguments. Private for now until: - There are other places in the codebase that could benefit from this (e.g. LSP), but might require other changes to accommodate. - Invalidation of the cache needs to be controllable. Using weak tables is an acceptable invalidation policy, but it shouldn't be the only one. - I don't think the story around `hash_fn` is completely thought out. We may be able to have a good default hash_fn by hashing each argument, so basically a better 'concat'.
2023-09-14docs: replace <pre> with ``` (#25136)Gregory Anders1
2023-09-14docs: fix typos and other small fixes (#25005)dundargoc1
Co-authored-by: nuid64 <lvkuzvesov@proton.me> Co-authored-by: Mike Smith <10135646+mikesmithgh@users.noreply.github.com> Co-authored-by: XTY <xty@xty.io> Co-authored-by: Empa <emanuel@empa.xyz> Co-authored-by: kyu08 <49891479+kyu08@users.noreply.github.com>
2023-09-05refactor(vim.system): factor out on_exit handlingLewis Russell1
2023-09-05fix(vim.system): make timeout work properlyLewis Russell1
Mimic the behaviour of timeout(1) from coreutils.
2023-08-27fix(types): add some return/parameter type annotations (#24867)Maria José Solano1
* fix(types): add some return/parameter type annotations * fix(types): narrow stdpath parameter further
2023-08-10Use Lua autocommand and make TermClose autocommand globalGregory Anders1
2023-08-09fix(lua): improve annotations for stricter luals diagnostics (#24609)Christian Clason1
Problem: luals returns stricter diagnostics with bundled luarc.json Solution: Improve some function and type annotations: * use recognized uv.* types * disable diagnostic for global `vim` in shared.lua * docs: don't start comment lines with taglink (otherwise LuaLS will interpret it as a type) * add type alias for lpeg pattern * fix return annotation for `vim.secure.trust` * rename local Range object in vim.version (shadows `Range` in vim.treesitter) * fix some "missing fields" warnings * add missing required fields for test functions in eval.lua * rename lsp meta files for consistency
2023-08-08fix(filetype): add typing and dry (#24573)Lewis Russell1
2023-08-01fix(defaults): don't use nvim_feedkeys in default mappings (#24520)zeertzjq1
Problem: Using nvim_feedkeys in default mappings makes it hard to use them as a part of another mapping. Solution: Use an expression mapping and stop Visual mode later. Fix #24518.
2023-07-24fix(gx): move to to _init_default_mappings #24420marshmallow1
Problem: netrw may conflict with the Nvim default "gx" mapping. Solution: Initialize keymapping earlier by moving it to vim._init_default_mappings(). That also avoids needing to check maparg().
2023-07-18docs(lua): more improvements (#24387)Lewis Russell1
* 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>
2023-07-17refactor: rename _meta.lua to _options.luaLewis Russell1
2023-07-10fix(lint): lint warnings #24226Raphael1
2023-07-08fix(defaults): visual star (*) on text with "?"Justin M. Keyes1
regression from 6318edadc32acce3ed41a6995a5faa5395b5f562
2023-07-08fix(defaults): visual hash (#) on text with "?"Justin M. Keyes1
Problem: The default "#" mapping fails on the following example after v$h# with cursor at start of the first line: aa?/\bb aa aa?/\bb Solution: Also escape "?".
2023-07-08docs: MAINTAIN.md, nvim_get_markJustin M. Keyes1
2023-07-06refactor(defaults): use vim.region for visual star (*,#)Justin M. Keyes1
Problem: The parent commit added a new vim.get_visual_selection() function to improve visual star. But that is redundant with vim.region(). Any current limitations of vim.region() should be fixed instead of adding a new function. Solution: Delete vim.get_visual_selection(). Use vim.region() to get the visual selection. TODO: fails with visual "block" selections.
2023-07-06fix(defaults): visual mode star (*,#) is fragileSteven Ward1
Problem: Visual mode "*", "#" mappings don't work on text with "/", "\", "?", and newlines. Solution: Get the visual selection and escape it as a search pattern. Add functions vim.get_visual_selection and _search_for_visual_selection. Fix #21676
2023-06-25docs: autocmds, miscJustin M. Keyes1
2023-06-22test: spellcheck :help (vimdoc) files #24109Justin M. Keyes1
Enforce consistent terminology (defined in `gen_help_html.lua:spell_dict`) for common misspellings. This does not spellcheck English in general (perhaps a future TODO, though it may be noisy).