summaryrefslogtreecommitdiffstats
path: root/lua
diff options
context:
space:
mode:
Diffstat (limited to 'lua')
-rw-r--r--lua/conf/autos.lua3
-rw-r--r--lua/conf/binds.lua9
-rw-r--r--lua/conf/init.lua3
-rw-r--r--lua/conf/opts.lua6
-rw-r--r--lua/conf/plugins/dap.lua20
-rw-r--r--lua/conf/plugins/gitsigns.lua3
-rw-r--r--lua/conf/plugins/harpoon.lua8
-rw-r--r--lua/conf/plugins/hml.lua5
-rw-r--r--lua/conf/plugins/leetcode.lua17
-rw-r--r--lua/conf/plugins/lspconfig.lua2
-rw-r--r--lua/conf/plugins/luasnip.lua20
-rw-r--r--lua/conf/plugins/neogen.lua3
-rw-r--r--lua/conf/plugins/oil.lua3
-rw-r--r--lua/conf/plugins/refactoring.lua9
-rw-r--r--lua/conf/plugins/telescope.lua3
-rw-r--r--lua/conf/plugins/todo-comments.lua3
-rw-r--r--lua/conf/plugins/treesitter-context.lua10
-rw-r--r--lua/conf/plugins/treesitter.lua12
-rw-r--r--lua/conf/plugins/treesj.lua5
-rw-r--r--lua/conf/plugins/undotree.lua3
-rw-r--r--lua/core/color.lua26
-rw-r--r--lua/core/init.lua41
-rw-r--r--lua/core/lsp.lua84
-rw-r--r--lua/core/lsp/functions.lua100
-rw-r--r--lua/core/misc.lua35
-rw-r--r--lua/core/snippets.lua (renamed from lua/core/snippets/shorthands.lua)4
-rw-r--r--lua/core/snippets/functions.lua3
-rw-r--r--lua/snippets/c.lua2
-rw-r--r--lua/snippets/java.lua3
-rw-r--r--lua/snippets/norg.lua3
-rw-r--r--lua/snippets/openscad.lua2
-rw-r--r--lua/snippets/php.lua2
-rw-r--r--lua/snippets/tex.lua3
33 files changed, 224 insertions, 231 deletions
diff --git a/lua/conf/autos.lua b/lua/conf/autos.lua
index c00745b..c1f97e7 100644
--- a/lua/conf/autos.lua
+++ b/lua/conf/autos.lua
@@ -1,5 +1,4 @@
-local misc = require("core.misc")
-local auto, augroup = misc.auto, misc.augroup
+local auto, augroup = core.misc.auto, core.misc.augroup
-- auto commands which interact with bufferes without modifying them
local bufcheck = augroup("bufcheck")
diff --git a/lua/conf/binds.lua b/lua/conf/binds.lua
index 6eb3519..ca7990f 100644
--- a/lua/conf/binds.lua
+++ b/lua/conf/binds.lua
@@ -1,5 +1,4 @@
-local misc = require("core.misc")
-local map = misc.map
+local map = core.misc.map
-- vim binds
vim.g.mapleader = " " -- set leader key
@@ -25,20 +24,20 @@ map("n", "<leader>x", function() -- execute order 111
local perm = vim.fn.getfperm(fn)
if string.match(perm, "x", 3) then
vim.notify("Removed executable flags", vim.log.levels.INFO, {
- title = misc.appid
+ title = core.misc.appid
})
vim.fn.setfperm(fn, string.sub(fn, 1, 2).."-"..string.sub(fn, 4, 5).."-"
..string.sub(fn, 7, 8).."-")
else
vim.notify("Add executable flags", vim.log.levels.INFO, {
- title = misc.appid
+ title = core.misc.appid
})
vim.fn.setfperm(fn, string.sub(fn, 1, 2).."x"..string.sub(fn, 4, 5).."x"
..string.sub(fn, 7, 8).."x")
end
else
vim.notify("File doesn't exist", vim.log.levels.INFO, {
- title = misc.appid
+ title = core.misc.appid
})
end
end, { desc = "toggle executable flag of the file" })
diff --git a/lua/conf/init.lua b/lua/conf/init.lua
new file mode 100644
index 0000000..507e4ef
--- /dev/null
+++ b/lua/conf/init.lua
@@ -0,0 +1,3 @@
+require("conf.opts") -- setup options
+require("conf.binds") -- setup keybinds
+require("conf.autos") -- setup autos
diff --git a/lua/conf/opts.lua b/lua/conf/opts.lua
index b78bed7..dc0549f 100644
--- a/lua/conf/opts.lua
+++ b/lua/conf/opts.lua
@@ -1,5 +1,4 @@
-local misc = require("core.misc")
-local auto = misc.auto
+local auto = core.misc.auto
-- color stuff
if vim.fn.has("termguicolors") then
@@ -84,8 +83,7 @@ do -- folding
vim.opt.foldenable = true
vim.o.fillchars = "fold: "
- _G.Fold_text = require("core.folding")
- vim.opt.foldtext = "v:lua.Fold_text()"
+ vim.opt.foldtext = "v:lua.core.folding()"
end
do -- statusline
diff --git a/lua/conf/plugins/dap.lua b/lua/conf/plugins/dap.lua
index afa9f29..3765350 100644
--- a/lua/conf/plugins/dap.lua
+++ b/lua/conf/plugins/dap.lua
@@ -1,18 +1,4 @@
-local misc = require("core.misc")
-local map = misc.map
-
---- select a program to execute
----@return thread coroutine containing the picker
-local function select_program()
- return coroutine.create(function(coro)
- ---@diagnostic disable-next-line: param-type-mismatch
- local entries = vim.fn.readdir(".", [[v:val !~ '^\.']])
- vim.ui.select(entries, { prompt = "Select the executable to run:" },
- function(choice)
- coroutine.resume(coro, choice)
- end)
- end)
-end
+local map = core.misc.map
local keymap_restore = {}
--- make the default hover binding work for nvim-dap instead of lsp
@@ -66,7 +52,9 @@ return { "mfussenegger/nvim-dap",
name = "Launch file",
type = "codelldb",
request = "launch",
- program = select_program,
+ program = function()
+ return vim.fn.input('Path to executable: ', vim.fn.getcwd()..'/', 'file')
+ end,
cwd = "${workspaceFolder}",
stopOnEntry = false
diff --git a/lua/conf/plugins/gitsigns.lua b/lua/conf/plugins/gitsigns.lua
index b420746..40e19c1 100644
--- a/lua/conf/plugins/gitsigns.lua
+++ b/lua/conf/plugins/gitsigns.lua
@@ -1,5 +1,4 @@
-local misc = require("core.misc")
-local map = misc.map
+local map = core.misc.map
return { "lewis6991/gitsigns.nvim",
disable = not vim.fn.has("nvim-0.9.0"),
diff --git a/lua/conf/plugins/harpoon.lua b/lua/conf/plugins/harpoon.lua
index 5bb02d0..06a00ff 100644
--- a/lua/conf/plugins/harpoon.lua
+++ b/lua/conf/plugins/harpoon.lua
@@ -1,5 +1,7 @@
-local misc = require("core.misc")
-local map = misc.map
+-- TODO: might end up writing my own because I like harpoon, but I hate that it
+-- doesn't work properly without being pinned to a specific commit
+
+local map = core.misc.map
return { "ThePrimeagen/harpoon",
disable = not vim.fn.has("nvim-0.8.0"),
@@ -14,7 +16,7 @@ return { "ThePrimeagen/harpoon",
map("n", "<leader>a", function()
harpoon:list():add()
vim.notify("added "..vim.fn.expand("%:t").." to quickmarks",
- vim.log.levels.INFO, { title = misc.appid })
+ vim.log.levels.INFO, { title = core.misc.appid })
end, { desc = "add current file to quickmarks" })
map("n", "<C-e>", function() harpoon.ui:toggle_quick_menu(harpoon:list()) end)
diff --git a/lua/conf/plugins/hml.lua b/lua/conf/plugins/hml.lua
deleted file mode 100644
index 8c605c4..0000000
--- a/lua/conf/plugins/hml.lua
+++ /dev/null
@@ -1,5 +0,0 @@
-return { "mawkler/hml.nvim",
- function()
- require("hml").setup {}
- end
-}
diff --git a/lua/conf/plugins/leetcode.lua b/lua/conf/plugins/leetcode.lua
deleted file mode 100644
index 9276295..0000000
--- a/lua/conf/plugins/leetcode.lua
+++ /dev/null
@@ -1,17 +0,0 @@
-return { "kawre/leetcode.nvim",
- requires = {
- "nvim-lua/plenary.nvim",
- "nvim-telescope/telescope.nvim",
- "MunifTanjim/nui.nvim",
- "nvim-treesitter/nvim-treesitter"
- },
- config = function()
- -- because we"re using treesitter make sure to install the html parser
- vim.cmd("TSUpdate html")
- end,
- function()
- require("leetcode").setup {
- lang = "java"
- }
- end
-}
diff --git a/lua/conf/plugins/lspconfig.lua b/lua/conf/plugins/lspconfig.lua
index b7f2cde..f2a3250 100644
--- a/lua/conf/plugins/lspconfig.lua
+++ b/lua/conf/plugins/lspconfig.lua
@@ -5,7 +5,7 @@ return { "neovim/nvim-lspconfig",
"mason-org/mason-lspconfig.nvim"
},
function()
- require("core.lsp.functions").setup()
+ core.lsp.setup()
require("mason-lspconfig").setup {
ensure_added = {
"clangd",
diff --git a/lua/conf/plugins/luasnip.lua b/lua/conf/plugins/luasnip.lua
index 7385af1..fc6b2e4 100644
--- a/lua/conf/plugins/luasnip.lua
+++ b/lua/conf/plugins/luasnip.lua
@@ -1,5 +1,4 @@
-local misc = require("core.misc")
-local map = misc.map
+local map, auto = core.misc.map, core.misc.auto
return { "L3MON4D3/LuaSnip",
branch = "v2.4.0",
@@ -55,14 +54,21 @@ return { "L3MON4D3/LuaSnip",
end
end)
- -- load all snippets from snippet directory
+ -- collect all snippets and add them when in the correct file type
for _, file in ipairs(vim.api.nvim_get_runtime_file("lua/snippets/*.lua",
true)) do
local fn = file:gsub("^.*/", ""):gsub("%.lua$", "")
- local ret = misc.include("snippets."..fn)
- if type(ret) ~= "boolean" then
- luasnip.add_snippets(fn, ret, { key = fn })
- end
+
+ auto("FileType", {
+ pattern = fn,
+ once = true,
+ callback = function()
+ local ret = require("snippets."..fn)
+ if type(ret) ~= "boolean" then
+ luasnip.add_snippets(fn, ret, { key = fn })
+ end
+ end
+ })
end
end
}
diff --git a/lua/conf/plugins/neogen.lua b/lua/conf/plugins/neogen.lua
index 1a670df..f7afbcf 100644
--- a/lua/conf/plugins/neogen.lua
+++ b/lua/conf/plugins/neogen.lua
@@ -1,5 +1,4 @@
-local misc = require("core.misc")
-local map = misc.map
+local map = core.misc.map
return { "danymat/neogen",
requires = {
diff --git a/lua/conf/plugins/oil.lua b/lua/conf/plugins/oil.lua
index 62f452b..76c41c5 100644
--- a/lua/conf/plugins/oil.lua
+++ b/lua/conf/plugins/oil.lua
@@ -1,5 +1,4 @@
-local misc = require("core.misc")
-local map = misc.map
+local map = core.misc.map
-- helper function to parse output
local function parse_output(proc)
diff --git a/lua/conf/plugins/refactoring.lua b/lua/conf/plugins/refactoring.lua
new file mode 100644
index 0000000..fb4a9d7
--- /dev/null
+++ b/lua/conf/plugins/refactoring.lua
@@ -0,0 +1,9 @@
+return { "ThePrimeagen/refactoring.nvim",
+ requires = {
+ "nvim-lua/plenary.nvim",
+ "nvim-treesitter/nvim-treesitter"
+ },
+ function()
+ require('refactoring').setup {}
+ end
+}
diff --git a/lua/conf/plugins/telescope.lua b/lua/conf/plugins/telescope.lua
index b6909b4..1c29d87 100644
--- a/lua/conf/plugins/telescope.lua
+++ b/lua/conf/plugins/telescope.lua
@@ -1,5 +1,4 @@
-local misc = require("core.misc")
-local map = misc.map
+local map = core.misc.map
--- get the root directory for telescope to search
---@return string the root directory
diff --git a/lua/conf/plugins/todo-comments.lua b/lua/conf/plugins/todo-comments.lua
index 24eccd0..bda84ef 100644
--- a/lua/conf/plugins/todo-comments.lua
+++ b/lua/conf/plugins/todo-comments.lua
@@ -1,3 +1,6 @@
+-- TODO: gotta rewrite this cause it's actual dogshit, and I don't want to deal
+-- with nerd fonts or folke anymore also add support for TODO(name):
+
return { "folke/todo-comments.nvim",
requires = "nvim-lua/plenary.nvim",
disable = not vim.fn.has("nvim-0.8.0"),
diff --git a/lua/conf/plugins/treesitter-context.lua b/lua/conf/plugins/treesitter-context.lua
new file mode 100644
index 0000000..35452b6
--- /dev/null
+++ b/lua/conf/plugins/treesitter-context.lua
@@ -0,0 +1,10 @@
+return { "nvim-treesitter/nvim-treesitter-context",
+ requires = "nvim-treesitter/nvim-treesitter",
+ function()
+ require("treesitter-context").setup {
+ max_lines = 2,
+ line_numbers = true,
+ trim_scope = 'inner'
+ }
+ end
+}
diff --git a/lua/conf/plugins/treesitter.lua b/lua/conf/plugins/treesitter.lua
index 4354953..17893b3 100644
--- a/lua/conf/plugins/treesitter.lua
+++ b/lua/conf/plugins/treesitter.lua
@@ -1,12 +1,3 @@
-table.contains = function(self, string)
- for _, v in pairs(self) do
- if v == string then
- return true
- end
- end
- return false
-end
-
return { "nvim-treesitter/nvim-treesitter",
disable = not vim.fn.has("nvim-0.10.0"),
config = function()
@@ -47,8 +38,7 @@ return { "nvim-treesitter/nvim-treesitter",
end
-- disable in big files
- -- TODO: update before nvim 1.0 when vim.loop is removed
- local ok, stats = pcall(vim.loop.fs_stat,
+ local ok, stats = pcall(vim.uv.fs_stat,
vim.api.nvim_buf_get_name(buf))
if ok and stats and stats.size > (1024 * 100 * 10) --[[1MB]] then
return true
diff --git a/lua/conf/plugins/treesj.lua b/lua/conf/plugins/treesj.lua
index 424c677..ebd4953 100644
--- a/lua/conf/plugins/treesj.lua
+++ b/lua/conf/plugins/treesj.lua
@@ -1,12 +1,11 @@
-local misc = require("core.misc")
-local map = misc.map
+local map = core.misc.map
return { "Wansmer/treesj",
disable = not vim.fn.has("nvim-0.9.0"),
requires = "nvim-treesitter/nvim-treesitter",
function()
require("treesj").setup {
- use_default_keymaps = false,
+ use_default_keymaps = false
}
map("n", "<leader>j", require("treesj").toggle, { desc = "fold code" })
diff --git a/lua/conf/plugins/undotree.lua b/lua/conf/plugins/undotree.lua
index fa57def..cdd0a7c 100644
--- a/lua/conf/plugins/undotree.lua
+++ b/lua/conf/plugins/undotree.lua
@@ -1,5 +1,4 @@
-local misc = require("core.misc")
-local map = misc.map
+local map = core.misc.map
return { "mbbill/undotree",
function()
diff --git a/lua/core/color.lua b/lua/core/color.lua
new file mode 100644
index 0000000..c4525f5
--- /dev/null
+++ b/lua/core/color.lua
@@ -0,0 +1,26 @@
+local M = {}
+
+--- copy highlight group
+---@param hlgroup string highlight group to copy
+---@param namespace? number highlight space
+---@return table
+function M.copyhl(hlgroup, namespace)
+ namespace = namespace or 0
+
+ local ok, hl = pcall(vim.api.nvim_get_hl, namespace, {
+ name = hlgroup,
+ create = false
+ })
+ if not ok then
+ return {}
+ end
+
+ for _, key in pairs({ "foreground", "background", "special" }) do
+ if hl[key] then
+ hl[key] = string.format("#%06x", hl[key])
+ end
+ end
+ return hl
+end
+
+return M
diff --git a/lua/core/init.lua b/lua/core/init.lua
new file mode 100644
index 0000000..f8d0c35
--- /dev/null
+++ b/lua/core/init.lua
@@ -0,0 +1,41 @@
+-- inspired by (and partially yoinked from): github.com/gonstoll/dotfiles
+
+local M = {
+ misc = require("core.misc"),
+ folding = require("core.folding"),
+ lsp = require("core.lsp"),
+ color = require("core.color"),
+ snippets = vim.fs.joinpath(vim.fn.stdpath("config"), "lua/core/snippets.lua"),
+}
+
+--- check if the given table contains an item, and return the key value pair if
+--- it does
+---@param self table table
+---@param item any item to find
+---@return boolean, [any, any]? found true if found
+table.contains = function(self, item)
+ for k, v in pairs(self) do
+ if v == item then
+ return true, { k, v }
+ end
+ end
+
+ return false
+end
+
+M.mason = {
+ --- Gets a path to a package in the Mason registry.
+ --- Prefer this to `get_package`, since the package might not always be
+ --- available yet and trigger errors.
+ ---@param pkg string
+ ---@param path? string
+ get_pkg_path = function(pkg, path)
+ pcall(require, "mason") -- make sure Mason is loaded. Will fail when generating docs
+
+ local root = vim.env.MASON or vim.fs.joinpath(vim.fn.stdpath("data"), "mason")
+ path = path or ""
+ return vim.fs.joinpath(root, "packages", pkg, path)
+ end
+}
+
+return M
diff --git a/lua/core/lsp.lua b/lua/core/lsp.lua
new file mode 100644
index 0000000..fd03a42
--- /dev/null
+++ b/lua/core/lsp.lua
@@ -0,0 +1,84 @@
+---@diagnostic disable: param-type-mismatch
+
+local misc = require("core.misc")
+local map, auto = misc.map, misc.auto
+local popup_opts, hover_opts, signature_opts, list_opts, location_opts
+
+-- TODO: find a way to make the qflist current item be the one closest to the
+-- cursor whenever we open it
+local function on_list(opts)
+ vim.fn.setqflist({}, "r", opts)
+ if #opts.items > 1 then
+ vim.cmd.copen()
+ end
+ vim.cmd(".cc! 1")
+end
+
+-- disable the default keybinds (they're bad)
+for _, bind in ipairs({ "grn", "gra", "gri", "grr" }) do
+ pcall(vim.keymap.del, "n", bind)
+end
+
+local M = {}
+
+--- setup vim lsp options
+function M.setup()
+ -- options for different lsp functions
+ popup_opts = { border = vim.g.border_style }
+ hover_opts = vim.tbl_deep_extend("force", popup_opts, {})
+ signature_opts = vim.tbl_deep_extend("force", popup_opts, {})
+ list_opts = { on_list = on_list }
+ location_opts = vim.tbl_deep_extend("force", list_opts, {})
+
+ -- confgiure lsp
+ vim.diagnostic.config {
+ virtual_text = false,
+ virtual_lines = {
+ current_line = true
+ },
+ update_in_insert = false,
+ underline = true,
+ severity_sort = true,
+ signs = {
+ text = {
+ [vim.diagnostic.severity.ERROR] = "x",
+ [vim.diagnostic.severity.WARN] = "!",
+ [vim.diagnostic.severity.INFO] = "i",
+ [vim.diagnostic.severity.HINT] = "h"
+ }
+ }
+ }
+
+ -- set default capabilities and attach function
+ vim.lsp.config['*'] = {
+ capabilities = vim.lsp.protocol.make_client_capabilities()
+ }
+
+ -- make my attach function always run
+ auto("LspAttach", {
+ callback = function(event)
+ local opts = { buffer = event.buf, nowait = true }
+
+ -- LSP actions
+ map("n", "K", function() vim.lsp.buf.hover(hover_opts) end, opts)
+ map("n", "gd", function() vim.lsp.buf.definition(location_opts) end, opts)
+ map("n", "gD", function() vim.lsp.buf.declaration(location_opts) end, opts)
+ map("n", "gi", function() vim.lsp.buf.implementation(location_opts) end, opts)
+ map("n", "gy", function() vim.lsp.buf.type_definition(location_opts) end, opts)
+ map("n", "gr", function() vim.lsp.buf.references(nil, list_opts) end, opts)
+ map("n", "<S-Tab>", function() vim.lsp.buf.signature_help(signature_opts) end, opts)
+ map("n", { "<leader>r", "<F2>" }, vim.lsp.buf.rename, opts)
+ map("n", { "gA", "<F4>" }, vim.lsp.buf.code_action, opts)
+
+ -- Diagnostics
+ map("n", "[d", function()
+ vim.diagnostic.jump({ count = -1 })
+ end, opts)
+ map("n", "]d", function()
+ vim.diagnostic.jump({ count = 1 })
+ end, opts)
+ end
+ })
+end
+
+return M
diff --git a/lua/core/lsp/functions.lua b/lua/core/lsp/functions.lua
deleted file mode 100644
index 4591205..0000000
--- a/lua/core/lsp/functions.lua
+++ /dev/null
@@ -1,100 +0,0 @@
-local misc = require("core.misc")
-local map, auto = misc.map, misc.auto
-
-local M = {}
-
--- TODO: find a way to make the qflist current item be the one closest to the
--- cursor whenever we open it
-local function on_list(opts)
- vim.fn.setqflist({}, "r", opts)
- if #opts.items > 1 then
- vim.cmd.copen()
- end
- vim.cmd(".cc! 1")
-end
-
----@type vim.lsp.util.open_floating_preview.Opts
-local popup_opts = {
- border = vim.g.border_style
-}
----@type vim.lsp.buf.hover.Opts
----@diagnostic disable-next-line: assign-type-mismatch
-local hover_opts = vim.tbl_deep_extend("force", popup_opts, {})
-
----@type vim.lsp.buf.signature_help.Opts
----@diagnostic disable-next-line: assign-type-mismatch
-local signature_opts = vim.tbl_deep_extend("force", popup_opts, {})
-
----@type vim.lsp.ListOpts
-local list_opts = {
- on_list = on_list
-}
-
----@type vim.lsp.LocationOpts
----@diagnostic disable-next-line: assign-type-mismatch
-local location_opts = vim.tbl_deep_extend("force", list_opts, {})
-
--- disable the default keybinds (they're bad)
-for _, bind in ipairs({ "grn", "gra", "gri", "grr" }) do
- pcall(vim.keymap.del, "n", bind)
-end
-
---- setup basic options on lsp attach
----@param bufnr number buffer number
-local function attach(bufnr)
- local opts = { buffer = bufnr, nowait = true }
-
- -- LSP actions
- map("n", "K", function() vim.lsp.buf.hover(hover_opts) end, opts)
- map("n", "gd", function() vim.lsp.buf.definition(location_opts) end, opts)
- map("n", "gD", function() vim.lsp.buf.declaration(location_opts) end, opts)
- map("n", "gi", function() vim.lsp.buf.implementation(location_opts) end, opts)
- map("n", "gy", function() vim.lsp.buf.type_definition(location_opts) end, opts)
- map("n", "gr", function() vim.lsp.buf.references(nil, list_opts) end, opts)
- map("n", "<S-Tab>", function() vim.lsp.buf.signature_help(signature_opts) end, opts)
- map("n", { "<leader>r", "<F2>" }, vim.lsp.buf.rename, opts)
- map("n", { "gA", "<F4>" }, vim.lsp.buf.code_action, opts)
-
- -- Diagnostics
- map("n", "[d", function()
- vim.diagnostic.jump({ count = -1 })
- end, opts)
- map("n", "]d", function()
- vim.diagnostic.jump({ count = 1 })
- end, opts)
-end
-
---- setup vim lsp options
-function M.setup()
- vim.diagnostic.config {
- virtual_text = false,
- virtual_lines = {
- current_line = true
- },
- update_in_insert = false,
- underline = true,
- severity_sort = true,
- signs = {
- text = {
- [vim.diagnostic.severity.ERROR] = "x",
- [vim.diagnostic.severity.WARN] = "!",
- [vim.diagnostic.severity.INFO] = "i",
- [vim.diagnostic.severity.HINT] = "h"
- }
- }
- }
-
- -- set default capabilities and attach function
- vim.lsp.config['*'] = {
- capabilities = vim.lsp.protocol.make_client_capabilities()
- }
-
- -- make my attach function always run
- auto("LspAttach", {
- callback = function(event)
- attach(event.buf)
- end
- })
-end
-
-return M
diff --git a/lua/core/misc.lua b/lua/core/misc.lua
index fab3258..24378b4 100644
--- a/lua/core/misc.lua
+++ b/lua/core/misc.lua
@@ -3,18 +3,6 @@ local M = {}
--- vim.notify title
M.appid = "Nvim Config"
---- safe version of require
----@param fn string name of file to include
----@return any
-function M.include(fn)
- local ok, r = pcall(require, fn)
- if not ok then
- vim.notify("Could not find '"..fn.."': "..r, vim.log.levels.WARN, { title = M.appid })
- return ok
- end
- return r
-end
-
--- loop through files in directory
---@param path string absolute path of directory to be looped through
---@param body function function to use on every recursion of the loop
@@ -99,29 +87,6 @@ function M.highlight(group, opts, namespace)
end
end
---- copy highlight group
----@param hlgroup string highlight group to copy
----@param namespace? number highlight space
----@return table
-function M.cpyhl(hlgroup, namespace)
- namespace = namespace or 0
-
- local ok, hl = pcall(vim.api.nvim_get_hl, namespace, {
- name = hlgroup,
- create = false
- })
- if not ok then
- return {}
- end
-
- for _, key in pairs({ "foreground", "background", "special" }) do
- if hl[key] then
- hl[key] = string.format("#%06x", hl[key])
- end
- end
- return hl
-end
-
--- highlight something with some highlight group for a certain amount of time
--- example:
--- ```lua
diff --git a/lua/core/snippets/shorthands.lua b/lua/core/snippets.lua
index 4e6aa10..48dd54f 100644
--- a/lua/core/snippets/shorthands.lua
+++ b/lua/core/snippets.lua
@@ -21,3 +21,7 @@ conds_expand = require("luasnip.extras.conditions.expand")
ts_postfix = require("luasnip.extras.treesitter_postfix").treesitter_postfix
postfix = require("luasnip.extras.postfix").postfix
ms = ls.multi_snippet
+
+function file_name(_, _, _)
+ return vim.fn.expand("%:t:r")
+end
diff --git a/lua/core/snippets/functions.lua b/lua/core/snippets/functions.lua
deleted file mode 100644
index 24fc8a6..0000000
--- a/lua/core/snippets/functions.lua
+++ /dev/null
@@ -1,3 +0,0 @@
-function file_name(_, _, _)
- return vim.fn.expand("%:t:r")
-end
diff --git a/lua/snippets/c.lua b/lua/snippets/c.lua
index ed63c1b..2699389 100644
--- a/lua/snippets/c.lua
+++ b/lua/snippets/c.lua
@@ -1,4 +1,4 @@
-require('core.snippets.shorthands')
+dofile(core.snippets)
return {
-- function snippet
diff --git a/lua/snippets/java.lua b/lua/snippets/java.lua
index 1cb8162..790336e 100644
--- a/lua/snippets/java.lua
+++ b/lua/snippets/java.lua
@@ -1,5 +1,4 @@
-require("core.snippets.shorthands")
-require("core.snippets.functions")
+dofile(core.snippets)
--- shortcut to choose between java access modifiers
---@param idx number index of the node
diff --git a/lua/snippets/norg.lua b/lua/snippets/norg.lua
index 67d3964..afe4c49 100644
--- a/lua/snippets/norg.lua
+++ b/lua/snippets/norg.lua
@@ -1,5 +1,4 @@
-require("core.snippets.shorthands")
-require("core.snippets.functions")
+dofile(core.snippets)
return {
-- header level 1, usually this has the same name as the file
diff --git a/lua/snippets/openscad.lua b/lua/snippets/openscad.lua
index caf19b9..130b66b 100644
--- a/lua/snippets/openscad.lua
+++ b/lua/snippets/openscad.lua
@@ -1,4 +1,4 @@
-require("core.snippets.shorthands")
+dofile(core.snippets)
return {
-- translate snippet
diff --git a/lua/snippets/php.lua b/lua/snippets/php.lua
index 88c542f..33fd4c4 100644
--- a/lua/snippets/php.lua
+++ b/lua/snippets/php.lua
@@ -1,4 +1,4 @@
-require("core.snippets.shorthands")
+dofile(core.snippets)
return {
s("php", {
diff --git a/lua/snippets/tex.lua b/lua/snippets/tex.lua
index f7fdfed..30999ea 100644
--- a/lua/snippets/tex.lua
+++ b/lua/snippets/tex.lua
@@ -1,5 +1,4 @@
-require("core.snippets.shorthands")
-require("core.snippets.functions")
+dofile(core.snippets)
return {
-- document snippet