Compare commits
6 Commits
f38e7720e1
...
3dbb63738b
| Author | SHA1 | Date | |
|---|---|---|---|
| 3dbb63738b | |||
| 3c768051f5 | |||
| 39b68e0d54 | |||
| 24bb947547 | |||
| 9d9934f133 | |||
| 7e7a4a5543 |
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
lua/testing
|
||||||
|
|
||||||
7
after/ftplugin/json.lua
Normal file
7
after/ftplugin/json.lua
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
vim.opt_local.tabstop = 2
|
||||||
|
vim.opt_local.shiftwidth = 2
|
||||||
|
vim.opt_local.softtabstop = 2
|
||||||
|
vim.opt_local.expandtab = true
|
||||||
|
|
||||||
|
vim.opt_local.conceallevel = 0
|
||||||
|
|
||||||
@@ -3,6 +3,6 @@ require("crentist.set")
|
|||||||
require("crentist.lazy_init")
|
require("crentist.lazy_init")
|
||||||
require("crentist.autocmd")
|
require("crentist.autocmd")
|
||||||
require("crentist.filetype")
|
require("crentist.filetype")
|
||||||
require("crentist.luasnip")
|
require("crentist.snippets")
|
||||||
require("crentist.null-ls")
|
require("crentist.null-ls")
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ return {
|
|||||||
'tpope/vim-fugitive',
|
'tpope/vim-fugitive',
|
||||||
config = function()
|
config = function()
|
||||||
vim.keymap.set('n', "<leader>gs", vim.cmd.Git)
|
vim.keymap.set('n', "<leader>gs", vim.cmd.Git)
|
||||||
|
vim.keymap.set('n', "<leader><leader>gl", function () vim.cmd.Git({ 'pull' }) end)
|
||||||
|
|
||||||
vim.api.nvim_create_user_command('Gcm', function() vim.cmd.Git({ 'switch main' }) end, {})
|
vim.api.nvim_create_user_command('Gcm', function() vim.cmd.Git({ 'switch main' }) end, {})
|
||||||
|
|
||||||
@@ -26,10 +27,6 @@ return {
|
|||||||
vim.keymap.set('n', "<leader>P", function()
|
vim.keymap.set('n', "<leader>P", function()
|
||||||
vim.cmd.Git({ 'pull', '--rebase' })
|
vim.cmd.Git({ 'pull', '--rebase' })
|
||||||
end, opts)
|
end, opts)
|
||||||
|
|
||||||
-- NOTE: It allows me to easily set the branch i am pushing and any tracking
|
|
||||||
-- needed if i did not set the branch up correctly
|
|
||||||
vim.keymap.set('n', "<leader>t", ":Git push -u origin ", opts);
|
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,158 +0,0 @@
|
|||||||
-- luasnip.lua
|
|
||||||
local ls = require('luasnip')
|
|
||||||
local s = ls.snippet
|
|
||||||
local i = ls.insert_node
|
|
||||||
local f = ls.function_node
|
|
||||||
local fmt = require("luasnip.extras.fmt").fmt
|
|
||||||
local vscode_loader = require("luasnip.loaders.from_vscode")
|
|
||||||
|
|
||||||
vim.keymap.set({ "i", "s" }, "<C-l>", function()
|
|
||||||
if ls.expand_or_jumpable() then
|
|
||||||
ls.expand_or_jump()
|
|
||||||
end
|
|
||||||
end, { desc = "Snippet next argument", silent = true })
|
|
||||||
|
|
||||||
--------------------
|
|
||||||
-- Snippets for LUA
|
|
||||||
--------------------
|
|
||||||
ls.add_snippets('lua', {
|
|
||||||
s({ name = 'LuaSnip Snippet', trig = 'snipf' },
|
|
||||||
fmt([[
|
|
||||||
s({ name='<name>', trig='<trig>'},
|
|
||||||
fmt(<template>,
|
|
||||||
{ <inputs> },
|
|
||||||
{ <opts> }
|
|
||||||
)
|
|
||||||
),
|
|
||||||
]], {
|
|
||||||
name = i(1, 'name'),
|
|
||||||
trig = i(2, 'trig'),
|
|
||||||
template = i(3, '[[]]'),
|
|
||||||
inputs = i(4, 'nodes'),
|
|
||||||
opts = i(5,
|
|
||||||
'opts')
|
|
||||||
},
|
|
||||||
{ delimiters = '<>' }
|
|
||||||
)
|
|
||||||
),
|
|
||||||
s({ name = 'Add snippets block', trig = 'add_snip' },
|
|
||||||
fmt([[
|
|
||||||
ls.add_snippets('<filetype>', {
|
|
||||||
<snippets>
|
|
||||||
})
|
|
||||||
]],
|
|
||||||
{ filetype = i(1, 'Filetype'), snippets = i(2, 'Snippets') },
|
|
||||||
{ delimiters = '<>' }
|
|
||||||
)
|
|
||||||
),
|
|
||||||
})
|
|
||||||
|
|
||||||
--------------------
|
|
||||||
-- Generic snippets
|
|
||||||
--------------------
|
|
||||||
local function com_string(_, snip, to_multiply)
|
|
||||||
local comment_string = vim.bo.commentstring
|
|
||||||
local repeats = snip.captures[1]
|
|
||||||
local result = comment_string:gsub("%%s", ""):gsub(" ", "")
|
|
||||||
|
|
||||||
if to_multiply then
|
|
||||||
return string.sub(
|
|
||||||
string.rep(result, repeats),
|
|
||||||
0,
|
|
||||||
repeats
|
|
||||||
)
|
|
||||||
end
|
|
||||||
|
|
||||||
return result
|
|
||||||
end
|
|
||||||
|
|
||||||
ls.add_snippets('all', {
|
|
||||||
s({ name = 'Comment block', trig = '#com(%d+)', regTrig = true },
|
|
||||||
fmt([[
|
|
||||||
{comment_block}
|
|
||||||
{comment} {comment_text}
|
|
||||||
{comment_block}
|
|
||||||
]],
|
|
||||||
{
|
|
||||||
comment_block = f(com_string, {}, { user_args = { true } }),
|
|
||||||
comment = f(com_string, {}, { user_args = { false } }),
|
|
||||||
comment_text = i(1,
|
|
||||||
'Comment')
|
|
||||||
}
|
|
||||||
)
|
|
||||||
),
|
|
||||||
})
|
|
||||||
|
|
||||||
--------------------
|
|
||||||
-- Terraform
|
|
||||||
--------------------
|
|
||||||
ls.add_snippets('terraform', {
|
|
||||||
s({ name = 'data_assume', trig = 'tf_assume' },
|
|
||||||
fmt([[
|
|
||||||
data "aws_iam_policy_document" "<name>" {
|
|
||||||
statement {
|
|
||||||
actions = ["sts:AssumeRole"]
|
|
||||||
|
|
||||||
principals {
|
|
||||||
type = "Service"
|
|
||||||
identifiers = ["<service>.amazonaws.com"]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]],
|
|
||||||
{
|
|
||||||
name = i(1, 'assume'),
|
|
||||||
service = i(2, 'service')
|
|
||||||
},
|
|
||||||
{ delimiters = '<>' }
|
|
||||||
)
|
|
||||||
),
|
|
||||||
})
|
|
||||||
|
|
||||||
------------------------------
|
|
||||||
-- YAML
|
|
||||||
------------------------------
|
|
||||||
local yaml_schema_snippet = s(
|
|
||||||
{ name = 'yaml_schema', trig = 'yaml_schema' },
|
|
||||||
fmt([[
|
|
||||||
{comment} yaml-language-server: $schema={path}
|
|
||||||
]],
|
|
||||||
{
|
|
||||||
path = i(1, 'path'),
|
|
||||||
comment = f(com_string, {}, { user_args = { false } }),
|
|
||||||
}
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
ls.add_snippets('yaml', { yaml_schema_snippet })
|
|
||||||
ls.add_snippets('helm', { yaml_schema_snippet })
|
|
||||||
|
|
||||||
|
|
||||||
local flux_cd_kustomization = s(
|
|
||||||
{ name = 'fluxcd_kustomization', trig = 'fluxkust' },
|
|
||||||
fmt([[
|
|
||||||
apiVersion: kustomize.toolkit.fluxcd.io/v1
|
|
||||||
kind: Kustomization
|
|
||||||
metadata:
|
|
||||||
name: {name}
|
|
||||||
namespace: {namespace}
|
|
||||||
spec:
|
|
||||||
interval: {interval}
|
|
||||||
path: {path}
|
|
||||||
prune: true
|
|
||||||
sourceRef:
|
|
||||||
kind: GitRepository
|
|
||||||
name: {repository_name}
|
|
||||||
]],
|
|
||||||
{
|
|
||||||
name = i(1, 'name'),
|
|
||||||
namespace = i(2, 'flux-system'),
|
|
||||||
interval = i(3, '5m'),
|
|
||||||
path = i(4, 'path'),
|
|
||||||
repository_name = i(5, 'repository_name'),
|
|
||||||
}
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
ls.add_snippets('yaml', { flux_cd_kustomization })
|
|
||||||
|
|
||||||
@@ -43,3 +43,9 @@ vim.keymap.set("v", "<leader>x", ":lua<CR>")
|
|||||||
vim.keymap.set("n", "<C-M-j>", "<cmd>cnext<CR>")
|
vim.keymap.set("n", "<C-M-j>", "<cmd>cnext<CR>")
|
||||||
vim.keymap.set("n", "<C-M-k>", "<cmd>cprev<CR>")
|
vim.keymap.set("n", "<C-M-k>", "<cmd>cprev<CR>")
|
||||||
|
|
||||||
|
vim.keymap.set({ 'i', 's' }, '<C-l>', function()
|
||||||
|
if ls.expand_or_jumpable() then
|
||||||
|
ls.expand_or_jump()
|
||||||
|
end
|
||||||
|
end, { desc = 'Snippet next argument', silent = true })
|
||||||
|
|
||||||
|
|||||||
39
lua/crentist/snippets/common.lua
Normal file
39
lua/crentist/snippets/common.lua
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
local ls = require('luasnip')
|
||||||
|
local s = ls.snippet
|
||||||
|
local i = ls.insert_node
|
||||||
|
local f = ls.function_node
|
||||||
|
local fmt = require('luasnip.extras.fmt').fmt
|
||||||
|
|
||||||
|
local function com_string(_, snip, to_multiply)
|
||||||
|
local comment_string = vim.bo.commentstring
|
||||||
|
local repeats = snip.captures[1]
|
||||||
|
local result = comment_string:gsub('%%s', ''):gsub(' ', '')
|
||||||
|
|
||||||
|
if to_multiply then
|
||||||
|
return string.sub(
|
||||||
|
string.rep(result, repeats),
|
||||||
|
0,
|
||||||
|
repeats
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
return result
|
||||||
|
end
|
||||||
|
|
||||||
|
ls.add_snippets('all', {
|
||||||
|
s({ name = 'Comment block', trig = '#com(%d+)', regTrig = true },
|
||||||
|
fmt([[
|
||||||
|
{comment_block}
|
||||||
|
{comment} {comment_text}
|
||||||
|
{comment_block}
|
||||||
|
]],
|
||||||
|
{
|
||||||
|
comment_block = f(com_string, {}, { user_args = { true } }),
|
||||||
|
comment = f(com_string, {}, { user_args = { false } }),
|
||||||
|
comment_text = i(1,
|
||||||
|
'Comment')
|
||||||
|
}
|
||||||
|
)
|
||||||
|
),
|
||||||
|
})
|
||||||
|
|
||||||
5
lua/crentist/snippets/init.lua
Normal file
5
lua/crentist/snippets/init.lua
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
require('crentist.snippets.common')
|
||||||
|
require('crentist.snippets.lua')
|
||||||
|
require('crentist.snippets.terraform')
|
||||||
|
require('crentist.snippets.yaml')
|
||||||
|
|
||||||
38
lua/crentist/snippets/lua.lua
Normal file
38
lua/crentist/snippets/lua.lua
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
local ls = require('luasnip')
|
||||||
|
local s = ls.snippet
|
||||||
|
local i = ls.insert_node
|
||||||
|
local f = ls.function_node
|
||||||
|
local fmt = require('luasnip.extras.fmt').fmt
|
||||||
|
|
||||||
|
ls.add_snippets('lua', {
|
||||||
|
s({ name = 'LuaSnip Snippet', trig = 'snipf' },
|
||||||
|
fmt([[
|
||||||
|
s({ name='<name>', trig='<trig>'},
|
||||||
|
fmt(<template>,
|
||||||
|
{ <inputs> },
|
||||||
|
{ <opts> }
|
||||||
|
)
|
||||||
|
),
|
||||||
|
]], {
|
||||||
|
name = i(1, 'name'),
|
||||||
|
trig = i(2, 'trig'),
|
||||||
|
template = i(3, '[[]]'),
|
||||||
|
inputs = i(4, 'nodes'),
|
||||||
|
opts = i(5,
|
||||||
|
'opts')
|
||||||
|
},
|
||||||
|
{ delimiters = '<>' }
|
||||||
|
)
|
||||||
|
),
|
||||||
|
s({ name = 'Add snippets block', trig = 'add_snip' },
|
||||||
|
fmt([[
|
||||||
|
ls.add_snippets('<filetype>', {
|
||||||
|
<snippets>
|
||||||
|
})
|
||||||
|
]],
|
||||||
|
{ filetype = i(1, 'Filetype'), snippets = i(2, 'Snippets') },
|
||||||
|
{ delimiters = '<>' }
|
||||||
|
)
|
||||||
|
),
|
||||||
|
})
|
||||||
|
|
||||||
29
lua/crentist/snippets/terraform.lua
Normal file
29
lua/crentist/snippets/terraform.lua
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
local ls = require('luasnip')
|
||||||
|
local s = ls.snippet
|
||||||
|
local i = ls.insert_node
|
||||||
|
local f = ls.function_node
|
||||||
|
local fmt = require('luasnip.extras.fmt').fmt
|
||||||
|
|
||||||
|
ls.add_snippets('terraform', {
|
||||||
|
s({ name = 'data_assume', trig = 'tf_assume' },
|
||||||
|
fmt([[
|
||||||
|
data "aws_iam_policy_document" "<name>" {
|
||||||
|
statement {
|
||||||
|
actions = ["sts:AssumeRole"]
|
||||||
|
|
||||||
|
principals {
|
||||||
|
type = "Service"
|
||||||
|
identifiers = ["<service>.amazonaws.com"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]],
|
||||||
|
{
|
||||||
|
name = i(1, 'assume'),
|
||||||
|
service = i(2, 'service')
|
||||||
|
},
|
||||||
|
{ delimiters = '<>' }
|
||||||
|
)
|
||||||
|
),
|
||||||
|
})
|
||||||
|
|
||||||
64
lua/crentist/snippets/yaml.lua
Normal file
64
lua/crentist/snippets/yaml.lua
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
local ls = require('luasnip')
|
||||||
|
local s = ls.snippet
|
||||||
|
local i = ls.insert_node
|
||||||
|
local f = ls.function_node
|
||||||
|
local fmt = require('luasnip.extras.fmt').fmt
|
||||||
|
|
||||||
|
------------------------------
|
||||||
|
-- YAML
|
||||||
|
------------------------------
|
||||||
|
local yaml_schema_snippet = s(
|
||||||
|
{ name = 'yaml_schema', trig = 'yaml_schema' },
|
||||||
|
fmt([[
|
||||||
|
{comment} yaml-language-server: $schema={path}
|
||||||
|
]],
|
||||||
|
{
|
||||||
|
path = i(1, 'path'),
|
||||||
|
comment = f(com_string, {}, { user_args = { false } }),
|
||||||
|
}
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
ls.add_snippets('yaml', { yaml_schema_snippet })
|
||||||
|
ls.add_snippets('helm', { yaml_schema_snippet })
|
||||||
|
|
||||||
|
local flux_cd_kustomization = s(
|
||||||
|
{ name = 'fluxcd_kustomization', trig = 'fluxkust' },
|
||||||
|
fmt([[
|
||||||
|
apiVersion: kustomize.toolkit.fluxcd.io/v1
|
||||||
|
kind: Kustomization
|
||||||
|
metadata:
|
||||||
|
name: {name}
|
||||||
|
namespace: {namespace}
|
||||||
|
spec:
|
||||||
|
interval: {interval}
|
||||||
|
path: {path}
|
||||||
|
prune: true
|
||||||
|
sourceRef:
|
||||||
|
kind: GitRepository
|
||||||
|
name: {repository_name}
|
||||||
|
]],
|
||||||
|
{
|
||||||
|
name = i(1, 'name'),
|
||||||
|
namespace = i(2, 'flux-system'),
|
||||||
|
interval = i(3, '5m'),
|
||||||
|
path = i(4, 'path'),
|
||||||
|
repository_name = i(5, 'repository_name'),
|
||||||
|
}
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
ls.add_snippets('yaml', { flux_cd_kustomization })
|
||||||
|
|
||||||
|
local sleep_command = s(
|
||||||
|
{ name = 'sleep_command', trig = 'sleep' },
|
||||||
|
fmt([[
|
||||||
|
command:
|
||||||
|
- /bin/sh
|
||||||
|
- -c
|
||||||
|
- while true; do sleep 3600; done
|
||||||
|
]], {})
|
||||||
|
)
|
||||||
|
|
||||||
|
ls.add_snippets('yaml', { sleep_command })
|
||||||
|
|
||||||
@@ -27,7 +27,17 @@ local advanced_grep = function(opts)
|
|||||||
|
|
||||||
if pieces[2] then
|
if pieces[2] then
|
||||||
table.insert(args, "-g")
|
table.insert(args, "-g")
|
||||||
table.insert(args, pieces[2])
|
|
||||||
|
local input_glob = pieces[2]
|
||||||
|
local glob = input_glob
|
||||||
|
if not input_glob:find("*", 1, true) then
|
||||||
|
glob = "*" .. input_glob .. "*"
|
||||||
|
if input_glob:find("d:", 1, true) then
|
||||||
|
glob = "**/" .. glob .. "/**"
|
||||||
|
glob = glob:gsub("d:", "")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
table.insert(args, glob)
|
||||||
end
|
end
|
||||||
|
|
||||||
return vim.iter({ args, { "--color=never", "--no-heading", "--with-filename", "--line-number", "--column", "--smart-case" } })
|
return vim.iter({ args, { "--color=never", "--no-heading", "--with-filename", "--line-number", "--column", "--smart-case" } })
|
||||||
|
|||||||
Reference in New Issue
Block a user