initial commit 2

This commit is contained in:
Tigor Hutasuhut 2024-06-17 15:22:39 +07:00
parent 8566de3260
commit 5c1199caf9
59 changed files with 1976 additions and 0 deletions

12
.gitignore vendored Normal file
View file

@ -0,0 +1,12 @@
tt.*
.tests
doc/tags
debug
.repro
foo.*
*.log
data
lazy-lock.json
lazyvim.json
.luarc.json

15
.neoconf.json Normal file
View file

@ -0,0 +1,15 @@
{
"neodev": {
"library": {
"enabled": true,
"plugins": true
}
},
"neoconf": {
"plugins": {
"lua_ls": {
"enabled": true
}
}
}
}

2
init.lua Normal file
View file

@ -0,0 +1,2 @@
-- bootstrap lazy.nvim, LazyVim and your plugins
require "config.lazy"

40
lua/config/autocmds.lua Normal file
View file

@ -0,0 +1,40 @@
-- Autocmds are automatically loaded on the VeryLazy event
-- Default autocmds that are always set: https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/config/autocmds.lua
-- Add any additional autocmds here
local opt = vim.opt
opt.shiftwidth = 4
opt.tabstop = 4
-- vim.api.nvim_create_autocmd("BufReadPost", {
-- group = vim.api.nvim_create_augroup("LazyVim_AutoUpdate", {}),
-- once = true,
-- callback = function()
-- require("lazy").update {
-- show = false,
-- wait = false,
-- concurrency = 4,
-- }
-- end,
-- })
-- Golang templ filetype
vim.filetype.add {
extension = {
templ = "templ",
},
}
require("lspconfig").nil_ls.setup {
settings = {
["nil"] = {
nix = {
flake = {
autoArchive = true,
autoEvalInputs = vim.fn.getenv "NIL_LS_NIX_AUTO_EVAL_INPUTS" ~= vim.NIL,
},
},
},
},
}

11
lua/config/keymaps.lua Normal file
View file

@ -0,0 +1,11 @@
-- Keymaps are automatically loaded on the VeryLazy event
-- Default keymaps that are always set: https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/config/keymaps.lua
-- Add any additional keymaps here
require "config.neovide"
vim.keymap.set("t", "<c-d>", "<C-\\><C-n>", { silent = true, desc = "Exit Terminal Mode" })
-- LazyVim hardcode tabs to jump snippet completions. Very fucking annoying.
vim.keymap.del({ "i" }, "<tab>")
vim.keymap.del({ "i" }, "<s-tab>")

65
lua/config/lazy.lua Normal file
View file

@ -0,0 +1,65 @@
local lazypath = vim.fn.stdpath "data" .. "/lazy/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
-- bootstrap lazy.nvim
-- stylua: ignore
vim.fn.system({ "git", "clone", "--filter=blob:none", "https://github.com/folke/lazy.nvim.git", "--branch=stable", lazypath })
end
vim.opt.rtp:prepend(vim.env.LAZY or lazypath)
require("lazy").setup {
spec = {
-- add LazyVim and import its plugins
{ "LazyVim/LazyVim", import = "lazyvim.plugins" },
-- import any extras modules here
{ import = "lazyvim.plugins.extras.lang.typescript" },
{ import = "lazyvim.plugins.extras.lang.json" },
{ import = "lazyvim.plugins.extras.coding.copilot" },
{ import = "lazyvim.plugins.extras.coding.yanky" },
{ import = "lazyvim.plugins.extras.coding.luasnip" },
{ import = "lazyvim.plugins.extras.formatting.prettier" },
{ import = "lazyvim.plugins.extras.dap.core" },
{ import = "lazyvim.plugins.extras.dap.nlua" },
{ import = "lazyvim.plugins.extras.test.core" },
{ import = "lazyvim.plugins.extras.lang.docker" },
{ import = "lazyvim.plugins.extras.lang.go" },
{ import = "lazyvim.plugins.extras.lang.json" },
-- { import = "lazyvim.plugins.extras.lang.markdown" },
{ import = "lazyvim.plugins.extras.lang.tailwind" },
{ import = "lazyvim.plugins.extras.lang.typescript" },
{ import = "lazyvim.plugins.extras.lang.yaml" },
{ import = "lazyvim.plugins.extras.lsp.none-ls" },
{ import = "lazyvim.plugins.extras.lang.java" },
{ import = "lazyvim.plugins.extras.util.project" },
{ import = "lazyvim.plugins.extras.editor.mini-files" },
-- { import = "lazyvim.plugins.extras.ui.edgy" },
-- import/override with your plugins
{ import = "plugins" },
},
defaults = {
-- By default, only LazyVim plugins will be lazy-loaded. Your custom plugins will load during startup.
-- If you know what you're doing, you can set this to `true` to have all your custom plugins lazy-loaded by default.
lazy = false,
-- It's recommended to leave version=false for now, since a lot the plugin that support versioning,
-- have outdated releases, which may break your Neovim install.
version = false, -- always use the latest git commit
-- version = "*", -- try installing the latest stable version for plugins that support semver
},
install = { colorscheme = { "tokyonight", "habamax" } },
checker = { enabled = false }, -- automatically check for plugin updates
performance = {
rtp = {
-- disable some rtp plugins
disabled_plugins = {
"gzip",
-- "matchit",
-- "matchparen",
-- "netrwPlugin",
"tarPlugin",
"tohtml",
"tutor",
"zipPlugin",
},
},
},
}

21
lua/config/neovide.lua Normal file
View file

@ -0,0 +1,21 @@
if not vim.g.neovide then
return
end
local font = "JetBrainsMono Nerd Font Mono"
local font_size = vim.o.lines < 60 and 11 or 12
vim.o.guifont = font .. ":h" .. font_size
vim.keymap.set("n", "<c-->", function()
font_size = font_size - 1
vim.o.guifont = font .. ":h" .. font_size
vim.notify("Font Set: " .. font .. ":h" .. font_size)
end, { desc = "Decrease font size" })
vim.keymap.set("n", "<c-=>", function()
font_size = font_size + 1
vim.o.guifont = font .. ":h" .. font_size
vim.notify("Font Set: " .. font .. ":h" .. font_size)
end, { desc = "Increase font size" })

10
lua/config/options.lua Normal file
View file

@ -0,0 +1,10 @@
-- Options are automatically loaded before lazy.nvim startup
-- Default options that are always set: https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/config/options.lua
-- Add any additional options here
-- Disable swap files
vim.opt.swapfile = false
vim.defer_fn(function()
vim.opt.title = true
end, 100)

10
lua/plugins/arrow.lua Normal file
View file

@ -0,0 +1,10 @@
return {
"otavioschwanck/arrow.nvim",
opts = {
show_icons = true,
leader_key = [[\]], -- Recommended to be a single key
},
keys = {
{ "<cr>", desc = "Open Arrow bookmarks" },
},
}

70
lua/plugins/base16.lua Normal file
View file

@ -0,0 +1,70 @@
return {
{
"rktjmp/fwatch.nvim",
dependencies = {
"xiyaowong/transparent.nvim", -- For Transparency support
{ "echasnovski/mini.nvim", version = false },
},
lazy = false,
config = function()
local fwatch = require "fwatch"
local color_file = vim.fn.getenv "HOME" .. "/.cache/wallust/base16-nvim.lua"
local error_fn = function(err)
vim.notify("Watch Error: " .. err, vim.log.levels.ERROR, { title = "fwatch.nvim" })
end
local command = {}
local source_fn = function(_, _, unwatch)
vim.schedule(function()
if vim.fn.filereadable(color_file) == 1 then
vim.cmd(("source %s"):format(color_file))
if not vim.g.neovide then
require("transparent").setup {
groups = {
"Normal",
"NormalNC",
"Comment",
"Constant",
"Special",
"Identifier",
"Statement",
"PreProc",
"Type",
"Underlined",
"Todo",
"String",
"Function",
"Conditional",
"Repeat",
"Operator",
"Structure",
"LineNr",
"NonText",
"SignColumn",
-- "CursorLine",
-- "CursorLineNr",
"StatusLine",
"StatusLineNC",
"EndOfBuffer",
},
}
end
if unwatch then
unwatch()
end
fwatch.watch(color_file, command)
end
end)
end
command.on_event = source_fn
command.on_error = error_fn
source_fn()
fwatch.watch(color_file, command)
end,
},
{
"brenoprata10/nvim-highlight-colors",
opts = {},
event = "VeryLazy",
},
}

9
lua/plugins/before.lua Normal file
View file

@ -0,0 +1,9 @@
return {
"bloznelis/before.nvim",
opts = {},
event = { "InsertEnter" },
keys = {
{ "<C-h>", "<cmd>lua require'before'.jump_to_last_edit()<CR>", desc = "Jump to last edit" },
{ "<C-l>", "<cmd>lua require'before'.jump_to_next_edit()<CR>", desc = "Jump to next edit" },
},
}

View file

@ -0,0 +1,4 @@
return {
"isobit/vim-caddyfile",
event = { "BufReadPre", "BufNewFile" },
}

View file

@ -0,0 +1,18 @@
return {
{
"catppuccin/nvim",
name = "catppuccin",
opts = {
styles = {
functions = { "italic" },
keywords = { "italic" },
},
},
},
-- {
-- "LazyVim/LazyVim",
-- opts = {
-- colorscheme = "catppuccin",
-- },
-- },
}

62
lua/plugins/cmp.lua Normal file
View file

@ -0,0 +1,62 @@
return {
"hrsh7th/nvim-cmp",
dependencies = {
"hrsh7th/cmp-cmdline",
"hrsh7th/cmp-nvim-lsp-document-symbol",
-- "hrsh7th/cmp-nvim-lsp-signature-help",
{ "lukas-reineke/cmp-rg", enabled = vim.fn.exepath "rg" ~= "" },
},
event = { "InsertEnter", "CmdlineEnter" },
opts = function(_, opts)
local cmp = require "cmp"
if vim.fn.exepath "rg" ~= "" then
table.insert(opts.sources, 3, { name = "rg" })
end
opts.preselect = cmp.PreselectMode.None
opts.mapping = cmp.mapping.preset.insert {
["<cr>"] = function(fallback)
cmp.abort()
fallback()
end,
["<c-cr>"] = cmp.mapping.confirm { select = true },
["<C-n>"] = cmp.mapping.select_next_item { behavior = cmp.SelectBehavior.Insert },
["<C-p>"] = cmp.mapping.select_prev_item { behavior = cmp.SelectBehavior.Insert },
["<C-b>"] = cmp.mapping.scroll_docs(-4),
["<C-f>"] = cmp.mapping.scroll_docs(4),
["<C-Space>"] = cmp.mapping.complete(),
["<C-e>"] = cmp.mapping.abort(),
["<S-CR>"] = cmp.mapping.confirm {
behavior = cmp.ConfirmBehavior.Replace,
select = true,
}, -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
}
---@diagnostic disable-next-line: missing-fields
cmp.setup.cmdline(":", {
mapping = cmp.mapping.preset.cmdline(),
sources = cmp.config.sources {
{ name = "path" },
{
name = "cmdline",
option = {
ignore_cmds = { "Man", "!" },
},
},
},
})
---@diagnostic disable-next-line: missing-fields
cmp.setup.cmdline("/", {
mapping = cmp.mapping.preset.cmdline(),
sources = cmp.config.sources {
{ name = "nvim_lsp_document_symbol" },
{ name = "buffer" },
},
})
return opts
end,
}

9
lua/plugins/conform.lua Normal file
View file

@ -0,0 +1,9 @@
return {
"conform.nvim",
opts = {
formatters_by_ft = {
nix = { "nixpkgs_fmt" },
templ = { "templ" },
},
},
}

28
lua/plugins/copilot.lua Normal file
View file

@ -0,0 +1,28 @@
return {
{
"zbirenbaum/copilot.lua",
event = { "InsertEnter" },
opts = {
panel = { enabled = false },
suggestion = {
enabled = true,
auto_trigger = true,
keymap = {
accept = "<M-l>",
accept_word = false,
accept_line = false,
next = "<M-j>",
prev = "<M-k>",
dismiss = "<M-h>",
},
},
filetypes = {
["*"] = true,
},
},
},
{
"zbirenbaum/copilot-cmp",
enabled = false,
},
}

21
lua/plugins/corn.lua Normal file
View file

@ -0,0 +1,21 @@
return {
"RaafatTurki/corn.nvim",
event = { "LspAttach" },
opts = {
border_style = "rounded",
icons = {
error = "",
warn = "",
hint = "",
info = "",
},
item_preprocess_func = function(item)
return item
end,
},
config = function(_, opts)
vim.diagnostic.config { virtual_text = false }
require("corn").setup(opts)
end,
enabled = false,
}

18
lua/plugins/diagflow.lua Normal file
View file

