Compare commits

..

No commits in common. "695cd74e5455c30eb1e63f26b302d5cab7d114a1" and "d9e7f76a5fb7e8c860bca0d16e5fc7c335b2f9b0" have entirely different histories.

5 changed files with 378 additions and 396 deletions

View File

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

View File

@ -10,13 +10,13 @@ opt.formatoptions = "trq1jp"
opt.tabstop = 4
-- Caps
vim.keymap.set("i", "AA", "À")
vim.keymap.set("i", "CC", "Ç")
vim.keymap.set("i", "EE", "É")
utils.map("i", "AA", "À")
utils.map("i", "CC", "Ç")
utils.map("i", "EE", "É")
-- Unbreakable spaces
vim.keymap.set("i", "<Space>etc", "\\,etc.")
vim.keymap.set("i", "<Space>:", "\\,:")
utils.map("i", "<Space>etc", "\\,etc.")
utils.map("i", "<Space>:", "\\,:")
-- Snippets
local ls = require("luasnip")
@ -44,7 +44,8 @@ local function rec_ls()
)
end
ls.add_snippets("tex", {
ls.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", {
@ -124,6 +125,5 @@ ls.add_snippets("tex", {
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 has_words_before = function()
local check_backspace = 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_locally_jumpable() then
elseif luasnip.expand_or_jumpable() then
luasnip.expand_or_jump()
elseif has_words_before() then
elseif check_backspace() then
cmp.complete()
else
fallback()

View File

@ -31,26 +31,7 @@ ls.config.set_config({
ext_opts = {
[types.choiceNode] = {
active = {
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" } },
virt_text = { { "choiceNode", "Comment" } },
},
},
},
@ -78,13 +59,15 @@ local function date_input(fmt)
return sn(nil, i(1, os.date(fmt)))
end
-- 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", {
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 = {
-- trigger is fn.
s("fn", {
-- Simple static text.
@ -338,9 +321,8 @@ ls.add_snippets( "all", {
"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 9b46e0fa3d2bfca3b376961d822eb5d965da48ed
Subproject commit d77e1cfe127418ab00c6d5fb076f89cdf9b49e94