From c4307e6855f17ff89f0132787e2daba27495d254 Mon Sep 17 00:00:00 2001 From: WieeRd <59733058+WieeRd@users.noreply.github.com> Date: Wed, 12 Apr 2023 13:47:59 +0900 Subject: [PATCH] fix: compatibility with Neovim v0.8 (#16) --- lua/nvim-yati/utils.lua | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lua/nvim-yati/utils.lua b/lua/nvim-yati/utils.lua index 7aa4672..2551bcb 100644 --- a/lua/nvim-yati/utils.lua +++ b/lua/nvim-yati/utils.lua @@ -7,6 +7,11 @@ function M.get_parser(bufnr) return vim.treesitter.get_parser(bufnr, lang) end +-- `get_lang` is only available in Neovim v0.9 and above +if vim.treesitter.language.get_lang == nil then + M.get_parser = require("nvim-treesitter.parser").get_parser +end + ---@return string function M.get_buf_line(bufnr, lnum) return vim.api.nvim_buf_get_lines(bufnr, lnum, lnum + 1, true)[1] or ""