aboutsummaryrefslogtreecommitdiff
path: root/runtime/lua/vim
Commit message (Collapse)AuthorAge
* fix(lsp): send empty "added" list when removing workspace folder #24440Mitchell Hanberg2023-07-24
| | | | | | | | | | | | | | | | | | When adding `workspace/didChangeWorkspaceFolders` support to my [language server](https://github.com/elixir-tools/next-ls), I noticed that when neovim removes a workspace, it sends an empty table (which is serialized to an empty JSON array) for the value in the `added` field. This does not follow the spec; the `added` table should just be empty. The following error led me to this discovery. Note the payload includes `"added" => [[]]`: ``` 22:46:48.476 [error] LSP Exited. Last message received: handle_notification %{"jsonrpc" => "2.0", "method" => "workspace/didChangeWorkspaceFolders", "params" => %{"event" => %{"added" => [[]], "removed" => [%{"name" => "/Users/mitchell/src/gen_lsp", "uri" => "file:///Users/mitchell/src/gen_lsp"}]}}} ** (MatchError) no match of right hand side value: {:error, %{"params" => %{"event" => %{"added" => [error: "expected a map"]}}}} (gen_lsp 0.4.0) lib/gen_lsp.ex:265: anonymous fn/4 in GenLSP.loop/3 (gen_lsp 0.4.0) lib/gen_lsp.ex:292: GenLSP.attempt/3 (stdlib 5.0.2) proc_lib.erl:241: :proc_lib.init_p_do_apply/3 ```
* fix(lsp): noisy warning about offset_encodings #24441Keith Smiley2023-07-24
| | | | | In the case you hit this warning in a buffer (like with C++ and clangd), this message potentially fires over and over again making it difficult to use the editor at all.
* fix(gx): move to to _init_default_mappings #24420marshmallow2023-07-24
| | | | | | | | 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().
* fix(treesitter): stop() should treat 0 as current buffer #24450Micah Halter2023-07-24
|
* refactor(lsp): use LspNotify for inlay_hint (#24411)Chris AtLee2023-07-22
|
* fix(api/options): validate buf and winLewis Russell2023-07-22
| | | Fixes #24398
* docs(lua): add missing word in docs for vim.empty_dict (#24401)Gnik2023-07-22
|
* fix(ui.open): some URLs fail on Windowsmarshmallow2023-07-21
| | | | | | | | | | | | Problem: On Windows, `explorer.exe` fails to open some URLs, for example: :lua vim.ui.open('https://devdocs.io/#q=lua%20lua_call') https://github.com/neovim/neovim/pull/23401#issuecomment-1641015704 Solution: Use rundll32 instead.
* feat(lsp): implement textDocument/diagnostic (#24128)Chris AtLee2023-07-20
|
* docs(lua): clarify fs.find() documentation #24394futsuuu2023-07-19
|
* feat(lsp): handle multiple clients in omnifunc (#24381)Mathias Fußenegger2023-07-19
| | | | | Also fixes https://github.com/neovim/neovim/issues/24369 by adding an extra `vim.schedule` to ensure the `vim.fn.complete` call happens outside of a luv callback
* 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>
* fix(fs.lua): normalize slash truncation (#23753)Mike2023-07-18
| | | Preserve last slash in windows' root drive directories
* Merge pull request #24363 from lewis6991/docs/luatypesLewis Russell2023-07-17
|\ | | | | docs(lua): move some function docs to lua files
| * fix: doc errorsLewis Russell2023-07-17
| |
| * fix: luacheckLewis Russell2023-07-17
| |
| * docs(lua): change *lua-foo* -> *vim.foo*Lewis Russell2023-07-17
| |
| * docs(lua): move function docs to lua filesLewis Russell2023-07-17
| |
| * refactor: rename _meta.lua to _options.luaLewis Russell2023-07-17
| |
* | feat(lsp)!: rename vim.lsp.get_active_clients to get_clients (#24113)Mathias Fußenegger2023-07-17
| |
* | fix(lsp): markdown code fence should allow space before info string #24364Mike2023-07-16
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Problem: Bash language server returns "hover" markdown content that starts with a code fence and info string of `man` preceded by whitespace, which Nvim does not render properly. See https://github.com/bash-lsp/bash-language-server/blob/0ee73c53cebdc18311d4a4ad9367185ea4d98a03/server/src/server.ts#L821C15-L821C15 ```typescript function getMarkdownContent(documentation: string, language?: string): LSP.MarkupContent { return { value: language ? // eslint-disable-next-line prefer-template ['``` ' + language, documentation, '```'].join('\n') : documentation, kind: LSP.MarkupKind.Markdown, } } ``` For example, ``` ``` man NAME git - the stupid content tracker ``` ``` If I remove the white space, then it is properly formatted. ``` ```man instead of ``` man ``` Per CommonMark Spec https://spec.commonmark.org/0.30/#info-string whitespace is allowed before and after the `info string` which identifies the language in a codeblock. > The line with the opening code fence may optionally contain some text > following the code fence; this is trimmed of leading and trailing > spaces or tabs and called the [info > string](https://spec.commonmark.org/0.30/#info-string). If the [info > string](https://spec.commonmark.org/0.30/#info-string) comes after > a backtick fence, it may not contain any backtick characters. (The > reason for this restriction is that otherwise some inline code would > be incorrectly interpreted as the beginning of a fenced code block.) Solution: Adjust stylize_markdown() to allow whitespace before codeblock info.
* feat(lsp): map K to hover by default #24331Mathias Fußenegger2023-07-14
| | | Related: https://github.com/neovim/neovim/issues/24252
* fix(lsp): remove unknown LSP protocol property (#24345)Techatrix2023-07-14
| | | 'hierarchicalWorkspaceSymbolSupport' is not part of the LSP Specification
* docs(lua): adds links to related keymap functions to keymap.set (#24337)Mathias Fußenegger2023-07-13
| | | Might help with discovery, given that there is no `keymap.get()`
* feat(lsp): add method filter to get_active_clients (#24319)Mathias Fußenegger2023-07-12
|
* fix(lint): lint warnings #24226Raphael2023-07-10
|
* fix(defaults): visual star (*) on text with "?"Justin M. Keyes2023-07-08
| | | | regression from 6318edadc32acce3ed41a6995a5faa5395b5f562
* fix(defaults): visual hash (#) on text with "?"Justin M. Keyes2023-07-08
| | | | | | | | | | | | | 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 "?".
* docs: MAINTAIN.md, nvim_get_markJustin M. Keyes2023-07-08
|
* fix(lsp): don't use hl_mode = combine for inlay hints #24276Chinmay Dalal2023-07-08
| | | | | | | Problem: `hl_mode` for inlay hints is `combine`, causing bugs like inlay hints using highlights from the previous character (#24152, #24068) Solution: Don't use hl_mode=combine for inlay hints.
* feat(lua): allow vim.wo to be double indexed (#20288)Lewis Russell2023-07-07
| | | | | | | | * feat(lua): allow vim.wo to be double indexed Problem: `vim.wo` does not implement `setlocal` Solution: Allow `vim.wo` to be double indexed Co-authored-by: Christian Clason <c.clason@uni-graz.at>
* fix(treesitter): update folds in all relevant windows (#24230)Jaehwang Jung2023-07-07
| | | | | | | | | Problem: When using treesitter foldexpr, * :diffput/get open diff folds, and * folds are not updated in other windows that contain the updated buffer. Solution: Update folds in all windows that contain the updated buffer and use expr foldmethod.
* refactor(defaults): use vim.region for visual star (*,#)Justin M. Keyes2023-07-06
| | | | | | | | | | | | | 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.
* fix(defaults): visual mode star (*,#) is fragileSteven Ward2023-07-06
| | | | | | | | | | | | 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
* fix(vim.system): close check handle (#24270)zeertzjq2023-07-06
| | | Fix hang after running vim.system() with sanitizers.
* fix(vim.ui.open): return (don't show) error messageJustin M. Keyes2023-07-05
| | | | | | | | | | Problem: Showing an error via vim.notify() makes it awkward for callers such as lsp/handlers.lua to avoid showing redundant errors. Solution: Return the message instead of showing it. Let the caller decide whether and when to show the message.
* fix(gx): visual selection, expand env varsJustin M. Keyes2023-07-04
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | --- Rejected experiment: move vim.ui.open() to vim.env.open() Problem: `vim.ui` is where user-interface "providers" live, which can be overridden. It would also be useful to have a "providers" namespace for platform-specific features such as "open", clipboard, python, and the other providers listed in `:help providers`. We could overload `vim.ui` to serve that purpose as the single "providers" namespace, but `vim.ui.nodejs()` for example seems awkward. Solution: `vim.env` currently has too narrow of a purpose. Overload it to also be a namespace for `vim.env.open`. diff --git a/runtime/lua/vim/_meta.lua b/runtime/lua/vim/_meta.lua index 913f1fe20348..17d05ff37595 100644 --- a/runtime/lua/vim/_meta.lua +++ b/runtime/lua/vim/_meta.lua @@ -37,8 +37,28 @@ local options_info = setmetatable({}, { end, }) -vim.env = setmetatable({}, { - __index = function(_, k) +vim.env = setmetatable({ + open = setmetatable({}, { + __call = function(_, uri) + print('xxxxx'..uri) + return true + end, + __tostring = function() + local v = vim.fn.getenv('open') + if v == vim.NIL then + return nil + end + return v + end, + }) + }, + { + __index = function(t, k, ...) + if k == 'open' then + error() + -- vim.print({...}) + -- return rawget(t, k) + end local v = vim.fn.getenv(k) if v == vim.NIL then return nil
* feat(vim.ui): vim.ui.open, "gx" without netrwmarshmallow2023-07-04
| | | | | | Co-authored-by: Mathias Fußenegger <mfussenegger@users.noreply.github.com> Co-authored-by: Justin M. Keyes <justinkz@gmail.com> Co-authored-by: ii14 <59243201+ii14@users.noreply.github.com>
* fix(lsp): revert change to buf.clear_references() #24238Raphael2023-07-04
| | | | | | | Problem: in #24046 the signature of buf.clear_references() changed, which indirectly breaks callers that were passing "ignored" args. Solution: because util.buf_clear_references() already defaulted to "current buffer", the change to buf.clear_references() isn't actually needed, so just revert it.
* perf(treesitter): cache fold query (#24222)Jaehwang Jung2023-07-02
| | | | | | | | | | | | | | | | | | | | | perf(treesitter): cache vim.treesitter.query.get Problem: vim.treesitter.query.get searches and reads query files every time it's called, if user hasn't overridden the query. So this can incur slowdown when called frequently. This can happen when using treesitter foldexpr. For example, when using `:h :range!` in markdown file to format fenced codeblock, on_changedtree in _fold.lua is triggered many times despite that the tree doesn't have syntactic changes (might be a bug in LanguageTree). (Incidentally, the resulting fold is incorrect due to a bug in `:h range!`.) on_changedtree calls vim.treesitter.query.get for each tree changes. In addition, it may request folds queries for injected languages without fold queries, such as markdown_inline. Solution: * Cache the result of vim.treesitter.query.get. * If query file was not found, fail quickly at later calls.
* fix(lsp): lint warnings, default offset_encoding #24046Raphael2023-07-01
| | | | | - fix lint / analysis warnings - locations_to_items(): get default offset_encoding from active client - character_offset(): get default offset_encoding from active client
* feat(treesitter): bundle markdown parser and queries (#22481)Christian Clason2023-07-01
| | | | | | | * bundle split Markdown parser from https://github.com/MDeiml/tree-sitter-markdown * add queries from https://github.com/nvim-treesitter/nvim-treesitter/tree/main * upstream `#trim!` and `#inject-language!` directives Co-authored-by: dundargoc <gocdundar@gmail.com>
* fix(lsp): fix attempt to call non existent function (#24212)Sanchayan Maity2023-06-30
| | | | | | | | | | | | Commit 37079fc moved inlay_hint to vim.lsp() but in the process did missed converting a call to disable/enable which are now local. Fixes the below error when trying to toggle inlay hints. E5108: Error executing lua /usr/local/share/nvim/runtime/lua/vim/lsp/inlay_hint.lua:248: attempt to call field 'disable' (a nil value) stack traceback: /usr/local/share/nvim/runtime/lua/vim/lsp/inlay_hint.lua:248: in function 'toggle' /usr/local/share/nvim/runtime/lua/vim/lsp/inlay_hint.lua:310: in function 'inlay_hint' [string ":lua"]:1: in main chunk
* feat(lsp): move inlay_hint() to vim.lsp (#24130)Mathias Fußenegger2023-06-30
| | | | | | Allows to keep more functions hidden and gives a path forward for further inlay_hint related functions - like applying textEdits. See https://github.com/neovim/neovim/pull/23984#pullrequestreview-1486624668
* fix(lsp): inlay_hint nil reference error #24202Chinmay Dalal2023-06-29
| | | | | | | | | Problem: vim_lsp_inlayhint: Error executing lua: .../lsp/_inlay_hint.lua:249: attempt to index field 'applied' (a nil value) Solution: Assign {} to bufstates.applied in on_reload fixes #24172
* fix(treesitter): handle empty region when logging (#24173)Jaehwang Jung2023-06-27
|
* fix(treesitter): make foldexpr work without highlighting (#24167)Jaehwang Jung2023-06-27
| | | | | | | | | | | | | | | Problem: Treesitter fold is not updated if treesitter hightlight is not active. More precisely, updating folds requires `LanguageTree:parse()`. Solution: Call `parse()` before computing folds and compute folds when lines are added/removed. This doesn't guarantee correctness of the folds, because some changes that don't add/remove line won't update the folds even if they should (e.g. adding pair of braces). But it is good enough for most cases, while not introducing big overhead. Also, if highlighting is active, it is likely that `TSHighlighter._on_buf` already ran `parse()` (or vice versa).
* docs(diagnostic): return value of get() #24144NAKAI Tsuyoshi2023-06-27
|
* vim-patch:9.0.1668: PEM files are not recognized (#24169)ObserverOfTime2023-06-27
| | | | | | Problem: PEM files are not recognized. Solution: Add patterns to match PEM files. (closes vim/vim#12582) https://github.com/vim/vim/commit/0256d76a3392aef270b38d1cf7633008e45c2003
* vim-patch:9.0.1632: not all cabal config files are recognized (#24025)Jonas Strittmatter2023-06-26
| | | | | | | | | | | | | Problem: Not all cabal config files are recognized. Solution: Add a couple of patterns. (Marcin Szamotulski, closes vim/vim#12463) https://github.com/vim/vim/commit/166cd7b801ebe4aa042a9bbd6007d1951800aaa9 Also: - Do not expand Lua patterns in environment variables used in file patterns. - Test $XDG_CONFIG_HOME on Windows, as it can be used by Nvim (and the runner sets it). Co-authored-by: Marcin Szamotulski <coot@coot.me>