Skip to content

Commit

Permalink
fix(runtime): stop treesitter highlight in b:undo_ftplugin (neovim#29533
Browse files Browse the repository at this point in the history
)

It seems that nvim-treesitter stops treesitter highlight when changing
filetype, so it makes sense for builtin ftplugins to do this as well.

Use :call and v:lua here to allow separation with '|'.
  • Loading branch information
zeertzjq committed Jul 3, 2024
1 parent 599fc7c commit 12c9791
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 6 deletions.
1 change: 1 addition & 0 deletions runtime/ftplugin/help.lua
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,5 @@ vim.keymap.set('n', 'gO', function()
require('vim.vimhelp').show_toc()
end, { buffer = 0, silent = true })

vim.b.undo_ftplugin = vim.b.undo_ftplugin .. ' | call v:lua.vim.treesitter.stop()'
vim.b.undo_ftplugin = vim.b.undo_ftplugin .. ' | nunmap <buffer> gO'
2 changes: 2 additions & 0 deletions runtime/ftplugin/lua.lua
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
-- use treesitter over syntax
vim.treesitter.start()

vim.b.undo_ftplugin = vim.b.undo_ftplugin .. ' | call v:lua.vim.treesitter.stop()'
5 changes: 3 additions & 2 deletions runtime/ftplugin/query.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
-- Neovim filetype plugin file
-- Language: Treesitter query
-- Last Change: 2023 Aug 23
-- Last Change: 2024 Jul 03

if vim.b.did_ftplugin == 1 then
return
Expand Down Expand Up @@ -32,6 +32,7 @@ if not vim.b.disable_query_linter and #query_lint_on > 0 then
end

-- it's a lisp!
vim.cmd([[ runtime! ftplugin/lisp.vim ]])
vim.cmd([[runtime! ftplugin/lisp.vim]])

vim.b.undo_ftplugin = vim.b.undo_ftplugin .. ' | setl omnifunc< iskeyword<'
vim.b.undo_ftplugin = vim.b.undo_ftplugin .. ' | call v:lua.vim.treesitter.stop()'
4 changes: 2 additions & 2 deletions runtime/indent/query.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
-- Neovim indent file
-- Language: Treesitter query
-- Last Change: 2022 Mar 29
-- Last Change: 2024 Jul 03

-- it's a lisp!
vim.cmd([[ runtime! indent/lisp.vim ]])
vim.cmd([[runtime! indent/lisp.vim]])
4 changes: 2 additions & 2 deletions runtime/syntax/query.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
-- Neovim syntax file
-- Language: Treesitter query
-- Last Change: 2022 Apr 13
-- Last Change: 2024 Jul 03

-- it's a lisp!
vim.cmd([[ runtime! syntax/lisp.vim ]])
vim.cmd([[runtime! syntax/lisp.vim]])

0 comments on commit 12c9791

Please sign in to comment.