Commit Graph

5698 Commits

Author SHA1 Message Date
Mike
e4da418ba8
fix(fs.lua): normalize slash truncation (#23753)
Preserve last slash in windows' root drive directories
2023-07-18 14:36:04 +08:00
Lewis Russell
80cf0f3d29
Merge pull request #24363 from lewis6991/docs/luatypes
docs(lua): move some function docs to lua files
2023-07-17 17:40:14 +01:00
Mathias Fußenegger
1b9ccd38a1
feat(lsp)!: rename vim.lsp.get_active_clients to get_clients (#24113) 2023-07-17 18:27:16 +02:00
Lewis Russell
6e9b204afb fix: doc errors 2023-07-17 17:09:16 +01:00
Lewis Russell
69d49727d7 fix: luacheck 2023-07-17 16:32:56 +01:00
Lewis Russell
c2d7c2826c docs(lua): change *lua-foo* -> *vim.foo* 2023-07-17 16:25:29 +01:00
Lewis Russell
0ac3c4d631 docs(lua): move function docs to lua files 2023-07-17 16:25:28 +01:00
Lewis Russell
881d17a113
feat(options)!: remove compatible behaviours for vim 5.0 and earlier 2023-07-17 14:27:21 +01:00
Lewis Russell
3fd504dbec docs: handle whitespace in emmycomments 2023-07-17 12:59:10 +01:00
Lewis Russell
a54f88ea64 docs(lua): do not render self args 2023-07-17 12:59:06 +01:00
Lewis Russell
d0b612f360 refactor: rename _meta.lua to _options.lua 2023-07-17 12:59:04 +01:00
Kai Ting
c3de6524a5
fix(clipboard): ignore exit caused by signal #23378
Problem:
If clipboard job exits by signal, the exit code is >=128:
939d9053bd
xclip 0.13 often exits with code 143, which spams unhelpful messages:

    clipboard: error invoking xclip: Waiting for selection requests,
    Control-C to quit   Waiting for selection request number 1

Solution:
Don't show a warning if the clipboard tool exit code is >=128.
Fixes: #7054
2023-07-16 04:15:30 -07:00
zeertzjq
047c22a28c
docs(term.txt): reorder paragraphs about TUI input (#24367)
Make |tui-modifyOtherKeys| and |tui-csiu| tags appear at a better place.
Also adapt the |<Tab>| help update from dad4473f02
2023-07-16 18:39:45 +08:00
Mike
251ca45ac9
fix(lsp): markdown code fence should allow space before info string #24364
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 0ee73c53ce/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.
2023-07-16 03:11:45 -07:00
zeertzjq
abe39f2b24
feat(api)!: change return type of nvim_win_text_height to Dict (#24365) 2023-07-16 18:02:53 +08:00
Mathias Fußenegger
33e1a8cd70
feat(lsp): map K to hover by default #24331
Related: https://github.com/neovim/neovim/issues/24252
2023-07-14 09:47:18 -07:00
Techatrix
2ecba65b4b
fix(lsp): remove unknown LSP protocol property (#24345)
'hierarchicalWorkspaceSymbolSupport' is not part of the LSP Specification
2023-07-14 07:36:10 +02:00
zeertzjq
dbb840da01
fix(runtime): respect 'rtp' order for all runtime files (#24335) 2023-07-14 06:46:16 +08:00
Mathias Fußenegger
a3f4598226
docs(lua): adds links to related keymap functions to keymap.set (#24337)
Might help with discovery, given that there is no `keymap.get()`
2023-07-13 14:43:36 +02:00
Lewis Russell
516b173780
perf(rtp): reduce rtp scans (#24191)
* perf(rtp): reduce rtp scans

Problem:
  Scanning the filesystem is expensive and particularly affects
  startuptime.

Solution:
  Reduce the amount of redundant directory scans by relying less on glob
  patterns and handle vim and lua sourcing lower down.
2023-07-13 10:17:19 +01:00
zeertzjq
9359701eae
test(extmarks): add test for virt_text_win_col with cpo+=n (#24328) 2023-07-13 07:02:06 +08:00
Mathias Fußenegger
317c80f460
feat(lsp): add method filter to get_active_clients (#24319) 2023-07-12 14:48:21 +02:00
Sean Dewar
bf5703042b
fix(tutor): don't use concealed text in expected lines #24316 2023-07-11 10:09:44 -07:00
zeertzjq
db8fe63a93
feat(api): add nvim_win_text_height (#24236)
It uses the same code as "scroll_delta" of "win_viewport" UI event to
calculate text height, but is more flexible.
2023-07-11 07:15:46 +08:00
Gregory Anders
3750e5ed9c
vim-patch:9.0.1673: cannot produce a status 418 or 503 message (#24287)
Problem:    Cannot produce a status 418 or 503 message.
Solution:   Add err_teapot().

80adaa8ae8

Co-authored-by: Bram Moolenaar <Bram@vim.org>
2023-07-10 11:55:12 -05:00
Raphael
766f4978d6
fix(lint): lint warnings #24226 2023-07-10 04:38:15 -07:00
Justin M. Keyes
b9a0e762f1 fix(defaults): visual star (*) on text with "?"
regression from 6318edadc3
2023-07-08 16:55:27 +02:00
Justin M. Keyes
0a90e4b05a fix(docs): match DocSearch style with site theme
ref 2b4f9e4780
2023-07-08 16:06:46 +02:00
Justin M. Keyes
6318edadc3 fix(defaults): visual hash (#) on text with "?"
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-08 15:33:28 +02:00
Justin M. Keyes
d2e44da516 docs: gather @notes items into one section
related: 21eacbfef3
2023-07-08 15:06:36 +02:00
Justin M. Keyes
3a721820c3 docs: "Return (multiple)" heading
Problem:
Lua functions that return multiple results are declared by using
multiple `@return` docstring directives. But the generated docs don't
make it obvious what this represents.

Solution:
- Generate a "Return (multiple)" heading for multiple-value functions.
- Fix `@note` directives randomly placed after `@return`.
2023-07-08 15:06:36 +02:00
Justin M. Keyes
00d2f4b96e docs: MAINTAIN.md, nvim_get_mark 2023-07-08 15:06:36 +02:00
Chinmay Dalal
21fa19f3e8
fix(lsp): don't use hl_mode = combine for inlay hints #24276
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.
2023-07-08 00:14:52 -07:00
Lewis Russell
c379d72c49
feat(lua): allow vim.wo to be double indexed (#20288)
* 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>
2023-07-07 16:37:36 +01:00
Jaehwang Jung
c44d819ae1
fix(treesitter): update folds in all relevant windows (#24230)
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.
2023-07-07 11:12:46 +01:00
Justin M. Keyes
f39ca5df23 refactor(defaults): use vim.region for visual star (*,#)
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-06 12:18:55 +02:00
Steven Ward
abd380e28d fix(defaults): visual mode star (*,#) is fragile
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-07-06 10:29:50 +02:00
zeertzjq
4e34ca8ae7
docs(luaref): remove parentheses from tags for typedefs (#24271)
And fix alignment.
2023-07-06 14:57:46 +08:00
zeertzjq
2afb04758c
fix(vim.system): close check handle (#24270)
Fix hang after running vim.system() with sanitizers.
2023-07-06 12:56:19 +08:00
fredizzimo
1de82e16c1
fix(ui): delay win_viewport until screen update #24182
Problem:
Sometimes, when nvim sends the `win_viewport` event, for example when scrolling
with visible folds on the screen, it reports the `scroll_delta` value one batch
into "future". So when the client application is trying to show the new viewport
it's not yet updated, resulting in temporary corruption / screen flickering.

For more details see #23609, and starting from [this comment](
https://github.com/neovide/neovide/pull/1790#issuecomment-1518697747) in
https://github.com/neovide/neovide/pull/1790,, where the issue was first
detected. Note that some of the conclusions in those are not fully accurate, but
the general observations are.

Solution:
When there are pending updates to a Window, delay the `win_viewport` UI event
until the updates are sent. This ensures that there's no flush between sending
the viewport and updating of the lines corresponding to the new viewport.

Document the existing viewport behaviour (for cases where there are no
extra flushes), give a hint about how applications can deal with the slightly
surprising behaviour of the viewport event being sent after the updates.

Fixes https://github.com/neovim/neovim/issues/23609
2023-07-05 06:31:34 -07:00
zeertzjq
8a788e2daa
Merge pull request #23228 from seandewar/cmdwin-jail
fix(api): use `text_locked()` to check for textlock
2023-07-05 17:04:17 +08:00
zeertzjq
df297e3c2b
fix(runtime): don't set gx mapping if already mapped (#24262)
This matches netrw's use of maparg().
2023-07-05 16:31:45 +08:00
Sean Dewar
aa4e47f704
fix(api): disallow some more functions during textlock
Problem: nvim_buf_set_text(), nvim_open_term() and termopen() all change buffer
text, which is forbidden during textlock. Additionally, nvim_open_term() and
termopen() may be used to convert the cmdwin buffer into a terminal buffer,
which is weird.

Solution: Allow nvim_buf_set_text() and nvim_open_term() in the cmdwin, but
disallow nvim_open_term() from converting the cmdwin buffer into a terminal
buffer. termopen() is not allowed in the cmdwin (as it always operates on
curbuf), so just check text_locked().

Also happens to improve the error in #21055: nvim_buf_set_text() was callable
during textlock, but happened to check textlock indirectly via u_save();
however, this caused the error to be overwritten by an unhelpful "Failed to
save undo information" message when msg_list == NULL (e.g: an `<expr>` mapping
invoked outside of do_cmdline()).
2023-07-05 08:33:32 +01:00
Sean Dewar
77118d0da8
fix(api): use text_locked() to check textlock
Problem: some API functions that check textlock (usually those that can change
curwin or curbuf) can break the cmdwin.

Solution: make FUNC_API_CHECK_TEXTLOCK call text_locked() instead, which already
checks for textlock, cmdwin and `<expr>` status.

Add FUNC_API_TEXTLOCK_ALLOW_CMDWIN to allow such functions to be usable in the
cmdwin if they can work properly there; the opt-in nature of this attribute
should hopefully help mitigate future bugs.

Also fix a regression in #22634 that made functions checking textlock usable in
`<expr>` mappings, and rename FUNC_API_CHECK_TEXTLOCK to FUNC_API_TEXTLOCK.
2023-07-05 08:31:52 +01:00
Justin M. Keyes
e644e7ce0b fix(vim.ui.open): return (don't show) error message
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.
2023-07-05 00:49:10 +02:00
Justin M. Keyes
67b2ed1004 fix(gx): visual selection, expand env vars
---
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
2023-07-04 23:45:35 +02:00
marshmallow
af6e6ccf3d feat(vim.ui): vim.ui.open, "gx" without netrw
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>
2023-07-04 23:45:00 +02:00
Raphael
cf5f1492d7
fix(lsp): revert change to buf.clear_references() #24238
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.
2023-07-04 05:30:31 -07:00
zeertzjq
a76b689b47
perf(ui-ext): approximate scroll_delta when scrolling too much (#24234) 2023-07-04 16:48:53 +08:00
bfredl
f771d62471
Merge pull request #23891 from rickyz/grid_line_flags
fix(ui): propagate line flags on grid_line events
2023-07-03 09:53:27 +02:00