aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/lua
Commit message (Collapse)AuthorAge
* ci(PVS): PVS/V009: add required header #15751dundargoc2021-09-21
|
* refactor: reformat with uncrustify #15736dundargoc2021-09-20
| | | | * fix function parameter comments * remove space after star in function names
* refactor: format with uncrustify #15722dundargoc2021-09-19
|
* Merge #15585 refactor: move vim.lsp.diagnostic to vim.diagnosticJustin M. Keyes2021-09-16
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ## Overview - Move vim.lsp.diagnostic to vim.diagnostic - Refactor client ids to diagnostic namespaces - Update tests - Write/update documentation and function signatures Currently, non-LSP diagnostics in Neovim must hook into the LSP subsystem. This is what e.g. null-ls and nvim-lint do. This is necessary because none of the diagnostic API is exposed separately from the LSP subsystem. This commit addresses this by generalizing the diagnostic subsystem beyond the scope of LSP. The `vim.lsp.diagnostic` module is now simply a specific diagnostic producer and primarily maintains the interface between LSP clients and the broader diagnostic API. The current diagnostic API uses "client ids" which only makes sense in the context of LSP. We replace "client ids" with standard API namespaces generated from `nvim_create_namespace`. This PR is *mostly* backward compatible (so long as plugins are only using the publicly documented API): LSP diagnostics will continue to work as usual, as will pseudo-LSP clients like null-ls and nvim-lint. However, the latter can now use the new interface, which looks something like this: ```lua -- The namespace *must* be given a name. Anonymous namespaces will not work with diagnostics local ns = vim.api.nvim_create_namespace("foo") -- Generate diagnostics local diagnostics = generate_diagnostics() -- Set diagnostics for the current buffer vim.diagnostic.set(ns, diagnostics, bufnr) ``` Some public facing API utility methods were removed and internalized directly in `vim.diagnostic`: * `vim.lsp.util.diagnostics_to_items` ## API Design `vim.diagnostic` contains most of the same API as `vim.lsp.diagnostic` with `client_id` simply replaced with `namespace`, with some differences: * Generally speaking, functions that modify or add diagnostics require a namespace as their first argument, e.g. ```lua vim.diagnostic.set({namespace}, {bufnr}, {diagnostics}[, {opts}]) ``` while functions that read or query diagnostics do not (although in many cases one may be supplied optionally): ```lua vim.diagnostic.get({bufnr}[, {namespace}]) ``` * We use our own severity levels to decouple `vim.diagnostic` from LSP. These are designed similarly to `vim.log.levels` and currently include: ```lua vim.diagnostic.severity.ERROR vim.diagnostic.severity.WARN vim.diagnostic.severity.INFO vim.diagnostic.severity.HINT ``` In practice, these match the LSP diagnostic severity levels exactly, but we should treat this as an interface and not assume that they are the same. The "translation" between the two severity types is handled transparently in `vim.lsp.diagnostic`. * The actual "diagnostic" data structure is: (**EDIT:** Updated 2021-09-09): ```lua { lnum = <number>, col = <number>, end_lnum = <number>, end_col = <number>, severity = <vim.diagnostic.severity>, message = <string> } ``` This differs from the LSP definition of a diagnostic, so we transform them in the handler functions in vim.lsp.diagnostic. ## Configuration The `vim.lsp.with` paradigm still works for configuring how LSP diagnostics are displayed, but this is a specific use-case for the `publishDiagnostics` handler. Configuration with `vim.diagnostic` is instead done with the `vim.diagnostic.config` function: ```lua vim.diagnostic.config({ virtual_text = true, signs = false, underline = true, update_in_insert = true, severity_sort = false, }[, namespace]) ``` (or alternatively passed directly to `set()` or `show()`.) When the `namespace` argument is `nil`, settings are set globally (i.e. for *all* diagnostic namespaces). This is what user's will typically use for their local configuration. Diagnostic producers can also set configuration options for their specific namespace, although this is generally discouraged in order to respect the user's global settings. All of the values in the table passed to `vim.diagnostic.config()` are resolved in the same way that they are in `on_publish_diagnostics`; that is, the value can be a boolean, a table, or a function: ```lua vim.diagnostic.config({ virtual_text = function(namespace, bufnr) -- Only enable virtual text in buffer 3 return bufnr == 3 end, }) ``` ## Misc Notes * `vim.diagnostic` currently depends on `vim.lsp.util` for floating window previews. I think this is okay for now, although ideally we'd want to decouple these completely.
| * refactor: move vim.lsp.diagnostic to vim.diagnosticGregory Anders2021-09-15
| | | | | | | | | | | | | | | | | | | | | | This generalizes diagnostic handling outside of just the scope of LSP. LSP clients are now a specific case of a diagnostic producer, but the diagnostic subsystem is decoupled from the LSP subsystem (or will be, eventually). More discussion at [1]. [1]: https://github.com/neovim/neovim/pull/15585
* | feat(nlua): convert Blobs to stringsSean Dewar2021-09-15
| |
* | vim-patch:8.1.0735: cannot handle binary dataSean Dewar2021-09-15
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Problem: Cannot handle binary data. Solution: Add the Blob type. (Yasuhiro Matsumoto, closes vim/vim#3638) https://github.com/vim/vim/commit/6e5ea8d2a995b32bbc5972edc4f827b959f2702f Nvim-specific Blob conversions are implemented in future commits. Refactor write_blob() to use a FileDescriptor, as f_writefile() was refactored to use one (does not apply to read_blob()). Use var_check_lock() in f_add() for Blobs from v8.1.0897. Add a modeline to test_blob.vim and fix some doc typos. Include if_perl.txt's VIM::Blob() documentation. Interestingly, this function already worked before this port, as it just returns a Blob string literal, not an actual Blob object. N/A patches for version.c: vim-patch:8.1.0741: viminfo with Blob is not tested Problem: Viminfo with Blob is not tested. Solution: Extend the viminfo test. Fix reading a blob. Fixed storing a special variable value. https://github.com/vim/vim/commit/8c8b8bb56c724cc1bfc3d8520eec33f2d399697c vim-patch:8.1.1022: may use NULL pointer when out of memory Problem: May use NULL pointer when out of memory. (Coverity) Solution: Check for blob_alloc() returning NULL. https://github.com/vim/vim/commit/e142a9467a7f6845a426d8db6efedf246d3c13ac
* docs: third-party licenses, TEST_COLORS, system() #15665Justin M. Keyes2021-09-14
|
* feat(lua): make vim.mpack support vim.NIL and vim.empty_dict()Björn Linse2021-09-09
|
* feat(lua): add vim.mpack for msgpack support in luaBjörn Linse2021-09-09
|
* feat(lua)!: register_keystroke_callback => on_keyJustin M. Keyes2021-09-09
| | | | | | | | | Analogous to nodejs's `on('data', …)` interface, here on_key is the "add listener" interface. ref 3ccdbc570d85 #12536 BREAKING_CHANGE: vim.register_keystroke_callback() is now an error.
* vim-patch:8.2.3390: included xdiff code is outdatedChristian Clason2021-09-08
| | | | | | Problem: Included xdiff code is outdated. Solution: Sync with xdiff in git 2.33. (Christian Brabandt, closes vim/vim#8431) https://github.com/vim/vim/commit/ba02e4720f863fdb456e7023520f0a354eec0dcf
* fix(lua): make core vim module not dependent on $VIMRUNTIME functionsBjörn Linse2021-08-30
| | | | | | | | | | fixes #15524 Note: this is obviously a quickfix. A scalabe solution will involve being able to specify a _list_ of modules to be put into packages.preload, without needing to manually copypasta a blurb of C code. Perhaps even involving bytecode for static builds (to speedup initialization)
* fix(lua): preserve argument lists which are not listsBjörn Linse2021-08-29
|
* perf(api): avoid spurious allocations when converting small objectsBjörn Linse2021-08-28
| | | | | | | Converter functions use a heap-allocated stack to handle complex nested objects. However, these are often called with simple, primitive values like integers or bools wrapped in an Object. Avoid the memory allocation in this case using kvec_withinit_t
* Merge #15293 Vimscript "method" syntaxJustin M. Keyes2021-08-26
|\ | | | | Port VimL's method call syntax - vim-patch:8.1.{1638,1800,1803,1807,1809,1816,1820,1821,1828,1834,1835,1861,1863,1878,1879,1888,1909,1911,1912}
| * vim-patch:8.1.1800: function call functions have too many argumentsSean Dewar2021-08-12
| | | | | | | | | | | | | | | | | | | | Problem: Function call functions have too many arguments. Solution: Pass values in a funcexe_T struct. https://github.com/vim/vim/commit/c6538bcc1cdd1fb83732f22fdc69bd9bb66f968a Use FUNCEXE_INIT to initialize funcexe_T instances. call_callback() and other Vim listener related stuff is N/A.
* | Merge pull request #15434 from Dkendal/feature-lua-treesitter-siblingThomas Vigouroux2021-08-23
|\ \ | | | | | | feat(treesitter): add next, prev sibling method
| * | feat(treesitter): add next, prev sibling methodDylan Kendal2021-08-20
| |/ | | | | | | | | Add tsnode methods to change to the next, previous, named or unnamed nodes.
* | 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.
* | refactor(map): remove extra-allocating map_new/map_free functionsBjörn Linse2021-08-22
| | | | | | | | | | | | | | | | | | | | Note: the reason for removing them is not that there after this refactor is no use of them, but rather that having them available is an anti-pattern: they manange an _extra_ heap allocation which has nothing to do with the functionality of the map itself (khash manages the real buffers internally). In case there happens to be a reason to allocate the map structure itself later, this should be made explicit using xcalloc/xfree calls.
* | Merge pull request #15451 from bfredl/metamapBjörn Linse2021-08-22
|\ \ | | | | | | perf(map): get rid of unnecessary pointer indirections for maps.
| * | refactor(api): remove unneccesary indirection around handlesBjörn Linse2021-08-22
| |/ | | | | | | | | These things are just maps to pointers, no need to perform a huge song and dance around it.
* / feat(api): add lua C bindings for xdiff (#14536)Lewis Russell2021-08-22
|/ | | | | | | | | | | | | | | | * feat(api): add lua C bindings for xdiff * chore: opt.hunk_lines -> opt.result_type opt.on_hunk now takes precedence over opt.result_type * chore: fix indents Fix indents * chore: change how priv is managed Assign priv NULL and unconditionally apply XFREE_CLEAR to it when finished.
* refactor(lua): initialize lua state at startup instead of dynamicallyBjörn Linse2021-07-19
| | | | | | | | | | lua is used as part of implementation for more core features. As an example, every user keypress will invoke a lua function to check for keypress handlers (regardless if they are registered or not). Thus not starting lua until it is first used doesn't make much sense anymore. nlua_enter was also needed due to the earlier stateful &rtp translation, which by now have been made stateless.
* chore: use codespell to spell check #15016dundargoc2021-07-07
|
* fixup(ts): put ts_query_cursor_set_match_limit behind feature guardChristian Clason2021-06-29
| | | | | | | | | | | | | | This is a fixup for #14915, which used the above-mentioned call to restore the behavior of the pre-release version of tree-sitter to that of 0.19.5. However, this function was introduced after 0.19.5, breaking distro builds that link against 0.19.5 instead of the tag specified in neovim's build script. Now the function should only be called when it is available _and_ needed. Once tree-sitter is bumped to 0.19.6 (when this is released), this guard can be removed again. Fixes #14923 (among others)
* fix(treesitter): set match limit for query cursorsChristian Clason2021-06-26
| | | | | | | | | | | | Upstream tree-sitter raised the number of pending matches for a query cursor from 32 to 64k in <https://github.com/tree-sitter/tree-sitter/commit/ 78010722a49ed6224c773c22b0d25a8c9fbde584>, which severely impacted performance for some highlighting queries. This uses the `ts_query_cursor_set_match_limit` function introduced in <https://github.com/tree-sitter/tree-sitter/commit/ cd96552448a6e0d4eb27fc54b27cb5130c4b6f76> to manually set this back to the old default of 32. Fixes #14897
* BugFix: Fix inconsistent verbose messageshadmansaleh2021-06-21
| | | | | | | When a keymap is set from lua currently verbose message says it's set from line 1. That's incorrect because we don't really know when it was set. So until proper :verbose support isn't added for sourceing lua it shouldn't say where it was set at.
* Merge pull request #14773 from mjlbach/fix/vim-region-boundsMichael Lingelbach2021-06-11
|\ | | | | fix(lua): ensure vim.region truncates to buf range
| * fix(lua): ensure vim.region truncates to buf rangeMichael Lingelbach2021-06-11
| | | | | | | | | | | | | | | | If vim.region receives a large range outside of the current buffer bounds, it will not check the range ahead of time and loop until neovim exhausts the system memory. Fixes #14743
* | refactor(source): Move lua file detection to do_sourceshadmansaleh2021-06-11
|/ | | | | | So now :source can run lua files too :) * feat: Add support for :[ranged]source for lua files
* lua: Add vim.opt and fix scopes of vim.o (#13479)TJ DeVries2021-05-28
| | | | | | | | | | | | | * lua: Add vim.opt * fixup: cleaning * fixup: comments * ty clason * fixup: comments * this is the last commit. period.
* lua: use proper conversion of vim.g valuesBjörn Linse2021-05-19
|
* lua: use WarningMsg for vim.notify() warnings (#14508)Shadman2021-05-10
|
* docs: Treesitter (#13260)TJ DeVries2021-05-01
| | | | | | | | | * doc & fixes: Generate treesitter docs * fixup to treesitter-core * docs(treesitter): fix docs for most functions Co-authored-by: Thomas Vigouroux <tomvig38@gmail.com>
* lua: make vim.cmd an alias of vim.api.nvim_exec() (#14401)Shadman2021-04-22
| | | | | Previously vim.cmd was an alias of nvim_command(). From now on it is an alias of nvim_exec().
* Merge pull request #14318 from chentau/extmark_luadoBjörn Linse2021-04-13
|\ | | | | extmark: splice extmarks on :luado
| * extmark: splice extmarks on :luadochentau2021-04-12
| |
* | Merge pull request #14200 from teto/treesitter-checkhealthMarco Hinz2021-04-07
|\ \ | | | | | | feat: treesitter checkhealth
| * | feat(ts): include parser ABI version in checkhealthThomas Vigouroux2021-04-06
| | |
* | | test/lsp: disable tracking in LSP tests (here be dragons)Björn Linse2021-04-03
| | |
* | | luaref: simplify handling of table callables and fix leak in vim.fn.call(table)Björn Linse2021-04-03
| | | | | | | | | | | | I AM THE TABLE
* | | luaref: fix leaks for global luarefsBjörn Linse2021-04-03
| | |
* | | lua: track reference ownership with ASAN when presentBjörn Linse2021-04-03
| |/ |/|
* | Merge pull request #14039 from theHamsta/fix-field-introspectionThomas Vigouroux2021-04-02
|\ \ | |/ |/| Fix(treesitter): Make treesitter.inspect_lang include last field name
| * Fix(treesitter): Make treesitter.inspect_lang include last field nameStephan Seitz2021-03-23
| |
* | ts: Add language version to vim.treesitter (#14255)TJ DeVries2021-03-30
|/
* chore(ts): show grammar that triggers the errorMatthieu Coudron2021-03-16
| | | | to help debugging
* Merge pull request #13875 from smolck/vim_fn_error_on_apiBjörn Linse2021-03-09
|\ | | | | vim.fn: throw error when trying to use API function