44 lines
1.4 KiB
Diff
44 lines
1.4 KiB
Diff
|
From: Jakub Jirutka <jakub@jirutka.cz>
|
||
|
Date: Thu, 23 May 2024 20:07:15 +0200
|
||
|
Subject: Fallback to classic syntax highlighting if tree-sitter parser
|
||
|
is not available
|
||
|
|
||
|
See https://gitlab.alpinelinux.org/alpine/aports/-/issues/16132,
|
||
|
https://github.com/neovim/neovim/pull/26824
|
||
|
|
||
|
--- a/runtime/ftplugin/help.lua
|
||
|
+++ b/runtime/ftplugin/help.lua
|
||
|
@@ -1,5 +1,8 @@
|
||
|
-- use treesitter over syntax (for highlighted code blocks)
|
||
|
-vim.treesitter.start()
|
||
|
+local ok, _ = pcall(vim.treesitter.start)
|
||
|
+if not ok then
|
||
|
+ print('Note: tree-sitter-vimdoc package is not installed, some features will not work')
|
||
|
+end
|
||
|
|
||
|
-- add custom highlights for list in `:h highlight-groups`
|
||
|
local bufname = vim.fs.normalize(vim.api.nvim_buf_get_name(0))
|
||
|
--- a/runtime/ftplugin/lua.lua
|
||
|
+++ b/runtime/ftplugin/lua.lua
|
||
|
@@ -1,2 +1,5 @@
|
||
|
-- use treesitter over syntax
|
||
|
-vim.treesitter.start()
|
||
|
+local ok, _ = pcall(vim.treesitter.start)
|
||
|
+if not ok then
|
||
|
+ print('Note: tree-sitter-lua package is not installed, some features will not work')
|
||
|
+end
|
||
|
--- a/runtime/ftplugin/query.lua
|
||
|
+++ b/runtime/ftplugin/query.lua
|
||
|
@@ -9,7 +9,10 @@
|
||
|
-- Do not set vim.b.did_ftplugin = 1 to allow loading of ftplugin/lisp.vim
|
||
|
|
||
|
-- use treesitter over syntax
|
||
|
-vim.treesitter.start()
|
||
|
+local ok, _ = pcall(vim.treesitter.start)
|
||
|
+if not ok then
|
||
|
+ print('Note: tree-sitter-query package is not installed, some features will not work')
|
||
|
+end
|
||
|
|
||
|
-- set omnifunc
|
||
|
vim.bo.omnifunc = 'v:lua.vim.treesitter.query.omnifunc'
|