Compare commits

...

5 Commits

5 changed files with 396 additions and 378 deletions

View File

@ -20,8 +20,7 @@ local f = ls.function_node
local copy = utils.copy
ls.snippets = {
c = {
ls.add_snippets( "c", {
s("main", {
t({ "int main(int argc, char* argv[])" }),
t({ "", "{", "\t" }),
@ -47,5 +46,6 @@ ls.snippets = {
t({ "", "\treturn 0;"}),
t({ "", "}"}),
}),
},
}
}, {
key = "c"
})

View File

@ -10,13 +10,13 @@ opt.formatoptions = "trq1jp"
opt.tabstop = 4
-- Caps
utils.map("i", "AA", "À")
utils.map("i", "CC", "Ç")
utils.map("i", "EE", "É")
vim.keymap.set("i", "AA", "À")
vim.keymap.set("i", "CC", "Ç")
vim.keymap.set("i", "EE", "É")
-- Unbreakable spaces
utils.map("i", "<Space>etc", "\\,etc.")
utils.map("i", "<Space>:", "\\,:")
vim.keymap.set("i", "<Space>etc", "\\,etc.")
vim.keymap.set("i", "<Space>:", "\\,:")
-- Snippets
local ls = require("luasnip")
@ -44,8 +44,7 @@ local function rec_ls()
)
end
ls.snippets = {
tex = {
ls.add_snippets("tex", {
-- rec_ls is self-referencing. That makes this snippet 'infinite' eg. have as many
-- \item as necessary by utilizing a choiceNode.
s("ls", {
@ -125,5 +124,6 @@ ls.snippets = {
i(1),
t({ "}"}),
}),
},
}
}, {
key = "tex"
})

View File

@ -7,7 +7,7 @@ local cmp = require("cmp")
local luasnip = require("luasnip")
local cmp_autopairs = require('nvim-autopairs.completion.cmp')
local check_backspace = function()
local has_words_before = function()
local line, col = unpack(vim.api.nvim_win_get_cursor(0))
return col ~= 0 and
vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:
@ -62,9 +62,9 @@ cmp.setup {
["<Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_next_item()
elseif luasnip.expand_or_jumpable() then
elseif luasnip.expand_or_locally_jumpable() then
luasnip.expand_or_jump()
elseif check_backspace() then
elseif has_words_before() then
cmp.complete()
else
fallback()

View File

@ -31,7 +31,26 @@ ls.config.set_config({
ext_opts = {
[types.choiceNode] = {
active = {
virt_text = { { "choiceNode", "Comment" } },
virt_text = { { "", "LuaSnipChoice" } },
},
inactive = {
virt_text = { { "", "LuaSnipInactive" } },
},
},
[types.functionNode] = {
active = {
virt_text = { { "", "LuaSnipFunction" } },
},
inactive = {
virt_text = { { "", "LuaSnipInactive" } },
},
},
[types.insertNode] = {
active = {
virt_text = { { "", "LuaSnipInsert" } },
},
inactive = {
virt_text = { { "", "LuaSnipInactive" } },
},
},
},
@ -59,15 +78,13 @@ local function date_input(fmt)
return sn(nil, i(1, os.date(fmt)))
end
ls.snippets = {
-- When trying to expand a snippet, luasnip first searches the tables for
-- each filetype specified in 'filetype' followed by 'all'.
-- If ie. the filetype is 'lua.c'
-- - luasnip.lua
-- - luasnip.c
-- - luasnip.all
-- are searched in that order.
all = {
-- snippets are added via ls.add_snippets(filetype, snippets[, opts]), where
-- opts may specify the `type` of the snippets ("snippets" or "autosnippets",
-- for snippets that should expand directly after the trigger is typed).
--
-- opts can also specify a key. By passing an unique key to each add_snippets, it's possible to reload snippets by
-- re-`:luafile`ing the file in which they are defined (eg. this one).
ls.add_snippets( "all", {
-- trigger is fn.
s("fn", {
-- Simple static text.
@ -321,8 +338,9 @@ ls.snippets = {
"fmt6",
fmt("use {} only", { t("this"), t("not this") }, { strict = false })
),
},
}
}, {
key = "all",
})
-- autotriggered snippets have to be defined in a separate table, luasnip.autosnippets.
ls.autosnippets = {

@ -1 +1 @@
Subproject commit d77e1cfe127418ab00c6d5fb076f89cdf9b49e94
Subproject commit 9b46e0fa3d2bfca3b376961d822eb5d965da48ed