Skip to content
Snippets Groups Projects
Commit 38613459 authored by Jakub Jirutka's avatar Jakub Jirutka :flag_ua:
Browse files

community/neovim: don't crash if tree-sitter is not installed

Resolves #16132
parent 9f71cc06
No related branches found
No related tags found
3 merge requests!75268main/postgresql15: security upgrade to 15.9,!75022community/linux-edge: add hexdump to makedepends,!66448[3.20] community/neovim: don't crash if tree-sitter is not installed
Pipeline #236351 passed
......@@ -4,7 +4,7 @@
# TODO: Try to trim the base package to include only common syntax files etc.
pkgname=neovim
pkgver=0.10.0
pkgrel=0
pkgrel=1
pkgdesc="Vim-fork focused on extensibility and agility"
url="https://neovim.io/"
arch="all"
......@@ -33,6 +33,7 @@ esac
subpackages="$pkgname-lang $pkgname-doc"
options="!check" # unit and functional tests fail
source="https://github.com/neovim/neovim/archive/v$pkgver/neovim-$pkgver.tar.gz
make-tree-sitter-optional.patch
nodoc.txt
"
# secfixes:
......@@ -100,5 +101,6 @@ doc() {
sha512sums="
878cb58729a18179b38303bd9cf79e38997c87946665ac4e7b76d87e15f5d001028fd1454ce30b20773b20a4fe929dfa399fc2ec7f6db0774a4e864c9e8586c1 neovim-0.10.0.tar.gz
660c83a863b8467a7f19febe4cae6f3ea08f985d5fda0c7466e00936c7b8113bf53077d4bd9a983744f131a68346da2f098425695f4c7c7fdd3244b26ee76927 make-tree-sitter-optional.patch
72ab288f53acddc088c567aafe8c5afa6835325fab7879e782d1d62f87a662f3a6bac123c450debbae1b32336cc60b2830b429838ee3dfcc7524773b5069f4f0 nodoc.txt
"
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'
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment