Commit Graph

61 Commits

Author SHA1 Message Date
Daiki Mizukami
ecc36c3d1c
docs: remove extra whitespaces 2022-03-14 08:16:01 +09:00
Daiki Mizukami
be2def4100
chore(gen_vimdoc): fall back to brief_desc_node when desc_node is empty 2022-03-14 07:53:42 +09:00
Daiki Mizukami
334a16c791
refactor(gen_vimdoc): simplify files in CONFIG 2022-03-14 07:53:42 +09:00
Daiki Mizukami
cf4786ddfa
chore(gen_vimdoc): call delete_lines_below only if the file exists
Previously, `delete_lines_below` would raise `FileNotFoundError` when
adding a new file to `CONFIG` and you had to manually write a file with
help tag of the first section as placeholder. This change relieves you
of that need.
2022-03-14 07:53:41 +09:00
Daiki Mizukami
2d28c40ef9
refactor(gen_vimdoc): detect section_start_token automatically 2022-03-14 07:53:41 +09:00
zeertzjq
80e6f81862 docs(lua): reference runtime/lua/vim/_editor.lua 2022-03-06 22:32:22 +08:00
TJ DeVries
991e472881 feat(lua): add api and lua autocmds 2022-02-27 22:04:55 +01:00
Dundar Göc
03e189d1a1 chore(gen_vimdoc): correct minimum python version 2022-02-05 13:36:27 +01:00
Dundar Göc
de672b6d7a chore(gen_vimdoc): remove duplicate extmark.c entry 2022-02-03 18:56:32 +01:00
shadmansaleh
6d41f65aa4 feat(lua): add vim.keymap
This introduces two new functions `vim.keymap.set` & `vim.keymap.del`

differences compared to regular set_keymap:
- remap is used as opposite of noremap. By default it's true for <Plug> keymaps and false for others.
- rhs can be lua function.
- mode can be a list of modes.
- replace_keycodes option for lua function expr maps. (Default: true)
- handles buffer specific keymaps