@ -0,0 +1,18 @@
return {
"dgagn/diagflow.nvim",
event = { "LspAttach" },
opts = {
scope = "line",
show_sign = false,
show_borders = true,
text_align = "right",
max_width = 60,
format = function(diagnostic)
if diagnostic.source and #diagnostic.source > 0 then
return string.format("[%s] %s: %s", diagnostic.source, diagnostic.code, diagnostic.message)
end
return diagnostic.message
end,
},
-- enabled = false,
}

View file

@ -0,0 +1,5 @@
return {
"andweeb/presence.nvim",
event = "BufReadPost",
config = true,
}

6
lua/plugins/gitsigns.lua Normal file
View file

@ -0,0 +1,6 @@
return {
"lewis6991/gitsigns.nvim",
opts = {
current_line_blame = true,
},
}

28
lua/plugins/incline.lua Normal file
View file

@ -0,0 +1,28 @@
return {
-- Show filenames in the right top most of buffer
"b0o/incline.nvim",
config = function()
local helpers = require "incline.helpers"
local devicons = require "nvim-web-devicons"
require("incline").setup {
window = {
padding = 0,
margin = { horizontal = 0 },
},
render = function(props)
local filename = vim.fn.fnamemodify(vim.api.nvim_buf_get_name(props.buf), ":t")
local ft_icon, ft_color = devicons.get_icon_color(filename)
local modified = vim.bo[props.buf].modified
return {
ft_icon and { " ", ft_icon, " ", guibg = ft_color, guifg = helpers.contrast_color(ft_color) } or "",
" ",
{ filename, gui = modified and "bold,italic" or "bold" },
" ",
guibg = "#44406e",
}
end,
}
end,
-- Optional: Lazy load Incline
event = "VeryLazy",
}

40
lua/plugins/java.lua Normal file
View file

@ -0,0 +1,40 @@
return {
{
"conform.nvim",
opts = function(_, opts)
opts.formatters_by_ft = opts.formatters_by_ft or {}
opts.formatters_by_ft.xml = { "xmlformat" }
require("conform").formatters.xmlformat = {
prepend_args = { "--indent", "1", "--indent-char", "\t" },
}
end,
},
{
"williamboman/mason.nvim",
opts = function(_, opts)
opts.ensure_installed = opts.ensure_installed or {}
vim.list_extend(opts.ensure_installed, { "xmlformatter" })
end,
},
{
-- Add lombok support
"mfussenegger/nvim-jdtls",
opts = function(_, opts)
local lombok_jar_path = (vim.fn.expand "$MASON") .. "/packages/jdtls/lombok.jar"
opts.cmd = {
vim.fn.exepath "jdtls",
([[--jvm-arg=-javaagent:%s]]):format(lombok_jar_path),
}
end,
},
{ "rcasia/neotest-java", lazy = true },
{
"nvim-neotest/neotest",
opts = function(_, opts)
opts = opts or {}
opts.adapters = opts.adapters or {}
vim.list_extend(opts.adapters, { "neotest-java" })
end,
},
}

108
lua/plugins/lang-go.lua Normal file
View file

@ -0,0 +1,108 @@
return {
{
"neovim/nvim-lspconfig",
opts = {
servers = {
gopls = {
settings = {
gopls = {
analyses = {
fieldalignment = false,
},
usePlaceholders = false,
hints = {
assignVariableTypes = false,
compositeLiteralFields = false,
compositeLiteralTypes = false,
constantValues = false,
functionTypeParameters = false,
parameterNames = false,
rangeVariableTypes = false,
},
},
},
},
},
setup = {
gopls = function(_, opts)
require("lazyvim.util").lsp.on_attach(function(client, bufnr)
if client.name == "gopls" then
-- workaround for gopls not supporting semanticTokensProvider
-- https://github.com/golang/go/issues/54531#issuecomment-1464982242
if not client.server_capabilities.semanticTokensProvider then
local semantic = client.config.capabilities.textDocument.semanticTokens
client.server_capabilities.semanticTokensProvider = {
full = true,
legend = {
tokenTypes = semantic.tokenTypes,
tokenModifiers = semantic.tokenModifiers,
},
range = true,
}
end
-- end workaround
-- run lsp imports code action on save.
vim.api.nvim_create_autocmd("BufWritePre", {
desc = "Auto format and organize imports on save (gopls)",
group = vim.api.nvim_create_augroup("GoplsAutoFormat", {}),
buffer = bufnr,
callback = function(event)
local context = { source = { organizeImports = true } }
local params = vim.lsp.util.make_range_params()
params.context = context
local result =
vim.lsp.buf_request_sync(event.buf, "textDocument/codeAction", params, 3000)
if not result then
return
end
if not result[1] then
return
end
result = result[1].result
if not result then
return
end
if not result[1] then
return
end
local edit = result[1].edit
if not edit then
return
end
vim.lsp.util.apply_workspace_edit(edit, "utf-8")
end,
})
end
end)
end,
},
},
},
{
"olexsmir/gopher.nvim",
ft = "go",
},
{
"edolphin-ydf/goimpl.nvim",
ft = "go",
config = function()
require("telescope").load_extension "goimpl"
vim.api.nvim_create_autocmd("LspAttach", {
group = vim.api.nvim_create_augroup("GoImpl", {}),
callback = function(ctx)
local client = vim.lsp.get_client_by_id(ctx.data.client_id) or {}
if client.name == "gopls" then
vim.api.nvim_create_user_command("Impl", [[Telescope goimpl]], {})
vim.keymap.set(
"n",
"<leader>ci",
[[<cmd>Telescope goimpl<cr>]],
{ buffer = ctx.buf, desc = "Generate implementation stub" }
)
end
end,
})
end,
},
}

11
lua/plugins/lazygit.lua Normal file
View file

@ -0,0 +1,11 @@
return {
"kdheepak/lazygit.nvim",
-- optional for floating window border decoration
dependencies = {
"nvim-lua/plenary.nvim",
},
enabled = vim.fn.exepath("lazygit") ~= "",
keys = {
{ "<leader>z", "<cmd>LazyGit<cr>", desc = "Symbols Outline" },
},
}

9
lua/plugins/lsp-html.lua Normal file
View file

@ -0,0 +1,9 @@
return {
{
"williamboman/mason.nvim",
opts = function(_, opts)
opts.ensure_installed = opts.ensure_installed or {}
vim.list_extend(opts.ensure_installed, { "html-lsp" })
end,
},
}

8
lua/plugins/lsp-lazy.lua Normal file
View file

@ -0,0 +1,8 @@
return {
"dundalek/lazy-lsp.nvim",
dependencies = { "neovim/nvim-lspconfig" },
opts = {
excluded_servers = { "jdtls", "gopls", "tsserver" },
},
enabled = false,
}

61
lua/plugins/lspconfig.lua Normal file
View file

@ -0,0 +1,61 @@
return {
"nvim-lspconfig",
init = function()
local keys = require("lazyvim.plugins.lsp.keymaps").get()
keys[#keys + 1] = {
"gD",
"<cmd>lua require('telescope.builtin').lsp_definitions({ jump_type = 'vsplit' })<cr>",
desc = "Jump to definitions in vsplit",
}
keys[#keys + 1] = {
"grr",
"<cmd>Trouble lsp_references focus=true<cr>",
desc = "Jump to references",
}
keys[#keys + 1] = {
"gri",
"<cmd>Trouble lsp_implementations focus=true<cr>",
desc = "Jump to references",
}
keys[#keys + 1] = {
"grt",
"<cmd>Trouble lsp_type_definitions focus=true<cr>",
desc = "Jump to references",
}
keys[#keys + 1] = {
"grs",
"<cmd>Trouble lsp_document_symbols focus=true<cr>",
desc = "Jump to references",
}
keys[#keys + 1] = {
"<F2>",
vim.lsp.buf.rename,
desc = "Rename Symbol",
}
keys[#keys + 1] = {
"<c-k>",
false,
mode = { "i" },
}
keys[#keys + 1] = {
"gr",
false,
}
end,
opts = {
servers = {
templ = {
on_attach = function(client, _)
client.server_capabilities.documentFormattingProvider = false
client.server_capabilities.documentRangeFormattingProvider = false
end,
},
html = {
on_attach = function(client, _)
client.server_capabilities.documentFormattingProvider = false
client.server_capabilities.documentRangeFormattingProvider = false
end,
},
},
},
}

7
lua/plugins/luasnip.lua Normal file
View file

@ -0,0 +1,7 @@
return {
"L3MON4D3/LuaSnip",
opts = function(_, opts)
require "snippets"
return opts
end,
}

14
lua/plugins/makefile.lua Normal file
View file

@ -0,0 +1,14 @@
return {
"sopa0/telescope-makefile",
dependencies = {
"akinsho/toggleterm.nvim",
},
cmd = { "Make" },
keys = {
{ "<leader>m", "<cmd>Telescope make<cr>", { desc = "Launch Make Items" } },
},
config = function()
require("telescope").load_extension "make"
vim.api.nvim_create_user_command("Make", [[Telescope make]], {})
end,
}

8
lua/plugins/markdown.lua Normal file
View file

@ -0,0 +1,8 @@
return {
"MeanderingProgrammer/markdown.nvim",
name = "render-markdown", -- Only needed if you have another plugin named markdown.nvim
dependencies = { "nvim-treesitter/nvim-treesitter" },
config = function()
require("render-markdown").setup {}
end,
}

7
lua/plugins/mason.lua Normal file
View file

@ -0,0 +1,7 @@
return {
"mason.nvim",
opts = {
-- NixOS packages should override Mason packages if exist
PATH = vim.loop.os_uname().version:find("NixOS") and "append" or "prepend",
},
}

View file

@ -0,0 +1,55 @@
return {
"echasnovski/mini.nvim",
version = false,
opts = {
windows = {
preview = true,
width_preview = 50,
},
},
config = function(_, opts)
require("mini.files").setup(opts)
local map_split = function(buf_id, lhs, direction)
local mf = require "mini.files"
local rhs = function()
-- Make new window and set it as target
local new_target_window
vim.api.nvim_win_call(mf.get_target_window(), function()
vim.cmd(direction .. " split")
new_target_window = vim.api.nvim_get_current_win()
end)
mf.set_target_window(new_target_window)
end
-- Adding `desc` will result into `show_help` entries
local desc = "Split " .. direction
vim.keymap.set("n", lhs, rhs, { buffer = buf_id, desc = desc })
end
vim.api.nvim_create_autocmd("User", {
pattern = "MiniFilesBufferCreate",
callback = function(args)
local mf = require "mini.files"
local buf_id = args.data.buf_id
-- Tweak keys to your liking
map_split(buf_id, "gs", "belowright horizontal")
map_split(buf_id, "gv", "belowright vertical")
vim.keymap.set("n", "<cr>", function()
mf.go_in { close_on_file = true }
end, { buffer = buf_id, desc = "Open file or directory" })
end,
})
end,
keys = {
{
"-",
function()
local mf = require "mini.files"
if not mf.close() then
mf.open(vim.api.nvim_buf_get_name(0), false)
end
end,
desc = "Open/Close mini files from current file directory",
},
},
}

12
lua/plugins/neotree.lua Normal file
View file

@ -0,0 +1,12 @@
return {
"nvim-neo-tree/neo-tree.nvim",
opts = {
filesystem = {
filtered_items = {
visible = true,
},
group_empty_dirs = true,
},
},
enabled = true,
}

9
lua/plugins/nix.lua Normal file
View file

@ -0,0 +1,9 @@
return {
{
"williamboman/mason.nvim",
opts = function(_, opts)
opts.ensure_installed = opts.ensure_installed or {}
vim.list_extend(opts.ensure_installed, { "nixpkgs-fmt", "nil" })
end,
},
}

9
lua/plugins/notifier.lua Normal file
View file

@ -0,0 +1,9 @@
return {
{ "rcarriga/nvim-notify", enabled = false },
{
"folke/noice.nvim",
dependencies = {
"vigoux/notifier.nvim",
},
},
}

53
lua/plugins/obsidian.lua Normal file
View file

@ -0,0 +1,53 @@
local function workspace(name)
return {
name = name,
path = ("%s/Obsidian/%s"):format(vim.env.HOME, name),
}
end
local function event(name)
return ("%s %s/Obsidian/**.md"):format(name, vim.env.HOME)
end
return {
"epwalsh/obsidian.nvim",
cmd = {
"ObsidianOpen",
"ObsidianNew",
"ObsidianToday",
"ObsidianYesterday",
"ObsidianWorkspace",
"ObsidianSearch",
"ObsidianQuickSwitch",
},
dependencies = {
-- Required.
"nvim-lua/plenary.nvim",
-- see below for full list of optional dependencies 👇
},
event = {
event "BufReadPre",
event "BufNewFile",
},
opts = {
workspaces = {
workspace "personal",
workspace "work",
workspace "stories",
workspace "tigor",
},
mappings = {},
},
config = function(_, opts)
require("obsidian").setup(opts)
vim.keymap.set("n", "gf", function()
if require("obsidian").util.cursor_on_markdown_link() then
return "<cmd>ObsidianFollowLink<CR>"
else
return "gf"
end
end, { noremap = false, expr = true, desc = "Obsidian Follow Link or Fallback" })
end,
}

15
lua/plugins/oil.lua Normal file
View file

@ -0,0 +1,15 @@
return {
"stevearc/oil.nvim",
opts = {
keymaps = {
["q"] = "actions.close",
["<bs>"] = "actions.parent",
},
},
dependencies = { "nvim-tree/nvim-web-devicons" },
cmd = { "Oil" },
keys = {
{ "-", "<cmd>Oil<cr>", desc = "Open Oil" },
},
enabled = false,
}

View file

@ -0,0 +1,27 @@
return {
"tris203/precognition.nvim",
event = "VeryLazy",
opts = {
-- startVisible = true,
-- showBlankVirtLine = true,
-- highlightColor = { link = "Comment" },
-- hints = {
-- Caret = { text = "^", prio = 2 },
-- Dollar = { text = "$", prio = 1 },
-- MatchingPair = { text = "%", prio = 5 },
-- Zero = { text = "0", prio = 1 },
-- w = { text = "w", prio = 10 },
-- b = { text = "b", prio = 9 },
-- e = { text = "e", prio = 8 },
-- W = { text = "W", prio = 7 },
-- B = { text = "B", prio = 6 },
-- E = { text = "E", prio = 5 },
-- },
-- gutterHints = {
-- G = { text = "G", prio = 10 },
-- gg = { text = "gg", prio = 9 },
-- PrevParagraph = { text = "{", prio = 8 },
-- NextParagraph = { text = "}", prio = 8 },
-- },
},
}

19
lua/plugins/protobuf.lua Normal file
View file

@ -0,0 +1,19 @@
return {
{
"williamboman/mason.nvim",
opts = function(_, opts)
opts.ensure_installed = opts.ensure_installed or {}
vim.list_extend(opts.ensure_installed, { "buf", "buf-language-server" })
end,
},
{
"nvimtools/none-ls.nvim",
opts = function(_, opts)
local nls = require("null-ls")
opts.sources = vim.list_extend(opts.sources or {}, {
nls.builtins.diagnostics.buf,
nls.builtins.formatting.buf,
})
end,
},
}

17
lua/plugins/rest.lua Normal file
View file

@ -0,0 +1,17 @@
return {
{
"nicwest/vim-http",
ft = "http",
init = function()
vim.g.vim_http_tempbuffer = 1
vim.g.vim_http_clean_before_do = 0
end,
},
{
"nvim-treesitter/nvim-treesitter",
opts = function(_, opts)
opts.ensure_installed = opts.ensure_installed or {}
vim.list_extend(opts.ensure_installed, { "http", "json" })
end,
},
}

View file

@ -0,0 +1,9 @@
return {
{ "rose-pine/neovim", name = "rose-pine" },
-- {
-- "LazyVim/LazyVim",
-- opts = {
-- colorscheme = "rose-pine",
-- },
-- },
}

56
lua/plugins/silicon.lua Normal file
View file

@ -0,0 +1,56 @@
return {
"tigorlazuardi/silicon.lua",
cmd = { "Silicon" },
config = function()
require("silicon").setup {
output = function()
return ([[%s/Pictures/SILICON_%s.png]]):format(vim.env.HOME, os.date "%Y-%m-%d_%H-%M-%S")
end,
padHoriz = 40,
padVert = 50,
}
vim.api.nvim_create_user_command("Silicon", function(ctx)
local args = (ctx.fargs or {})[1]
local opts = {}
if args == "buffer" then
opts.show_buf = true
end
if args == "visible" then
opts.visible = true
end
if not ctx.bang then
opts.to_clip = true
end
require("silicon").visualise_cmdline(opts)
end, {
range = 2,
desc = "Create screenshot from given range. Add Bang (!) at the end of the command to save to file instead of clipboard",
bang = true,
nargs = "?",
complete = function(arg)
if not arg then
return { "buffer", "visible" }
end
if arg:gsub(" ", "") == "" then
return { "buffer", "visible" }
end
if string.find("buffer", arg) then
return { "buffer" }
end
if string.find("visible", arg) then
return { "visible" }
end
return {}
end,
})
vim.api.nvim_create_autocmd({ "ColorScheme" }, {
group = vim.api.nvim_create_augroup("SiliconRefresh", {}),
callback = function()
local silicon_utils = require "silicon.utils"
silicon_utils.build_tmTheme()
silicon_utils.reload_silicon_cache { async = true }
end,
desc = "Reload silicon themes cache on colorscheme switch",
})
end,
}

13
lua/plugins/ssh.lua Normal file
View file

@ -0,0 +1,13 @@
return {
"ojroques/nvim-osc52",
cond = vim.env.SSH_CLIENT ~= nil,
config = function()
require("osc52").setup({})
vim.api.nvim_create_autocmd("TextYankPost", {
callback = function()
require("osc52").copy(table.concat(vim.v.event.regcontents, "\n"))
end,
desc = "Copy to Clipboard from SSH Session",
})
end,
}

15
lua/plugins/tailwind.lua Normal file
View file

@ -0,0 +1,15 @@
return {
"neovim/nvim-lspconfig",
opts = {
servers = {
tailwindcss = {
-- exclude a filetype from the default_config
filetypes_exclude = { "markdown", "javascript", "typescript" },
-- add additional filetypes to the default_config
filetypes_include = {},
-- to fully override the default_config, change the below
-- filetypes = {}
},
},
},
}

View file

@ -0,0 +1,10 @@
return {
"telescope.nvim",
dependencies = {
"nvim-telescope/telescope-fzf-native.nvim",
build = "make",
config = function()
require("telescope").load_extension("fzf")
end,
},
}

View file

@ -0,0 +1,21 @@
return {
"akinsho/toggleterm.nvim",
keys = {
{ "<F5>", "Open Toggleterm" },
},
cmd = { "ToggleTerm" },
version = "*",
opts = {
size = function(term)
if term.direction == "horizontal" then
if vim.o.lines < 60 then
return 12
end
return 20
elseif term.direction == "vertical" then
return vim.o.columns * 0.3
end
end,
open_mapping = [[<F5>]],
},
}

View file

@ -0,0 +1,38 @@
return {
{
"nvim-treesitter/nvim-treesitter",
dependencies = {
"RRethy/nvim-treesitter-endwise",
},
opts = {
endwise = {
enable = true,
},
},
},
{
"windwp/nvim-ts-autotag",
opts = {
filetypes = {
"astro",
"glimmer",
"handlebars",
"hbs",
"html",
"javascript",
"javascriptreact",
"jsx",
"markdown",
"php",
"rescript",
"svelte",
"templ",
"tsx",
"typescript",
"typescriptreact",
"vue",
"xml",
},
},
},
}

