Drop snippets except UTF-8.

main
Joshua Potter 2024-02-24 16:08:58 -07:00
parent f573cc7ada
commit c073ebf763
11 changed files with 6 additions and 190 deletions

View File

@ -15,23 +15,17 @@ in
programs.neovim = {
nvim-dap = ''
require('cxx.init').nvim_dap()
require('lang.cxx').nvim_dap()
'';
nvim-lspconfig = ''
require('cxx.init').nvim_lspconfig()
require('lang.cxx').nvim_lspconfig()
vim.filetype.add({
pattern = {
['.*%.h'] = 'c',
},
})
'';
nvim-snippets = ''
require('luasnip').add_snippets('c', require('cxx.snippets'))
require('luasnip').add_snippets('cpp', require('cxx.snippets'))
'';
};
xdg.configFile."nvim/after/ftplugin/c.lua".text = ''

View File

@ -6,11 +6,7 @@
programs.neovim = {
nvim-lspconfig = ''
require('lua.init').nvim_lspconfig()
'';
nvim-snippets = ''
require('luasnip').add_snippets('lua', require('lua.snippets'))
require('lang.lua').nvim_lspconfig()
'';
};
}

View File

@ -13,15 +13,11 @@
programs.neovim = {
nvim-dap = ''
require('python.init').nvim_dap()
require('lang.python').nvim_dap()
'';
nvim-lspconfig = ''
require('python.init').nvim_lspconfig()
'';
nvim-snippets = ''
require('luasnip').add_snippets('python', require('python.snippets'))
require('lang.python').nvim_lspconfig()
'';
};

View File

@ -1,57 +0,0 @@
local fmt = require('luasnip.extras.fmt').fmt
local ls = require('luasnip')
local ki = require('luasnip.nodes.key_indexer')
local ul = require('utils.luasnip')
local c = ls.choice_node
local d = ls.dynamic_node
local i = ls.insert_node
local k = ki.new_key
local r = ls.restore_node
local s = ls.snippet
local sn = ls.snippet_node
local t = ls.text_node
return {
s(
{ name = 'for', trig = 'for' },
fmt([[
for (<>; <>) {
<>
}]],
{
c(1, {
sn(nil, {
i(1, 'int'),
t(' '),
i(2, 'i'),
}),
sn(nil, {
i(1, 'char *'),
i(2, 'c'),
}),
}),
d(2, function(_, parent)
local index = ul.choice_index(parent.nodes[2])
return sn(
nil,
r(1, string.format('for-%d', index), ({
sn(nil, {
i(1, 'i < N'),
t('; '),
i(2, '++i'),
}),
sn(nil, {
i(1, 'c'),
t('; '),
i(2, '++c'),
}),
})[index])
)
end, { 1 }),
ul.visual_isn(3),
},
{ delimiters = '<>' }
)
),
}

View File

@ -1,48 +0,0 @@
local fmt = require('luasnip.extras.fmt').fmt
local ls = require('luasnip')
local ul = require('utils.luasnip')
local c = ls.choice_node
local i = ls.insert_node
local s = ls.snippet
local sn = ls.snippet_node
local t = ls.text_node
return {
s(
{ name = 'for', trig = 'for' },
fmt([[
for {} do
{}
end]],
{
c(1, {
sn(nil, {
i(1, 'i'),
t('='),
i(2, 'm'),
t(','),
i(3, 'n'),
}),
sn(nil, {
i(1, 'k'),
t(', '),
i(2, 'v'),
t(' in pairs('),
i(3, 'tbl'),
t(')'),
}),
sn(nil, {
i(1, 'i'),
t(', '),
i(2, 'v'),
t(' in ipairs('),
i(3, 'seq'),
t(')'),
}),
}),
ul.visual_isn(2),
}
)
),
}

View File

@ -1,54 +0,0 @@
local fmt = require('luasnip.extras.fmt').fmt
local ls = require('luasnip')
local ul = require('utils.luasnip')
local c = ls.choice_node
local d = ls.dynamic_node
local i = ls.insert_node
local r = ls.restore_node
local s = ls.snippet
local sn = ls.snippet_node
local t = ls.text_node
return {
s(
{ name = 'for', trig = 'for' },
fmt([[
for {} in {}:
{}]],
{
c(1, {
i(nil, 'i'),
i(nil, 'k'),
i(nil, 'v'),
{ i(1, 'k'), t(', '), i(2, 'v') },
}),
d(2, function(_, parent)
local index = ul.choice_index(parent.nodes[2])
return sn(
nil,
r(1, string.format('for-%d', index), ({
c(nil, {
{ t('range('), i(1, 'n'), t(')') },
i(nil, 'val'),
}),
c(nil, {
{ i(1, 'dict'), t('.keys()') },
i(nil, 'val'),
}),
c(nil, {
{ i(1, 'dict'), t('.values()') },
i(nil, 'val'),
}),
c(nil, {
{ i(1, 'dict'), t('.items()') },
i(nil, 'val'),
}),
})[index])
)
end, { 1 }),
ul.visual_isn(3),
}
)
),
}

View File

@ -32,10 +32,9 @@ let
plugin = pkgs.vimPlugins.luasnip;
config = ''
require('utils.luasnip').setup()
require('luasnip').add_snippets('all', require('utf8.snippets'), {
require('luasnip').add_snippets('all', require('utils.utf8'), {
type = "autosnippets",
})
${config.programs.neovim.nvim-snippets}
'';
};
@ -109,16 +108,6 @@ in
Language-specific configurations for the `nvim-lspconfig` plugin.
'';
};
nvim-snippets = lib.mkOption {
type = lib.types.lines;
example = ''
require('...').nvim_lspconfig()
'';
description = lib.mdDoc ''
Language-specific configurations for the `luasnip` plugin.
'';
};
};
config = {