nvim: config removed from repository and moved to other repo

This commit is contained in:
Tigor Hutasuhut 2024-06-17 17:50:57 +07:00
parent 0738bef0b3
commit c5761763e7
64 changed files with 8 additions and 2186 deletions

View file

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

View file

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

View file

@ -1,201 +0,0 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

View file

@ -1,4 +0,0 @@
# 💤 LazyVim
A starter template for [LazyVim](https://github.com/LazyVim/LazyVim).
Refer to the [documentation](https://lazyvim.github.io/installation) to get started.

View file

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

View file

@ -1,40 +0,0 @@
-- 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,
},
},
},
},
}

View file

@ -1,11 +0,0 @@
-- 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>")

View file

@ -1,65 +0,0 @@
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",
},
},
},
}

View file

@ -1,21 +0,0 @@
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" })

View file

@ -1,10 +0,0 @@
-- 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)

View file

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

View file

@ -1,70 +0,0 @@
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",
},
}

View file

@ -1,9 +0,0 @@
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

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

View file

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

View file

@ -1,62 +0,0 @@
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,
}

View file

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

View file

@ -1,28 +0,0 @@
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,
},
}

View file

@ -1,21 +0,0 @@
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,
}

View file

@ -1,18 +0,0 @@
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

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

View file

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

View file

@ -1,28 +0,0 @@
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",
}

View file

@ -1,40 +0,0 @@
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,
},
}

View file

@ -1,108 +0,0 @@
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,
},
}

View file

@ -1,11 +0,0 @@
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" },
},
}

View file

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

View file

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

View file

@ -1,61 +0,0 @@
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,
},
},
},
}

View file

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

View file

@ -1,14 +0,0 @@
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,
}

View file

@ -1,8 +0,0 @@
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,
}

View file

@ -1,7 +0,0 @@
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

@ -1,55 +0,0 @@
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",
},
},
}

View file

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

View file

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

View file

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

View file

@ -1,53 +0,0 @@
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,
}

View file

@ -1,15 +0,0 @@
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

@ -1,27 +0,0 @@
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 },
-- },
},
}

View file

@ -1,19 +0,0 @@
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,
},
}

View file

@ -1,17 +0,0 @@
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

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

View file

@ -1,56 +0,0 @@
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,
}

View file

@ -1,13 +0,0 @@
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,
}

View file

@ -1,15 +0,0 @@
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

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

View file

@ -1,21 +0,0 @@
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

@ -1,38 +0,0 @@
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",
},
},
},
}

View file

@ -1,10 +0,0 @@
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" },
},
}

View file

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

View file

@ -1,170 +0,0 @@
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),
}
)
),
})

View file

@ -1,178 +0,0 @@
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

@ -1,452 +0,0 @@
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()

View file

@ -1,9 +0,0 @@
-- 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"

View file

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

View file

@ -1,10 +0,0 @@
[
(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

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

View file

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

View file

@ -1,11 +0,0 @@
[
(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)))
]

View file

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

View file

@ -11,7 +11,6 @@ in
./modules ./modules
./config/wezterm ./config/wezterm
./config/nvim
./direnv.nix ./direnv.nix
./config/kitty ./config/kitty
./config/ideavim ./config/ideavim

View file

@ -11,6 +11,7 @@
./microsoft-edge.nix ./microsoft-edge.nix
./mpv.nix ./mpv.nix
./neovide.nix ./neovide.nix
./neovim.nix
./nextcloud.nix ./nextcloud.nix
./nnn.nix ./nnn.nix
./node.nix ./node.nix

View file

@ -1,4 +1,4 @@
{ config, pkgs, lib, unstable, ... }: { config, pkgs, lib, ... }:
let let
cfg = config.profile.neovim; cfg = config.profile.neovim;
inherit (lib) mkIf; inherit (lib) mkIf;
@ -23,14 +23,14 @@ in
host = "github.com"; host = "github.com";
sleep = "${pkgs.coreutils}/bin/sleep"; sleep = "${pkgs.coreutils}/bin/sleep";
script = pkgs.writeScriptBin "clone-nvim.sh" '' script = pkgs.writeScriptBin "clone-nvim.sh" ''
#!${bash} #!${bash}
if [ -d "${nvimCloneDir}" ]; then if [ -d "${nvimCloneDir}" ]; then
exit 0; exit 0;
fi fi
until ${ping} -c 1 ${host}; do until ${ping} -c 1 ${host}; do
${sleep} 1; ${sleep} 1;
done done
mkdir -p ${nvimCloneDir} mkdir -p ${nvimCloneDir}
@ -44,6 +44,9 @@ in
ExecStart = "${bash} ${path}"; ExecStart = "${bash} ${path}";
Restart = "on-failure"; Restart = "on-failure";
RemainAfterExit = "yes"; RemainAfterExit = "yes";
Environment = [
''GIT_SSH_COMMAND=${pkgs.openssh}/bin/ssh -i ${config.sops.secrets."ssh/id_ed25519/private".path}''
];
}; };
Install = { Install = {
WantedBy = [ "default.target" ]; WantedBy = [ "default.target" ];