10
lua/plugins/vim-test.lua Normal file
View file

@ -0,0 +1,10 @@
return {
"vim-test/vim-test",
keys = {
{ "<leader>Tr", "<cmd>TestNearest<cr>", desc = "Test Run Nearest" },
{ "<leader>Tt", "<cmd>TestFile<cr>", desc = "Test File" },
{ "<leader>TT", "<cmd>TestSuite<cr>", desc = "Test All Files" },
{ "<leader>Tl", "<cmd>TestLast<cr>", desc = "Test Last" },
{ "<leader>Tg", "<cmd>TestVisit<cr>", desc = "Test Visit" },
},
}

10
lua/plugins/yanky.lua Normal file
View file

@ -0,0 +1,10 @@
return {
"gbprod/yanky.nvim",
dependencies = {
{ "kkharji/sqlite.lua" },
},
opts = {
ring = { storage = "sqlite" },
highlight = { timer = 150 },
},
}

View file

@ -0,0 +1,170 @@
local ls = require "luasnip"
local sn = ls.sn
local s = ls.s
local i = ls.insert_node
local t = ls.text_node
local d = ls.dynamic_node
local f = ls.function_node
local fmta = require("luasnip.extras.fmt").fmta
local c = ls.choice_node
local get_node_text = vim.treesitter.get_node_text
local create_package_query = function()
return vim.treesitter.query.parse(
"go",
[[
((package_identifier) @package)
]]
)
end
local function get_method_receiver_type_text(node)
local query = vim.treesitter.query.parse(
"go",
[[
(method_declaration receiver: (parameter_list
(parameter_declaration type: (_) @method_receiver)))
]]
)
for _, capture in query:iter_captures(node, 0) do
return get_node_text(capture, 0)
end
return "Method Receiver Not Found"
end
local function get_package_node(node)
local root = node:tree():root()
local query = create_package_query()
for _, capture in query:iter_captures(root, 0) do
return capture
end
return nil
end
local function get_method_or_function_declaration_node(node)
local parent = node:parent()
while parent ~= nil do
if parent:type() == "function_declaration" or parent:type() == "method_declaration" then
return parent
end
parent = parent:parent()
end
end
local root_types = {
method_declaration = true,
function_declaration = true,
func_literal = true,
}
local handlers = {
["context.Context"] = function(node)
local var_name_node = node:prev_named_sibling()
local text = get_node_text(var_name_node, 0)
return text
end,
["*http.Request"] = function(node)
local var_name_node = node:prev_named_sibling()
local text = get_node_text(var_name_node, 0)
return text .. ".Context()"
end,
}
local build_context_node = function()
local query = assert(vim.treesitter.query.get("go", "search-context"), "No Query")
local node = vim.treesitter.get_node()
while node ~= nil do
if root_types[node:type()] then
for _, capture in query:iter_captures(node, 0) do
local text = get_node_text(capture, 0)
local handle = handlers[text]
if handle then
return handle(capture)
end
end
end
node = node:parent()
end
return "context.Background()"
end
local function get_method_or_function_name(node)
if node:type() == "method_declaration" then
return get_node_text(node:named_child(1), 0)
end
return get_node_text(node:named_child(0), 0)
end
local build_span_type_node = function(ctx)
local node = vim.treesitter.get_node()
local method_or_function_node = get_method_or_function_declaration_node(node)
if method_or_function_node == nil then
vim.notify "Not inside method or function"
return { t "" }
end
local package_node = get_package_node(node)
if package_node == nil then
vim.notify "No package node found"
return { t "" }
end
local package_text = get_node_text(package_node, 0)
local final_name = ""
if method_or_function_node:type() == "method_declaration" then
local method_node = method_or_function_node
local receiver_type = get_method_receiver_type_text(method_node)
final_name = ([[%s.%s]]):format(package_text, receiver_type)
else
if method_or_function_node:type() == "function_declaration" then
local function_node = method_or_function_node
local fn_name = get_method_or_function_name(function_node)
final_name = ([[%s.%s]]):format(package_text, fn_name)
end
end
ctx.index = ctx.index + 1
return { i(ctx.index, final_name) }
end
local build_span_name_node = function(ctx)
local node = vim.treesitter.get_node()
local method_or_function_node = get_method_or_function_declaration_node(node)
if method_or_function_node == nil then
vim.notify "Not inside method or function"
return { t "" }
end
local fn_name = get_method_or_function_name(method_or_function_node)
ctx.index = ctx.index + 1
return { i(ctx.index, fn_name) }
end
local get_span_name_node = function()
return sn(nil, build_span_name_node { index = 0 })
end
local get_span_type_node = function()
return sn(nil, build_span_type_node { index = 0 })
end
ls.add_snippets("go", {
s(
"apm:span",
fmta(
[[
span, <ctx_var> := apm.StartSpan(<ctx>, "<span_name>", "<span_type>")
defer span.End()
<finish>
]],
{
ctx_var = c(1, {
t "ctx",
t "_",
}),
ctx = f(build_context_node, {}),
span_name = d(2, get_span_name_node),
span_type = d(3, get_span_type_node),
finish = i(0),
}
)
),
})

178
lua/snippets/go/efi.lua Normal file
View file

