summaryrefslogtreecommitdiffstatshomepage
path: root/runtime/lua/vim/shared.lua
AgeCommit message (Collapse)AuthorFiles
2021-11-30docs(lsp): add annotations for private functionsGregory Anders1
2021-11-26fix(lua): fix vim.deepcopy for metatables & cycled tables (#16435)Shadman1
vim.deepcopy previously didn't retain metatables in copies and caused stackoverflow on recursive tables/cycled tables this fixes these issues
2021-11-06feat(lua): enable stack traces in error output (#16228)Gregory Anders1
2021-09-25refactor: use kwargs parameter in vim.splitGregory Anders1
2021-09-25feat: add trimempty optional parameter to vim.splitGregory Anders1
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.
2021-09-10perf(lua): optimize vim.deep_equal #15236Javier Lopez1
By remembering the keys already compared in repeating a comparison is avoided. Thanks: https://stackoverflow.com/a/32660766
2021-08-22docs: make Lua docstrings consistent #15255Gregory Anders1
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.
2021-07-19docs: made can_merge private (#15138)Folke Lemaitre1
2021-07-19fix(shared): do not treat empty tables as list in deep extend (#15094)Folke Lemaitre1
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 } }`
2021-03-09lsp: add incremental text synchronizationMichael Lingelbach1
* Implementation derived from and validated by vim-lsc authored by Nate Bosch
2020-11-12lsp: vim.lsp.diagnostic (#12655)TJ DeVries1
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)
2020-10-05test/vim.validate(): assert normalized stacktraceJustin M. Keyes1
- 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()
2020-10-05vim.validate(): include stacktrace in messageTJ DeVries1
2020-08-31docs, remove 'guifontset' #11708Justin M. Keyes1
- 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...).
2020-07-02doc: fix scripts and regenerate (#12506)TJ DeVries1
* 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
2020-06-04lua: fix behavior when split empty string (#12429)notomo1
* lua: fix behavior when split empty string * test: lsp.util.apply_text_edits with an empty edit
2020-06-02lua: fix infinite loop for vim.split on empty string (#12420)notomo1
2020-05-17lua: add tbl_deep_extend (#11969)Hirokazu Hata1
2020-04-19lua: allow deepcopy of functions (#12136)Tristan Konolige1
2020-03-01lua: add vim.tbl_len() #11889Hirokazu Hata1
2020-02-18lua: move test helper function, map and filter, to vim.shared moduleHirokazu Hata1
2020-02-14lua: if second argument is vim.empty_dict(), vim.tbl_extend uses ↵Hirokazu Hata1
empty_dict() instead of {}
2020-02-13lua: vim.deepcopy uses empty_dict() instead of {} for empty_dict()Hirokazu Hata1
fix: https://github.com/neovim/nvim-lsp/issues/94
2020-01-26terminal: absolute CWD in term:// URI #11289Chris LaRose1
This makes it possible to restore the working directory of :terminal buffers when reading those buffers from a session file. Fixes #11288 Co-authored-by: Justin M. Keyes <justinkz@gmail.com>
2020-01-12doc [ci skip] #11656Justin M. Keyes1
2020-01-01lua: metatable for empty dict valueBjörn Linse1
2019-12-01Add vim.startswith and vim.endswith (#11248)Ashkan Kiani1
2019-11-25doc + extmarks tweaks #11421Justin M. Keyes1
- nvim_buf_get_extmarks: rename "amount" => "limit" - rename `set_extmark_index_from_obj`
2019-11-24Merge branch 'master' into lsp-followupAshkan Kiani1
2019-11-24Lua: vim.env, vim.{g,v,w,bo,wo} #11442Ashkan Kiani1
- Add vim variable meta accessors: vim.env, vim.{g,v,w,bo,wo} - Redo gen_char_blob to generate multiple blobs instead of just one so that multiple Lua modules can be inlined. - Reorder vim.lua inclusion so that it can use previously defined C functions and utility functions like vim.shared and vim.inspect things. - Inline shared.lua into nvim, but also keep it available in runtime.
2019-11-20Extend list_extend to take start/finish.Ashkan Kiani1
2019-11-13lua LSP client: initial implementation (#11336)Ashkan Kiani1
Mainly configuration and RPC infrastructure can be considered "done". Specific requests and their callbacks will be improved later (and also served by plugins). There are also some TODO:s for the client itself, like incremental updates. Co-authored by at-tjdevries and at-h-michael, with many review/suggestion contributions.
2019-11-10Lua: Use vim.validate() instead of assert()Justin M. Keyes1
2019-11-10Lua: vim.validate()Justin M. Keyes1
2019-11-10Lua: vim.validate()Hirokazu Hata1
We often want to do type checking of public function arguments. - test: Rename utility_function_spec.lua to vim_spec.lua - .luacov: Map lua module names
2019-10-23runtime: Use module pattern with vim/shared.luaHirokazu Hata1
It's a bit cumbersome for us to add an export target every time we define a new function. It's also cumbersome to care about the order of definition when creating a new function by referring to other functions in the module.
2019-10-26lua/stdlib: adjust some validation messages #11271Hirokazu Hata1
close #11271
2019-09-06test: Rename meth_pcall to pcall_errJustin M. Keyes1
- Rename `meth_pcall`. - Make `pcall_err` raise an error if the function does not fail. - Add `vim.pesc()` to treat a string as literal where a Lua pattern is expected.
2019-05-25doc #10017Justin M. Keyes1
- gen_vimdoc.py: fancy "bullet" - rework `:help channel-callback` - rename `:help buffered` to `:help channel-buffered`
2019-05-20lua/shared: share trim() implJustin M. Keyes1
2019-05-19lintJustin M. Keyes1
2019-05-19lua/shared: share more stuffJustin M. Keyes1
Leave trim() in vim.lua, because gen_vimdoc.py needs at least one function in there, else it gets confused...
2019-05-19lua/shared: share deepcopy() with test/*Justin M. Keyes1
deepcopy() was duplicated in test/helpers.lua
2019-05-19gen_vimdoc.py: support lua/shared.lua module [ci skip]Justin M. Keyes1
2019-05-18lua/shared: move table util funcs to vim.sharedJustin M. Keyes1
Use `tbl_` prefix for all table-util functions. Specify in the function docstring if it expects a list-like or map-like table.
2019-05-18lua/stdlib: Introduce vim.sharedJustin M. Keyes1
This is where "pure functions" can live, which can be shared by Nvim and test logic which may not have a running Nvim instance available. If in the future we use Nvim itself as the Lua engine for tests, then these functions could be moved directly onto the `vim` Lua module. closes #6580