Commit Graph

6295 Commits

Author SHA1 Message Date
Lewis Russell
97bea3163a feat(lsp): more annotations 2023-12-14 12:39:18 +00:00
Raphael
619407eb54
feat(nvim_open_term): convert LF => CRLF (#26384)
Problem:
Unlike termopen(), nvim_open_term() PTYs do not carriage-return the
cursor on newline ("\n") input.

    nvim --clean
    :let chan_id = nvim_open_term(1, {})
    :call chansend(chan_id, ["here", "are", "some", "lines"])

Actual behavior:

    here
        are
           some
               lines

Expected behaviour:

    here
    are
    some
    lines

Solution:
Add `force_crlf` option, and enable it by default.
2023-12-14 16:08:00 +08:00
Jaehwang Jung
5aa1ba3efe
fix(defaults): background detection in tmux (#26557)
Wrap the query with passthrough sequence
2023-12-14 06:16:21 +08:00
dundargoc
1d63a057a6 docs: fix links 2023-12-13 20:31:16 +01:00
dundargoc
7908dc0d15 docs: move vim-patch wiki page to runtime documentation 2023-12-13 18:31:05 +01:00
dundargoc
fbd0f6658f docs: add installation and build guides from wiki to repo 2023-12-13 17:53:36 +01:00
Gregory Anders
ad6c4c2e9d
Merge pull request #26555 from gpanders/diagnostic-sign-fixup
Diagnostic sign fixups
2023-12-13 10:38:16 -06:00
dundargoc
ef58ee48f4
docs: add wiki FAQ to the runtime documentation (#26539)
Problem: Wiki contents are not discoverable and hard to maintain.
Solution: Move FAQ to runtime docs.

Co-authored-by: Christian Clason <c.clason@uni-graz.at>
2023-12-13 17:31:39 +01:00
Gregory Anders
a3b3978474 feat(diagnostics): support numhl and linehl for diagnostic signs 2023-12-13 09:56:10 -06:00
Gregory Anders
39112c72dd docs(diagnostic): fix typo in example 2023-12-13 09:43:27 -06:00
Gregory Anders
29d5ff6ac4 fix(diagnostic): check for sign namespace instead of sign group 2023-12-13 09:30:13 -06:00
Raphael
8122470f83
refactor(diagnostic): set sign by using extmark (#26193)
after sign implementation refactor by using extmark, we can use
`nvim_buf_set_extmark` to set diagnostic sign instead use `sign_define`
2023-12-13 08:19:53 -06:00
Gregory Anders
e527842211
fix(termcap): only call callback for requested capabilities (#26546)
If multiple XTGETTCAP requests are active at once (for example, for
requesting the Ms capability and truecolor capabilities), then the
TermResponse autocommand may fire for capabilities that were not
requested. Instead, make sure that the provided callback is only called
for capabilities that were actually requested.
2023-12-13 08:14:30 -06:00
Will Hopkins
69ffbb76c2
feat(iter): add Iter.take (#26525) 2023-12-12 14:27:24 -06:00
Raphael
1d4a5cd185
feat(eval): exists() function supports checking v:lua functions (#26485)
Problem:  Vimscript function exists() can't check v:lua functions.
Solution: Add support for v:lua functions to exists().
2023-12-12 19:06:22 +08:00
Lewis Russell
8097b4a725
Merge pull request #26506 from tomtomjhj/tsfold
fix(treesitter): improve vim.treesitter.foldexpr
2023-12-11 19:30:53 +00:00
Jaehwang Jung
6f75facb9d fix(treesitter): improve vim.treesitter.foldexpr
* Collect on_bytes and flush at the invocation of the scheduled callback
  to take account of commands that triggers multiple on_bytes.
* More accurately track movement of folds so that foldexpr returns
  reasonable values even when the scheduled computation is not run yet.
* Start computing folds from the line above (+ foldminlines) the changed
  lines to handle the folds that are removed due to the size limit.
* Shrink folds that end at the line at which another fold starts to
  assign proper level to that line.
* Use level '=' for lines that are not computed yet.
2023-12-12 02:29:59 +09:00
Jaehwang Jung
7c6f9690f7 fix(treesitter): fix indexing in foldexpr 2023-12-12 02:29:59 +09:00
Jongwook Choi
3692fd4c87
feat(gen_lsp.lua): validate CLI args #26514
- Improve CLI argument parsing, rejects invalid argument and commands as
  early as possible. Also prints USAGE in the command line.
- No longer allows `--<outfile>`, use `--out <outfile>` instead.
- Print a little bit of verbose messages to better know what's going on
  rather than remaining silent at all times.
- Add type annotation `gen_lsp._opt` to avoid type warnings.
2023-12-11 01:10:00 -08:00
Christian Clason
c675e51c2f docs(news): very, very minorly
* fix garbled item for new treesitter injection format
* add missing item for new `vim.lpeg` and `vim.re`
* use taglinks where possible
* remove redundant "Added" and "Removed" from items
2023-12-10 14:28:07 +01:00
zeertzjq
29aa4dd10a
vim-patch:61e984e212ed (#26484)
runtime(doc): link cmdline completion to to |wildcards| and fix typos (vim/vim#13636)

The docs for cmdline completion doesn't mention that [abc] is considered
a wildcard, and |wildcards| contains more detailed information, so just
link to it.

Also fix some typos in other help files.

61e984e212
2023-12-09 15:35:45 +08:00
zeertzjq
f45bf44176
vim-patch:ff0baca86523 (#26476)
runtime(syntax): unlet b:filetype_in_cpp_family for cpp & squirrel

Update runtime/syntax/cpp.vim and runtime/syntax/squirrel.vim to unlet
b:filetype_in_cpp_family as it remains set even after updating the ft of
a file manually or through a modeline, not allowing c specific keywords
to be highlighted.

Since the variable b:filetype_in_cpp_family is only used by the c.vim
syntax script, unlet it directly after sourcing the c.vim runtime file
instead of at the end of the script.

Also update the last Change Header for both files.

closes: vim/vim#13650

ff0baca865

Co-authored-by: laburnumT <laburnumtec@gmail.com>
2023-12-09 07:45:31 +08:00
Maria José Solano
a1bdf2852d
fix(snippet): remove misleading comment about TM_FILENAME_BASE (#26465) 2023-12-08 21:23:46 +01:00
Gregory Anders
08545bd45b
Merge pull request #26407 from gpanders/default-tgc
feat(defaults): enable 'termguicolors' by default when supported by terminal
2023-12-06 10:55:50 -08:00
Gregory Anders
2613ba5000 feat(defaults): enable 'termguicolors' by default when supported by terminal
Enable 'termguicolors' automatically when Nvim can detect that truecolor
is supported by the host terminal.

If $COLORTERM is set to "truecolor" or "24bit", or the terminal's
terminfo entry contains capabilities for Tc, RGB, or setrgbf and
setrgbb, then we assume that the terminal supports truecolor. Otherwise,
the terminal is queried (using both XTGETTCAP and SGR + DECRQSS). If the
terminal's response to these queries (if any) indicates that it supports
truecolor, then 'termguicolors' is enabled.
2023-12-06 07:57:09 -08:00
Emanuel
e057b38e70
fix(json): allow objects with empty keys #25564
Problem:
Empty string is a valid JSON key, but json_decode() treats an object
with empty key as ":help msgpack-special-dict". #20757

    :echo json_decode('{"": "1"}')
    {'_TYPE': [], '_VAL': [['', '1']]}

Note: vim returns `{'': '1'}`.

Solution:
Allow empty string as an object key.

Note that we still (currently) disallow empty keys in object_to_vim() (since 7c01d5ff92):
f64e4b43e1/src/nvim/api/private/converter.c (L333-L334)

Fix #20757

Co-authored-by: Justin M. Keyes <justinkz@gmail.com>
2023-12-06 07:56:04 -08:00
Christian Clason
f64e4b43e1 vim-patch:6863084d3bd0
runtime(fortran): update syntax and ftplugins

closes: vim/vim#13629

6863084d3b

Co-authored-by: Ajit-Thakkar <142174202+Ajit-Thakkar@users.noreply.github.com>
2023-12-06 14:59:38 +01:00
Christian Clason
b95eba22ff vim-patch:4e043b1fc7ee
runtime(vim): Update syntax file and syntax test (vim/vim#13632)

Add missing assignment operators (:let*=, :let/= and :let%=).

4e043b1fc7

Co-authored-by: dkearns <dougkearns@gmail.com>
2023-12-06 14:59:38 +01:00
Gregory Anders
5b40a1c09d
feat(lua): implement Iter:join() (#26416) 2023-12-05 18:35:22 -08:00
dundargoc
cc38086039
docs: small fixes (#26243)
Co-authored-by: umlx5h <umlx5h21@protonmail.com>
Co-authored-by: Gregory Anders <greg@gpanders.com>
Co-authored-by: Evan Farrar <evan@evanfarrar.com>
2023-12-06 08:04:21 +08:00
zeertzjq
4a1abc91a0
vim-patch:2103a56eab5a (#26411)
runtime(doc): remove non-existent parameter in shift-command (vim/vim#13626)

The variant with the {count} parameter is explained in the next item.

2103a56eab

N/A patches:
vim-patch:9.0.2150: Using int for errbuflen in option funcs
vim-patch:3f7855a6123c

Co-authored-by: Roy Orbitson <Roy-Orbison@users.noreply.github.com>
2023-12-06 06:44:37 +08:00
Riccardo Mazzarini
0b74ad0a64
refactor(api): complete conversion from Dictionary to Dict(opts) (#26365) 2023-12-05 19:33:57 +08:00
Christian Clason
c9828200ac vim-patch:9.0.2148: Vim does not detect pacman.log file
Problem:  Vim does not detect pacman.log file
Solution: Detect pacmanlogs and add syntax highlighting

pacman.log is a filetype common to Arch Liux and related distributions.
Add some simple syntax highlighting for the pacmanlog filetype.

closes: vim/vim#13618

1e5d66408e

Co-authored-by: Ronan Pigott <ronan@rjp.ie>
2023-12-05 09:45:13 +01:00
Jongwook Choi
cf612c64b0
fix(treesitter): allow passing lang to vim.treesitter.get_node() now correctly takes opts.lang (#26360)
PROBLEM: `vim.treesitter.get_node()` does not recognize the `lang` in
the option table. This option was used in somewhere else, for instance,
`vim.treesitter.dev` (for `inspect_tree`) but was never implemented.

SOLUTION: Make `get_node()` correctly use `opts.lang` when getting a
treesitter parser.
2023-12-04 10:00:49 +01:00
Christian Clason
988b472d90
feat(treesitter): highlight help files by default (#26347) 2023-12-03 15:58:27 +01:00
Evgeni Chasnovski
64a14026d7
feat(highlight): update default color scheme
Problem: Default color scheme is suboptimal.

Solution: Start using new color scheme. Introduce new `vim` color scheme
for opt-in backward compatibility.

------
Main design ideas
- Be "Neovim branded".
- Be minimal for 256 colors with a bit more shades for true colors.
- Be accessible through high enough contrast ratios.
- Be suitable for dark and light backgrounds via exchange of dark and
  light palettes.

------
Palettes

- Have dark and light variants. Implemented through exporeted
  `NvimDark*` and `NvimLight*` hex colors.

- Palettes have 4 shades of grey for UI elements and 6 colors (red,
  yellow, green, cyan, blue, magenta).

- Actual values are computed procedurally in Oklch color space based on
  a handful of hyperparameters.

- Each color has a 256 colors variant with perceptually closest color.

------
Highlight groups

Use:

- Grey shades for general UI according to their design.

- Bold text for keywords (`Statement` highlight group). This is an
  important choice to increase accessibility for people with color
  deficiencies, as it doesn't rely on actual color.

- Green for strings, `DiffAdd` (as background), `DiagnosticOk`, and some
  minor text UI elements.

- Cyan as main syntax color, i.e. for function usage (`Function`
  highlight group), `DiffText`, `DiagnosticInfo`, and some minor text UI
  elements.

- Red to generally mean high user attention, i.e. errors; in particular
  for `ErrorMsg`, `DiffDelete`, `DiagnosticError`.

- Yellow very sparingly only with true colors to mean mild user
  attention, i.e. warnings. That is, `DiagnosticWarn` and `WarningMsg`.

- Blue very sparingly only with true colors as `DiagnosticHint` and some
  additional important syntax group (like `Identifier`).

- Magenta very carefully (if at all).

------
Notes

- To make tests work without relatively larege updates, each one is
  prepended with an equivalent of the call `:colorscheme vim`.

  Plus some tests which spawn new Neovim instances also now use 'vim'
  color scheme.

  In some cases tests are updated to fit new default color scheme.
2023-12-02 18:53:19 +02:00
zeertzjq
fedbf32250
vim-patch:9.0.2139: html.angular ft is problematic (#26357)
Problem:  html.angular ft is problematic
Solution: partly revert v9.0.2137

The html.angular filetype causes issues and does not trigger FileType
autocommands for the html or angular filetypes.

So let's roll back that particular change and detect this only as html
file

related: https://github.com/vim/vim/pull/13594#issuecomment-1834465890

closes: vim/vim#13604

4f3480c943

Co-authored-by: Christian Brabandt <cb@256bit.org>
2023-12-02 09:42:16 +08:00
Gregory Anders
b32b5b2711
fix: use BEL to terminate OSC 11 request (#26335) 2023-11-30 16:17:38 -06:00
ObserverOfTime
307d5bcc79 vim-patch:9.0.2137: Can't detect angular & mustache filetypes
Problem:  Can't detect angular & mustache filetypes
Solution: Detect *.mustache as Mustache filetype;
          detect *.component.html as html.angular filetype

closes: vim/vim#13594

7bed263c34
2023-11-30 18:40:27 +01:00
Pham Huy Hoang
f5573fba3d
fix: Remove nested for_each_tree in TSTreeView (#26328)
Problem:
`LanguageTree:for_each_tree` calls itself for child nodes, so when we
calls `for_each_tree` inside `for_each_tree`, this quickly leads to
exponential tree calls.

Solution:
Use `pairs(child:trees())` directly in this case, as we don't need the
extra callback for each children, this is already handled from the outer
`for_each_tree` call
2023-11-30 10:37:42 -06:00
Gregory Anders
01b91deec7
fix(treesitter): fix parens stacking in inspector display (#26304)
When first opened, the tree-sitter inspector traverses all of the nodes
in the buffer to calculate an array of nodes. This traversal is done
only once, and _all_ nodes (both named and anonymous) are included.
Toggling anonymous nodes in the inspector only changes how the tree is
drawn in the buffer, but does not affect the underlying data structure
at all.

When the buffer is traversed and the list of nodes is calculated, we
don't know whether or not anonymous nodes will be displayed in the
inspector or not. Thus, we cannot determine during traversal where to
put closing parentheses. Instead, this must be done when drawing.

When we draw, the tree structure has been flatted into a single array,
so we lose parent-child relationships that would otherwise make
determining the number of closing parentheses straightforward. However,
we can instead rely on the fact that a delta between the depth of a node
and the depth of the successive node _must_ mean that more closing
parentheses are required:

  (foo
    (bar)
  (baz)  ↑
         │
         └ (bar) and (baz) have different depths, so (bar) must have an
           extra closing parenthesis

This does not depend on whether or not anonymous nodes are displayed and
so works in both cases.
2023-11-30 07:04:20 -06:00
zeertzjq
543e0256c1
build: don't define FUNC_ATTR_* as empty in headers (#26317)
FUNC_ATTR_* should only be used in .c files with generated headers.
Defining FUNC_ATTR_* as empty in headers causes misuses of them to be
silently ignored. Instead don't define them by default, and only define
them as empty after a .c file has included its generated header.
2023-11-30 15:51:05 +08:00
Christian Clason
8594b0858f vim-patch:a9058440b7b9
runtime(html): Update syntax file (vim/vim#13591)

Add missing search element and update ARIA attribute list.

Add a very basic test file to check all elements are matched.

a9058440b7

Co-authored-by: dkearns <dougkearns@gmail.com>
2023-11-29 21:00:07 +01:00
Gregory Anders
4a8bf24ac6
fix(treesitter): adjust indentation in inspector highlights (#26302) 2023-11-29 10:17:53 -06:00
Gregory Anders
400b7842a9
fix(termcap): escape escapes in passthrough sequence (#26301)
When using the tmux passthrough sequence any escape characters in the
inner sequence must be escaped by adding another escape character.
2023-11-29 09:49:44 -06:00
Gregory Anders
9b4b23493d
fix(defaults): wait until VimEnter to set background (#26284)
The OptionSet autocommand does not fire until Vim has finished starting,
so setting 'background' before the VimEnter event would not fire the
OptionSet event. The prior implementation also waited until VimEnter to
set 'background', so this was a regression introduced when moving
background detection into Lua.
2023-11-29 09:43:11 -06:00
Gregory Anders
18c1fd8e9d
docs: document TSNode:byte_length() (#26287)
Also update the type annotation of TSNode:id(), which returns a string,
not an integer.
2023-11-29 08:59:36 -06:00
Pham Huy Hoang
b6e339eb90
fix(treesitter): make InspectTree correctly handle nested injections (#26085)
Problem: Only injections under the top level tree are found.

Solution: Iterate through all trees to find injections. When two
injections are contained within the same node in the parent tree, prefer
the injection with the larger byte length.
2023-11-29 08:16:52 -06:00
Gregory Anders
7bc5ee7f93
fix(treesitter): use proper query syntax for inspector (#26274) 2023-11-29 08:10:02 -06:00
zeertzjq
a6cba103ce
refactor: move some constants out of vim_defs.h (#26298) 2023-11-29 20:32:40 +08:00