feat(snippets): add friendly snippets
This commit is contained in:
parent
abed04444e
commit
ef19b15e4f
3 changed files with 42 additions and 4 deletions
|
@ -29,8 +29,8 @@ M.init = function()
|
||||||
map('n', '<leader>bn', ':bnext<cr>')
|
map('n', '<leader>bn', ':bnext<cr>')
|
||||||
|
|
||||||
-- tab navigation
|
-- tab navigation
|
||||||
map('n', '<leader>tp', ':tprev<cr>')
|
map('n', '<leader>tp', ':tabprevious<cr>')
|
||||||
map('n', '<leader>tn', ':tnext<cr>')
|
map('n', '<leader>tn', ':tabnext<cr>')
|
||||||
end
|
end
|
||||||
|
|
||||||
return M
|
return M
|
||||||
|
|
31
lua/cosmic/core/snippets/init.lua
Normal file
31
lua/cosmic/core/snippets/init.lua
Normal 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()
|
|
@ -117,7 +117,14 @@ return packer.startup(function()
|
||||||
|
|
||||||
use({
|
use({
|
||||||
'L3MON4D3/LuaSnip',
|
'L3MON4D3/LuaSnip',
|
||||||
event = 'InsertEnter',
|
config = function()
|
||||||
|
require('cosmic.core.snippets')
|
||||||
|
end,
|
||||||
|
requires = {
|
||||||
|
{
|
||||||
|
'rafamadriz/friendly-snippets',
|
||||||
|
},
|
||||||
|
},
|
||||||
disable = vim.tbl_contains(user_plugins.disable, 'autocomplete'),
|
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-nvim-lua', after = 'cmp-buffer' },
|
||||||
{ 'hrsh7th/cmp-path', after = 'cmp-nvim-lua' },
|
{ 'hrsh7th/cmp-path', after = 'cmp-nvim-lua' },
|
||||||
},
|
},
|
||||||
after = 'LuaSnip',
|
event = 'InsertEnter',
|
||||||
})
|
})
|
||||||
|
|
||||||
use({
|
use({
|
||||||
|
|
Loading…
Add table
Reference in a new issue