added snippets for latex!
This commit is contained in:
parent
fda013288f
commit
b8f74170b6
5 changed files with 106 additions and 6 deletions
6
after/plugin/luasnip.lua
Normal file
6
after/plugin/luasnip.lua
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
require('luasnip').config.set_config({
|
||||
enable_autosnippets = true,
|
||||
store_selection_keys = '<Tab>',
|
||||
})
|
||||
|
||||
require('luasnip.loaders.from_lua').load({paths = {vim.fn.stdpath('config') .. '/snippets'}})
|
||||
|
|
@ -16,11 +16,14 @@ return {
|
|||
sources = {
|
||||
{ name = 'nvim_lsp' },
|
||||
{ name = 'nvim_lua' },
|
||||
{ name = 'luasnip' },
|
||||
},
|
||||
mapping = cmp.mapping.preset.insert({
|
||||
['<Tab>'] = cmp.mapping(function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.select_next_item()
|
||||
elseif require('luasnip').expand_or_jumpable() then
|
||||
require('luasnip').expand_or_jump()
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
|
|
@ -28,6 +31,8 @@ return {
|
|||
['<S-Tab>'] = cmp.mapping(function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.select_prev_item()
|
||||
elseif require('luasnip').jumpable(-1) then
|
||||
require('luasnip').jump(-1)
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ return {
|
|||
version = "v2.*",
|
||||
build = 'make install_jsregexp',
|
||||
},
|
||||
{ 'saadparwaiz1/cmp_luasnip' },
|
||||
'lewis6991/gitsigns.nvim',
|
||||
{
|
||||
'nvim-telescope/telescope.nvim',
|
||||
|
|
|
|||
|
|
@ -7,12 +7,12 @@
|
|||
-- require('cmp_nvim_lsp').default_capabilities()
|
||||
--)
|
||||
|
||||
vim.api.nvim_create_autocmd('FileType', {
|
||||
pattern = 'tex',
|
||||
callback = function()
|
||||
require('cmp').setup.buffer { sources = {{ name = 'omni' }} }
|
||||
end,
|
||||
})
|
||||
--vim.api.nvim_create_autocmd('FileType', {
|
||||
-- pattern = 'tex',
|
||||
-- callback = function()
|
||||
-- require('cmp').setup.buffer { sources = {{ name = 'omni' }} }
|
||||
-- end,
|
||||
--})
|
||||
|
||||
vim.api.nvim_create_autocmd('LspAttach', {
|
||||
desc = 'LSP actions',
|
||||
|
|
|
|||
88
snippets/tex/environments.lua
Normal file
88
snippets/tex/environments.lua
Normal file
|
|
@ -0,0 +1,88 @@
|
|||
local ls = require('luasnip')
|
||||
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 d = ls.dynamic_node
|
||||
local fmt = require('luasnip.extras.fmt').fmt
|
||||
local fmta = require('luasnip.extras.fmt').fmta
|
||||
local rep = require('luasnip.extras').rep
|
||||
|
||||
return {
|
||||
s(
|
||||
{
|
||||
trig = 'env',
|
||||
name = 'Environment',
|
||||
dscr = 'Creates generic \\begin{} \\end{} environment',
|
||||
},
|
||||
fmta(
|
||||
[[
|
||||
\begin{<>}
|
||||
<>
|
||||
\end{<>}
|
||||
]],
|
||||
{
|
||||
i(1),
|
||||
i(2),
|
||||
rep(1),
|
||||
}
|
||||
)
|
||||
),
|
||||
s(
|
||||
{
|
||||
trig = 'frame',
|
||||
name = 'Beamer Frame',
|
||||
dscr = 'Frame environment for beamer slides',
|
||||
},
|
||||
fmta(
|
||||
[[
|
||||
\begin{frame}
|
||||
\frametitle{<>}
|
||||
<>
|
||||
\end{frame}
|
||||
]],
|
||||
{
|
||||
i(1),
|
||||
i(2),
|
||||
}
|
||||
)
|
||||
),
|
||||
s(
|
||||
{
|
||||
trig = 'frame-fragile',
|
||||
name = 'Frame Fragile',
|
||||
dscr = 'Required for verbatim content like code listings.',
|
||||
},
|
||||
fmta(
|
||||
[[
|
||||
\begin{frame}[fragile]
|
||||
\frametitle{<>}
|
||||
<>
|
||||
\end{frame}
|
||||
]],
|
||||
{
|
||||
i(1),
|
||||
i(2),
|
||||
}
|
||||
)
|
||||
),
|
||||
s(
|
||||
{
|
||||
trig = 'noindent',
|
||||
name = 'No Indent',
|
||||
dscr = 'Add no indent instructin for latexindent. Useful for code-blocks.'
|
||||
},
|
||||
fmta(
|
||||
[[
|
||||
% \begin{noindent}
|
||||
<>
|
||||
% \end{noindent}
|
||||
]]
|
||||
,
|
||||
{
|
||||
i(1),
|
||||
}
|
||||
)
|
||||
),
|
||||
}
|
||||
Loading…
Reference in a new issue