mirror of
https://github.com/neovim/neovim.git
synced 2025-09-06 11:28:22 +00:00
docs: handle whitespace in emmycomments
This commit is contained in:
@@ -1189,8 +1189,8 @@ format({options}) *vim.lsp.buf.format()*
|
|||||||
server clients.
|
server clients.
|
||||||
|
|
||||||
Parameters: ~
|
Parameters: ~
|
||||||
• {options} table|nil Optional table which holds the following optional
|
• {options} (table|nil) Optional table which holds the following
|
||||||
fields:
|
optional fields:
|
||||||
• formatting_options (table|nil): Can be used to specify
|
• formatting_options (table|nil): Can be used to specify
|
||||||
FormattingOptions. Some unspecified options will be
|
FormattingOptions. Some unspecified options will be
|
||||||
automatically derived from the current Nvim options. See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#formattingOptions
|
automatically derived from the current Nvim options. See https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#formattingOptions
|
||||||
|
@@ -1423,15 +1423,16 @@ keycode({str}) *vim.keycode()*
|
|||||||
Translate keycodes.
|
Translate keycodes.
|
||||||
|
|
||||||
Example: >lua
|
Example: >lua
|
||||||
|
|
||||||
local k = vim.keycode
|
local k = vim.keycode
|
||||||
vim.g.mapleader = k'<bs>'
|
vim.g.mapleader = k'<bs>'
|
||||||
<
|
<
|
||||||
|
|
||||||
Parameters: ~
|
Parameters: ~
|
||||||
• {str} string String to be converted.
|
• {str} (string) String to be converted.
|
||||||
|
|
||||||
Return: ~
|
Return: ~
|
||||||
string
|
(string)
|
||||||
|
|
||||||
See also: ~
|
See also: ~
|
||||||
• |nvim_replace_termcodes()|
|
• |nvim_replace_termcodes()|
|
||||||
@@ -1527,6 +1528,7 @@ print({...}) *vim.print()*
|
|||||||
"Pretty prints" the given arguments and returns them unmodified.
|
"Pretty prints" the given arguments and returns them unmodified.
|
||||||
|
|
||||||
Example: >lua
|
Example: >lua
|
||||||
|
|
||||||
local hl_normal = vim.print(vim.api.nvim_get_hl_by_name('Normal', true))
|
local hl_normal = vim.print(vim.api.nvim_get_hl_by_name('Normal', true))
|
||||||
<
|
<
|
||||||
|
|
||||||
@@ -1775,8 +1777,8 @@ gsplit({s}, {sep}, {opts}) *vim.gsplit()*
|
|||||||
<
|
<
|
||||||
|
|
||||||
Parameters: ~
|
Parameters: ~
|
||||||
• {s} string String to split
|
• {s} (string) String to split
|
||||||
• {sep} string Separator or pattern
|
• {sep} (string) Separator or pattern
|
||||||
• {opts} (table|nil) Keyword arguments |kwargs|:
|
• {opts} (table|nil) Keyword arguments |kwargs|:
|
||||||
• plain: (boolean) Use `sep` literally (as in string.find).
|
• plain: (boolean) Use `sep` literally (as in string.find).
|
||||||
• trimempty: (boolean) Discard empty segments at start and end
|
• trimempty: (boolean) Discard empty segments at start and end
|
||||||
@@ -2501,6 +2503,7 @@ get_option({filetype}, {option}) *vim.filetype.get_option()*
|
|||||||
files.
|
files.
|
||||||
|
|
||||||
Example: >lua
|
Example: >lua
|
||||||
|
|
||||||
vim.filetype.get_option('vim', 'commentstring')
|
vim.filetype.get_option('vim', 'commentstring')
|
||||||
<
|
<
|
||||||
|
|
||||||
@@ -2509,8 +2512,8 @@ get_option({filetype}, {option}) *vim.filetype.get_option()*
|
|||||||
may not reflect later changes.
|
may not reflect later changes.
|
||||||
|
|
||||||
Parameters: ~
|
Parameters: ~
|
||||||
• {filetype} string Filetype
|
• {filetype} (string) Filetype
|
||||||
• {option} string Option name
|
• {option} (string) Option name
|
||||||
|
|
||||||
Return: ~
|
Return: ~
|
||||||
string|boolean|integer: Option value
|
string|boolean|integer: Option value
|
||||||
@@ -2649,7 +2652,7 @@ dir({path}, {opts}) *vim.fs.dir()*
|
|||||||
• {path} (string) An absolute or relative path to the directory to
|
• {path} (string) An absolute or relative path to the directory to
|
||||||
iterate over. The path is first normalized
|
iterate over. The path is first normalized
|
||||||
|vim.fs.normalize()|.
|
|vim.fs.normalize()|.
|
||||||
• {opts} table|nil Optional keyword arguments:
|
• {opts} (table|nil) Optional keyword arguments:
|
||||||
• depth: integer|nil How deep the traverse (default 1)
|
• depth: integer|nil How deep the traverse (default 1)
|
||||||
• skip: (fun(dir_name: string): boolean)|nil Predicate to
|
• skip: (fun(dir_name: string): boolean)|nil Predicate to
|
||||||
control traversal. Return false to stop searching the
|
control traversal. Return false to stop searching the
|
||||||
@@ -3010,7 +3013,7 @@ range({spec}) *vim.version.range()*
|
|||||||
<
|
<
|
||||||
|
|
||||||
Parameters: ~
|
Parameters: ~
|
||||||
• {spec} string Version range "spec"
|
• {spec} (string) Version range "spec"
|
||||||
|
|
||||||
See also: ~
|
See also: ~
|
||||||
• # https://github.com/npm/node-semver#ranges
|
• # https://github.com/npm/node-semver#ranges
|
||||||
|
@@ -793,17 +793,17 @@ get_filetypes({lang}) *vim.treesitter.language.get_filetypes()*
|
|||||||
Get the filetypes associated with the parser named {lang}.
|
Get the filetypes associated with the parser named {lang}.
|
||||||
|
|
||||||
Parameters: ~
|
Parameters: ~
|
||||||
• {lang} string Name of parser
|
• {lang} (string) Name of parser
|
||||||
|
|
||||||
Return: ~
|
Return: ~
|
||||||
string[] filetypes
|
string[] filetypes
|
||||||
|
|
||||||
get_lang({filetype}) *vim.treesitter.language.get_lang()*
|
get_lang({filetype}) *vim.treesitter.language.get_lang()*
|
||||||
Parameters: ~
|
Parameters: ~
|
||||||
• {filetype} string
|
• {filetype} (string)
|
||||||
|
|
||||||
Return: ~
|
Return: ~
|
||||||
string|nil
|
(string|nil)
|
||||||
|
|
||||||
inspect({lang}) *vim.treesitter.language.inspect()*
|
inspect({lang}) *vim.treesitter.language.inspect()*
|
||||||
Inspects the provided language.
|
Inspects the provided language.
|
||||||
@@ -821,7 +821,7 @@ register({lang}, {filetype}) *vim.treesitter.language.register()*
|
|||||||
Register a parser named {lang} to be used for {filetype}(s).
|
Register a parser named {lang} to be used for {filetype}(s).
|
||||||
|
|
||||||
Parameters: ~
|
Parameters: ~
|
||||||
• {lang} string Name of parser
|
• {lang} (string) Name of parser
|
||||||
• {filetype} string|string[] Filetype(s) to associate with lang
|
• {filetype} string|string[] Filetype(s) to associate with lang
|
||||||
|
|
||||||
|
|
||||||
@@ -1051,7 +1051,9 @@ contents.
|
|||||||
To create a LanguageTree (parser object) for a given buffer and language, use:
|
To create a LanguageTree (parser object) for a given buffer and language, use:
|
||||||
|
|
||||||
>lua
|
>lua
|
||||||
|
|
||||||
local parser = vim.treesitter.get_parser(bufnr, lang)
|
local parser = vim.treesitter.get_parser(bufnr, lang)
|
||||||
|
|
||||||
<
|
<
|
||||||
|
|
||||||
(where `bufnr=0` means current buffer). `lang` defaults to 'filetype'.
|
(where `bufnr=0` means current buffer). `lang` defaults to 'filetype'.
|
||||||
@@ -1062,7 +1064,9 @@ it wants incremental updates.
|
|||||||
Whenever you need to access the current syntax tree, parse the buffer:
|
Whenever you need to access the current syntax tree, parse the buffer:
|
||||||
|
|
||||||
>lua
|
>lua
|
||||||
|
|
||||||
local tree = parser:parse()
|
local tree = parser:parse()
|
||||||
|
|
||||||
<
|
<
|
||||||
|
|
||||||
This returns a table of immutable |treesitter-tree| objects representing
|
This returns a table of immutable |treesitter-tree| objects representing
|
||||||
@@ -1178,19 +1182,20 @@ LanguageTree:register_cbs({cbs}, {recursive})
|
|||||||
• {cbs} (table) An |nvim_buf_attach()|-like table argument with
|
• {cbs} (table) An |nvim_buf_attach()|-like table argument with
|
||||||
the following handlers:
|
the following handlers:
|
||||||
• `on_bytes` : see |nvim_buf_attach()|, but this will be called after the parsers callback.
|
• `on_bytes` : see |nvim_buf_attach()|, but this will be called after the parsers callback.
|
||||||
• `on_changedtree` : a callback that will be called
|
• `on_changedtree` : a callback that will be called every
|
||||||
every time the tree has syntactical changes. It will
|
time the tree has syntactical changes. It will be
|
||||||
be passed two arguments: a table of the ranges (as
|
passed two arguments: a table of the ranges (as node
|
||||||
node ranges) that changed and the changed tree.
|
ranges) that changed and the changed tree.
|
||||||
• `on_child_added` : emitted when a child is added to
|
• `on_child_added` : emitted when a child is added to the
|
||||||
the tree.
|
tree.
|
||||||
• `on_child_removed` : emitted when a child is removed
|
• `on_child_removed` : emitted when a child is removed
|
||||||
from the tree.
|
from the tree.
|
||||||
• `on_detach` : emitted when the buffer is detached, see
|
• `on_detach` : emitted when the buffer is detached, see
|
||||||
|nvim_buf_detach_event|. Takes one argument, the
|
|nvim_buf_detach_event|. Takes one argument, the number
|
||||||
number of the buffer.
|
of the buffer.
|
||||||
• {recursive?} boolean Apply callbacks recursively for all children.
|
• {recursive} (boolean|nil) Apply callbacks recursively for all
|
||||||
Any new children will also inherit the callbacks.
|
children. Any new children will also inherit the
|
||||||
|
callbacks.
|
||||||
|
|
||||||
LanguageTree:source() *LanguageTree:source()*
|
LanguageTree:source() *LanguageTree:source()*
|
||||||
Returns the source content of the language tree (bufnr or string).
|
Returns the source content of the language tree (bufnr or string).
|
||||||
|
@@ -328,6 +328,7 @@ function TLua2DoX_filter.filter(this, AppStamp, Filename)
|
|||||||
line = string_trim(inStream:getLine())
|
line = string_trim(inStream:getLine())
|
||||||
l = l + 1
|
l = l + 1
|
||||||
if string.sub(line, 1, 2) == '--' then -- it's a comment
|
if string.sub(line, 1, 2) == '--' then -- it's a comment
|
||||||
|
line = line:gsub('^---%s+@', '---@')
|
||||||
-- Allow people to write style similar to EmmyLua (since they are basically the same)
|
-- Allow people to write style similar to EmmyLua (since they are basically the same)
|
||||||
-- instead of silently skipping things that start with ---
|
-- instead of silently skipping things that start with ---
|
||||||
if string.sub(line, 3, 3) == '@' then -- it's a magic comment
|
if string.sub(line, 3, 3) == '@' then -- it's a magic comment
|
||||||
@@ -341,6 +342,7 @@ function TLua2DoX_filter.filter(this, AppStamp, Filename)
|
|||||||
if vim.startswith(line, '---@cast')
|
if vim.startswith(line, '---@cast')
|
||||||
or vim.startswith(line, '---@diagnostic')
|
or vim.startswith(line, '---@diagnostic')
|
||||||
or vim.startswith(line, '---@overload')
|
or vim.startswith(line, '---@overload')
|
||||||
|
or vim.startswith(line, '---@meta')
|
||||||
or vim.startswith(line, '---@type') then
|
or vim.startswith(line, '---@type') then
|
||||||
-- Ignore LSP directives
|
-- Ignore LSP directives
|
||||||
outStream:writeln('// gg:"' .. line .. '"')
|
outStream:writeln('// gg:"' .. line .. '"')
|
||||||
|
Reference in New Issue
Block a user