Commit Graph

3840 Commits

Author SHA1 Message Date
altermo
c0b99bb1de
feat(treesitter): show root nodes in :InspectTree (#26944)
Co-authored-by: altermo <>
Co-authored-by: Jongwook Choi <wookayin@gmail.com>
2024-02-06 14:51:53 -06:00
Lewis Russell
c4417ae70c fix(doc): prevent doxygen confusion 2024-02-06 15:29:01 +00:00
dundargoc
63b810c9d8
docs: small fixes (#27213)
Co-authored-by: Matthieu Coudron <886074+teto@users.noreply.github.com>
2024-02-06 19:30:02 +08:00
Christian Clason
9a761019da vim-patch:f7f33e3719c8
runtime(dosbatch): improve '::' comment highlighting

Added a syntax region for command blocks so that the highlighting of
`::` comments in them can be controlled.  The `dosbatch_colons_comment`
variable now controls if all `::` comments in a code block are
highlighted as comments or errors.  A `::` comment at the end of a
command block is always highlighted as an error.

This re-enables the highlighting of `::` comments in `.bat` files as
requested in vim/vim#13666, while allowing control of highlighting them in
command blocks requested in vim/vim#11778 and first attempted in vim/vim#11980.

related: vim/vim#11980
fixes: vim/vim#13666

f7f33e3719

Co-authored-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Mike Williams <mikew@globalgraphics.com>
2024-02-06 11:42:15 +01:00
Jongwook Choi
a478bf936b feat(treesitter): use 0-based indexing to show ranges in :InspectTree
Problem:

- `:InspectTree` was showing node ranges in 1-based indexing, i.e., in
  vim cursor position (lnum, col). However, treesitter API adopts
  0-based indexing to represent ranges (Range4). This can often be
  confusing for developers and plugin authors when debugging code
  written with treesiter APIs.

Solution:

- Change to 0-based indexing from 1-based indexing to show node ranges
  in `:InspectTree`.

- Note: To make things not complicated, we do not provide an option or
  keymap to configure which indexing mode to use.
2024-02-05 16:23:22 -05:00
zeertzjq
e98decf9a6
feat(quickfix): support -q - to read 'errorfile' from stdin (#27303)
Note that this only works when stdin is a pipe.
2024-02-02 21:17:37 +08:00
Will Hopkins
6bba4beced
feat(api): make nvim_open_win support non-floating windows (#25550)
Adds support to `nvim_open_win` and `nvim_win_set_config` for creating
and manipulating split (non-floating) windows.
2024-02-01 11:43:35 +08:00
Will Hopkins
ca9f6f5694
feat(api): add nvim_tabpage_set_win (#27222)
Allows setting the current window of a non-current tabpage
without switching tabpages.
2024-01-29 15:18:33 +08:00
Jongwook Choi
5b1b765610
docs: enforce "treesitter" spelling #27110
It's the "tree-sitter" project, but "treesitter" in our code and docs.
2024-01-28 17:53:14 -08:00
Sean Dewar
d85f180f26
vim-patch:9.1.0049: Make "[Command Line]" a special buffer name
Problem:  E95 is possible if a buffer called "[Command Line]" already
          exists when opening the cmdwin. This can also happen if the
          cmdwin's buffer could not be deleted when closing.

Solution: Un-name the cmdwin buffer, and give it a special name instead,
          similar to what's done for quickfix buffers and for unnamed
          prompt and scratch buffers. As a result, BufFilePre/Post are
          no longer fired when opening the cmdwin. Add a "command" key
          to the dictionary returned by getbufinfo() to differentiate
          the cmdwin buffer instead. (Sean Dewar)

Cherry-pick test_normal changes from v9.0.0954.

1fb4103206
2024-01-28 12:29:42 +00:00
Justin M. Keyes
2cd76a758b
docs(lua): update ":{range}lua" docs + error message #27231
- `:lua (no file)` is misleading because `:lua` never takes a file arg,
  unlike `:source`.
- Update various related docs.
2024-01-27 10:40:30 -08:00
luukvbaal
c2433589dc
feat(ex_cmds): ranged :lua #27167
:{range}lua executes the specified lines in the current buffer as
Lua code, regardless of its extension or 'filetype'.

Close #27103
2024-01-26 17:00:50 -08:00
Till Bungert
0892c080d1
revert: "feat(treesitter): add foldtext with treesitter highlighting"
This reverts commit 9ce1623 in favor of #20750.
2024-01-27 08:38:56 +08:00
zeertzjq
226466a469
vim-patch:9.1.0058: Cannot map Super Keys in GTK UI (#27204)
Problem:  Cannot map Super Keys in GTK UI
          (Casey Tucker)
Solution: Enable Super Key mappings in GTK using <D-Key>
          (Casey Tucker)

As a developer who works in both Mac and Linux using the same keyboard,
it can be frustrating having to remember different key combinations or
having to rely on system utilities to remap keys.

This change allows `<D-z>` `<D-x>` `<D-c>` `<D-v>` etc. to be recognized
by the `map` commands, along with the `<D-S-...>` shifted variants.

```vimrc
if has('gui_gtk')
	nnoremap  <D-z>    u
	nnoremap  <D-S-Z>  <C-r>
	vnoremap  <D-x>    "+d
	vnoremap  <D-c>    "+y
	cnoremap  <D-v>    <C-R>+
	inoremap  <D-v>    <C-o>"+gP
	nnoremap  <D-v>    "+P
	vnoremap  <D-v>    "-d"+P
	nnoremap  <D-s>    :w<CR>
	inoremap  <D-s>    <C-o>:w<CR>
	nnoremap  <D-w>    :q<CR>
	nnoremap  <D-q>    :qa<CR>
	nnoremap  <D-t>    :tabe<CR>
	nnoremap  <D-S-T>  :vs#<CR><C-w>T
	nnoremap  <D-a>    ggVG
	vnoremap  <D-a>    <ESC>ggVG
	inoremap  <D-a>    <ESC>ggVG
	nnoremap  <D-f>    /
	nnoremap  <D-g>    n
	nnoremap  <D-S-G>  N
	vnoremap  <D-x>    "+x
endif
```

closes: vim/vim#12698

92e90a1e10

Co-authored-by: Casey Tucker <dctucker@hotmail.com>
2024-01-26 11:04:54 +08:00
Evgeni Chasnovski
1e0996b572 feat(colorscheme): update treesitter groups
Problem: Currently default color scheme defines most of treesitter
  highlight groups. This might be an issue for users defining their own
  color scheme as it breaks the "fallback property" for some of groups.

Solution: Define less default treesitter groups; just enough for default
  color scheme to be useful. That is:
    - All first level groups (`@character`, `@string`, etc.).
    - All `@xxx.builtin` groups as a most common subgroup.
    - Some special cases (links/URLs, `@diff.xxx`, etc.).
2024-01-25 20:09:24 +01:00
Gregory Anders
6ea6b3fee2
feat(ui): add support for OSC 8 hyperlinks (#27109)
Extmarks can contain URLs which can then be drawn in any supporting UI.
In the TUI, for example, URLs are "drawn" by emitting the OSC 8 control
sequence to the TTY. On terminals which support the OSC 8 sequence this
will create clickable hyperlinks.

URLs are treated as inline highlights in the decoration subsystem, so
are included in the `DecorSignHighlight` structure. However, unlike
other inline highlights they use allocated memory which must be freed,
so they set the `ext` flag in `DecorInline` so that their lifetimes are
managed along with other allocated memory like virtual text.

The decoration subsystem then adds the URLs as a new highlight
attribute. The highlight subsystem maintains a set of unique URLs to
avoid duplicating allocations for the same string. To attach a URL to an
existing highlight attribute we call `hl_add_url` which finds the URL in
the set (allocating and adding it if it does not exist) and sets the
`url` highlight attribute to the index of the URL in the set (using an
index helps keep the size of the `HlAttrs` struct small).

This has the potential to lead to an increase in highlight attributes
if a URL is used over a range that contains many different highlight
attributes, because now each existing attribute must be combined with
the URL. In practice, however, URLs typically span a range containing a
single highlight (e.g. link text in Markdown), so this is likely just a
pathological edge case.

When a new highlight attribute is defined with a URL it is copied to all
attached UIs with the `hl_attr_define` UI event. The TUI manages its own
set of URLs (just like the highlight subsystem) to minimize allocations.
The TUI keeps track of which URL is "active" for the cell it is
printing. If no URL is active and a cell containing a URL is printed,
the opening OSC 8 sequence is emitted and that URL becomes the actively
tracked URL. If the cursor is moved while in the middle of a URL span,
we emit the terminating OSC sequence to prevent the hyperlink from
spanning multiple lines.

This does not support nested hyperlinks, but that is a rare (and,
frankly, bizarre) use case. If a valid use case for nested hyperlinks
ever presents itself we can address that issue then.
2024-01-24 16:36:25 -06:00
Christian Clason
964dd93266 vim-patch:e1ddc2d5875d
runtime(fortran): update syntax and documentation (vim/vim#13912)

* runtime (doc): update Fortran section
* runtime(syntax): Complete support for Fortran 2023.
   Minor improvements.

e1ddc2d587

Co-authored-by: Ajit-Thakkar <142174202+Ajit-Thakkar@users.noreply.github.com>
2024-01-24 23:23:23 +01:00
zeertzjq
8c044f0862
fix(spell): always accept ':' as filename char in 'spellfile' (#27172)
Follow-up to #25236
2024-01-24 18:13:39 +08:00
Christian Clason
0c1119ac75 vim-patch:ca0e9823a1df
runtime(c): Highlight user defined functions

closes: vim/vim#13763

ca0e9823a1

Co-authored-by: Luca Saccarola <github.e41mv@aleeas.com>
2024-01-24 11:05:25 +01:00
Christian Clason
9808a781d3 vim-patch:9c5b90db035b
runtime(vim): Update syntax file (vim/vim#13906)

Highlight :2match and :3match and add these to :help ex-cmd-index.

9c5b90db03

Co-authored-by: dkearns <dougkearns@gmail.com>
2024-01-24 11:05:25 +01:00
Jongwook Choi
913469ff21 docs(treesitter): add more examples, and improve consistency
Docs for treesitter would benefit from including more real-world and
practical examples of queries and usages, rather than hypothetical ones
(e.g. names such as "foo", "bar"). Improved examples should be more
user-friendly and clear to understand.

In addition, align the capture names in some examples with the actual
ones being used in the built-in query files or in the nvim-treesitter
plugin, e.g.:

- `@parameter` -> `@variable.parameter`
- `@comment.doc.java` -> `@comment.documentation.java`
- etc.
2024-01-24 11:04:16 +01:00
zeertzjq
6cbfe45454
vim-patch:e13b665a6e2a (#27163)
runtime(doc): change "VIsual mode" to "Visual mode" in :h SafeState (vim/vim#13901)

"Visual mode" is used everywhere else in the help when not referring to
something in the source code.

e13b665a6e
2024-01-24 06:07:42 +08:00
zeertzjq
cb6320e13f
docs(options): remove misleading sentence (#27129)
Setting 'verbose' to 1 doesn't cause Nvim to produce messages. It adds
more information to existing messages, which is documented above.
2024-01-22 22:54:45 +08:00
Lewis Russell
1233ac467d
feat(fold): transparent foldtext
'foldtext' can be set to an empty string to disable and render the
line with:
  - extmark highlight
  - syntax highlighting
  - search highlighting
  - no line wrapping
  - spelling
  - conceal
  - inline virtual text
  - respects `fillchars:fold`

Currently normal virtual text is not displayed


Co-authored-by: zeertzjq <zeertzjq@outlook.com>
2024-01-22 10:13:35 +00:00
Raphael
12d123959f
fix(eval): properly support checking v:lua function in exists() (#27124) 2024-01-22 16:04:50 +08:00
zeertzjq
8c6de9147c
Merge pull request #26813 from VanaIgr/screen-pos-speedup
perf: make screen size and position calculations more efficient

N/A patches for version.c:
vim-patch:9.1.0037: Calling get_breakindent_win() repeatedly when computing virtcol
vim-patch:9.1.0038: Unnecessary loop in getvcol()
2024-01-22 10:00:11 +08:00
VanaIgr
fd08de4b85 docs(news): expand the list of performance improvements
When computing on-screen size or position, the size 'breakindent' and 'showbreak' is now cached,
and checks for whether a faster character size function can be used are performed only once at the start.
Multibyte characters are not decodes multiple times anymore, and character decoding functions are more efficient.
Additionally, the amount of trailing spaces for pasted blockwise text is now calculated correctly for multibyte characters.
Internal lisp formatting now doesn't erroneously use inline virtual text from a different line.
2024-01-22 09:05:01 +08:00
Jongwook Choi
fa4b02fa67 feat(vim.version): add vim.version.le and vim.version.ge
- Problem: One cannot easily write something like, for example:
    `version_current >= {0, 10, 0}`; writing like
    `not vim.version.lt(version_current, {0, 10, 0})` is verbose.

- Solution: add {`le`,`ge`} in addition to {`lt`,`gt`}.

- Also improve typing on the operator methods: allow `string` as well.

- Update the example in `vim.version.range()` docs: `ge` in place of
  `gt` better matches the semantics of `range:has`.
2024-01-21 11:41:50 +01:00
Christian Clason
f5dc453109 feat(treesitter)!: new standard capture names
Problem: Sharing queries with upstream and Helix is difficult due to
different capture names.

Solution: Define and document a new set of standard captures that
matches tree-sitter "standard captures" (where defined) and is closer to
Helix' Atom-style nested groups.

This is a breaking change for colorschemes that defined highlights based
on the old captures. On the other hand, the default colorscheme now
defines links for all standard captures (not just those used in bundled
queries), improving the out-of-the-box experience.
2024-01-21 10:41:18 +01:00
Raphael
98a4ed0a11
feat(api): support getting abbreviations (#26868) 2024-01-20 08:08:44 +08:00
Gregory Anders
d3a8e9217f
feat(ui): add chdir UI event (#27093)
When an embedded Nvim instance changes its current directory a "chdir"
UI event is emitted. Attached UIs can use this information however they
wish. In the TUI it is used to synchronize the cwd of the TUI process
with the cwd of the embedded Nvim process.
2024-01-19 14:51:10 -06:00
bfredl
0b36cbbafd
Merge pull request #27061 from luukvbaal/extmark
fix(extmarks): do not remove invalid marks from decor upon deletion
2024-01-19 10:49:13 +01:00
Luuk van Baal
2645c9d576 docs(extmarks): add undocumented "details" array fields 2024-01-18 17:06:47 +01:00
notomo
ab3a7fc3e3
docs(vim.iter): correct bool to boolean (#27018) 2024-01-18 07:01:57 -06:00
Justin M. Keyes
95cbedaa17
docs: various #25289
Co-authored-by: Jongwook Choi <wookayin@gmail.com>
Co-authored-by: Oliver Marriott <hello@omarriott.com>
Co-authored-by: Benoit de Chezelles <bew@users.noreply.github.com>
Co-authored-by: Jongwook Choi <wookayin@gmail.com>
2024-01-18 00:14:48 -08:00
zeertzjq
780dd88b68
vim-patch:9.1.0039: too vague errors for 'listchars'/'fillchars' (#27070)
Problem:  too vague errors for 'listchars'/'fillchars'
Solution: Include the field name in error message.
          (zeertzjq)

related: #27050
closes: vim/vim#13877

6a8d2e1634

Co-authored-by: Cole Frankenhoff <cole.nhf@gmail.com>
2024-01-18 07:14:12 +08:00
dundargoc
b3e5587b7f
docs: various fixes (#26929)
Co-authored-by: Patrick Bollinger <owner@pjbollinger.com>
Co-authored-by: vilo1839 <139687192+vilo1839@users.noreply.github.com>
2024-01-17 14:01:39 +08:00
Jongwook Choi
3973a5e405 refactor(lsp): deprecate vim.lsp.util.lookup_section
This function is used only in the `workspace/configuration` handler,
and does not warrant a public API because of its confusing return types.

The only caller `vim.lsp.handlers["workspace.configuration"]` is also
refactored to use `vim.tbl_get()` instead.
2024-01-16 20:14:17 +00:00
Sean Dewar
91dc04a5e1
vim-patch:9.1.0013: Modula2 filetype support lacking (#27020)
Problem:  Modula2 filetype support lacking
Solution: Improve the Modula-2 runtime support, add additional modula2
          dialects, add compiler plugin, update syntax highlighting,
          include syntax tests, update Makefiles (Doug Kearns)

closes: vim/vim#6796
closes: vim/vim#8115

68a8947069

- Luaify the detection script:

  - Split the `(*!m2foo*)` and `(*!m2foo+bar*)` detection into two Lua patterns,
    as Lua capture groups cannot be used with `?` and friends (as they only work
    on character classes).

  - Use `vim.api.nvim_buf_call()` (ew) to call `modula2#SetDialect()` to ensure
    `b:modula2` is set for the given bufnr.

- Skip the syntax screendump tests. (A shame as they test some of the detection
  from `(*!m2foo+bar*)` tags, but I tested this locally and it seems to work)

- Port the synmenu.vim changes from Vim9 script. (Also tested this locally)

- (And also add the missing comma for `b:browsefilter` from earlier.)

Co-authored-by: Doug Kearns <dougkearns@gmail.com>
2024-01-16 17:45:57 +00:00
Luuk van Baal
463cb28a22 docs(column): 'statuscolumn' redraw interaction with 'relativenumber' 2024-01-16 12:14:00 +01:00
Lewis Russell
50284d07b6 fix(diagnostic): typing 2024-01-16 09:33:10 +00:00
zeertzjq
92672a161c
docs(builtin): remove signatures of undocumented functions (#27039)
Having an empty signature causes an empty line in generated docs,  so
remove it.

Also change ">" to ">vim" in foreach() docs.
2024-01-16 12:07:35 +08:00
zeertzjq
46a7c1b319
vim-patch:partial:9.1.0027: Vim is missing a foreach() func (#27037)
Problem:  Vim is missing a foreach() func
Solution: Implement foreach({expr1}, {expr2}) function,
          which applies {expr2} for each item in {expr1}
          without changing it (Ernie Rael)

closes: vim/vim#12166

e79e207760

Partial port as this doesn't handle non-materialized range() lists.

vim-patch:c92b8bed1fa6

runtime(help): delete duplicate help tag E741 (vim/vim#13861)

c92b8bed1f

Co-authored-by: Ernie Rael <errael@raelity.com>
2024-01-16 11:30:35 +08:00
zeertzjq
73e1942abe
vim-patch:9.1.0009: Cannot easily get the list of matches (#27028)
Problem:  Cannot easily get the list of matches
Solution: Add the matchstrlist() and matchbufline() Vim script
          functions (Yegappan Lakshmanan)

closes: vim/vim#13766

Omit CHECK_LIST_MATERIALIZE(): it populates a List with numbers only,
and there is a check for strings below.

f93b1c881a

vim-patch:eb3475df0d92

runtime(doc): Replace non-breaking space with normal space (vim/vim#13868)

eb3475df0d

Co-authored-by: Yegappan Lakshmanan <4298407+yegappan@users.noreply.github.com>
2024-01-16 08:00:08 +08:00
Daniel Steinberg
7589336120
feat(terminal): respond to OSC background and foreground request (#17197)
The motivation for this update is Issue #15365, where background=light
is not properly set for Nvim running from an Nvim :terminal. This can be
encountered when e.g., opening a terminal to make git commits, which
opens EDITOR=nvim in the nested terminal.

Under the implementation of this commit, the OSC response always
indicates a black or white foreground/background. While this may not
reflect the actual foreground/background color, it permits 'background'
to be retained for a nested Nvim instance running in the terminal
emulator. The behaviour matches Vim.
2024-01-15 10:12:07 -06:00
Christian Clason
7ed6966023 vim-patch:93197fde0f1d
runtime(ftplugin): Use "*" browsefilter pattern to match "All Files"

Problem:  The "*.*" browsefilter pattern only matches all files on
	  Windows (Daryl Lee)
Solution: Use "*" to filter on all platforms but keep "*.*" as the label
	  text on Windows. (Fixes vim/vim#12685, Doug Kearns)

The *.* browsefilter pattern used to match "All Files" on Windows is a
legacy of the DOS 8.3 filename wildcard matching algorithm.  For reasons
of backward compatibility this still works on Windows to match all
files, even those without an extension.

However, this pattern only matches filenames containing a dot on other
platforms.  This often makes files without an extension difficult to
access from the file dialog, e.g., "Makefile"

On Windows it is still standard practice to use "*.*" for the filter
label so ftplugins should use "All Files (*.*)" on Windows and "All
Files (*)" on other platforms.  This matches Vim's default browsefilter
values.

This commit also normalises the browsefilter conditional test to check
for the Win32 and GTK GUI features and an unset b:browsefilter.

closes: vim/vim#12759

93197fde0f

Co-authored-by: Doug Kearns <dougkearns@gmail.com>
2024-01-15 11:40:44 +01:00
Jongwook Choi
4d91604c88 docs: add lua typing for vim.NIL 2024-01-15 08:45:30 +00:00
Jongwook Choi
2cdea852e8 docs: auto-generate docs for vim.lpeg and vim.re
- Add section `VIM.LPEG` and `VIM.RE` to docs/lua.txt.

- Add `_meta/re.lua` which adds luadoc and type annotations, for the
  vendored `vim.re` package.

- Fix minor style issues on `_meta/lpeg.lua` luadoc for better vimdocs
  generation.

- Fix a bug on `gen_vimdoc` where non-helptags in verbatim code blocks
  were parsed as helptags, affecting code examples on `vim.lpeg.Cf`,
  etc.

- Also move the `vim.regex` section below so that it can be located
  closer to `vim.lpeg` and `vim.re`.
2024-01-14 11:08:33 +00:00
Jongwook Choi
ce4ea638c7 fix(lsp): fix incorrect typing and doc for vim.lsp.rpc
Typings introduced in #26032 and #26552 have a few conflicts, so we
merge and clean them up. We also fix some incorrect type annotation in
the `vim.lsp.rpc` package. See the associated PR for more details.

Summary:

- vim.rpc.Dispatchers -> vim.lsp.rpc.Dispatchers
- vim.lsp.rpc.Error -> lsp.ResponseError
- Revise docs
2024-01-14 09:02:45 +01:00
zeertzjq
2bdd8fad4c
docs(builtin): fix mapset() signature (#27008) 2024-01-14 08:44:16 +08:00