mirror of
https://github.com/neovim/neovim.git
synced 2025-01-01 17:23:36 -07:00
Merge pull request #20097 from clason/ts-syntax-off
fix(treesitter): don't support legacy syntax in start()
This commit is contained in:
commit
aaa54a8b3e
@ -446,20 +446,21 @@ node_contains({node}, {range}) *node_contains()*
|
|||||||
Return: ~
|
Return: ~
|
||||||
(boolean) True if the node contains the range
|
(boolean) True if the node contains the range
|
||||||
|
|
||||||
start({bufnr}, {lang}, {opts}) *start()*
|
start({bufnr}, {lang}) *start()*
|
||||||
Start treesitter highlighting for a buffer
|
Start treesitter highlighting for a buffer
|
||||||
|
|
||||||
Can be used in an ftplugin or FileType autocommand
|
Can be used in an ftplugin or FileType autocommand
|
||||||
|
|
||||||
Note: By default, disables regex syntax highlighting, which may be
|
Note: By default, disables regex syntax highlighting, which may be
|
||||||
required for some plugins. In this case, add `{ syntax = true }`.
|
required for some plugins. In this case, add vim.bo.syntax = 'on `after the call to` start`.
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
>
|
>
|
||||||
|
|
||||||
vim.api.nvim_create_autocmd( 'FileType', { pattern = 'tex',
|
vim.api.nvim_create_autocmd( 'FileType', { pattern = 'tex',
|
||||||
callback = function(args)
|
callback = function(args)
|
||||||
vim.treesitter.start(args.buf, 'latex', { syntax = true })
|
vim.treesitter.start(args.buf, 'latex')
|
||||||
|
vim.bo[args.buf].syntax = 'on' -- only if additional legacy syntax is needed
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
<
|
<
|
||||||
@ -469,9 +470,6 @@ start({bufnr}, {lang}, {opts}) *start()*
|
|||||||
buffer)
|
buffer)
|
||||||
{lang} (string|nil) Language of the parser (default: buffer
|
{lang} (string|nil) Language of the parser (default: buffer
|
||||||
filetype)
|
filetype)
|
||||||
{opts} (table|nil) Optional keyword arguments:
|
|
||||||
• `syntax` boolean Run regex syntax highlighting (default
|
|
||||||
false)
|
|
||||||
|
|
||||||
stop({bufnr}) *stop()*
|
stop({bufnr}) *stop()*
|
||||||
Stop treesitter highlighting for a buffer
|
Stop treesitter highlighting for a buffer
|
||||||
|
@ -250,23 +250,22 @@ end
|
|||||||
--- Can be used in an ftplugin or FileType autocommand
|
--- Can be used in an ftplugin or FileType autocommand
|
||||||
---
|
---
|
||||||
--- Note: By default, disables regex syntax highlighting, which may be required for some plugins.
|
--- Note: By default, disables regex syntax highlighting, which may be required for some plugins.
|
||||||
--- In this case, add `{ syntax = true }`.
|
--- In this case, add `vim.bo.syntax = 'on'` after the call to `start`.
|
||||||
---
|
---
|
||||||
--- Example:
|
--- Example:
|
||||||
---
|
---
|
||||||
--- <pre>
|
--- <pre>
|
||||||
--- vim.api.nvim_create_autocmd( 'FileType', { pattern = 'tex',
|
--- vim.api.nvim_create_autocmd( 'FileType', { pattern = 'tex',
|
||||||
--- callback = function(args)
|
--- callback = function(args)
|
||||||
--- vim.treesitter.start(args.buf, 'latex', { syntax = true })
|
--- vim.treesitter.start(args.buf, 'latex')
|
||||||
|
--- vim.bo[args.buf].syntax = 'on' -- only if additional legacy syntax is needed
|
||||||
--- end
|
--- end
|
||||||
--- })
|
--- })
|
||||||
--- </pre>
|
--- </pre>
|
||||||
---
|
---
|
||||||
---@param bufnr number|nil Buffer to be highlighted (default: current buffer)
|
---@param bufnr number|nil Buffer to be highlighted (default: current buffer)
|
||||||
---@param lang string|nil Language of the parser (default: buffer filetype)
|
---@param lang string|nil Language of the parser (default: buffer filetype)
|
||||||
---@param opts table|nil Optional keyword arguments:
|
function M.start(bufnr, lang)
|
||||||
--- - `syntax` boolean Run regex syntax highlighting (default false)
|
|
||||||
function M.start(bufnr, lang, opts)
|
|
||||||
bufnr = bufnr or a.nvim_get_current_buf()
|
bufnr = bufnr or a.nvim_get_current_buf()
|
||||||
|
|
||||||
local parser = M.get_parser(bufnr, lang)
|
local parser = M.get_parser(bufnr, lang)
|
||||||
@ -274,10 +273,6 @@ function M.start(bufnr, lang, opts)
|
|||||||
M.highlighter.new(parser)
|
M.highlighter.new(parser)
|
||||||
|
|
||||||
vim.b[bufnr].ts_highlight = true
|
vim.b[bufnr].ts_highlight = true
|
||||||
|
|
||||||
if opts and opts.syntax then
|
|
||||||
vim.bo[bufnr].syntax = 'on'
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
---Stop treesitter highlighting for a buffer
|
---Stop treesitter highlighting for a buffer
|
||||||
|
Loading…
Reference in New Issue
Block a user