add(nvim): haskell snippets

This commit is contained in:
Léana 江 2023-11-25 13:05:57 +01:00 committed by Léana 江
parent dadce4af44
commit bdeb98cb94
3 changed files with 29 additions and 38 deletions

View file

@ -21,21 +21,25 @@ local types = require "luasnip.util.types"
local conds = require "luasnip.extras.conditions"
local conds_expand = require "luasnip.extras.conditions.expand"
require "luasnip.loaders.from_vscode".lazy_load { paths = { "./snippets" } }
ls.setup {
update_events = { "TextChanged", "TextChangedI" },
}
local has_words_before = function()
unpack = unpack or table.unpack
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]:sub(col, col):match "%s" == nil
end
--------------
-- Snippets --
--------------
-----------------
-- Lazy loader --
-----------------
require "luasnip.loaders.from_vscode".lazy_load { paths = { "./snippets" } }
----------
-- Init --
----------
ls.setup { update_events = { "TextChanged", "TextChangedI" } }
-----------
-- Typst --
-----------
local function show_date()
return os.date "(year: %Y, month: %m, day: %d, hour: %H, minute: %M, second: %S)"
end
@ -54,10 +58,7 @@ local function get_cms()
local left = vim.bo.commentstring:gsub("%s*%%s.*", "")
local right = vim.bo.commentstring:gsub(".*%%s%s*", "")
if right == "" then right = left end
return {
left = left,
right = right,
}
return { left = left, right = right }
end
local function horizon(args)
local cms = get_cms()
@ -90,23 +91,11 @@ ls.add_snippets("all", {
}),
})
local function fold_start()
local cms = get_cms()
return cms.left .. " {{{" .. cms.right
end
local function fold_end()
local cms = get_cms()
return cms.left .. " }}}" .. cms.right
end
ls.add_snippets("all", {
s("fold", {
f(fold_start),
t { "", "" },
i(1),
t { "", "" },
f(fold_end),
}),
})
-------------
-- Haskell --
-------------
local haskell_snippets = require('haskell-snippets').all
ls.add_snippets('haskell', haskell_snippets, { key = 'haskell' })
---------------
-- Setup CMP --