feat(snippets): add friendly snippets

This commit is contained in:
Matt Leong 2021-11-08 11:05:25 -08:00
parent abed04444e
commit ef19b15e4f
3 changed files with 42 additions and 4 deletions

View file

@ -29,8 +29,8 @@ M.init = function()
map('n', '<leader>bn', ':bnext<cr>')
-- tab navigation
map('n', '<leader>tp', ':tprev<cr>')
map('n', '<leader>tn', ':tnext<cr>')
map('n', '<leader>tp', ':tabprevious<cr>')
map('n', '<leader>tn', ':tabnext<cr>')
end
return M

View file

@ -0,0 +1,31 @@
local ls = require('luasnip')
-- some shorthands...
--[[ local s = ls.snippet
local sn = ls.snippet_node
local t = ls.text_node
local i = ls.insert_node
local f = ls.function_node
local c = ls.choice_node
local d = ls.dynamic_node ]]
-- Every unspecified option will be set to the default.
ls.config.set_config({
history = true,
-- Update more often, :h events for more info.
updateevents = 'TextChanged,TextChangedI',
})
ls.snippets = {
all = {},
html = {},
}
-- enable html snippets in javascript/javascript(REACT)
ls.snippets.javascript = ls.snippets.html
ls.snippets.javascriptreact = ls.snippets.html
ls.snippets.typescriptreact = ls.snippets.html
require('luasnip/loaders/from_vscode').load({ include = { 'html' } })
-- You can also use lazy loading so you only get in memory snippets of languages you use
require('luasnip/loaders/from_vscode').lazy_load()

View file

@ -117,7 +117,14 @@ return packer.startup(function()
use({
'L3MON4D3/LuaSnip',
event = 'InsertEnter',
config = function()
require('cosmic.core.snippets')
end,
requires = {
{
'rafamadriz/friendly-snippets',
},
},
disable = vim.tbl_contains(user_plugins.disable, 'autocomplete'),
})
@ -133,7 +140,7 @@ return packer.startup(function()
{ 'hrsh7th/cmp-nvim-lua', after = 'cmp-buffer' },
{ 'hrsh7th/cmp-path', after = 'cmp-nvim-lua' },
},
after = 'LuaSnip',
event = 'InsertEnter',
})
use({