Update bindings + luasnip config
This commit is contained in:
parent
de9fd67b6f
commit
3c332abf0f
24
lua/snippets/c-cpp.lua
Normal file
24
lua/snippets/c-cpp.lua
Normal file
@ -0,0 +1,24 @@
|
||||
print 'c-cpp init'
|
||||
ls.add_snippets('c', {
|
||||
s('fn', {
|
||||
i(1, 'void'),
|
||||
t ' ',
|
||||
i(2, 'func_name'),
|
||||
t '(',
|
||||
i(3),
|
||||
t ') ',
|
||||
t '{ ',
|
||||
i(4, '...'),
|
||||
t ' }',
|
||||
}),
|
||||
s('test', {
|
||||
t 'printf("',
|
||||
i(1),
|
||||
t '");',
|
||||
}),
|
||||
})
|
||||
ls.filetype_extend('cpp', { 'c' })
|
||||
-- Return false to invalidate cache entry for require()
|
||||
-- This is so sourcing snippets/init.lua also "reloads" this file
|
||||
-- https://stackoverflow.com/questions/72242451/sourcing-nvim-init-does-not-source-required-lua-files
|
||||
return false
|
27
lua/snippets/common.lua
Normal file
27
lua/snippets/common.lua
Normal file
@ -0,0 +1,27 @@
|
||||
ls = require 'luasnip'
|
||||
s = ls.snippet
|
||||
sn = ls.snippet_node
|
||||
isn = ls.indent_snippet_node
|
||||
t = ls.text_node
|
||||
i = ls.insert_node
|
||||
f = ls.function_node
|
||||
c = ls.choice_node
|
||||
d = ls.dynamic_node
|
||||
r = ls.restore_node
|
||||
events = require 'luasnip.util.events'
|
||||
ai = require 'luasnip.nodes.absolute_indexer'
|
||||
extras = require 'luasnip.extras'
|
||||
l = extras.lambda
|
||||
rep = extras.rep
|
||||
p = extras.partial
|
||||
m = extras.match
|
||||
n = extras.nonempty
|
||||
dl = extras.dynamic_lambda
|
||||
fmt = require('luasnip.extras.fmt').fmt
|
||||
fmta = require('luasnip.extras.fmt').fmta
|
||||
conds = require 'luasnip.extras.expand_conditions'
|
||||
postfix = require('luasnip.extras.postfix').postfix
|
||||
types = require 'luasnip.util.types'
|
||||
parse = require('luasnip.util.parser').parse_snippet
|
||||
ms = ls.multi_snippet
|
||||
k = require('luasnip.nodes.key_indexer').new_key
|
4
lua/snippets/init.lua
Normal file
4
lua/snippets/init.lua
Normal file
@ -0,0 +1,4 @@
|
||||
print 'init.lua init'
|
||||
require 'snippets.common'
|
||||
require 'snippets.lua'
|
||||
require 'snippets.c-cpp'
|
19
lua/snippets/lua.lua
Normal file
19
lua/snippets/lua.lua
Normal file
@ -0,0 +1,19 @@
|
||||
ls.add_snippets('lua', {
|
||||
s('func', {
|
||||
t 'function() ',
|
||||
i(1),
|
||||
t ' end',
|
||||
}),
|
||||
|
||||
s('if', {
|
||||
t 'if ',
|
||||
i(1, 'true'),
|
||||
t ' then ',
|
||||
i(2),
|
||||
t ' end',
|
||||
}),
|
||||
})
|
||||
-- Return false to invalidate cache entry for require()
|
||||
-- This is so sourcing snippets/init.lua also "reloads" this file
|
||||
-- https://stackoverflow.com/questions/72242451/sourcing-nvim-init-does-not-source-required-lua-files
|
||||
return false
|
Loading…
Reference in New Issue
Block a user