Skip to content

Commit

Permalink
refactor: from cr
Browse files Browse the repository at this point in the history
  • Loading branch information
opalmay committed Feb 6, 2023
1 parent 070565d commit 430a42d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
9 changes: 5 additions & 4 deletions lua/lvim/core/luasnip.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,19 @@ local types = {

function M.config()
lvim.builtin.luasnip = {
active = true,
sources = {
friendly_snippets = true,
},
config = {
opts = {
history = false,
update_events = "InsertLeave",
enable_autosnippets = false,
ext_opts = {
-- Show virtual text to signal when you are inside an sippets
[types.insertNode] = {
active = {
virt_text = { { "<-- snip insert", "BufferInactiveIndex" } },
virt_text = { { "<-- insert", "BufferInactiveIndex" } },
},
},
-- Helps to notice when you are within a choice node
Expand All @@ -45,7 +46,7 @@ function M.setup()
local utils = require "lvim.utils"
local paths = {}
if lvim.builtin.luasnip.sources.friendly_snippets then
paths[#paths + 1] = utils.join_paths(get_runtime_dir(), "site", "pack", "packer", "start", "friendly-snippets")
paths[#paths + 1] = utils.join_paths(get_runtime_dir(), "site", "pack", "lazy", "opt", "friendly-snippets")
end

local user_snippets = utils.join_paths(get_config_dir(), "snippets")
Expand All @@ -54,7 +55,7 @@ function M.setup()
end

local luasnip = require "luasnip"
luasnip.config.set_config(lvim.builtin.luasnip.config)
luasnip.config.set_config(lvim.builtin.luasnip.opts)

-- When no paths are provided, luasnip will search in the runtimepath
require("luasnip.loaders.from_lua").lazy_load()
Expand Down
7 changes: 6 additions & 1 deletion lua/lvim/plugins.lua
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,13 @@ local core_plugins = {
},
},
{ "hrsh7th/cmp-nvim-lsp", lazy = true },
{ "saadparwaiz1/cmp_luasnip", lazy = true },
{ "hrsh7th/cmp-buffer", lazy = true },
{ "hrsh7th/cmp-path", lazy = true },
{
"saadparwaiz1/cmp_luasnip",
lazy = true,
enabled = lvim.builtin.luasnip.active,
},
{
"hrsh7th/cmp-cmdline",
lazy = true,
Expand All @@ -82,6 +86,7 @@ local core_plugins = {
dependencies = {
"friendly-snippets",
},
enabled = lvim.builtin.luasnip.active,
},
{ "rafamadriz/friendly-snippets", lazy = true, cond = lvim.builtin.luasnip.sources.friendly_snippets },
{
Expand Down

0 comments on commit 430a42d

Please sign in to comment.