aboutsummaryrefslogtreecommitdiff
path: root/runtime/lua/vim/shared.lua
Commit message (Collapse)AuthorAge
* build: make generated source files reproducible #21586Arnout Engelen2023-01-23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Problem: Build is not reproducible, because generated source files (.c/.h/) are not deterministic, mostly because Lua pairs() is unordered by design (for security). https://github.com/LuaJIT/LuaJIT/issues/626#issuecomment-707005671 https://www.lua.org/manual/5.1/manual.html#pdf-next > The order in which the indices are enumerated is not specified [...] > >> The hardening of the VM deliberately randomizes string hashes. This in >> turn randomizes the iteration order of tables with string keys. Solution: - Update the code generation scripts to be deterministic. - That is only a partial solution: the exported function (funcs_metadata.generated.h) and ui event (ui_events_metadata.generated.h) metadata have some mpack'ed tables, which are not serialized deterministically. - As a workaround, introduce `PRG_GEN_LUA` cmake setting, so you can inject a modified build of luajit (with LUAJIT_SECURITY_PRN=0) that preserves table order. - Longer-term we should change the mpack'ed data structure so it no longer uses tables keyed by strings. Closes #20124 Co-Authored-By: dundargoc <gocdundar@gmail.com> Co-Authored-By: Arnout Engelen <arnout@bzzt.net>
* docs(lua): use luaref tag instead of www.lua.org #21813Naru2023-01-15
|
* docs(lua): adjust some type annotationsnotomo2023-01-04
|
* docs(lua): fix treesitter parsing errorsChristian Clason2023-01-01
|
* fix(lua): always return nil values in vim.tbl_get when no resultsWilliam Boman2022-12-15
| | | | | | | | | | | | | | | | | | | While `return` and `return nil` are for most intents and purposes identical, there are situations where they're not. For example, calculating the amount of values via the `select()` function will yield varying results: ```lua local function nothing() return end local function null() return nil end select('#', nothing()) -- 0 select('#', null()) -- 1 ``` `vim.tbl_get` currently returns both nil and no results, which makes it unreliable to use in certain situations without manually accounting for these discrepancies.
* docs(gen): support language annotation in docstringsChristian Clason2022-12-02
|
* fix(lua): make `vim.deepcopy` work with `vim.NIL`Max2022-11-14
| | | | | | | | style: changed double quotes to single quotes feat: add tests fix tests
* fix(lua): pesc, tbl_islist result types #20751NAKAI Tsuyoshi2022-10-24
| | | | | | | | | | | | Problem: - pesc() returns multiple results, it should return a single result. - tbl_islist() returns non-boolean in some branches. - Docstring: @generic must be declared first Solution: Constrain docstring annotations. Fix return types. Co-authored-by: Justin M. Keyes <justinkz@gmail.com>
* fix(docs-html): update parserJustin M. Keyes2022-10-10
| | | | | | | | | | | - Improve generated HTML by updating parser which includes fixes for single "'" and single "|": https://github.com/neovim/tree-sitter-vimdoc/pull/31 - Updated parser also fixes the conceal issue for "help" highlight queries https://github.com/neovim/tree-sitter-vimdoc/issues/23 by NOT including whitespace in nodes. - But this means we need to restore the getws() function which scrapes leading whitespace from the original input (buffer).
* fix(lua): properly configure luacheck and remove `local vim = ...` lines ↵Folke Lemaitre2022-10-09
| | | | (#20551)
* feat: added support for specifying types for lua2doxFolke Lemaitre2022-10-06
|
* feat: added support for optional params to lua2doxFolke Lemaitre2022-10-06
|
* docs: added proper annotations to functions in shared.luaFolke Lemaitre2022-10-06
|
* docs(docstrings): fix runtime type annotationsElizabeth Paź2022-10-05
|
* fix(docs): invalid :help links #20345Justin M. Keyes2022-09-25
| | | | | Fix those naughty single quotes. closes #20159
* docs(treesitter): clean up and update treesitter.txt (#20142)Christian Clason2022-09-14
| | | | | * add type annotations to code * clean up and expand static documentation * consistent use of tags for static and generated docs
* Use weak tables in tree-sitter code (#17117)Thomas Vigouroux2022-09-07
| | | | | | feat(treesitter): use weak tables when possible Also add the defaulttable function to create a table whose values are created when a key is missing.
* docs(lua): add Lua 5.1 reference manual (#19663)dundargoc2022-08-08
| | | | | | | | based on http://www.vim.org/scripts/script.php?script_id=1291 reformatted to match Nvim documentation style; removed irrelevant sections Co-authored-by: dundargoc <gocundar@gmail.com> Co-authored-by: Christian Clason <c.clason@uni-graz.at> Co-authored-by: Lewis Russell <lewis6991@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
* docs(api): improve shared lua functions docs (#17933)adrian52022-05-11
|
* chore: format runtime with styluaChristian Clason2022-05-09
|
* fix(shared): avoid indexing unindexable values in vim.tbl_get() (#18337)William Boman2022-05-01
|
* feat: add vim.tbl_get (#17831)Michael Lingelbach2022-03-24
| | | | | | vim.tbl_get takes a table with subsequent string arguments (variadic) that index into the table. If the value pointed to by the set of keys exists, the function returns the value. If the set of keys does not exist, the function returns nil.
* chore: fix typos (#17670)dundargoc2022-03-17
| | | Co-authored-by: zeertzjq <zeertzjq@outlook.com>
* refactor(lua): make vim submodule lazy loading declarativebfredl2022-03-07
| | | | | This will allow us to also use the same logic for lua threads and processes, later.
* docs(lua): reference runtime/lua/vim/_editor.luazeertzjq2022-03-06
|
* fix(diagnostic): improve validation for list arguments (#16855)Gregory Anders2022-01-01
| | | | | | Function arguments that expect a list should explicitly use tbl_islist rather than just checking for a table. This helps catch some simple errors where a single table item is passed as an argument, which passes validation (since it's a table), but causes other errors later on.
* feat(lua): add support for multiple optional types in vim.validate (#16864)Shadman2022-01-01
|
* docs(lsp): add annotations for private functionsGregory Anders2021-11-30
|
* fix(lua): fix vim.deepcopy for metatables & cycled tables (#16435)Shadman2021-11-26
| | | | | vim.deepcopy previously didn't retain metatables in copies and caused stackoverflow on recursive tables/cycled tables this fixes these issues
* feat(lua): enable stack traces in error output (#16228)Gregory Anders2021-11-06
|
* refactor: use kwargs parameter in vim.splitGregory Anders2021-09-25
|
* feat: add trimempty optional parameter to vim.splitGregory Anders2021-09-25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The `split()` VimL function trims empty items from the returned list by default, so that, e.g. split("\nhello\nworld\n\n", "\n") returns ["hello", "world"] The Lua implementation of vim.split does not do this. For example, vim.split("\nhello\nworld\n\n", "\n") returns {'', 'hello', 'world', '', ''} Add an optional parameter to the vim.split function that, when true, trims these empty elements from the front and back of the returned table. This is only possible for vim.split and not vim.gsplit; because vim.gsplit is an iterator, there is no way for it to know if the current item is the last non-empty item. Note that in order to preserve backward compatibility, the parameter for the Lua vim.split function is `trimempty`, while the VimL function uses `keepempty` (i.e. they are opposites). This means there is a disconnect between these two functions that may surprise users.
* perf(lua): optimize vim.deep_equal #15236Javier Lopez2021-09-10
| | | | By remembering the keys already compared in repeating a comparison is avoided. Thanks: https://stackoverflow.com/a/32660766
* 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.
* docs: made can_merge private (#15138)Folke Lemaitre2021-07-19
|
* fix(shared): do not treat empty tables as list in deep extend (#15094)Folke Lemaitre2021-07-19
| | | | | | | | | | An empty table was previously always treated as a list, which means that while merging tables, whenever an empty table was encountered it would always truncate any table on the left. `vim.tbl_deep_extend("force", { b = { a = 1 } }, { b = {} })` Before: `{ b = {} }` After: `{ b = { a = 1 } }`
* lsp: add incremental text synchronizationMichael Lingelbach2021-03-09
| | | | | * Implementation derived from and validated by vim-lsc authored by Nate Bosch
* 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)
* test/vim.validate(): assert normalized stacktraceJustin M. Keyes2020-10-05
| | | | | | | - The previous commit lost information in the tests. Instead, add some more "normalization" substitutions in pcall_err(), so that the general shape of the stacktrace is included in the asserted text. - Eliminate contains(), it is redundant with matches()
* vim.validate(): include stacktrace in messageTJ DeVries2020-10-05
|
* docs, remove 'guifontset' #11708Justin M. Keyes2020-08-31
| | | | | | | | | | | | | - remove redundant autocmd list This "grouped" list is useless, it only gets in the way when searching for event names. - intro.txt: cleanup - starting.txt: update, revisit - doc: `:help bisect` - mbyte.txt: update aliases 1656367b90bd. closes #11960 - options: remove 'guifontset'. Why: - It is complicated and is used by almost no one. - It is unlikely to be implemented by Nvim GUIs (complicated to parse, specific to Xorg...).
* doc: fix scripts and regenerate (#12506)TJ DeVries2020-07-02
| | | | | | | | | | | | | | | | | * Fix some small doc issues * doc: fixup * doc: fixup * Fix lint and rebase * Remove bad advice * Ugh, stupid mpack files... * Don't let people include these for now until they specifically want to * Prevent duplicate tag
* lua: fix behavior when split empty string (#12429)notomo2020-06-04
| | | | | * lua: fix behavior when split empty string * test: lsp.util.apply_text_edits with an empty edit
* lua: fix infinite loop for vim.split on empty string (#12420)notomo2020-06-02
|
* lua: add tbl_deep_extend (#11969)Hirokazu Hata2020-05-17
|
* lua: allow deepcopy of functions (#12136)Tristan Konolige2020-04-19
|
* lua: add vim.tbl_len() #11889Hirokazu Hata2020-03-01
|
* lua: move test helper function, map and filter, to vim.shared moduleHirokazu Hata2020-02-18
|
* lua: if second argument is vim.empty_dict(), vim.tbl_extend uses ↵Hirokazu Hata2020-02-14
| | | | empty_dict() instead of {}