aboutsummaryrefslogtreecommitdiff
path: root/common/config/nvim/lua/plugins/snippets.lua
blob: 989ad8aa50390734db7dbb56c66693fc5c93889a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
local M = {}

function M.setup()
  local ok, ls = pcall(require, "luasnip")
  if not ok or not ls then
    return false
  end

  -- Safely load snippets
  pcall(function() require("luasnip.loaders.from_lua").load({ paths = "~/.config/nvim/snippets/" }) end)
  pcall(function() require("luasnip.loaders.from_vscode").lazy_load() end)
  pcall(function() require("luasnip.loaders.from_snipmate").lazy_load() end)

  ls.config.set_config {
    history = true,
    updateevents = "TextChanged,TextChangedI",
    enable_autosnippets = true,
    region_check_events = "InsertEnter",
    delete_check_events = "TextChanged",
    store_selection_keys = "<Tab>",
    ext_opts = {
      [require("luasnip.util.types").choiceNode] = {
        active = {
          virt_text = { { "«", "GruvboxOrange" } },
        },
      },
    },
  }

  return true
end

return M