mirror of
https://codeberg.org/leana8959/.files.git
synced 2025-12-06 14:49:14 +00:00
add(nvim): haskell snippets
This commit is contained in:
parent
dadce4af44
commit
bdeb98cb94
3 changed files with 29 additions and 38 deletions
|
|
@ -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 --
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue