mirror of
https://github.com/neovim/neovim.git
synced 2025-09-06 03:18:16 +00:00
docs: misc #32959
This commit is contained in:
@@ -3716,7 +3716,7 @@ nvim_create_augroup({name}, {opts}) *nvim_create_augroup()*
|
|||||||
Create or get an autocommand group |autocmd-groups|.
|
Create or get an autocommand group |autocmd-groups|.
|
||||||
|
|
||||||
To get an existing group id, do: >lua
|
To get an existing group id, do: >lua
|
||||||
local id = vim.api.nvim_create_augroup("MyGroup", {
|
local id = vim.api.nvim_create_augroup('my.lsp.config', {
|
||||||
clear = false
|
clear = false
|
||||||
})
|
})
|
||||||
<
|
<
|
||||||
@@ -3742,8 +3742,8 @@ nvim_create_autocmd({event}, {opts}) *nvim_create_autocmd()*
|
|||||||
string).
|
string).
|
||||||
|
|
||||||
Example using Lua callback: >lua
|
Example using Lua callback: >lua
|
||||||
vim.api.nvim_create_autocmd({"BufEnter", "BufWinEnter"}, {
|
vim.api.nvim_create_autocmd({'BufEnter', 'BufWinEnter'}, {
|
||||||
pattern = {"*.c", "*.h"},
|
pattern = {'*.c', '*.h'},
|
||||||
callback = function(ev)
|
callback = function(ev)
|
||||||
print(string.format('event fired: %s', vim.inspect(ev)))
|
print(string.format('event fired: %s', vim.inspect(ev)))
|
||||||
end
|
end
|
||||||
@@ -3751,15 +3751,15 @@ nvim_create_autocmd({event}, {opts}) *nvim_create_autocmd()*
|
|||||||
<
|
<
|
||||||
|
|
||||||
Example using an Ex command as the handler: >lua
|
Example using an Ex command as the handler: >lua
|
||||||
vim.api.nvim_create_autocmd({"BufEnter", "BufWinEnter"}, {
|
vim.api.nvim_create_autocmd({'BufEnter', 'BufWinEnter'}, {
|
||||||
pattern = {"*.c", "*.h"},
|
pattern = {'*.c', '*.h'},
|
||||||
command = "echo 'Entering a C or C++ file'",
|
command = "echo 'Entering a C or C++ file'",
|
||||||
})
|
})
|
||||||
<
|
<
|
||||||
|
|
||||||
Note: `pattern` is NOT automatically expanded (unlike with |:autocmd|),
|
Note: `pattern` is NOT automatically expanded (unlike with |:autocmd|),
|
||||||
thus names like "$HOME" and "~" must be expanded explicitly: >lua
|
thus names like "$HOME" and "~" must be expanded explicitly: >lua
|
||||||
pattern = vim.fn.expand("~") .. "/some/path/*.py"
|
pattern = vim.fn.expand('~') .. '/some/path/*.py'
|
||||||
<
|
<
|
||||||
|
|
||||||
Attributes: ~
|
Attributes: ~
|
||||||
@@ -3881,14 +3881,14 @@ nvim_get_autocmds({opts}) *nvim_get_autocmds()*
|
|||||||
These examples will get autocommands matching ALL the given criteria: >lua
|
These examples will get autocommands matching ALL the given criteria: >lua
|
||||||
-- Matches all criteria
|
-- Matches all criteria
|
||||||
autocommands = vim.api.nvim_get_autocmds({
|
autocommands = vim.api.nvim_get_autocmds({
|
||||||
group = "MyGroup",
|
group = 'MyGroup',
|
||||||
event = {"BufEnter", "BufWinEnter"},
|
event = {'BufEnter', 'BufWinEnter'},
|
||||||
pattern = {"*.c", "*.h"}
|
pattern = {'*.c', '*.h'}
|
||||||
})
|
})
|
||||||
|
|
||||||
-- All commands from one group
|
-- All commands from one group
|
||||||
autocommands = vim.api.nvim_get_autocmds({
|
autocommands = vim.api.nvim_get_autocmds({
|
||||||
group = "MyGroup",
|
group = 'MyGroup',
|
||||||
})
|
})
|
||||||
<
|
<
|
||||||
|
|
||||||
|
@@ -178,8 +178,8 @@ ENVIRONMENT VARIABLES
|
|||||||
• get the server name (use |v:servername| instead)
|
• get the server name (use |v:servername| instead)
|
||||||
• detect a parent Nvim (use |$NVIM| instead)
|
• detect a parent Nvim (use |$NVIM| instead)
|
||||||
• Ignored if --listen is given.
|
• Ignored if --listen is given.
|
||||||
• Unset by |terminal| and |jobstart()| unless explicitly given by the "env"
|
• Unset at startup (after |v:servername| is initialized). Can be explicitly
|
||||||
option. Example: >vim
|
provided to |terminal| and |jobstart()| by the "env" option. Example: >vim
|
||||||
call jobstart(['foo'], { 'env': { 'NVIM_LISTEN_ADDRESS': v:servername } })
|
call jobstart(['foo'], { 'env': { 'NVIM_LISTEN_ADDRESS': v:servername } })
|
||||||
<
|
<
|
||||||
|
|
||||||
|
@@ -1092,19 +1092,20 @@ CTRL-X CTRL-Z Stop completion without changing the text.
|
|||||||
|
|
||||||
AUTO-COMPLETION *compl-autocomplete*
|
AUTO-COMPLETION *compl-autocomplete*
|
||||||
|
|
||||||
To get basic "autocompletion" without installing a plugin, try this script: >lua
|
To get LSP-driven auto-completion, see |lsp-completion|. To get basic
|
||||||
|
auto-completion without installing plugins or LSP, try this: >lua
|
||||||
|
|
||||||
local triggers = {"."}
|
local triggers = {'.'}
|
||||||
vim.api.nvim_create_autocmd("InsertCharPre", {
|
vim.api.nvim_create_autocmd('InsertCharPre', {
|
||||||
buffer = vim.api.nvim_get_current_buf(),
|
buffer = vim.api.nvim_get_current_buf(),
|
||||||
callback = function()
|
callback = function()
|
||||||
if vim.fn.pumvisible() == 1 or vim.fn.state("m") == "m" then
|
if vim.fn.pumvisible() == 1 or vim.fn.state('m') == 'm' then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
local char = vim.v.char
|
local char = vim.v.char
|
||||||
if vim.list_contains(triggers, char) then
|
if vim.list_contains(triggers, char) then
|
||||||
local key = vim.keycode("<C-x><C-n>")
|
local key = vim.keycode('<C-x><C-n>')
|
||||||
vim.api.nvim_feedkeys(key, "m", false)
|
vim.api.nvim_feedkeys(key, 'm', false)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
@@ -185,11 +185,14 @@ Example: given the following configs... >lua
|
|||||||
To use LSP features beyond those provided by Nvim (see |lsp-buf|), you can set
|
To use LSP features beyond those provided by Nvim (see |lsp-buf|), you can set
|
||||||
keymaps and options on |Client:on_attach()| or |LspAttach|. Not all language
|
keymaps and options on |Client:on_attach()| or |LspAttach|. Not all language
|
||||||
servers provide the same capabilities; check `supports_method()` in your
|
servers provide the same capabilities; check `supports_method()` in your
|
||||||
LspAttach handler. Example: >lua
|
LspAttach handler.
|
||||||
|
*lsp-lint* *lsp-format*
|
||||||
|
Example: Enable auto-completion and auto-formatting ("linting"): >lua
|
||||||
|
|
||||||
vim.api.nvim_create_autocmd('LspAttach', {
|
vim.api.nvim_create_autocmd('LspAttach', {
|
||||||
|
group = vim.api.nvim_create_augroup('my.lsp', {}),
|
||||||
callback = function(args)
|
callback = function(args)
|
||||||
local client = vim.lsp.get_client_by_id(args.data.client_id)
|
local client = assert(vim.lsp.get_client_by_id(args.data.client_id))
|
||||||
if client:supports_method('textDocument/implementation') then
|
if client:supports_method('textDocument/implementation') then
|
||||||
-- Create a keymap for vim.lsp.buf.implementation ...
|
-- Create a keymap for vim.lsp.buf.implementation ...
|
||||||
end
|
end
|
||||||
@@ -199,12 +202,15 @@ LspAttach handler. Example: >lua
|
|||||||
vim.lsp.completion.enable(true, client.id, args.buf, {autotrigger = true})
|
vim.lsp.completion.enable(true, client.id, args.buf, {autotrigger = true})
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Format the current buffer on save.
|
-- Auto-format ("lint") on save.
|
||||||
if client:supports_method('textDocument/formatting') then
|
-- Usually not needed if server supports "textDocument/willSaveWaitUntil".
|
||||||
|
if not client:supports_method('textDocument/willSaveWaitUntil')
|
||||||
|
and client:supports_method('textDocument/formatting') then
|
||||||
vim.api.nvim_create_autocmd('BufWritePre', {
|
vim.api.nvim_create_autocmd('BufWritePre', {
|
||||||
|
group = vim.api.nvim_create_augroup('my.lsp', {clear=false}),
|
||||||
buffer = args.buf,
|
buffer = args.buf,
|
||||||
callback = function()
|
callback = function()
|
||||||
vim.lsp.buf.format({bufnr = args.buf, id = client.id})
|
vim.lsp.buf.format({ bufnr = args.buf, id = client.id, timeout_ms = 1000 })
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
@@ -238,21 +244,19 @@ FAQ *lsp-faq*
|
|||||||
" (async = false is the default for format)
|
" (async = false is the default for format)
|
||||||
autocmd BufWritePre *.rs lua vim.lsp.buf.format({ async = false })
|
autocmd BufWritePre *.rs lua vim.lsp.buf.format({ async = false })
|
||||||
<
|
<
|
||||||
*lsp-vs-treesitter*
|
*lsp-vs-treesitter*
|
||||||
- Q: How do LSP and Treesitter compare?
|
- Q: How do LSP and Treesitter compare?
|
||||||
- A: LSP requires a client and language server. The language server uses
|
- A: LSP requires a client and language server. The language server uses
|
||||||
semantic analysis to understand code at a project level. This provides
|
semantic analysis to understand code at a project level. This provides
|
||||||
language servers with the ability to rename across files, find
|
language servers with the ability to rename across files, find
|
||||||
definitions in external libraries and more.
|
definitions in external libraries and more.
|
||||||
|
|
||||||
Treesitter is a language parsing library that provides excellent tools
|
|treesitter| is a language parsing library that provides excellent tools
|
||||||
for incrementally parsing text and handling errors. This makes it a great
|
for incrementally parsing text and handling errors. This makes it a great
|
||||||
fit for editors to understand the contents of the current file for things
|
fit for editors to understand the contents of the current file for things
|
||||||
like syntax highlighting, simple goto-definitions, scope analysis and
|
like syntax highlighting, simple goto-definitions, scope analysis and
|
||||||
more.
|
more.
|
||||||
|
|
||||||
LSP and Treesitter are both great tools for editing and inspecting code.
|
|
||||||
|
|
||||||
================================================================================
|
================================================================================
|
||||||
LSP API *lsp-api*
|
LSP API *lsp-api*
|
||||||
|
|
||||||
|
@@ -185,13 +185,12 @@ clipboard.
|
|||||||
OSC 52 sequences sent from the :terminal buffer do not emit a |TermRequest|
|
OSC 52 sequences sent from the :terminal buffer do not emit a |TermRequest|
|
||||||
event. The event is handled directly by Nvim and is not forwarded to plugins.
|
event. The event is handled directly by Nvim and is not forwarded to plugins.
|
||||||
|
|
||||||
OSC 133: shell integration *terminal-osc133*
|
OSC 133: shell integration *terminal-osc133* *shell-prompt*
|
||||||
|
|
||||||
Shells can emit semantic escape sequences (OSC 133) to mark where each prompt
|
Shells can emit semantic escape sequences (OSC 133) to mark where each prompt
|
||||||
starts and ends. The start of a prompt is marked by sequence `OSC 133 ; A ST`,
|
starts and ends. The start of a prompt is marked by sequence `OSC 133 ; A ST`,
|
||||||
and the end by `OSC 133 ; B ST`.
|
and the end by `OSC 133 ; B ST`.
|
||||||
|
|
||||||
*shell-prompt-config*
|
|
||||||
You can configure your shell "rc" (e.g. ~/.bashrc) to emit OSC 133 sequences,
|
You can configure your shell "rc" (e.g. ~/.bashrc) to emit OSC 133 sequences,
|
||||||
or your terminal may attempt to do it for you (assuming your shell config
|
or your terminal may attempt to do it for you (assuming your shell config
|
||||||
doesn't interfere).
|
doesn't interfere).
|
||||||
@@ -214,6 +213,9 @@ emits OSC 133 as described above.
|
|||||||
To annotate each terminal prompt with a sign, call |nvim_buf_set_extmark()|
|
To annotate each terminal prompt with a sign, call |nvim_buf_set_extmark()|
|
||||||
from a |TermRequest| handler: >lua
|
from a |TermRequest| handler: >lua
|
||||||
|
|
||||||
|
vim.api.nvim_create_autocmd('TermOpen', {
|
||||||
|
command = 'setlocal signcolumn=auto',
|
||||||
|
})
|
||||||
local ns = vim.api.nvim_create_namespace('my.terminal.prompt')
|
local ns = vim.api.nvim_create_namespace('my.terminal.prompt')
|
||||||
vim.api.nvim_create_autocmd('TermRequest', {
|
vim.api.nvim_create_autocmd('TermRequest', {
|
||||||
callback = function(args)
|
callback = function(args)
|
||||||
@@ -226,10 +228,6 @@ from a |TermRequest| handler: >lua
|
|||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
-- Enable signcolumn in terminal buffers.
|
|
||||||
vim.api.nvim_create_autocmd('TermOpen', {
|
|
||||||
command = 'setlocal signcolumn=auto',
|
|
||||||
})
|
|
||||||
<
|
<
|
||||||
==============================================================================
|
==============================================================================
|
||||||
Status Variables *terminal-status*
|
Status Variables *terminal-status*
|
||||||
|
@@ -563,8 +563,9 @@ v:servername
|
|||||||
Read-only.
|
Read-only.
|
||||||
|
|
||||||
*$NVIM*
|
*$NVIM*
|
||||||
$NVIM is set by |terminal| and |jobstart()|, and is thus
|
$NVIM is set to v:servername by |terminal| and |jobstart()|,
|
||||||
a hint that the current environment is a subprocess of Nvim.
|
and is thus a hint that the current environment is a child
|
||||||
|
(direct subprocess) of Nvim.
|
||||||
|
|
||||||
Example: a child Nvim process can detect and make requests to
|
Example: a child Nvim process can detect and make requests to
|
||||||
its parent Nvim: >lua
|
its parent Nvim: >lua
|
||||||
|
@@ -8,7 +8,7 @@
|
|||||||
-- - "opt-in": runtime/pack/dist/opt/
|
-- - "opt-in": runtime/pack/dist/opt/
|
||||||
-- 2. runtime/lua/vim/ (the runtime): Lazy-loaded modules. Examples: `inspect`, `lpeg`.
|
-- 2. runtime/lua/vim/ (the runtime): Lazy-loaded modules. Examples: `inspect`, `lpeg`.
|
||||||
-- 3. runtime/lua/vim/shared.lua: pure Lua functions which always are available. Used in the test
|
-- 3. runtime/lua/vim/shared.lua: pure Lua functions which always are available. Used in the test
|
||||||
-- runner, as well as worker threads and processes launched from Nvim.
|
-- runner, and worker threads/processes launched from Nvim.
|
||||||
-- 4. runtime/lua/vim/_editor.lua: Eager-loaded code which directly interacts with the Nvim
|
-- 4. runtime/lua/vim/_editor.lua: Eager-loaded code which directly interacts with the Nvim
|
||||||
-- editor state. Only available in the main thread.
|
-- editor state. Only available in the main thread.
|
||||||
--
|
--
|
||||||
|
20
runtime/lua/vim/_meta/api.lua
generated
20
runtime/lua/vim/_meta/api.lua
generated
@@ -885,7 +885,7 @@ function vim.api.nvim_command_output(command) end
|
|||||||
--- To get an existing group id, do:
|
--- To get an existing group id, do:
|
||||||
---
|
---
|
||||||
--- ```lua
|
--- ```lua
|
||||||
--- local id = vim.api.nvim_create_augroup("MyGroup", {
|
--- local id = vim.api.nvim_create_augroup('my.lsp.config', {
|
||||||
--- clear = false
|
--- clear = false
|
||||||
--- })
|
--- })
|
||||||
--- ```
|
--- ```
|
||||||
@@ -904,8 +904,8 @@ function vim.api.nvim_create_augroup(name, opts) end
|
|||||||
--- Example using Lua callback:
|
--- Example using Lua callback:
|
||||||
---
|
---
|
||||||
--- ```lua
|
--- ```lua
|
||||||
--- vim.api.nvim_create_autocmd({"BufEnter", "BufWinEnter"}, {
|
--- vim.api.nvim_create_autocmd({'BufEnter', 'BufWinEnter'}, {
|
||||||
--- pattern = {"*.c", "*.h"},
|
--- pattern = {'*.c', '*.h'},
|
||||||
--- callback = function(ev)
|
--- callback = function(ev)
|
||||||
--- print(string.format('event fired: %s', vim.inspect(ev)))
|
--- print(string.format('event fired: %s', vim.inspect(ev)))
|
||||||
--- end
|
--- end
|
||||||
@@ -915,8 +915,8 @@ function vim.api.nvim_create_augroup(name, opts) end
|
|||||||
--- Example using an Ex command as the handler:
|
--- Example using an Ex command as the handler:
|
||||||
---
|
---
|
||||||
--- ```lua
|
--- ```lua
|
||||||
--- vim.api.nvim_create_autocmd({"BufEnter", "BufWinEnter"}, {
|
--- vim.api.nvim_create_autocmd({'BufEnter', 'BufWinEnter'}, {
|
||||||
--- pattern = {"*.c", "*.h"},
|
--- pattern = {'*.c', '*.h'},
|
||||||
--- command = "echo 'Entering a C or C++ file'",
|
--- command = "echo 'Entering a C or C++ file'",
|
||||||
--- })
|
--- })
|
||||||
--- ```
|
--- ```
|
||||||
@@ -925,7 +925,7 @@ function vim.api.nvim_create_augroup(name, opts) end
|
|||||||
--- and "~" must be expanded explicitly:
|
--- and "~" must be expanded explicitly:
|
||||||
---
|
---
|
||||||
--- ```lua
|
--- ```lua
|
||||||
--- pattern = vim.fn.expand("~") .. "/some/path/*.py"
|
--- pattern = vim.fn.expand('~') .. '/some/path/*.py'
|
||||||
--- ```
|
--- ```
|
||||||
---
|
---
|
||||||
--- @see `:help autocommand`
|
--- @see `:help autocommand`
|
||||||
@@ -1222,14 +1222,14 @@ function vim.api.nvim_get_all_options_info() end
|
|||||||
--- ```lua
|
--- ```lua
|
||||||
--- -- Matches all criteria
|
--- -- Matches all criteria
|
||||||
--- autocommands = vim.api.nvim_get_autocmds({
|
--- autocommands = vim.api.nvim_get_autocmds({
|
||||||
--- group = "MyGroup",
|
--- group = 'MyGroup',
|
||||||
--- event = {"BufEnter", "BufWinEnter"},
|
--- event = {'BufEnter', 'BufWinEnter'},
|
||||||
--- pattern = {"*.c", "*.h"}
|
--- pattern = {'*.c', '*.h'}
|
||||||
--- })
|
--- })
|
||||||
---
|
---
|
||||||
--- -- All commands from one group
|
--- -- All commands from one group
|
||||||
--- autocommands = vim.api.nvim_get_autocmds({
|
--- autocommands = vim.api.nvim_get_autocmds({
|
||||||
--- group = "MyGroup",
|
--- group = 'MyGroup',
|
||||||
--- })
|
--- })
|
||||||
--- ```
|
--- ```
|
||||||
---
|
---
|
||||||
|
5
runtime/lua/vim/_meta/vvars.lua
generated
5
runtime/lua/vim/_meta/vvars.lua
generated
@@ -586,8 +586,9 @@ vim.v.searchforward = ...
|
|||||||
--- Read-only.
|
--- Read-only.
|
||||||
---
|
---
|
||||||
--- *$NVIM*
|
--- *$NVIM*
|
||||||
--- $NVIM is set by `terminal` and `jobstart()`, and is thus
|
--- $NVIM is set to v:servername by `terminal` and `jobstart()`,
|
||||||
--- a hint that the current environment is a subprocess of Nvim.
|
--- and is thus a hint that the current environment is a child
|
||||||
|
--- (direct subprocess) of Nvim.
|
||||||
---
|
---
|
||||||
--- Example: a child Nvim process can detect and make requests to
|
--- Example: a child Nvim process can detect and make requests to
|
||||||
--- its parent Nvim:
|
--- its parent Nvim:
|
||||||
|
@@ -1,3 +1,5 @@
|
|||||||
|
-- Generates C code to bridge API <=> Lua.
|
||||||
|
--
|
||||||
-- Example (manual) invocation:
|
-- Example (manual) invocation:
|
||||||
--
|
--
|
||||||
-- make
|
-- make
|
||||||
@@ -192,7 +194,7 @@ for _, f in ipairs(shallowcopy(functions)) do
|
|||||||
.. ' has deprecated alias\n'
|
.. ' has deprecated alias\n'
|
||||||
.. newname
|
.. newname
|
||||||
.. ' which has a separate implementation.\n'
|
.. ' which has a separate implementation.\n'
|
||||||
.. 'Please remove it from src/nvim/api/dispatch_deprecated.lua'
|
.. 'Remove it from src/nvim/api/dispatch_deprecated.lua'
|
||||||
)
|
)
|
||||||
os.exit(1)
|
os.exit(1)
|
||||||
end
|
end
|
||||||
@@ -729,6 +731,10 @@ output:write('\n')
|
|||||||
|
|
||||||
local lua_c_functions = {}
|
local lua_c_functions = {}
|
||||||
|
|
||||||
|
--- Generates C code to bridge RPC API <=> Lua.
|
||||||
|
---
|
||||||
|
--- Inspect the result here:
|
||||||
|
--- build/src/nvim/auto/api/private/dispatch_wrappers.generated.h
|
||||||
local function process_function(fn)
|
local function process_function(fn)
|
||||||
local lua_c_function_name = ('nlua_api_%s'):format(fn.name)
|
local lua_c_function_name = ('nlua_api_%s'):format(fn.name)
|
||||||
write_shifted_output(
|
write_shifted_output(
|
||||||
|
@@ -53,14 +53,14 @@ static int64_t next_autocmd_id = 1;
|
|||||||
/// ```lua
|
/// ```lua
|
||||||
/// -- Matches all criteria
|
/// -- Matches all criteria
|
||||||
/// autocommands = vim.api.nvim_get_autocmds({
|
/// autocommands = vim.api.nvim_get_autocmds({
|
||||||
/// group = "MyGroup",
|
/// group = 'MyGroup',
|
||||||
/// event = {"BufEnter", "BufWinEnter"},
|
/// event = {'BufEnter', 'BufWinEnter'},
|
||||||
/// pattern = {"*.c", "*.h"}
|
/// pattern = {'*.c', '*.h'}
|
||||||
/// })
|
/// })
|
||||||
///
|
///
|
||||||
/// -- All commands from one group
|
/// -- All commands from one group
|
||||||
/// autocommands = vim.api.nvim_get_autocmds({
|
/// autocommands = vim.api.nvim_get_autocmds({
|
||||||
/// group = "MyGroup",
|
/// group = 'MyGroup',
|
||||||
/// })
|
/// })
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
@@ -336,8 +336,8 @@ cleanup:
|
|||||||
/// Example using Lua callback:
|
/// Example using Lua callback:
|
||||||
///
|
///
|
||||||
/// ```lua
|
/// ```lua
|
||||||
/// vim.api.nvim_create_autocmd({"BufEnter", "BufWinEnter"}, {
|
/// vim.api.nvim_create_autocmd({'BufEnter', 'BufWinEnter'}, {
|
||||||
/// pattern = {"*.c", "*.h"},
|
/// pattern = {'*.c', '*.h'},
|
||||||
/// callback = function(ev)
|
/// callback = function(ev)
|
||||||
/// print(string.format('event fired: %s', vim.inspect(ev)))
|
/// print(string.format('event fired: %s', vim.inspect(ev)))
|
||||||
/// end
|
/// end
|
||||||
@@ -347,8 +347,8 @@ cleanup:
|
|||||||
/// Example using an Ex command as the handler:
|
/// Example using an Ex command as the handler:
|
||||||
///
|
///
|
||||||
/// ```lua
|
/// ```lua
|
||||||
/// vim.api.nvim_create_autocmd({"BufEnter", "BufWinEnter"}, {
|
/// vim.api.nvim_create_autocmd({'BufEnter', 'BufWinEnter'}, {
|
||||||
/// pattern = {"*.c", "*.h"},
|
/// pattern = {'*.c', '*.h'},
|
||||||
/// command = "echo 'Entering a C or C++ file'",
|
/// command = "echo 'Entering a C or C++ file'",
|
||||||
/// })
|
/// })
|
||||||
/// ```
|
/// ```
|
||||||
@@ -357,7 +357,7 @@ cleanup:
|
|||||||
/// and "~" must be expanded explicitly:
|
/// and "~" must be expanded explicitly:
|
||||||
///
|
///
|
||||||
/// ```lua
|
/// ```lua
|
||||||
/// pattern = vim.fn.expand("~") .. "/some/path/*.py"
|
/// pattern = vim.fn.expand('~') .. '/some/path/*.py'
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
/// @param event (string|array) Event(s) that will trigger the handler (`callback` or `command`).
|
/// @param event (string|array) Event(s) that will trigger the handler (`callback` or `command`).
|
||||||
@@ -603,7 +603,7 @@ void nvim_clear_autocmds(Dict(clear_autocmds) *opts, Arena *arena, Error *err)
|
|||||||
/// To get an existing group id, do:
|
/// To get an existing group id, do:
|
||||||
///
|
///
|
||||||
/// ```lua
|
/// ```lua
|
||||||
/// local id = vim.api.nvim_create_augroup("MyGroup", {
|
/// local id = vim.api.nvim_create_augroup('my.lsp.config', {
|
||||||
/// clear = false
|
/// clear = false
|
||||||
/// })
|
/// })
|
||||||
/// ```
|
/// ```
|
||||||
|
@@ -514,8 +514,7 @@ void channel_from_connection(SocketWatcher *watcher)
|
|||||||
channel_create_event(channel, watcher->addr);
|
channel_create_event(channel, watcher->addr);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Creates an API channel from stdin/stdout. This is used when embedding
|
/// Creates an API channel from stdin/stdout. Used when embedding Nvim.
|
||||||
/// Neovim
|
|
||||||
uint64_t channel_from_stdio(bool rpc, CallbackReader on_output, const char **error)
|
uint64_t channel_from_stdio(bool rpc, CallbackReader on_output, const char **error)
|
||||||
FUNC_ATTR_NONNULL_ALL
|
FUNC_ATTR_NONNULL_ALL
|
||||||
{
|
{
|
||||||
|
@@ -3834,6 +3834,7 @@ static const char *pty_ignored_env_vars[] = {
|
|||||||
"COLORFGBG",
|
"COLORFGBG",
|
||||||
"COLORTERM",
|
"COLORTERM",
|
||||||
#endif
|
#endif
|
||||||
|
// Nvim-owned env vars. #6764
|
||||||
"VIM",
|
"VIM",
|
||||||
"VIMRUNTIME",
|
"VIMRUNTIME",
|
||||||
NULL
|
NULL
|
||||||
@@ -3870,9 +3871,8 @@ dict_T *create_environment(const dictitem_T *job_env, const bool clear_env, cons
|
|||||||
tv_dict_free(temp_env.vval.v_dict);
|
tv_dict_free(temp_env.vval.v_dict);
|
||||||
|
|
||||||
if (pty) {
|
if (pty) {
|
||||||
// These environment variables generally shouldn't be propagated to the
|
// These env vars shouldn't propagate to the child process. #6764
|
||||||
// child process. We're removing them here so the user can still decide
|
// Remove them here, then the user may decide to explicitly set them below.
|
||||||
// they want to explicitly set them.
|
|
||||||
for (size_t i = 0;
|
for (size_t i = 0;
|
||||||
i < ARRAY_SIZE(pty_ignored_env_vars) && pty_ignored_env_vars[i];
|
i < ARRAY_SIZE(pty_ignored_env_vars) && pty_ignored_env_vars[i];
|
||||||
i++) {
|
i++) {
|
||||||
|
@@ -165,7 +165,7 @@ void event_init(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// @returns false if main_loop could not be closed gracefully
|
/// @returns false if main_loop could not be closed gracefully
|
||||||
bool event_teardown(void)
|
static bool event_teardown(void)
|
||||||
{
|
{
|
||||||
if (!main_loop.events) {
|
if (!main_loop.events) {
|
||||||
input_stop();
|
input_stop();
|
||||||
|
@@ -674,8 +674,9 @@ M.vars = {
|
|||||||
Read-only.
|
Read-only.
|
||||||
|
|
||||||
*$NVIM*
|
*$NVIM*
|
||||||
$NVIM is set by |terminal| and |jobstart()|, and is thus
|
$NVIM is set to v:servername by |terminal| and |jobstart()|,
|
||||||
a hint that the current environment is a subprocess of Nvim.
|
and is thus a hint that the current environment is a child
|
||||||
|
(direct subprocess) of Nvim.
|
||||||
|
|
||||||
Example: a child Nvim process can detect and make requests to
|
Example: a child Nvim process can detect and make requests to
|
||||||
its parent Nvim: >lua
|
its parent Nvim: >lua
|
||||||
|
@@ -713,7 +713,7 @@ describe('jobs', function()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
it('jobstart() environment: $NVIM, $NVIM_LISTEN_ADDRESS #11009', function()
|
it('jobstart() environment: $NVIM, $NVIM_LISTEN_ADDRESS #11009', function()
|
||||||
local function get_env_in_child_job(envname, env)
|
local function get_child_env(envname, env)
|
||||||
return exec_lua(
|
return exec_lua(
|
||||||
[[
|
[[
|
||||||
local envname, env = ...
|
local envname, env = ...
|
||||||
@@ -741,17 +741,17 @@ describe('jobs', function()
|
|||||||
-- $NVIM is _not_ defined in the top-level Nvim process.
|
-- $NVIM is _not_ defined in the top-level Nvim process.
|
||||||
eq('', eval('$NVIM'))
|
eq('', eval('$NVIM'))
|
||||||
-- jobstart() shares its v:servername with the child via $NVIM.
|
-- jobstart() shares its v:servername with the child via $NVIM.
|
||||||
eq('NVIM=' .. addr, get_env_in_child_job('NVIM'))
|
eq('NVIM=' .. addr, get_child_env('NVIM'))
|
||||||
-- $NVIM_LISTEN_ADDRESS is unset by server_init in the child.
|
-- $NVIM_LISTEN_ADDRESS is unset by server_init in the child.
|
||||||
eq('NVIM_LISTEN_ADDRESS=v:null', get_env_in_child_job('NVIM_LISTEN_ADDRESS'))
|
eq('NVIM_LISTEN_ADDRESS=v:null', get_child_env('NVIM_LISTEN_ADDRESS'))
|
||||||
eq(
|
eq(
|
||||||
'NVIM_LISTEN_ADDRESS=v:null',
|
'NVIM_LISTEN_ADDRESS=v:null',
|
||||||
get_env_in_child_job('NVIM_LISTEN_ADDRESS', { NVIM_LISTEN_ADDRESS = 'Xtest_jobstart_env' })
|
get_child_env('NVIM_LISTEN_ADDRESS', { NVIM_LISTEN_ADDRESS = 'Xtest_jobstart_env' })
|
||||||
)
|
)
|
||||||
-- User can explicitly set $NVIM_LOG_FILE, $VIM, $VIMRUNTIME.
|
-- User can explicitly set $NVIM_LOG_FILE, $VIM, $VIMRUNTIME.
|
||||||
eq(
|
eq(
|
||||||
'NVIM_LOG_FILE=Xtest_jobstart_env',
|
'NVIM_LOG_FILE=Xtest_jobstart_env',
|
||||||
get_env_in_child_job('NVIM_LOG_FILE', { NVIM_LOG_FILE = 'Xtest_jobstart_env' })
|
get_child_env('NVIM_LOG_FILE', { NVIM_LOG_FILE = 'Xtest_jobstart_env' })
|
||||||
)
|
)
|
||||||
os.remove('Xtest_jobstart_env')
|
os.remove('Xtest_jobstart_env')
|
||||||
end)
|
end)
|
||||||
|
Reference in New Issue
Block a user