Home Explore Blog CI



neovim

6th chunk of `runtime/doc/dev_vimpatch.txt`
2fc299a5add32a2a2229a98978af1dfbfec602305ef555a500000001000007d2
 To be avoided if possible, must use list which li belongs to.
                                  Suggestion by @ZyX-l:                Use TV_LIST_ITER or indexing instead of the previous two calls.
  list->lv_len                    tv_list_len(list)
  list->lv_lock                   tv_list_locked(list)
  &li->li_tv                      TV_LIST_ITEM_TV(li)
  list->lv_refcount++             tv_list_ref(list)
  val = list->lv_copyID           val = tv_list_copyid(list)
  list->lv_copyID = val           tv_list_set_copyid(list, val)

  for (li = list->lv_first;       TV_LIST_ITER_CONST(list, li,         Use TV_LIST_ITER(...) if you need to
  li != NULL && another_cond;     { if (another_cond) {break;} code})  modify list items (note: assigning copyID is also modification and this happens
  li = li->li_next) code                                               always when recursively traversing a list).

  --------------------------------------------------------------------------------------
<
For more details and some more advanced usage, see `typval.h` and `typval.c`.

==============================================================================
DOCUMENTATION DIFFERENCES          *dev-vimpatch-documentation*

The following should be removed from all imported documentation, and not be
used in new documentation:

- `{Only when compiled with ...}`: the vast majority of features have been
  made non-optional (see https://github.com/neovim/neovim/wiki/Introduction)

==============================================================================
FILETYPE DETECTION                 *dev-vimpatch-filetype*

Nvim's filetype detection behavior matches Vim, but is implemented as part of
|vim.filetype| (see `$VIMRUNTIME/lua/vim/filetype.lua`). The logic is encoded in
three tables, listed in order of precedence (the first match is returned):
1. `filename` for literal full path or basename lookup;
2. `pattern` for matching filenames or paths against |lua-pattern|s, optimized
   for fast

Title: List Management Details, Documentation and Filetype Detection Differences in Nvim
Summary
This section continues detailing changes in list management within Nvim, comparing old and new methods for accessing list properties. It emphasizes using `TV_LIST_ITER` or indexing instead of direct access to `li_next` and `li_prev`. It also instructs to remove `{Only when compiled with ...}` from documentation since most features are non-optional. Finally, it explains how filetype detection is implemented in Nvim using `vim.filetype`, with logic encoded in three Lua tables (`filename`, `pattern`).