Examples:
```lua
vim.keymap.set('n', 'asdf', function() print("real lua function") end)
vim.keymap.set({'n', 'v'}, '<leader>lr', vim.lsp.buf.references, {buffer=true})
vim.keymap.set('n', '<leader>w', "<cmd>w<cr>", {silent = true, buffer = 5 })
vim.keymap.set('i', '<Tab>', function()
  return vim.fn.pumvisible() == 1 and "<C-n>" or "<Tab>"
end, {expr = true})
vim.keymap.set('n', '[%', '<Plug>(MatchitNormalMultiBackward)')

vim.keymap.del('n', 'asdf')
vim.keymap.del({'n', 'i', 'v'}, '<leader>w', {buffer = 5 })
```
2022-01-04 22:31:59 +06:00
Gregory Anders
3fd454bd4a
feat: filetype.lua (#16600)
Adds a new vim.filetype module that provides support for filetype detection in
Lua.
2022-01-04 07:28:29 -07:00
Michael Lingelbach
0746f0021f fix(docgen): add tagfunc.lua 2021-11-18 11:30:09 -07:00
Michael Lingelbach
9d6a475ced
fix(docs): add sync.lua to gen_vimdoc (#16285) 2021-11-11 07:23:52 -07:00
Björn Linse
a60beeb34f refactor(api): break out Vim script functions to its own file 2021-10-29 16:59:53 +02:00
dundargoc
3e1ef18579
ci: add newly added api file extmark.c to gen-vimdoc (#16158) 2021-10-27 11:42:19 -06:00
Gregory Anders
dfef90a518
fix(gen_vimdoc.py): spacing around inline elements #16092
The spacing fix drew attention to a couple of places that were using
incorrect formatting such as the key listing for `nvim_open_win`, so
those were fixed too.
2021-10-19 12:55:22 -07:00
Justin M. Keyes
dd7812ec66 fix(docs): add win_config.c 2021-10-05 09:56:22 -07:00
Mathias Fußenegger
63fde086d9
feat(ui): add vim.ui.select and use in code actions (#15771)
Continuation of https://github.com/neovim/neovim/pull/15202

A plugin like telescope could override it with a fancy implementation
and then users would get the telescope-ui within each plugin that
utilizes the vim.ui.select function.

There are some plugins which override the `textDocument/codeAction`
handler solely to provide a different UI. With custom client commands and
soon codeAction resolve support, it becomes more difficult to implement
the handler right - so having a dedicated way to override the picking
function will be useful.
2021-09-27 21:57:28 +02:00
Justin M. Keyes
2e8103475e
Merge #15585 refactor: move vim.lsp.diagnostic to vim.diagnostic
## Overview

- Move vim.lsp.diagnostic to vim.diagnostic
- Refactor client ids to diagnostic namespaces
- Update tests
- Write/update documentation and function signatures

Currently, non-LSP diagnostics in Neovim must hook into the LSP subsystem. This
is what e.g. null-ls and nvim-lint do. This is necessary because none of the
diagnostic API is exposed separately from the LSP subsystem.

This commit addresses this by generalizing the diagnostic subsystem beyond the
scope of LSP. The `vim.lsp.diagnostic` module is now simply a specific
diagnostic producer and primarily maintains the interface between LSP clients
and the broader diagnostic API.

The current diagnostic API uses "client ids" which only makes sense in the
context of LSP. We replace "client ids" with standard API namespaces generated
from `nvim_create_namespace`.

This PR is *mostly* backward compatible (so long as plugins are only using the
publicly documented API): LSP diagnostics will continue to work as usual, as
will pseudo-LSP clients like null-ls and nvim-lint. However, the latter can now
use the new interface, which looks something like this:

```lua
-- The namespace *must* be given a name. Anonymous namespaces will not work with diagnostics
local ns = vim.api.nvim_create_namespace("foo")

-- Generate diagnostics
local diagnostics = generate_diagnostics()

-- Set diagnostics for the current buffer
vim.diagnostic.set(ns, diagnostics, bufnr)
```

Some public facing API utility methods were removed and internalized directly in `vim.diagnostic`:

* `vim.lsp.util.diagnostics_to_items`

## API Design

`vim.diagnostic` contains most of the same API as `vim.lsp.diagnostic` with
`client_id` simply replaced with `namespace`, with some differences:

* Generally speaking, functions that modify or add diagnostics require a namespace as their first argument, e.g.

  ```lua
  vim.diagnostic.set({namespace}, {bufnr}, {diagnostics}[, {opts}])
  ```

   while functions that read or query diagnostics do not (although in many cases one may be supplied optionally):

   ```lua
   vim.diagnostic.get({bufnr}[, {namespace}])
   ```

* We use our own severity levels to decouple `vim.diagnostic` from LSP. These
  are designed similarly to `vim.log.levels` and currently include:

  ```lua
  vim.diagnostic.severity.ERROR
  vim.diagnostic.severity.WARN
  vim.diagnostic.severity.INFO
  vim.diagnostic.severity.HINT
  ```

  In practice, these match the LSP diagnostic severity levels exactly, but we
  should treat this as an interface and not assume that they are the same. The
  "translation" between the two severity types is handled transparently in
  `vim.lsp.diagnostic`.

* The actual "diagnostic" data structure is: (**EDIT:** Updated 2021-09-09):

  ```lua
  {
    lnum = <number>,
    col = <number>,
    end_lnum = <number>,
    end_col = <number>,
    severity = <vim.diagnostic.severity>,
    message = <string>
  }
  ```

This differs from the LSP definition of a diagnostic, so we transform them in
the handler functions in vim.lsp.diagnostic.

## Configuration

The `vim.lsp.with` paradigm still works for configuring how LSP diagnostics are
displayed, but this is a specific use-case for the `publishDiagnostics` handler.
Configuration with `vim.diagnostic` is instead done with the
`vim.diagnostic.config` function:

```lua
vim.diagnostic.config({
    virtual_text = true,
    signs = false,
    underline = true,
    update_in_insert = true,
    severity_sort = false,
}[, namespace])
```

(or alternatively passed directly to `set()` or `show()`.)

When the `namespace` argument is `nil`, settings are set globally (i.e. for
*all* diagnostic namespaces). This is what user's will typically use for their
local configuration. Diagnostic producers can also set configuration options for
their specific namespace, although this is generally discouraged in order to
respect the user's global settings. All of the values in the table passed to
`vim.diagnostic.config()` are resolved in the same way that they are in
`on_publish_diagnostics`; that is, the value can be a boolean, a table, or
a function:

```lua
vim.diagnostic.config({
    virtual_text = function(namespace, bufnr)
        -- Only enable virtual text in buffer 3
        return bufnr == 3
    end,
})
```

## Misc Notes

* `vim.diagnostic` currently depends on `vim.lsp.util` for floating window
  previews. I think this is okay for now, although ideally we'd want to decouple
  these completely.
2021-09-16 14:23:42 -07:00
Gregory Anders
d140d3bd33
fix(docs): ignore _*.lua files from auto doc generation #15678 2021-09-16 10:49:11 -07:00
Gregory Anders
a5bbb932f9 refactor: move vim.lsp.diagnostic to vim.diagnostic
This generalizes diagnostic handling outside of just the scope of LSP.
LSP clients are now a specific case of a diagnostic producer, but the
diagnostic subsystem is decoupled from the LSP subsystem (or will be,
eventually).

More discussion at [1].

[1]: https://github.com/neovim/neovim/pull/15585
2021-09-15 14:09:47 -06:00
Gregory Anders
a422f2136a
docs(gen_vimdoc.py): ignore health.lua files #15614 2021-09-09 18:28:12 -07:00
Matthieu Coudron
389cbe63bf chore: add log hander to gen_vimdoc
so it actually dumps output.
Plus a description of what it does in the argparser.
2021-07-10 17:55:45 +02:00
Mathias Fussenegger
2bdd553c9e feat(lsp): Add codelens support 2021-06-14 21:45:14 +02:00
TJ DeVries
27da5511a0
docs: Treesitter (#13260)
* doc & fixes: Generate treesitter docs

* fixup to treesitter-core

* docs(treesitter): fix docs for most functions

Co-authored-by: Thomas Vigouroux <tomvig38@gmail.com>
2021-05-01 08:19:48 -04:00
Matthieu Coudron
513ac58043 fix: section_name must be a dict {filename:name}
else it was triggering an error during regeneration of the files.
2021-03-04 15:44:40 +01:00
notomo
93ba977793 docs: add check_textlock attribute 2020-12-16 21:57:24 +09:00
TJ DeVries
f75be5e9d5
lsp: vim.lsp.diagnostic (#12655)
Breaking Changes:
- Deprecated all `vim.lsp.util.{*diagnostics*}()` functions.
    - Instead, all functions must be found in vim.lsp.diagnostic
    - For now, they issue a warning ONCE per neovim session. In a
      "little while" we will remove them completely.
- `vim.lsp.callbacks` has moved to `vim.lsp.handlers`.
    - For a "little while" we will just redirect `vim.lsp.callbacks` to
      `vim.lsp.handlers`. However, we will remove this at some point, so
      it is recommended that you change all of your references to
      `callbacks` into `handlers`.
    - This also means that for functions like |vim.lsp.start_client()|
      and similar, keyword style arguments have moved from "callbacks"
      to "handlers". Once again, these are currently being forward, but
      will cease to be forwarded in a "little while".
- Changed the highlight groups for LspDiagnostic highlight as they were
  inconsistently named.
    - For more information, see |lsp-highlight-diagnostics|
- Changed the sign group names as well, to be consistent with
  |lsp-highlight-diagnostics|

General Enhancements:
- Rewrote much of the getting started help document for lsp. It also
  provides a much nicer configuration strategy, so as to not recommend
  globally overwriting builtin neovim mappings.

LSP Enhancements:
- Introduced the concept of |lsp-handlers| which will allow much better
  customization for users without having to copy & paste entire files /
  functions / etc.

Diagnostic Enhancements:
- "goto next diagnostic" |vim.lsp.diagnostic.goto_next()|
- "goto prev diagnostic" |vim.lsp.diagnostic.goto_prev()|
    - For each of the gotos, auto open diagnostics is available as a
      configuration option
- Configurable diagnostic handling:
    - See |vim.lsp.diagnostic.on_publish_diagnostics()|
    - Delay display until after insert mode
    - Configure signs
    - Configure virtual text
    - Configure underline
- Set the location list with the buffers diagnostics.
    - See |vim.lsp.diagnostic.set_loclist()|
- Better performance for getting counts and line diagnostics
    - They are now cached on save, to enhance lookups.
    - Particularly useful for checking in statusline, etc.
- Actual testing :)
    - See ./test/functional/plugin/lsp/diagnostic_spec.lua
- Added `guisp` for underline highlighting

NOTE: "a little while" means enough time to feel like most plugins and
plugin authors have had a chance to refactor their code to use the
updated calls. Then we will remove them completely. There is no need to
keep them, because we don't have any released version of neovim that
exposes these APIs. I'm trying to be nice to people following HEAD :)

Co-authored: [Twitch Chat 2020](https://twitch.tv/teej_dv)
2020-11-12 22:21:34 -05:00
TJ DeVries
4a2618c817
doc: Add docs for uri functions (#12887) 2020-09-14 09:12:17 -04:00
Justin M. Keyes
c2662210b5
docs, remove 'guifontset' #11708
- remove redundant autocmd list
  This "grouped" list is useless, it only gets in the way when searching
  for event names.
- intro.txt: cleanup
- starting.txt: update, revisit
- doc: `:help bisect`
- mbyte.txt: update aliases 1656367b90. closes #11960
- options: remove 'guifontset'. Why:
  - It is complicated and is used by almost no one.
  - It is unlikely to be implemented by Nvim GUIs (complicated to parse,
    specific to Xorg...).
2020-08-31 00:51:35 -07:00
Patrice Peterson
9d9edebceb gen_vimdoc: Allow to keep intermediary output 2020-08-23 13:48:27 +02:00
Patrice Peterson
ac05343a10 Add docs for most vim.lsp methods
Most of the lsp.log will be addressed in a separate PR.
2020-08-23 13:48:25 +02:00
jnozsc
44cbf288ec
script: simplify python version check (#12672) 2020-07-24 22:42:25 +02:00
TJ DeVries
7b529e7912
doc: fix scripts and regenerate (#12506)
* Fix some small doc issues

* doc: fixup

* doc: fixup

* Fix lint and rebase

* Remove bad advice

* Ugh, stupid mpack files...

* Don't let people include these for now until they specifically want to

* Prevent duplicate tag
2020-07-02 07:09:17 -04:00
Justin M. Keyes
9231684986
doc [ci skip] #11656 2020-01-12 23:41:55 -08:00
Justin M. Keyes
0dcf4bd3eb gen_vimdoc.py: rename mode to target 2019-12-31 15:39:17 -08:00
Justin M. Keyes
b112fe828f gen_vimdoc.py: generate LSP docs 2019-12-31 08:06:48 -08:00
Justin M. Keyes
c24f8f46b4 gen_vimdoc.py: sort by name 2019-12-30 03:31:32 -08:00
Justin M. Keyes
b81547ce6d gen_vimdoc.py: better handling of inline (non-block) nodes 2019-12-30 03:12:24 -08:00
Justin M. Keyes
27b678f577 gen_vimdoc.py: fix deprecated check 2019-12-30 00:15:49 -08:00
Daniel Hahler
2e280dac7d gen_vimdoc.py: lint #11593 2019-12-23 07:08:49 +01:00
Justin M. Keyes
781c708c27
Merge #11396 'gen_vimdoc.py: mpack result' [ci skip] 2019-12-22 05:40:31 +01:00
Justin M. Keyes
9ea7aeb308 gen_vimdoc.py: rename for clarity
- render_para => fmt_node_as_vimhelp
- Inline parse_parblock() in fmt_node_as_vimhelp()
2019-12-21 20:36:00 -08:00
Justin M. Keyes
4657819e80 gen_vimdoc.py: mpack: collect functions in 1 dict
All Nvim API, core Vimscript, and core Lua functions are globally
unique, so there is no need for per-module nested dicts.

BEFORE (generated mpack structure):
    [
      {
        "buffer.c": {
          "nvim__buf_stats": { ... },
          ...
        },
        "window.c": {
          "nvim_win_close": { ... },
          ...
        },
        ...
      }
    ]

AFTER (generated mpack structure):
    [
      {
        "nvim__buf_stats": {
          ...
        },
        "nvim_buf_attach": {
          ...
        },
        "nvim_tabpage_set_var": {
          ...
        },
        "nvim_ui_attach": {
          ...
        },
        "nvim_win_close": {
          ...
        }
      }
    ]
2019-12-21 20:36:00 -08:00
Justin M. Keyes
f968dad3bf gen_vimdoc.py: fix "seealso", "xrefs"
- Also fix xrefs ("Deprecated" section)
- Fix "Deprecated" rendering by a weird hack (see comment).
- Eliminate unnecessary use of render_para()
2019-12-21 20:36:00 -08:00
Justin M. Keyes
62e365f577 gen_vimdoc.py: mpack: exclude deprecated functions
The `mpack` variable was a tuple, which manifests as an array in the
generated msgpack structure.
- Removes noise from the mpack data (deprecated functions are
  deprecated).
- Eliminates 1 level of nesting.

BEFORE:
    [
      {
        "buffer.c": [
          {
            "nvim__buf_stats": { ... },
            ...
          },
          {
            "buffer_del_line": { ... },
            ...
          },
        ],
        ...
      }
    ]

AFTER:
    [
      {
        "buffer.c": {
          "nvim__buf_stats": { ... },
          ...
        },
        ...
    ]
2019-12-21 20:36:00 -08:00
Justin M. Keyes
481da1ce40 gen_vimdoc.py: fix mpack generator
- make parameters_doc a dict intead of a list
  BEFORE:
    "parameters_doc": [
        {
            "buffer": "Buffer handle, or 0 for current buffer"
        }
    ],
  AFTER:
    "parameters_doc": {
        "buffer": "Buffer handle, or 0 for current buffer"
    },
- make "return", "seealso", lists instead of strings
2019-12-21 20:36:00 -08:00
Justin M. Keyes
01adb81c55 gen_vimdoc.py: DRY 2019-12-21 20:36:00 -08:00
Justin M. Keyes
af53a0c012
doc: Lua [ci skip] #11378
- Rework :help lua-commands
- Rename if_lua.txt => lua.txt
2019-11-17 19:06:59 -08:00
smolck
4bd7881fce [scripts/gen_vimdoc.py] Generate better-formatted mpack
Changes the generated msgpack result values in the runtime/doc/*.mpack
files to be formatted like this (instead of being formatted like Vim help text):
    [
        'nvim_win_get_var': {
                'signature': 'nvim_win_get_var({window}, {name}, {err})',
                'parameters': [('Window', 'window'), ('String', 'name'), ('Error *', 'err')],
                'parameters_doc': [{'window': 'Window handle, or 0 for current window', 'name': 'Variable name'}],
                'doc': ['Gets a window-scoped (w:) variable'],
                'return': ['Variable value'],
                'seealso': []
            }
        },
        ...
    ]
2019-11-15 20:00:13 -06:00