@ -0,0 +1,178 @@
local ls = require "luasnip"
local sn = ls.sn
local s = ls.s
local i = ls.insert_node
local t = ls.text_node
local d = ls.dynamic_node
local c = ls.choice_node
local fmta = require("luasnip.extras.fmt").fmta
local rep = require("luasnip.extras").rep
local get_node_text = vim.treesitter.get_node_text
local default_values = {
int = "0",
int8 = "0",
int16 = "0",
int32 = "0",
int64 = "0",
uint = "0",
uint8 = "0",
uint16 = "0",
uint32 = "0",
uint64 = "0",
["time.Time"] = "time.Time{}",
["time.Duration"] = "time.Duration(0)",
bool = "false",
string = [[""]],
float32 = "0",
float64 = "0",
error = function(_, info)
if info then
info.index = info.index + 1
return c(info.index, {
t(info.err_name),
t(string.format('errors.Wrap(%s, "%s")', info.err_name, info.func_name)),
})
else
return t "err"
end
end,
-- Types with a "*" mean they are pointers, so return nil
[function(text)
return string.find(text, "*", 1, true) ~= nil
end] = function(_, _)
return t "nil"
end,
[function(text)
return not string.find(text, "*", 1, true) and string.upper(string.sub(text, 1, 1)) == string.sub(text, 1, 1)
end] = function(text, info)
info.index = info.index + 1
return sn(info.index, {
c(1, {
t(text .. "{}"),
i(2, text),
}),
})
end,
}
local transform = function(text, info)
local condition_matches = function(condition, ...)
if type(condition) == "string" then
return condition == text
else
return condition(...)
end
end
for condition, result in pairs(default_values) do
if condition_matches(condition, text, info) then
if type(result) == "string" then
return t(result)
end
return result(text, info)
end
end
info.index = info.index + 1
return sn(info.index, {
c(1, {
t(text .. "{}"),
i(2, text),
}),
})
end
local handlers = {
parameter_list = function(node, info)
local result = {}
local count = node:named_child_count()
for idx = 0, count - 1 do
local matching_node = node:named_child(idx)
local type_node = matching_node:field("type")[1]
table.insert(result, transform(get_node_text(type_node, 0), info))
if idx ~= count - 1 then
table.insert(result, t { ", " })
end
end
return result
end,
type_identifier = function(node, info)
local text = get_node_text(node, 0)
return { transform(text, info) }
end,
}
local function_node_types = {
function_declaration = true,
method_declaration = true,
func_literal = true,
}
local function go_result_type(info)
local node = vim.treesitter.get_node()
while node ~= nil do
if function_node_types[node:type()] then
break
end
node = node:parent()
end
if not node then
vim.notify("Not inside a function", vim.log.levels.ERROR, { title = "Snippet" })
return t ""
end
local query = assert(vim.treesitter.query.get("go", "return-snippet"), "No Query")
for _, capture in query:iter_captures(node, 0) do
if handlers[capture:type()] then
return handlers[capture:type()](capture, info)
end
end
info.index = info.index + 1
return { i(info.index, "nil") }
end
local go_return_values = function(args)
return sn(
nil,
go_result_type {
index = 0,
err_name = args[1][1],
func_name = args[2][1],
}
)
end
ls.add_snippets("go", {
s(
"efi",
fmta(
[[
<val>, <err> := <f>(<args>)
if <err_same> != nil {
return <result>
}
<finish>
]],
{
val = i(1),
err = i(2, "err"),
f = i(3),
args = i(4),
err_same = rep(2),
result = d(5, go_return_values, { 2, 3 }),
finish = i(0),
}
)
),
})

View file

