diff options
| author | Nanderty <psopka@sopka.ch> | 2023-03-26 16:04:40 +0200 |
|---|---|---|
| committer | Nanderty <psopka@sopka.ch> | 2023-03-26 16:04:40 +0200 |
| commit | ef44657937474145403c2b441b862035914d6a44 (patch) | |
| tree | cefeca8f30c2b8b16dd7b7ed877310a0f181fba0 /lua | |
| parent | 063c2d97218cdabe0634054a8038cd6b5c9a9a12 (diff) | |
| download | neovim-config-ef44657937474145403c2b441b862035914d6a44.tar.gz neovim-config-ef44657937474145403c2b441b862035914d6a44.tar.bz2 neovim-config-ef44657937474145403c2b441b862035914d6a44.zip | |
Snippets
Diffstat (limited to 'lua')
| -rw-r--r-- | lua/Snippets/luasniphelpers.lua | 9 | ||||
| -rw-r--r-- | lua/Snippets/luasniphelperslatex.lua | 26 | ||||
| -rw-r--r-- | lua/Snippets/tex/environments.lua | 49 | ||||
| -rw-r--r-- | lua/Snippets/tex/general.lua | 23 | ||||
| -rw-r--r-- | lua/Snippets/tex/greek.lua | 17 | ||||
| -rw-r--r-- | lua/Snippets/tex/math.lua | 29 | ||||
| -rw-r--r-- | lua/plugins/cmp.lua | 6 | ||||
| -rw-r--r-- | lua/plugins/telescope.lua | 17 |
8 files changed, 156 insertions, 20 deletions
diff --git a/lua/Snippets/luasniphelpers.lua b/lua/Snippets/luasniphelpers.lua new file mode 100644 index 0000000..5aa3e44 --- /dev/null +++ b/lua/Snippets/luasniphelpers.lua @@ -0,0 +1,9 @@ +local M = {} + +local ls = require("luasnip") +local sn = ls.snippet_node +local i = ls.insert_node + +M.line_begin = require("luasnip.extras.expand_conditions").line_begin + +return M diff --git a/lua/Snippets/luasniphelperslatex.lua b/lua/Snippets/luasniphelperslatex.lua new file mode 100644 index 0000000..a31e714 --- /dev/null +++ b/lua/Snippets/luasniphelperslatex.lua @@ -0,0 +1,26 @@ +local M = {} + +M.in_mathzone = function() + return vim.fn['vimtex#syntax#in_mathzone']() == 1 +end +M.in_text = function() + return not tex_utils.in_mathzone() +end +M.in_comment = function() + return vim.fn['vimtex#syntax#in_comment']() == 1 +end +M.in_env = function(name) + local is_inside = vim.fn['vimtex#env#is_inside'](name) + return (is_inside[1] > 0 and is_inside[2] > 0) +end +M.in_equation = function() + return tex_utils.in_env('equation') +end +M.in_itemize = function() + return tex_utils.in_env('itemize') +end +M.in_tikz = function() + return tex_utils.in_env('tikzpicture') +end + +return M diff --git a/lua/Snippets/tex/environments.lua b/lua/Snippets/tex/environments.lua new file mode 100644 index 0000000..fd19387 --- /dev/null +++ b/lua/Snippets/tex/environments.lua @@ -0,0 +1,49 @@ +local helper = require('Snippets.luasniphelpers') +local helper = require('Snippets.luasniphelpers') + +return { + -- variable environment + s({ trig = 'beg', snippetType = 'autosnippet' }, + fmta( + [[ +\begin{<>} + <> +\end{<>} +]], + { + i(1), + i(2), + rep(1), + } + ), + { condition = helper.line_begin } + ), + -- enumerate environment + s({ trig = 'enu', snippetType = 'autosnippet' }, + fmta( + [[ +\begin{enumerate*} + \item <> +\end{enumerate*} +]], + { + i(1), + } + ), + { condition = helper.line_begin } + ), + -- align environment + s({ trig = 'ali', snippetType = 'autosnippet' }, + fmta( + [[ +\begin{align*} + <> +\end{align*} +]], + { + i(1), + } + ), + { condition = helper.line_begin } + ), +} diff --git a/lua/Snippets/tex/general.lua b/lua/Snippets/tex/general.lua new file mode 100644 index 0000000..ebe76fe --- /dev/null +++ b/lua/Snippets/tex/general.lua @@ -0,0 +1,23 @@ +local tex = require('Snippets.luasniphelperslatex') +local helper = require('Snippets.luasniphelpers') + +return { + s({ trig = "sec", snippetType = "autosnippet" }, + fmta( + '\\section*{<>}', + { + i(1), + } + ), + { condition = line_begin } + ), + s({ trig = "hh", snippetType = "autosnippet" }, + fmta( + '\\SI{<>}{<>}', + { + i(1), + i(2), + } + ) + ), +} diff --git a/lua/Snippets/tex/greek.lua b/lua/Snippets/tex/greek.lua new file mode 100644 index 0000000..f47cdac --- /dev/null +++ b/lua/Snippets/tex/greek.lua @@ -0,0 +1,17 @@ +local tex = require('Snippets.luasniphelperslatex') +local helper = require('Snippets.luasniphelpers') + +return { + s({ trig = "pi", snippetType = "autosnippet" }, + { + t("\\pi"), + }, + { condition = tex.in_mathzone } + ), + s({ trig = "0eps", snippetType = "autosnippet" }, + { + t("\\epsilon_0"), + }, + { condition = tex.in_mathzone } + ), +} diff --git a/lua/Snippets/tex/math.lua b/lua/Snippets/tex/math.lua new file mode 100644 index 0000000..670ed80 --- /dev/null +++ b/lua/Snippets/tex/math.lua @@ -0,0 +1,29 @@ +local tex = require('Snippets.luasniphelperslatex') +local helper = require('Snippets.luasniphelpers') + +return { + s({ trig = '/', snippetType = 'autosnippet' }, + fmta( + '\\frac{<>}{<>}', + { + i(1), + i(2), + } + ), + { condition = tex.in_mathzone } + ), + s({ trig = "in", snippetType = "autosnippet" }, + fmta( + '\\int_{<>}^{<>}', + { + i(1), + i(2), + } + ), + { condition = tex.in_mathzone } + ), + s({ trig = 'df', snippetType = 'autosnippet' }, + { t('\\diff ') }, + { condition = tex.in_mathzone } + ), +} diff --git a/lua/plugins/cmp.lua b/lua/plugins/cmp.lua index 76e8101..3f7b6ea 100644 --- a/lua/plugins/cmp.lua +++ b/lua/plugins/cmp.lua @@ -14,7 +14,7 @@ return { }, config = function(_, opts) require('luasnip').config.set_config(opts) - require('luasnip.loaders.from_lua').lazy_load({ paths = vim.fn.stdpath('config') .. '/Snippets/' }) + require('luasnip.loaders.from_lua').lazy_load({ paths = vim.fn.stdpath('config') .. '/lua/Snippets/' }) end }, { @@ -23,7 +23,7 @@ return { dependencies = { 'hrsh7th/cmp-nvim-lsp', 'hrsh7th/cmp-buffer', - 'hrsh7th/cmp-path', + 'FelipeLema/cmp-async-path', 'hrsh7th/cmp-calc', 'saadparwaiz1/cmp_luasnip', 'L3MON4D3/LuaSnip', @@ -55,7 +55,7 @@ return { { name = 'nvim_lsp' }, { name = 'luasnip' }, { name = 'buffer' }, - { name = 'path' }, + { name = 'async_path' }, { name = 'calc' }, }), formatting = { diff --git a/lua/plugins/telescope.lua b/lua/plugins/telescope.lua index b62373d..3f1a9b8 100644 --- a/lua/plugins/telescope.lua +++ b/lua/plugins/telescope.lua @@ -36,11 +36,6 @@ return { }, borderchars = { ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' }, }, - extensions = { - sessions_picker = { - sessions_dir = vim.fn.stdpath('data') .. '/session/', - } - }, }, }, { @@ -56,18 +51,6 @@ return { end, }, { - dir = vim.fn.stdpath('data') .. '/localplugins/telemini/', - keys = { - { '<leader>ps', '<cmd>Telescope telemini<cr>', desc = 'sessions' } - }, - dependencies = { - 'nvim-telescope/telescope.nvim', - }, - config = function() - require('telescope').load_extension 'telemini' - end, - }, - { 'nvim-telescope/telescope-fzf-native.nvim', build = 'make', config = function() |
