generated from ellisonleao/nvim-plugin-template
-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
BREAKING CHANGES: - Depends on tree-sitter-regex [v0.20.0](https://github.com/tree-sitter/tree-sitter-regex/pull/15/files) * chore: simplify test runner, ci, and makefile * test: fixup lookbehind cases * fix: lookbehind
- Loading branch information
1 parent
49ade10
commit aeacf14
Showing
8 changed files
with
107 additions
and
89 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
vendor | ||
.tests | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,64 @@ | ||
vim.cmd([[ | ||
set rtp+=. | ||
set noswapfile | ||
filetype on | ||
packloadall | ||
runtime plugin/regexplainer.vim | ||
]]) | ||
|
||
local did, configs = pcall(require, 'nvim-treesitter.configs') | ||
if not did then print(configs) end | ||
|
||
configs.setup {} | ||
local M = {} | ||
|
||
function M.root(root) | ||
local f = debug.getinfo(1, "S").source:sub(2) | ||
return vim.fn.fnamemodify(f, ":p:h:h") .. "/" .. (root or "") | ||
end | ||
|
||
---@param plugin string | ||
function M.load(plugin) | ||
local name = plugin:match(".*/(.*)") | ||
local package_root = M.root(".tests/site/pack/deps/start/") | ||
if not vim.loop.fs_stat(package_root .. name) then | ||
print("Installing " .. plugin) | ||
vim.fn.mkdir(package_root, "p") | ||
vim.fn.system({ | ||
"git", | ||
"clone", | ||
"--depth=1", | ||
"https://github.com/" .. plugin .. ".git", | ||
package_root .. "/" .. name, | ||
}) | ||
end | ||
end | ||
|
||
local langs = { | ||
'html', | ||
'javascript', | ||
'typescript', | ||
'regex', | ||
} | ||
|
||
function M.setup() | ||
vim.cmd([[ | ||
set noswapfile | ||
filetype on | ||
set runtimepath=$VIMRUNTIME | ||
runtime plugin/regexplainer.vim | ||
]]) | ||
|
||
vim.opt.runtimepath:append(M.root()) | ||
vim.opt.packpath = { M.root(".tests/site") } | ||
|
||
M.load("MunifTanjim/nui.nvim") | ||
M.load("nvim-lua/plenary.nvim") | ||
M.load("nvim-treesitter/nvim-treesitter") | ||
|
||
local parser_install_dir = M.root(".tests/share/treesitter"); | ||
vim.opt.runtimepath:append(parser_install_dir) | ||
|
||
vim.cmd[[packloadall]] | ||
|
||
require 'nvim-treesitter.configs'.setup { | ||
parser_install_dir = parser_install_dir, | ||
} | ||
|
||
for _, lang in ipairs(langs) do | ||
if not require'nvim-treesitter.parsers'.has_parser(lang) then | ||
vim.cmd('TSInstallSync ' .. lang) | ||
end | ||
end | ||
end | ||
|
||
M.setup() | ||
|