@ -0,0 +1,452 @@
local ls = require "luasnip"
local sn = ls.snippet_node
local isn = ls.indent_snippet_node
local s = ls.s
local i = ls.insert_node
local t = ls.text_node
local d = ls.dynamic_node
local c = ls.choice_node
local f = ls.function_node
local fmta = require("luasnip.extras.fmt").fmta
local rep = require("luasnip.extras").rep
local get_node_text = vim.treesitter.get_node_text
local default_values = {
int = "0",
int8 = "0",
int16 = "0",
int32 = "0",
int64 = "0",
uint = "0",
uint8 = "0",
uint16 = "0",
uint32 = "0",
uint64 = "0",
["time.Time"] = "time.Time{}",
["time.Duration"] = "time.Duration(0)",
bool = "false",
string = [[""]],
float32 = "0",
float64 = "0",
error = "errt",
-- Types with a "*" mean they are pointers, so return nil
[function(text)
return string.find(text, "*", 1, true) ~= nil
end] = function(_, _)
return t "nil"
end,
[function(text)
return not string.find(text, "*", 1, true) and string.upper(string.sub(text, 1, 1)) == string.sub(text, 1, 1)
end] = function(text, info)
info.index = info.index + 1
return sn(info.index, {
c(1, {
t(text .. "{}"),
i(2, text),
}),
})
end,
}
local transform = function(text, info)
local condition_matches = function(condition, ...)
if type(condition) == "string" then
return condition == text
else
return condition(...)
end
end
for condition, result in pairs(default_values) do
if condition_matches(condition, text, info) then
if type(result) == "string" then
return t(result)
end
return result(text, info)
end
end
info.index = info.index + 1
return sn(info.index, {
c(1, {
t(text .. "{}"),
i(2, text),
}),
})
end
local handlers = {
parameter_list = function(node, info)
local result = {}
local count = node:named_child_count()
for idx = 0, count - 1 do
local matching_node = node:named_child(idx)
local type_node = matching_node:field("type")[1]
table.insert(result, transform(get_node_text(type_node, 0), info))
if idx ~= count - 1 then
table.insert(result, t { ", " })
end
end
return result
end,
type_identifier = function(node, info)
local text = get_node_text(node, 0)
return { transform(text, info) }
end,
}
local function_node_types = {
function_declaration = true,
method_declaration = true,
func_literal = true,
}
local function go_result_type(info)
local node = vim.treesitter.get_node()
while node ~= nil do
if function_node_types[node:type()] then
break
end
node = node:parent()
end
if not node then
vim.notify("Not inside a function", vim.log.levels.ERROR, { title = "Snippet" })
return t ""
end
local query = assert(vim.treesitter.query.get("go", "return-snippet"), "No Query")
for _, capture in query:iter_captures(node, 0) do
if handlers[capture:type()] then
return handlers[capture:type()](capture, info)
end
end
return {}
end
local go_return_values = function()
return sn(
nil,
go_result_type {
index = 0,
}
)
end
local function get_method_or_function_declaration_node(node)
local parent = node:parent()
while parent ~= nil do
if parent:type() == "function_declaration" or parent:type() == "method_declaration" then
return parent
end
parent = parent:parent()
end
end
local function get_method_or_function_name(node)
if node:type() == "method_declaration" then
return get_node_text(node:named_child(1), 0)
end
return get_node_text(node:named_child(0), 0)
end
local function get_method_receiver_type_text(node)
local query = vim.treesitter.query.parse(
"go",
[[
(method_declaration receiver: (parameter_list
(parameter_declaration type: (_) @method_receiver)))
]]
)
for _, capture in query:iter_captures(node, 0) do
local text = get_node_text(capture, 0)
if text:sub(1, 1) == "*" then
return "(" .. text .. ")"
end
return text
end
return "Method Receiver Not Found"
end
local function get_package_node(node)
local root = node:tree():root()
local query = assert(vim.treesitter.query.get("go", "package-node"), "No Query")
for _, capture in query:iter_captures(root, 0) do
return capture
end
return nil
end
local function get_package_text(node)
local package_node = get_package_node(node)
if package_node then
return get_node_text(package_node, 0) .. "."
end
vim.notify("Package name not found", vim.log.levels.ERROR, { title = "Snippet" })
return ""
end
local function get_function_name()
local node = vim.treesitter.get_node()
local method_or_function_node = get_method_or_function_declaration_node(node)
if not method_or_function_node then
vim.notify("Not inside a function", vim.log.levels.ERROR, { title = "Snippet" })
return ""
end
local fn_name = get_method_or_function_name(method_or_function_node)
if method_or_function_node:type() == "method_declaration" then
return ([[(%s.%s.%s)]]):format(get_package_text(node), get_method_receiver_type_text(node), fn_name)
end
return ([[(%s.%s)]]):format(get_package_text(node), fn_name)
end
local function get_context_var_name()
local node = vim.treesitter.get_node()
while node ~= nil do
if function_node_types[node:type()] then
local query = assert(vim.treesitter.query.get("go", "get-function-params"), "No Query")
for _, capture in query:iter_captures(node, 0) do
local var_name = capture:named_child(0)
if var_name:type() == "identifier" then
local type_name = capture:named_child(1)
local type_text = get_node_text(type_name, 0)
if type_text == "context.Context" then
return get_node_text(var_name, 0)
end
end
end
end
node = node:parent()
end
return "context.Background()"
end
local create_tower_build_choice = function(index)
return c(index, {
t "Freeze()",
sn(nil, { i(1), t "Log(", f(get_context_var_name), t ")" }),
-- stylua: ignore start
isn(nil, {
i(1), t "Log(", f(get_context_var_name), t ").",
t {"", "Notify("}, f(get_context_var_name), t ")",
}, "$PARENT_INDENT\t\t"),
-- stylua: ignore end
}, {
node_ext_opts = {
active = {
virt_text = { { "<-- Choose build choice" } },
},
},
})
end
local function register_snippet()
ls.add_snippets("go", {
s(
"errt",
fmta(
[[
if <err> != nil {
errt := tower.
Wrap(<err_same>, "<caller> <message>").
<build>
return <result>
}
<finish>
]],
{
err = i(1, "err"),
err_same = rep(1),
caller = f(get_function_name),
message = i(2, "message"),
build = create_tower_build_choice(3),
result = d(4, go_return_values),
finish = i(0),
}
)
),
s(
"errtc",
fmta(
[[
if <err> != nil {
errt := tower.
Wrap(<err_same>, "<caller> <message>").
Context(<fields>).
<build>
return <result>
}
<finish>
]],
{
err = i(1, "err"),
err_same = rep(1),
caller = f(get_function_name),
message = i(2, "message"),
fields = i(3),
build = create_tower_build_choice(4),
result = d(5, go_return_values),
finish = i(0),
}
)
),
s(
"errtp",
fmta(
[[
if <err> != nil {
errt := tower.
Wrap(<err_same>, "<caller> <message>").
PublicMessage("<public_message>").
<build>
return <result>
}
<finish>
]],
{
err = i(1, "err"),
err_same = rep(1),
caller = f(get_function_name),
message = i(2, "message"),
public_message = i(3, "public_message"),
build = create_tower_build_choice(4),
result = d(5, go_return_values),
finish = i(0),
}
)
),
s(
"errtpc",
fmta(
[[
if <err> != nil {
errt := tower.
Wrap(<err_same>, "<caller> <message>").
PublicMessage("<public_message>").
Context(<fields>).
<build>
return <result>
}
<finish>
]],
{
err = i(1, "err"),
err_same = rep(1),
caller = f(get_function_name),
message = i(2, "message"),
public_message = i(3, "public_message"),
fields = i(4),
build = create_tower_build_choice(5),
result = d(6, go_return_values),
finish = i(0),
}
)
),
s(
"errb",
fmta(
[[
if <condition> {
errt := tower.
Bail("<caller> <message>").
<build>
return <result>
}
<finish>
]],
{
condition = i(1),
caller = f(get_function_name),
message = i(2, "message"),
build = create_tower_build_choice(3),
result = d(4, go_return_values),
finish = i(0),
}
)
),
s(
"errbc",
fmta(
[[
if <condition> {
errt := tower.
Bail("<caller> <message>").
Context(<fields>).
<build>
return <result>
}
<finish>
]],
{
condition = i(1),
caller = f(get_function_name),
message = i(2, "message"),
fields = i(3),
build = create_tower_build_choice(4),
result = d(5, go_return_values),
finish = i(0),
}
)
),
s(
"errbp",
fmta(
[[
if <condition> {
errt := tower.
Bail("<caller> <message>").
PublicMessage("<public_message>").
<build>
return <result>
}
<finish>
]],
{
condition = i(1),
caller = f(get_function_name),
message = i(2, "message"),
public_message = i(3, "public_message"),
build = create_tower_build_choice(4),
result = d(5, go_return_values),
finish = i(0),
}
)
),
s(
"errbpc",
fmta(
[[
if <condition> {
errt := tower.
Bail("<caller> <message>").
PublicMessage("<public_message>").
Context(<fields>).
<build>
return <result>
}
<finish>
]],
{
condition = i(1),
caller = f(get_function_name),
message = i(2, "message"),
public_message = i(3, "public_message"),
fields = i(4),
build = create_tower_build_choice(5),
result = d(6, go_return_values),
finish = i(0),
}
)
),
})
end
register_snippet()

9
lua/snippets/go/init.lua Normal file
View file

@ -0,0 +1,9 @@
-- Use to clear snippets when sourced.
--
-- Useful when building a new snippet.
--
-- require("luasnip.session.snippet_collection").clear_snippets("go")
require "snippets.go.efi"
require "snippets.go.apm_span"
require "snippets.go.err_tower"

1
lua/snippets/init.lua Normal file
View file

@ -0,0 +1 @@
require "snippets.go"

View file

@ -0,0 +1,10 @@
[
(method_declaration
parameters: (parameter_list
(parameter_declaration) @params))
(function_declaration
parameters: (parameter_list
(parameter_declaration) @params))
(func_literal parameters:
(parameter_list (parameter_declaration) @params))
]

View file

@ -0,0 +1 @@
(source_file (package_clause (package_identifier) @package_name) )

View file

@ -0,0 +1,5 @@
[
(method_declaration result: (_) @type)
(function_declaration result: (_) @type)
(func_literal result: (_) @type)
]

View file

@ -0,0 +1,11 @@
[
(method_declaration
parameters: (parameter_list
(parameter_declaration type: (_) @type)))
(function_declaration
parameters: (parameter_list
(parameter_declaration type: (_) @type)))
(func_literal
parameters: (parameter_list
(parameter_declaration type: (_) @type)))
]

4
stylua.toml Normal file
View file

@ -0,0 +1,4 @@
indent_type = "Spaces"
indent_width = 4
column_width = 120
call_parentheses = "None"