You've already forked dotfiles
fix: Setting up luasnip a bit better with with dependency installation
properly working for jsregexp
This commit is contained in:
@@ -15,12 +15,12 @@ vim.schedule(function()
|
|||||||
require('plugins.language_support') -- LSP, treesitter and any other language specific support plugins
|
require('plugins.language_support') -- LSP, treesitter and any other language specific support plugins
|
||||||
require('plugins.gitsigns') -- Git gutter notifiers
|
require('plugins.gitsigns') -- Git gutter notifiers
|
||||||
require('plugins.nvim-cmp') -- Autocompletion plugin (TODO: Move to builtin completion?)
|
require('plugins.nvim-cmp') -- Autocompletion plugin (TODO: Move to builtin completion?)
|
||||||
|
require('plugins.luasnip') -- Snippet engine
|
||||||
require('plugins.telescope') -- Floating window fuzzy searching different sources
|
require('plugins.telescope') -- Floating window fuzzy searching different sources
|
||||||
require('plugins.telekasten') -- Note taking plugins
|
require('plugins.telekasten') -- Note taking plugins
|
||||||
require('plugins.mason') -- LSP and DAP manager
|
require('plugins.mason') -- LSP and DAP manager
|
||||||
require('plugins.twilight') -- Focus mode, dim lines around the cursor's location
|
require('plugins.twilight') -- Focus mode, dim lines around the cursor's location
|
||||||
require('plugins.render-markdown') -- Render markdown directly in neovim
|
require('plugins.render-markdown') -- Render markdown directly in neovim
|
||||||
require('plugins.luasnip') -- Snippet engine
|
|
||||||
|
|
||||||
vim.pack.add({
|
vim.pack.add({
|
||||||
'https://github.com/windwp/nvim-autopairs', -- Autocomplete symbol pairs when typing
|
'https://github.com/windwp/nvim-autopairs', -- Autocomplete symbol pairs when typing
|
||||||
|
|||||||
@@ -4,17 +4,41 @@ vim.pack.add({
|
|||||||
'https://github.com/L3MON4D3/LuaSnip'
|
'https://github.com/L3MON4D3/LuaSnip'
|
||||||
})
|
})
|
||||||
|
|
||||||
local luasnip_lua_path = vim.api.nvim_get_runtime_file('lua/luasnip/init.lua', false)[1]
|
local function luasnip_dependency_update()
|
||||||
if not luasnip_lua_path then return end
|
local luasnip_lua_path = vim.api.nvim_get_runtime_file('lua/luasnip/init.lua', false)[1]
|
||||||
local luasnip_root = vim.fn.fnamemodify(luasnip_lua_path, ':h:h:h')
|
if not luasnip_lua_path then return end -- Short circuit if not found
|
||||||
|
local luasnip_root = vim.fn.fnamemodify(luasnip_lua_path, ':h:h:h')
|
||||||
|
local artifact = luasnip_root .. '/deps/jsregexp/jsregexp.so'
|
||||||
|
|
||||||
vim.api.nvim_create_autocmd('PackChanged', { callback = function(args)
|
-- Verify the lib exists, (re)run the make install target
|
||||||
local name, kind = args.data.spec.name, args.data.kind
|
if vim.uv.fs_stat(artifact) then
|
||||||
if name == 'luasnip' and kind == 'update' then
|
vim.notify('Building LuaSnip jsregexp dependency...', vim.log.levels.INFO)
|
||||||
if not args.data.active then vim.cmd.packadd('luasnip') end
|
vim.system({ 'make', 'install_jsregexp' }, { cwd = luasnip_root }, function (out)
|
||||||
vim.system({'make', 'install_jsregexp'}, { cwd = luasnip_root })
|
vim.schedule(function()
|
||||||
|
if out.code == 0 then
|
||||||
|
vim.notify('LuaSnip jsregexp built successfully!', vim.log.levels.INFO)
|
||||||
|
else
|
||||||
|
vim.notify('Failed to build LuaSnip jsregexp:\n' .. (out.stderr or out.stdout or ''), vim.log.levels.ERROR)
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end)
|
||||||
end
|
end
|
||||||
end})
|
end
|
||||||
|
|
||||||
|
vim.api.nvim_create_autocmd('PackChanged', {
|
||||||
|
callback = function(args)
|
||||||
|
local name, kind = args.data.spec.name, args.data.kind
|
||||||
|
if name == 'luasnip' and kind == 'update' then
|
||||||
|
luasnip_dependency_update()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
})
|
||||||
|
|
||||||
|
require('luasnip').setup {
|
||||||
|
enable_autosnippets = true,
|
||||||
|
}
|
||||||
|
|
||||||
|
-- local types = require('luasnip.util.types')
|
||||||
|
|
||||||
require('luasnip.loaders.from_vscode').lazy_load()
|
require('luasnip.loaders.from_vscode').lazy_load()
|
||||||
require('luasnip.loaders.from_lua').lazy_load({ paths = "./snippets" })
|
require('luasnip.loaders.from_lua').lazy_load({ paths = "./snippets" })
|
||||||
|
|||||||
Reference in New Issue
Block a user