You've already forked dotfiles
feat: Replacement of the autopairs plugin using snippets, extension of
snippets (mainly python) and cleanup of keymappings for snippets.
This commit is contained in:
@@ -1,44 +1,36 @@
|
||||
local ls = require('luasnip')
|
||||
local s = ls.snippet
|
||||
-- local sn = ls.snippet_node
|
||||
local i = ls.insert_node
|
||||
local t = ls.text_node
|
||||
local l = require('luasnip.extras').lambda
|
||||
-- local l = require('luasnip.extras').lambda
|
||||
local fmt = require('luasnip.extras.fmt').fmt
|
||||
local ts_post = require('luasnip.extras.treesitter_postfix').treesitter_postfix
|
||||
-- local ts_post = require('luasnip.extras.treesitter_postfix').treesitter_postfix
|
||||
|
||||
return {
|
||||
ts_post({
|
||||
matchTSNode = {
|
||||
query = [[
|
||||
(function_definition
|
||||
parameters: (parameters) @params
|
||||
return_type: (type) @return
|
||||
) @prefix
|
||||
]],
|
||||
query_lang = "python",
|
||||
},
|
||||
trig = "docstring",
|
||||
}, fmt([[
|
||||
''' {}
|
||||
|
||||
Keyword arguments:
|
||||
{} () -
|
||||
|
||||
Return:
|
||||
{} - {}
|
||||
'''
|
||||
ls.add_snippets('python', {
|
||||
s('docstring single', {
|
||||
t("''' "), i(0, 'text'), t(" '''")
|
||||
}),
|
||||
s('def', fmt([[
|
||||
def {func}({args}) -> {ret}:
|
||||
''' {doc} '''
|
||||
{body}
|
||||
]], {
|
||||
i(1, 'Description'),
|
||||
l(l.LS_TSCAPTURE_PARAMS),
|
||||
l(l.LS_TSCAPTURE_RETURN),
|
||||
l(l.LS_TSDATA),
|
||||
func = i(1, 'fname'),
|
||||
args = i(2),
|
||||
ret = i(3, 'None'),
|
||||
doc = i(4, 'docstring'),
|
||||
body = i(5, 'pass'),
|
||||
}, {
|
||||
})),
|
||||
-- s(
|
||||
-- { trig = "thingy" },
|
||||
-- { t('Woot!') }
|
||||
-- ),
|
||||
-- s(
|
||||
-- { trig = 'thingy2' },
|
||||
-- { t('Woot2!') }
|
||||
-- )
|
||||
}
|
||||
s('ternary', {
|
||||
i(1, 'then'), t(' if '), i(2, 'condition'), t(' else '), i(3, 'else')
|
||||
}),
|
||||
s('tuple ternary', fmt([[
|
||||
({if_true}, {if_false})[{condition}]
|
||||
]], {
|
||||
if_true = i(1, 'if_true'),
|
||||
if_false = i(2, 'if_false'),
|
||||
condition = i(3, 'condition'),
|
||||
})),
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user