aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/nvim
diff options
context:
space:
mode:
authorToby Vincent <tobyv13@gmail.com>2022-11-24 23:48:35 -0600
committerToby Vincent <tobyv13@gmail.com>2022-11-24 23:48:35 -0600
commit44454f35733699d0413f8ea4b29b58026275bf9b (patch)
treee226fdc2912c870bbeff2d03ba2d029bc8722fe9 /nvim
parent9f7df07a8c39ef496c4f3ea0b24a5a792f3d2bd8 (diff)
feat(nvim): remove setup func in configs
Diffstat (limited to 'nvim')
-rw-r--r--nvim/.config/nvim/init.lua4
-rw-r--r--nvim/.config/nvim/lua/tobyvin.lua52
-rw-r--r--nvim/.config/nvim/lua/tobyvin/autocmds.lua113
-rw-r--r--nvim/.config/nvim/lua/tobyvin/diagnostic.lua61
-rw-r--r--nvim/.config/nvim/lua/tobyvin/keymaps.lua49
-rw-r--r--nvim/.config/nvim/lua/tobyvin/lsp.lua35
-rw-r--r--nvim/.config/nvim/lua/tobyvin/lsp/formatting.lua46
-rw-r--r--nvim/.config/nvim/lua/tobyvin/lsp/handlers.lua65
-rw-r--r--nvim/.config/nvim/lua/tobyvin/lsp/highlighting.lua52
-rw-r--r--nvim/.config/nvim/lua/tobyvin/options.lua170
-rw-r--r--nvim/.config/nvim/lua/tobyvin/plugins.lua148
-rw-r--r--nvim/.config/nvim/lua/tobyvin/plugins/alpha.lua224
-rw-r--r--nvim/.config/nvim/lua/tobyvin/plugins/cmp-git.lua16
-rw-r--r--nvim/.config/nvim/lua/tobyvin/plugins/cmp-npm.lua16
-rw-r--r--nvim/.config/nvim/lua/tobyvin/plugins/cmp.lua189
-rw-r--r--nvim/.config/nvim/lua/tobyvin/plugins/comment.lua30
-rw-r--r--nvim/.config/nvim/lua/tobyvin/plugins/crates.lua55
-rw-r--r--nvim/.config/nvim/lua/tobyvin/plugins/dap.lua147
-rw-r--r--nvim/.config/nvim/lua/tobyvin/plugins/dapui.lua84
-rw-r--r--nvim/.config/nvim/lua/tobyvin/plugins/diffview.lua26
-rw-r--r--nvim/.config/nvim/lua/tobyvin/plugins/dressing.lua80
-rw-r--r--nvim/.config/nvim/lua/tobyvin/plugins/fidget.lua31
-rw-r--r--nvim/.config/nvim/lua/tobyvin/plugins/git-conflict.lua28
-rw-r--r--nvim/.config/nvim/lua/tobyvin/plugins/gitsigns.lua49
-rw-r--r--nvim/.config/nvim/lua/tobyvin/plugins/gruvbox.lua82
-rw-r--r--nvim/.config/nvim/lua/tobyvin/plugins/indent_blankline.lua58
-rw-r--r--nvim/.config/nvim/lua/tobyvin/plugins/lspconfig.lua45
-rw-r--r--nvim/.config/nvim/lua/tobyvin/plugins/lspkind.lua13
-rw-r--r--nvim/.config/nvim/lua/tobyvin/plugins/lualine.lua246
-rw-r--r--nvim/.config/nvim/lua/tobyvin/plugins/luasnip.lua24
-rw-r--r--nvim/.config/nvim/lua/tobyvin/plugins/mason.lua76
-rw-r--r--nvim/.config/nvim/lua/tobyvin/plugins/neodev.lua48
-rw-r--r--nvim/.config/nvim/lua/tobyvin/plugins/neogit.lua32
-rw-r--r--nvim/.config/nvim/lua/tobyvin/plugins/notify.lua42
-rw-r--r--nvim/.config/nvim/lua/tobyvin/plugins/null-ls.lua56
-rw-r--r--nvim/.config/nvim/lua/tobyvin/plugins/nvim-bqf.lua42
-rw-r--r--nvim/.config/nvim/lua/tobyvin/plugins/nvim-dap-virtual-text.lua16
-rw-r--r--nvim/.config/nvim/lua/tobyvin/plugins/nvim-navic.lua52
-rw-r--r--nvim/.config/nvim/lua/tobyvin/plugins/rust-tools.lua143
-rw-r--r--nvim/.config/nvim/lua/tobyvin/plugins/session_manager.lua32
-rw-r--r--nvim/.config/nvim/lua/tobyvin/plugins/surround.lua22
-rw-r--r--nvim/.config/nvim/lua/tobyvin/plugins/telescope.lua207
-rw-r--r--nvim/.config/nvim/lua/tobyvin/plugins/tokyonight.lua28
-rw-r--r--nvim/.config/nvim/lua/tobyvin/plugins/treesitter.lua116
-rw-r--r--nvim/.config/nvim/lua/tobyvin/plugins/undotree.lua24
-rw-r--r--nvim/.config/nvim/lua/tobyvin/plugins/yanky.lua40
-rw-r--r--nvim/.config/nvim/lua/tobyvin/utils/log.lua33
47 files changed, 1429 insertions, 1818 deletions
diff --git a/nvim/.config/nvim/init.lua b/nvim/.config/nvim/init.lua
index f1b7215..beee497 100644
--- a/nvim/.config/nvim/init.lua
+++ b/nvim/.config/nvim/init.lua
@@ -1,3 +1,3 @@
pcall(require, "impatient")
-
-require("tobyvin").setup()
+require("tobyvin.utils.log")
+require("tobyvin")
diff --git a/nvim/.config/nvim/lua/tobyvin.lua b/nvim/.config/nvim/lua/tobyvin.lua
index dd40e3a..fea0abe 100644
--- a/nvim/.config/nvim/lua/tobyvin.lua
+++ b/nvim/.config/nvim/lua/tobyvin.lua
@@ -1,46 +1,6 @@
-local log = require("plenary.log").new({ plugin = "notify" })
-local levels = {}
-for k, v in pairs(vim.log.levels) do
- levels[v] = k:lower()
- levels[k] = k:lower()
- levels[k:lower()] = k:lower()
-end
-
-setmetatable(log, {
- __call = function(t, msg, level, opts)
- local log_msg = msg
- if opts and opts.title then
- log_msg = string.format("%s: %s", opts.title, log_msg)
- end
-
- local level_name = vim.F.if_nil(levels[level], "info")
- pcall(t[level_name], log_msg)
-
- vim.api.nvim_exec_autocmds("User", {
- pattern = "Notify",
- data = { msg, level, opts },
- })
- end,
-})
-
-vim.notify = log
-
-local M = {
- options = require("tobyvin.options"),
- autocmds = require("tobyvin.autocmds"),
- keymaps = require("tobyvin.keymaps"),
- plugins = require("tobyvin.plugins"),
- diagnostic = require("tobyvin.diagnostic"),
- lsp = require("tobyvin.lsp"),
-}
-
-M.setup = function()
- M.options.setup()
- M.autocmds.setup()
- M.keymaps.setup()
- M.plugins.setup()
- M.diagnostic.setup()
- M.lsp.setup()
-end
-
-return M
+require("tobyvin.options")
+require("tobyvin.autocmds")
+require("tobyvin.keymaps")
+require("tobyvin.plugins")
+require("tobyvin.diagnostic")
+require("tobyvin.lsp")
diff --git a/nvim/.config/nvim/lua/tobyvin/autocmds.lua b/nvim/.config/nvim/lua/tobyvin/autocmds.lua
index d3fb74c..c322739 100644
--- a/nvim/.config/nvim/lua/tobyvin/autocmds.lua
+++ b/nvim/.config/nvim/lua/tobyvin/autocmds.lua
@@ -1,66 +1,61 @@
local Path = require("plenary").path
-local M = {}
-M.setup = function()
- vim.api.nvim_create_autocmd("TextYankPost", {
- group = vim.api.nvim_create_augroup("tobyvin_hl", { clear = true }),
- pattern = "*",
- callback = function()
- vim.highlight.on_yank()
- end,
- desc = "Highlight yank",
- })
+vim.api.nvim_create_autocmd("TextYankPost", {
+ group = vim.api.nvim_create_augroup("tobyvin_hl", { clear = true }),
+ pattern = "*",
+ callback = function()
+ vim.highlight.on_yank()
+ end,
+ desc = "Highlight yank",
+})
- vim.api.nvim_create_autocmd("BufWritePre", {
- group = vim.api.nvim_create_augroup("tobyvin_mkdir", { clear = true }),
- callback = function(args)
- local parent = Path:new(args.file):parent()
- local prompt = string.format("%s does not exist. Create it?", parent:make_relative())
- if not parent:is_dir() and vim.fn.confirm(prompt, "&Yes\n&No") == 1 then
- parent:mkdir()
- end
- end,
- desc = "Check for missing directory on write",
- })
+vim.api.nvim_create_autocmd("BufWritePre", {
+ group = vim.api.nvim_create_augroup("tobyvin_mkdir", { clear = true }),
+ callback = function(args)
+ local parent = Path:new(args.file):parent()
+ local prompt = string.format("%s does not exist. Create it?", parent:make_relative())
+ if not parent:is_dir() and vim.fn.confirm(prompt, "&Yes\n&No") == 1 then
+ parent:mkdir()
+ end
+ end,
+ desc = "Check for missing directory on write",
+})
- vim.api.nvim_create_autocmd("BufWritePre", {
- group = vim.api.nvim_create_augroup("tobyvin_whitespace", { clear = true }),
- pattern = "*",
- callback = function()
- local cursor = vim.api.nvim_win_get_cursor(0)
- vim.cmd("%s/\\s\\+$//e")
- vim.api.nvim_win_set_cursor(0, cursor)
- end,
- desc = "Trim whitespace on write",
- })
+vim.api.nvim_create_autocmd("BufWritePre", {
+ group = vim.api.nvim_create_augroup("tobyvin_whitespace", { clear = true }),
+ pattern = "*",
+ callback = function()
+ local cursor = vim.api.nvim_win_get_cursor(0)
+ vim.cmd("%s/\\s\\+$//e")
+ vim.api.nvim_win_set_cursor(0, cursor)
+ end,
+ desc = "Trim whitespace on write",
+})
- vim.api.nvim_create_autocmd("FileType", {
- group = vim.api.nvim_create_augroup("tobyvin_tabstop", { clear = true }),
- pattern = { "sh", "zsh", "xml", "html", "xhtml", "css", "scss", "javascript", "lua", "dart", "markdown" },
- callback = function(args)
- vim.bo[args.buf].tabstop = 2
- end,
- desc = "Set tabstop",
- })
+vim.api.nvim_create_autocmd("FileType", {
+ group = vim.api.nvim_create_augroup("tobyvin_tabstop", { clear = true }),
+ pattern = { "sh", "zsh", "xml", "html", "xhtml", "css", "scss", "javascript", "lua", "dart", "markdown" },
+ callback = function(args)
+ vim.bo[args.buf].tabstop = 2
+ end,
+ desc = "Set tabstop",
+})
- vim.api.nvim_create_autocmd("FileType", {
- group = vim.api.nvim_create_augroup("tobyvin_unlisted", { clear = true }),
- pattern = { "qf", "help", "gitcommit", "gitrebase", "Neogit*" },
- callback = function(args)
- vim.bo[args.buf].buflisted = false
- end,
- desc = "Set buffer as unlisted",
- })
+vim.api.nvim_create_autocmd("FileType", {
+ group = vim.api.nvim_create_augroup("tobyvin_unlisted", { clear = true }),
+ pattern = { "qf", "help", "gitcommit", "gitrebase", "Neogit*" },
+ callback = function(args)
+ vim.bo[args.buf].buflisted = false
+ end,
+ desc = "Set buffer as unlisted",
+})
- vim.api.nvim_create_autocmd("FileType", {
- group = vim.api.nvim_create_augroup("tobyvin_help", { clear = true }),
- pattern = "help",
- callback = function()
- vim.wo.colorcolumn = nil
- vim.cmd("wincmd L")
- end,
- desc = "Vertical help window",
- })
-end
-
-return M
+vim.api.nvim_create_autocmd("FileType", {
+ group = vim.api.nvim_create_augroup("tobyvin_help", { clear = true }),
+ pattern = "help",
+ callback = function()
+ vim.wo.colorcolumn = nil
+ vim.cmd("wincmd L")
+ end,
+ desc = "Vertical help window",
+})
diff --git a/nvim/.config/nvim/lua/tobyvin/diagnostic.lua b/nvim/.config/nvim/lua/tobyvin/diagnostic.lua
index fe74ea2..9bf0f72 100644
--- a/nvim/.config/nvim/lua/tobyvin/diagnostic.lua
+++ b/nvim/.config/nvim/lua/tobyvin/diagnostic.lua
@@ -1,38 +1,33 @@
local utils = require("tobyvin.utils")
-local M = {}
-M.setup = function()
- vim.diagnostic.config({
- virtual_text = {
- source = "if_many",
- },
- signs = true,
- underline = true,
- update_in_insert = true,
- severity_sort = true,
- float = {
- border = "single",
- scope = "cursor",
- },
- })
+vim.diagnostic.config({
+ virtual_text = {
+ source = "if_many",
+ },
+ signs = true,
+ underline = true,
+ update_in_insert = true,
+ severity_sort = true,
+ float = {
+ border = "single",
+ scope = "cursor",
+ },
+})
- vim.fn.sign_define("DiagnosticSignError", utils.diagnostic.signs.error)
- vim.fn.sign_define("DiagnosticSignWarn", utils.diagnostic.signs.warn)
- vim.fn.sign_define("DiagnosticSignInfo", utils.diagnostic.signs.info)
- vim.fn.sign_define("DiagnosticSignHint", utils.diagnostic.signs.hint)
+vim.fn.sign_define("DiagnosticSignError", utils.diagnostic.signs.error)
+vim.fn.sign_define("DiagnosticSignWarn", utils.diagnostic.signs.warn)
+vim.fn.sign_define("DiagnosticSignInfo", utils.diagnostic.signs.info)
+vim.fn.sign_define("DiagnosticSignHint", utils.diagnostic.signs.hint)
- vim.api.nvim_create_autocmd("CursorHold", {
- callback = function()
- vim.diagnostic.open_float(nil, {
- focus = false,
- })
- end,
- })
+vim.api.nvim_create_autocmd("CursorHold", {
+ callback = function()
+ vim.diagnostic.open_float(nil, {
+ focus = false,
+ })
+ end,
+})
- vim.keymap.set("n", "]d", utils.diagnostic.goto_next, { desc = "next diagnostic" })
- vim.keymap.set("n", "[d", utils.diagnostic.goto_prev, { desc = "prev diagnostic" })
- vim.keymap.set("n", "<leader>e", vim.diagnostic.open_float, { desc = "open diagnostic float" })
- vim.keymap.set("n", "<leader>E", vim.diagnostic.setqflist, { desc = "qf diagnostic" })
-end
-
-return M
+vim.keymap.set("n", "]d", utils.diagnostic.goto_next, { desc = "next diagnostic" })
+vim.keymap.set("n", "[d", utils.diagnostic.goto_prev, { desc = "prev diagnostic" })
+vim.keymap.set("n", "<leader>e", vim.diagnostic.open_float, { desc = "open diagnostic float" })
+vim.keymap.set("n", "<leader>E", vim.diagnostic.setqflist, { desc = "qf diagnostic" })
diff --git a/nvim/.config/nvim/lua/tobyvin/keymaps.lua b/nvim/.config/nvim/lua/tobyvin/keymaps.lua
index 33fa7b0..63f5dcb 100644
--- a/nvim/.config/nvim/lua/tobyvin/keymaps.lua
+++ b/nvim/.config/nvim/lua/tobyvin/keymaps.lua
@@ -1,35 +1,24 @@
local utils = require("tobyvin.utils")
-local M = {}
-M.setup = function()
- for i = 1, 999, 1 do
- local lhs = string.format("%sgb", i)
- local desc = string.format("buffer %s", i)
- local rhs = string.format("<cmd>%sb<cr>", i)
- vim.keymap.set("n", lhs, rhs, { desc = desc })
+local hover = function()
+ if utils.hover.open() then
+ -- Fix for diagnostics immediately overriding hover window
+ vim.api.nvim_command("set eventignore=CursorHold")
+ vim.api.nvim_command('autocmd CursorMoved <buffer> ++once set eventignore=""')
+ return "<Ignore>"
end
-
- vim.keymap.set("n", "gn", "<cmd>bnext<cr>", { desc = "bnext" })
- vim.keymap.set("n", "gp", "<cmd>bprev<cr>", { desc = "bprev" })
- vim.keymap.set("n", "gb", utils.buffer.bselect, { desc = "bselect" })
- vim.keymap.set("n", "gk", utils.documentation.open, { desc = "documentation" })
- vim.keymap.set("n", "K", function()
- if utils.hover.open() then
- -- Fix for diagnostics immediately overriding hover window
- vim.api.nvim_command("set eventignore=CursorHold")
- vim.api.nvim_command('autocmd CursorMoved <buffer> ++once set eventignore=""')
- return "<Ignore>"
- end
- return "K"
- end, { expr = true, desc = "hover" })
-
- vim.keymap.set("n", "<leader>c", utils.buffer.bdelete, { desc = "bdelete" })
- vim.keymap.set("n", "<C-u>", "<C-u>zz", { desc = "up half page and center" })
- vim.keymap.set("n", "<C-d>", "<C-d>zz", { desc = "down half page and center" })
- vim.keymap.set("n", "<a-j>", "<CMD>m +1<CR>", { desc = "move line down" })
- vim.keymap.set("n", "<a-k>", "<CMD>m -2<CR>", { desc = "move line up" })
- vim.keymap.set("v", "<a-k>", "<CMD>m '<-2<CR>gv=gv", { desc = "move selection up" })
- vim.keymap.set("v", "<a-j>", "<CMD>m '>+1<CR>gv=gv", { desc = "move selection down" })
+ return "K"
end
-return M
+vim.keymap.set("n", "gn", "<cmd>bnext<cr>", { desc = "bnext" })
+vim.keymap.set("n", "gp", "<cmd>bprev<cr>", { desc = "bprev" })
+vim.keymap.set("n", "gb", utils.buffer.bselect, { desc = "bselect" })
+vim.keymap.set("n", "gk", utils.documentation.open, { desc = "documentation" })
+vim.keymap.set("n", "K", hover, { expr = true, desc = "hover" })
+vim.keymap.set("n", "<leader>c", utils.buffer.bdelete, { desc = "bdelete" })
+vim.keymap.set("n", "<C-u>", "<C-u>zz", { desc = "up half page and center" })
+vim.keymap.set("n", "<C-d>", "<C-d>zz", { desc = "down half page and center" })
+vim.keymap.set("n", "<a-j>", "<CMD>m +1<CR>", { desc = "move line down" })
+vim.keymap.set("n", "<a-k>", "<CMD>m -2<CR>", { desc = "move line up" })
+vim.keymap.set("v", "<a-k>", "<CMD>m '<-2<CR>gv=gv", { desc = "move selection up" })
+vim.keymap.set("v", "<a-j>", "<CMD>m '>+1<CR>gv=gv", { desc = "move selection down" })
diff --git a/nvim/.config/nvim/lua/tobyvin/lsp.lua b/nvim/.config/nvim/lua/tobyvin/lsp.lua
index 2d60f82..733c589 100644
--- a/nvim/.config/nvim/lua/tobyvin/lsp.lua
+++ b/nvim/.config/nvim/lua/tobyvin/lsp.lua
@@ -1,24 +1,17 @@
-local lsp = {
+vim.api.nvim_create_autocmd("LspAttach", {
+ group = vim.api.nvim_create_augroup("tobyvin_lsp", { clear = true }),
+ desc = "lsp",
+ callback = function(args)
+ local client = vim.lsp.get_client_by_id(args.data.client_id)
+ vim.api.nvim_exec_autocmds("User", { pattern = "LspAttach", data = { client_id = client.id } })
+ end,
+})
+
+require("tobyvin.lsp.handlers")
+require("tobyvin.lsp.highlighting")
+require("tobyvin.lsp.formatting")
+
+return {
default_config = {},
configs = require("tobyvin.lsp.configs"),
- handlers = require("tobyvin.lsp.handlers"),
- highlighting = require("tobyvin.lsp.highlighting"),
- formatting = require("tobyvin.lsp.formatting"),
}
-
-lsp.setup = function()
- lsp.handlers.setup()
- lsp.highlighting.setup()
- lsp.formatting.setup()
-
- vim.api.nvim_create_autocmd("LspAttach", {
- group = vim.api.nvim_create_augroup("tobyvin_lsp", { clear = true }),
- desc = "lsp",
- callback = function(args)
- local client = vim.lsp.get_client_by_id(args.data.client_id)
- vim.api.nvim_exec_autocmds("User", { pattern = "LspAttach", data = { client_id = client.id } })
- end,
- })
-end
-
-return lsp
diff --git a/nvim/.config/nvim/lua/tobyvin/lsp/formatting.lua b/nvim/.config/nvim/lua/tobyvin/lsp/formatting.lua
index c08fe99..736de75 100644
--- a/nvim/.config/nvim/lua/tobyvin/lsp/formatting.lua
+++ b/nvim/.config/nvim/lua/tobyvin/lsp/formatting.lua
@@ -1,28 +1,22 @@
-local formatting = {}
+vim.api.nvim_create_autocmd("LspAttach", {
+ group = vim.api.nvim_create_augroup("tobyvin_lsp_formatting", { clear = true }),
+ desc = "setup lsp formatting",
+ callback = function(args)
+ local bufnr = args.buf
+ local client = vim.lsp.get_client_by_id(args.data.client_id)
+ if client.name == "sumneko_lua" then
+ return
+ end
-formatting.setup = function()
- vim.api.nvim_create_autocmd("LspAttach", {
- group = vim.api.nvim_create_augroup("tobyvin_lsp_formatting", { clear = true }),
- desc = "setup lsp formatting",
- callback = function(args)
- local bufnr = args.buf
- local client = vim.lsp.get_client_by_id(args.data.client_id)
- if client.name == "sumneko_lua" then
- return
- end
+ if client.server_capabilities.documentFormattingProvider then
+ vim.api.nvim_buf_set_option(bufnr, "formatexpr", "v:lua.vim.lsp.formatexpr()")
+ vim.api.nvim_buf_create_user_command(bufnr, "Format", vim.lsp.buf.format, { nargs = "*" })
+ vim.keymap.set("n", "<leader>lf", vim.lsp.buf.format, { desc = "format", buffer = bufnr })
+ end
- if client.server_capabilities.documentFormattingProvider then
- vim.api.nvim_buf_set_option(bufnr, "formatexpr", "v:lua.vim.lsp.formatexpr()")
- vim.api.nvim_buf_create_user_command(bufnr, "Format", vim.lsp.buf.format, { nargs = "*" })
- vim.keymap.set("n", "<leader>lf", vim.lsp.buf.format, { desc = "format", buffer = bufnr })
- end
-
- if client.server_capabilities.documentRangeFormattingProvider then
- vim.api.nvim_buf_create_user_command(bufnr, "FormatRange", vim.lsp.buf.format, { nargs = "*" })
- vim.keymap.set("n", "<leader>lf", vim.lsp.buf.format, { desc = "format range", buffer = bufnr })
- end
- end,
- })
-end
-
-return formatting
+ if client.server_capabilities.documentRangeFormattingProvider then
+ vim.api.nvim_buf_create_user_command(bufnr, "FormatRange", vim.lsp.buf.format, { nargs = "*" })
+ vim.keymap.set("n", "<leader>lf", vim.lsp.buf.format, { desc = "format range", buffer = bufnr })
+ end
+ end,
+})
diff --git a/nvim/.config/nvim/lua/tobyvin/lsp/handlers.lua b/nvim/.config/nvim/lua/tobyvin/lsp/handlers.lua
index d3e5378..89101b5 100644
--- a/nvim/.config/nvim/lua/tobyvin/lsp/handlers.lua
+++ b/nvim/.config/nvim/lua/tobyvin/lsp/handlers.lua
@@ -1,5 +1,4 @@
local utils = require("tobyvin.utils")
-local M = {}
local location_handler = vim.lsp.handlers["textDocument/definition"]
local definition_handler = function(err, result, ctx, config)
@@ -18,37 +17,33 @@ local show_message = function(_, result, ctx)
})
end
-M.setup = function()
- local hover_ops = { border = "single" }
- vim.lsp.handlers["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, hover_ops)
- vim.lsp.handlers["textDocument/signatureHelp"] = vim.lsp.with(vim.lsp.handlers.signature_help, hover_ops)
- vim.lsp.handlers["textDocument/definition"] = definition_handler
- vim.lsp.handlers["window/showMessage"] = show_message
-
- vim.api.nvim_create_autocmd("LspAttach", {
- group = vim.api.nvim_create_augroup("tobyvin_lsp_handlers", { clear = true }),
- desc = "setup lsp handlers",
- callback = function(args)
- local bufnr = args.buf
- local client = vim.lsp.get_client_by_id(args.data.client_id)
- if client.server_capabilities["definitionProvider"] then
- vim.bo[bufnr].tagfunc = "v:lua.vim.lsp.tagfunc"
- end
-
- utils.hover.register(vim.lsp.buf.hover, { desc = "lsp", buffer = bufnr, priority = 1 })
-
- vim.keymap.set("n", "<C-k>", vim.lsp.buf.signature_help, { desc = "signature help", buffer = bufnr })
- vim.keymap.set("n", "gd", vim.lsp.buf.definition, { desc = "definition", buffer = bufnr })
- vim.keymap.set("n", "gD", vim.lsp.buf.declaration, { desc = "declaration", buffer = bufnr })
- vim.keymap.set("n", "gt", vim.lsp.buf.type_definition, { desc = "type definition", buffer = bufnr })
- vim.keymap.set("n", "gi", vim.lsp.buf.implementation, { desc = "implementation", buffer = bufnr })
- vim.keymap.set("n", "gr", vim.lsp.buf.references, { desc = "references", buffer = bufnr })
-
- vim.keymap.set("n", "<leader>lr", vim.lsp.buf.rename, { desc = "rename", buffer = bufnr })
- vim.keymap.set("n", "<leader>la", vim.lsp.buf.code_action, { desc = "code action", buffer = bufnr })
- vim.keymap.set("n", "<leader>ll", vim.lsp.codelens.run, { desc = "codelens", buffer = bufnr })
- end,
- })
-end
-
-return M
+local hover_ops = { border = "single" }
+vim.lsp.handlers["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, hover_ops)
+vim.lsp.handlers["textDocument/signatureHelp"] = vim.lsp.with(vim.lsp.handlers.signature_help, hover_ops)
+vim.lsp.handlers["textDocument/definition"] = definition_handler
+vim.lsp.handlers["window/showMessage"] = show_message
+
+vim.api.nvim_create_autocmd("LspAttach", {
+ group = vim.api.nvim_create_augroup("tobyvin_lsp_handlers", { clear = true }),
+ desc = "setup lsp handlers",
+ callback = function(args)
+ local bufnr = args.buf
+ local client = vim.lsp.get_client_by_id(args.data.client_id)
+ if client.server_capabilities["definitionProvider"] then
+ vim.bo[bufnr].tagfunc = "v:lua.vim.lsp.tagfunc"
+ end
+
+ utils.hover.register(vim.lsp.buf.hover, { desc = "lsp", buffer = bufnr, priority = 1 })
+
+ vim.keymap.set("n", "<C-k>", vim.lsp.buf.signature_help, { desc = "signature help", buffer = bufnr })
+ vim.keymap.set("n", "gd", vim.lsp.buf.definition, { desc = "definition", buffer = bufnr })
+ vim.keymap.set("n", "gD", vim.lsp.buf.declaration, { desc = "declaration", buffer = bufnr })
+ vim.keymap.set("n", "gt", vim.lsp.buf.type_definition, { desc = "type definition", buffer = bufnr })
+ vim.keymap.set("n", "gi", vim.lsp.buf.implementation, { desc = "implementation", buffer = bufnr })
+ vim.keymap.set("n", "gr", vim.lsp.buf.references, { desc = "references", buffer = bufnr })
+
+ vim.keymap.set("n", "<leader>lr", vim.lsp.buf.rename, { desc = "rename", buffer = bufnr })
+ vim.keymap.set("n", "<leader>la", vim.lsp.buf.code_action, { desc = "code action", buffer = bufnr })
+ vim.keymap.set("n", "<leader>ll", vim.lsp.codelens.run, { desc = "codelens", buffer = bufnr })
+ end,
+})
diff --git a/nvim/.config/nvim/lua/tobyvin/lsp/highlighting.lua b/nvim/.config/nvim/lua/tobyvin/lsp/highlighting.lua
index 89fce57..8073d62 100644
--- a/nvim/.config/nvim/lua/tobyvin/lsp/highlighting.lua
+++ b/nvim/.config/nvim/lua/tobyvin/lsp/highlighting.lua
@@ -1,32 +1,26 @@
-local M = {}
+vim.api.nvim_create_autocmd("LspAttach", {
+ group = vim.api.nvim_create_augroup("tobyvin_lsp_highlighting", { clear = true }),
+ desc = "setup lsp highlighting",
+ callback = function(args)
+ local bufnr = args.buf
+ local client = vim.lsp.get_client_by_id(args.data.client_id)
-M.setup = function()
- vim.api.nvim_create_autocmd("LspAttach", {
- group = vim.api.nvim_create_augroup("tobyvin_lsp_highlighting", { clear = true }),
- desc = "setup lsp highlighting",
- callback = function(args)
- local bufnr = args.buf
- local client = vim.lsp.get_client_by_id(args.data.client_id)
+ if client.server_capabilities.documentHighlightProvider then
+ local augroup_highlight = vim.api.nvim_create_augroup("DocumentHighlight", { clear = false })
- if client.server_capabilities.documentHighlightProvider then
- local augroup_highlight = vim.api.nvim_create_augroup("DocumentHighlight", { clear = false })
+ vim.api.nvim_create_autocmd({ "CursorHold", "CursorHoldI" }, {
+ group = augroup_highlight,
+ buffer = bufnr,
+ callback = vim.lsp.buf.document_highlight,
+ desc = "Highlight lsp references",
+ })
- vim.api.nvim_create_autocmd({ "CursorHold", "CursorHoldI" }, {
- group = augroup_highlight,
- buffer = bufnr,
- callback = vim.lsp.buf.document_highlight,
- desc = "Highlight lsp references",
- })
-
- vim.api.nvim_create_autocmd({ "CursorMoved", "CursorMovedI" }, {
- group = augroup_highlight,
- buffer = bufnr,
- callback = vim.lsp.buf.clear_references,
- desc = "Clear highlighted references",
- })
- end
- end,
- })
-end
-
-return M
+ vim.api.nvim_create_autocmd({ "CursorMoved", "CursorMovedI" }, {
+ group = augroup_highlight,
+ buffer = bufnr,
+ callback = vim.lsp.buf.clear_references,
+ desc = "Clear highlighted references",
+ })
+ end
+ end,
+})
diff --git a/nvim/.config/nvim/lua/tobyvin/options.lua b/nvim/.config/nvim/lua/tobyvin/options.lua
index 4461393..893da4f 100644
--- a/nvim/.config/nvim/lua/tobyvin/options.lua
+++ b/nvim/.config/nvim/lua/tobyvin/options.lua
@@ -1,89 +1,83 @@
-local M = {}
+vim.g.mapleader = " "
+vim.g.netrw_keepdir = 0
+vim.g.netrw_preview = 1
+vim.g.netrw_banner = 0
+vim.g.netrw_altv = "spr"
+vim.g.netrw_winsize = 30
+vim.g.netrw_usetab = 1
+vim.g.netrw_altfile = 1
-M.setup = function()
- vim.g.mapleader = " "
- vim.g.netrw_keepdir = 0
- vim.g.netrw_preview = 1
- vim.g.netrw_banner = 0
- vim.g.netrw_altv = "spr"
- vim.g.netrw_winsize = 30
- vim.g.netrw_usetab = 1
- vim.g.netrw_altfile = 1
-
- vim.opt.termguicolors = true
- vim.opt.background = "dark"
- vim.opt.laststatus = 3
- vim.opt.undofile = true
- vim.opt.swapfile = false
- vim.opt.clipboard = vim.opt.clipboard + "unnamedplus"
- vim.opt.shortmess = vim.opt.shortmess + "c"
- vim.opt.wrap = false
- vim.opt.showmatch = true
- vim.opt.cursorline = true
- vim.opt.number = true
- vim.opt.relativenumber = true
- vim.opt.incsearch = true
- vim.opt.hlsearch = true
- vim.opt.ignorecase = true
- vim.opt.smartcase = true
- vim.opt.scrolloff = 10
- vim.opt.sidescrolloff = 2
- vim.opt.backspace = { "indent", "start", "eol" }
- vim.opt.mouse = "a"
- vim.opt.updatetime = 500
- vim.opt.timeoutlen = 1000
- vim.opt.textwidth = 100
- vim.opt.tabstop = 4
- vim.opt.softtabstop = 0
- vim.opt.shiftwidth = 0
- vim.opt.smarttab = true
- vim.opt.expandtab = true
- vim.opt.autoindent = true
- vim.opt.breakindent = true
- vim.opt.showbreak = string.rep(" ", 3) -- Make it so that long lines wrap smartly
- vim.opt.linebreak = true
- vim.opt.shiftround = true
- vim.opt.splitbelow = true
- vim.opt.splitright = true
- vim.opt.laststatus = 2
- vim.opt.colorcolumn = "+0"
- vim.opt.signcolumn = "yes:1"
- vim.opt.hidden = true
- vim.opt.inccommand = "split"
- vim.opt.shell = "zsh"
- vim.opt.wildignore = vim.opt.wildignore + { "*.o", "*.rej", "*.so" }
- vim.opt.completeopt = { "menuone", "noselect", "noinsert" }
- vim.opt.spelllang = "en_us"
- vim.opt.spellfile = vim.fn.stdpath("config") .. "/spell/en.utf-8.add"
- vim.opt.spelloptions = { "camel", "noplainbuffer" }
- vim.opt.listchars = {
- eol = "↵",
- tab = "»-",
- trail = "·",
- extends = "…",
- precedes = "…",
- }
- vim.opt.sessionoptions = {
- "blank",
- "buffers",
- "curdir",
- "folds",
- "help",
- "tabpages",
- "winsize",
- "winpos",
- "terminal",
- }
- vim.opt.formatoptions = vim.opt.formatoptions
- - "a" -- Auto formatting is BAD.
- - "t" -- Don't auto format my code. I got linters for that.
- + "c" -- In general, I like it when comments respect textwidth
- + "q" -- Allow formatting comments w/ gq
- - "o" -- O and o, don't continue comments
- + "r" -- But do continue when pressing enter.
- + "n" -- Indent past the formatlistpat, not underneath it.
- + "j" -- Auto-remove comments if possible.
- - "2" -- I'm not in gradeschool anymore
-end
-
-return M
+vim.opt.termguicolors = true
+vim.opt.background = "dark"
+vim.opt.laststatus = 3
+vim.opt.undofile = true
+vim.opt.swapfile = false
+vim.opt.clipboard = vim.opt.clipboard + "unnamedplus"
+vim.opt.shortmess = vim.opt.shortmess + "c"
+vim.opt.wrap = false
+vim.opt.showmatch = true
+vim.opt.cursorline = true
+vim.opt.number = true
+vim.opt.relativenumber = true
+vim.opt.incsearch = true
+vim.opt.hlsearch = true
+vim.opt.ignorecase = true
+vim.opt.smartcase = true
+vim.opt.scrolloff = 10
+vim.opt.sidescrolloff = 2
+vim.opt.backspace = { "indent", "start", "eol" }
+vim.opt.mouse = "a"
+vim.opt.updatetime = 500
+vim.opt.timeoutlen = 1000
+vim.opt.textwidth = 100
+vim.opt.tabstop = 4
+vim.opt.softtabstop = 0
+vim.opt.shiftwidth = 0
+vim.opt.smarttab = true
+vim.opt.expandtab = true
+vim.opt.autoindent = true
+vim.opt.breakindent = true
+vim.opt.showbreak = string.rep(" ", 3) -- Make it so that long lines wrap smartly
+vim.opt.linebreak = true
+vim.opt.shiftround = true
+vim.opt.splitbelow = true
+vim.opt.splitright = true
+vim.opt.laststatus = 2
+vim.opt.colorcolumn = "+0"
+vim.opt.signcolumn = "yes:1"
+vim.opt.hidden = true
+vim.opt.inccommand = "split"
+vim.opt.shell = "zsh"
+vim.opt.wildignore = vim.opt.wildignore + { "*.o", "*.rej", "*.so" }
+vim.opt.completeopt = { "menuone", "noselect", "noinsert" }
+vim.opt.spelllang = "en_us"
+vim.opt.spellfile = vim.fn.stdpath("config") .. "/spell/en.utf-8.add"
+vim.opt.spelloptions = { "camel", "noplainbuffer" }
+vim.opt.listchars = {
+ eol = "↵",
+ tab = "»-",
+ trail = "·",
+ extends = "…",
+ precedes = "…",
+}
+vim.opt.sessionoptions = {
+ "blank",
+ "buffers",
+ "curdir",
+ "folds",
+ "help",
+ "tabpages",
+ "winsize",
+ "winpos",
+ "terminal",
+}
+vim.opt.formatoptions = vim.opt.formatoptions
+ - "a" -- Auto formatting is BAD.
+ - "t" -- Don't auto format my code. I got linters for that.
+ + "c" -- In general, I like it when comments respect textwidth
+ + "q" -- Allow formatting comments w/ gq
+ - "o" -- O and o, don't continue comments
+ + "r" -- But do continue when pressing enter.
+ + "n" -- Indent past the formatlistpat, not underneath it.
+ + "j" -- Auto-remove comments if possible.
+ - "2" -- I'm not in gradeschool anymore
diff --git a/nvim/.config/nvim/lua/tobyvin/plugins.lua b/nvim/.config/nvim/lua/tobyvin/plugins.lua
index ae69d31..dca8de3 100644
--- a/nvim/.config/nvim/lua/tobyvin/plugins.lua
+++ b/nvim/.config/nvim/lua/tobyvin/plugins.lua
@@ -1,6 +1,10 @@
-local M = {}
+local status_ok, packer = pcall(require, "packer")
+if not status_ok then
+ vim.notify("Failed to load module 'packer'", vim.log.levels.ERROR)
+ return
+end
-M.ensure_packer = function()
+local ensure_packer = function()
local install_path = vim.fn.stdpath("data") .. "/site/pack/packer/start/packer.nvim"
if vim.fn.empty(vim.fn.glob(install_path)) > 0 then
vim.fn.system({ "git", "clone", "--depth", "1", "https://github.com/wbthomason/packer.nvim", install_path })
@@ -10,7 +14,10 @@ M.ensure_packer = function()
return false
end
-M.try_local = function(opts)
+local packer_bootstrap = ensure_packer()
+
+---@diagnostic disable-next-line: unused-local, unused-function
+local try_local = function(opts)
if type(opts) == "string" then
opts = { opts }
end
@@ -21,7 +28,7 @@ M.try_local = function(opts)
return opts
end
-M.plugins = function(use)
+local plugins = function(use)
use("wbthomason/packer.nvim")
use("lewis6991/impatient.nvim")
@@ -30,7 +37,7 @@ M.plugins = function(use)
"goolord/alpha-nvim",
requires = { "kyazdani42/nvim-web-devicons" },
config = function()
- require("tobyvin.plugins.alpha").setup()
+ require("tobyvin.plugins.alpha")
end,
})
@@ -38,35 +45,35 @@ M.plugins = function(use)
"rcarriga/nvim-notify",
event = "VimEnter",
config = function()
- require("tobyvin.plugins.notify").setup()
+ require("tobyvin.plugins.notify")
end,
})
use({
"stevearc/dressing.nvim",
config = function()
- require("tobyvin.plugins.dressing").setup()
+ require("tobyvin.plugins.dressing")
end,
})
use({
"ellisonleao/gruvbox.nvim",
config = function()
- require("tobyvin.plugins.gruvbox").setup()
+ require("tobyvin.plugins.gruvbox")
end,
})
use({
"folke/tokyonight.nvim",
config = function()
- require("tobyvin.plugins.tokyonight").setup()
+ require("tobyvin.plugins.tokyonight")
end,
})
use({
"Shatur/neovim-session-manager",
config = function()
- require("tobyvin.plugins.session_manager").setup()
+ require("tobyvin.plugins.session_manager")
end,
})
@@ -79,7 +86,7 @@ M.plugins = function(use)
"jayp0521/mason-nvim-dap.nvim",
},
config = function()
- require("tobyvin.plugins.mason").setup()
+ require("tobyvin.plugins.mason")
end,
})
@@ -89,7 +96,7 @@ M.plugins = function(use)
"nvim-lua/plenary.nvim",
},
config = function()
- require("tobyvin.plugins.null-ls").setup()
+ require("tobyvin.plugins.null-ls")
end,
})
@@ -101,7 +108,7 @@ M.plugins = function(use)
"jose-elias-alvarez/null-ls.nvim",
},
config = function()
- require("tobyvin.plugins.crates").setup()
+ require("tobyvin.plugins.crates")
end,
})
@@ -126,7 +133,7 @@ M.plugins = function(use)
"kdheepak/cmp-latex-symbols",
},
config = function()
- require("tobyvin.plugins.cmp").setup()
+ require("tobyvin.plugins.cmp")
end,
})
@@ -134,7 +141,7 @@ M.plugins = function(use)
"petertriho/cmp-git",
requires = "nvim-lua/plenary.nvim",
config = function()
- require("tobyvin.plugins.cmp-git").setup()
+ require("tobyvin.plugins.cmp-git")
end,
})
@@ -145,21 +152,21 @@ M.plugins = function(use)
"nvim-lua/plenary.nvim",
},
config = function()
- require("tobyvin.plugins.cmp-npm").setup()
+ require("tobyvin.plugins.cmp-npm")
end,
})
use({
"onsails/lspkind-nvim",
config = function()
- require("tobyvin.plugins.lspkind").setup()
+ require("tobyvin.plugins.lspkind")
end,
})
use({
"folke/neodev.nvim",
config = function()
- require("tobyvin.plugins.neodev").setup()
+ require("tobyvin.plugins.neodev")
end,
})
@@ -170,7 +177,7 @@ M.plugins = function(use)
"nvim-lua/plenary.nvim",
},
config = function()
- require("tobyvin.plugins.rust-tools").setup()
+ require("tobyvin.plugins.rust-tools")
end,
})
@@ -181,7 +188,7 @@ M.plugins = function(use)
"cmp-nvim-lsp",
},
config = function()
- require("tobyvin.plugins.lspconfig").setup()
+ require("tobyvin.plugins.lspconfig")
end,
})
@@ -193,7 +200,7 @@ M.plugins = function(use)
},
ft = "qf",
config = function()
- require("tobyvin.plugins.nvim-bqf").setup()
+ require("tobyvin.plugins.nvim-bqf")
end,
})
@@ -208,14 +215,14 @@ M.plugins = function(use)
"nvim-telescope/telescope-dap.nvim",
},
config = function()
- require("tobyvin.plugins.telescope").setup()
+ require("tobyvin.plugins.telescope")
end,
})
use({
"gbprod/yanky.nvim",
config = function()
- require("tobyvin.plugins.yanky").setup()
+ require("tobyvin.plugins.yanky")
end,
})
@@ -226,7 +233,7 @@ M.plugins = function(use)
"molleweide/LuaSnip-snippets.nvim",
},
config = function()
- require("tobyvin.plugins.luasnip").setup()
+ require("tobyvin.plugins.luasnip")
end,
})
@@ -241,7 +248,7 @@ M.plugins = function(use)
"mfussenegger/nvim-ts-hint-textobject",
},
config = function()
- require("tobyvin.plugins.treesitter").setup()
+ require("tobyvin.plugins.treesitter")
end,
})
@@ -250,7 +257,7 @@ M.plugins = function(use)
use({
"lukas-reineke/indent-blankline.nvim",
config = function()
- require("tobyvin.plugins.indent_blankline").setup()
+ require("tobyvin.plugins.indent_blankline")
end,
})
@@ -268,14 +275,14 @@ M.plugins = function(use)
"SmiteshP/nvim-navic",
},
config = function()
- require("tobyvin.plugins.lualine").setup()
+ require("tobyvin.plugins.lualine")
end,
})
use({
"j-hui/fidget.nvim",
config = function()
- require("tobyvin.plugins.fidget").setup()
+ require("tobyvin.plugins.fidget")
end,
})
@@ -283,7 +290,7 @@ M.plugins = function(use)
"SmiteshP/nvim-navic",
requires = "onsails/lspkind-nvim",
config = function()
- require("tobyvin.plugins.nvim-navic").setup()
+ require("tobyvin.plugins.nvim-navic")
end,
})
@@ -291,7 +298,7 @@ M.plugins = function(use)
"TimUntersberger/neogit",
requires = { "sindrets/diffview.nvim" },
config = function()
- require("tobyvin.plugins.neogit").setup()
+ require("tobyvin.plugins.neogit")
end,
})
@@ -302,14 +309,14 @@ M.plugins = function(use)
"kyazdani42/nvim-web-devicons",
},
config = function()
- require("tobyvin.plugins.diffview").setup()
+ require("tobyvin.plugins.diffview")
end,
})
use({
"akinsho/git-conflict.nvim",
config = function()
- require("tobyvin.plugins.git-conflict").setup()
+ require("tobyvin.plugins.git-conflict")
end,
})
@@ -317,7 +324,7 @@ M.plugins = function(use)
"lewis6991/gitsigns.nvim",
requires = "nvim-lua/plenary.nvim",
config = function()
- require("tobyvin.plugins.gitsigns").setup()
+ require("tobyvin.plugins.gitsigns")
end,
})
@@ -331,7 +338,7 @@ M.plugins = function(use)
"nvim-lua/plenary.nvim",
},
config = function()
- require("tobyvin.plugins.undotree").setup()
+ require("tobyvin.plugins.undotree")
end,
})
@@ -343,7 +350,7 @@ M.plugins = function(use)
"leoluz/nvim-dap-go",
},
config = function()
- require("tobyvin.plugins.dap").setup()
+ require("tobyvin.plugins.dap")
end,
})
@@ -354,31 +361,21 @@ M.plugins = function(use)
"nvim-treesitter/nvim-treesitter",
},
config = function()
- require("tobyvin.plugins.nvim-dap-virtual-text").setup()
- end,
- })
-
- use({
- "rcarriga/nvim-dap-ui",
- requires = {
- "mfussenegger/nvim-dap",
- },
- config = function()
- require("tobyvin.plugins.dapui").setup()
+ require("tobyvin.plugins.nvim-dap-virtual-text")
end,
})
use({
"ur4ltz/surround.nvim",
config = function()
- require("tobyvin.plugins.surround").setup()
+ require("tobyvin.plugins.surround")
end,
})
use({
"numToStr/Comment.nvim",
config = function()
- require("tobyvin.plugins.comment").setup()
+ require("tobyvin.plugins.comment")
end,
})
@@ -401,37 +398,26 @@ M.plugins = function(use)
})
end
-M.setup = function()
- local packer_bootstrap = M.ensure_packer()
- local status_ok, packer = pcall(require, "packer")
- if not status_ok then
- vim.notify("Failed to load module 'packer'", vim.log.levels.ERROR)
- return
- end
-
- vim.keymap.set("n", "<leader>pc", packer.compile, { desc = "compile" })
- vim.keymap.set("n", "<leader>pC", packer.clean, { desc = "clean" })
- vim.keymap.set("n", "<leader>pi", packer.install, { desc = "install" })
- vim.keymap.set("n", "<leader>pp", packer.profile_output, { desc = "profile" })
- vim.keymap.set("n", "<leader>ps", packer.sync, { desc = "sync" })
- vim.keymap.set("n", "<leader>pu", packer.update, { desc = "update" })
-
- return packer.startup({
- function(...)
- M.plugins(...)
- if packer_bootstrap then
- packer.sync()
- end
- end,
- config = {
- display = {
- open_fn = function()
- return require("packer.util").float({ border = "single" })
- end,
- },
- autoremove = true,
+vim.keymap.set("n", "<leader>pc", packer.compile, { desc = "compile" })
+vim.keymap.set("n", "<leader>pC", packer.clean, { desc = "clean" })
+vim.keymap.set("n", "<leader>pi", packer.install, { desc = "install" })
+vim.keymap.set("n", "<leader>pp", packer.profile_output, { desc = "profile" })
+vim.keymap.set("n", "<leader>ps", packer.sync, { desc = "sync" })
+vim.keymap.set("n", "<leader>pu", packer.update, { desc = "update" })
+
+return packer.startup({
+ function(...)
+ plugins(...)
+ if packer_bootstrap then
+ packer.sync()
+ end
+ end,
+ config = {
+ display = {
+ open_fn = function()
+ return require("packer.util").float({ border = "single" })
+ end,
},
- })
-end
-
-return M
+ autoremove = true,
+ },
+})
diff --git a/nvim/.config/nvim/lua/tobyvin/plugins/alpha.lua b/nvim/.config/nvim/lua/tobyvin/plugins/alpha.lua
index 20ca68e..585da4d 100644
--- a/nvim/.config/nvim/lua/tobyvin/plugins/alpha.lua
+++ b/nvim/.config/nvim/lua/tobyvin/plugins/alpha.lua
@@ -125,139 +125,137 @@ M.actions = function()
return M.actions_cache
end
-M.setup = function()
- local status_ok, alpha = pcall(require, "alpha")
- if not status_ok then
- vim.notify("Failed to load module 'alpha'", vim.log.levels.ERROR)
- return
- end
+local status_ok, alpha = pcall(require, "alpha")
+if not status_ok then
+ vim.notify("Failed to load module 'alpha'", vim.log.levels.ERROR)
+ return
+end
- alpha.keymaps_element.button = function(el, _, state)
- if el.opts and el.opts.keymap then
- if type(el.opts.keymap[1]) == "table" then
- for _, map in el.opts.keymap do
- map[4].buffer = state.buffer
- vim.keymap.set(unpack(map))
- end
- else
- local map = el.opts.keymap
+alpha.keymaps_element.button = function(el, _, state)
+ if el.opts and el.opts.keymap then
+ if type(el.opts.keymap[1]) == "table" then
+ for _, map in el.opts.keymap do
map[4].buffer = state.buffer
vim.keymap.set(unpack(map))
end
+ else
+ local map = el.opts.keymap
+ map[4].buffer = state.buffer
+ vim.keymap.set(unpack(map))
end
end
+end
- local fortune = require("alpha.fortune")
+local fortune = require("alpha.fortune")
- local logo = {
- type = "text",
- val = {
- " ",
- " ███╗ ██╗███████╗ ██████╗ ██╗ ██╗██╗███╗ ███╗ ",
- " ████╗ ██║██╔════╝██╔═══██╗██║ ██║██║████╗ ████║ ",
- " ██╔██╗ ██║█████╗ ██║ ██║██║ ██║██║██╔████╔██║ ",
- " ██║╚██╗██║██╔══╝ ██║ ██║╚██╗ ██╔╝██║██║╚██╔╝██║ ",
- " ██║ ╚████║███████╗╚██████╔╝ ╚████╔╝ ██║██║ ╚═╝ ██║ ",
- " ╚═╝ ╚═══╝╚══════╝ ╚═════╝ ╚═══╝ ╚═╝╚═╝ ╚═╝ ",
- },
- opts = {
- position = M.position,
- hl = "DevIconVim",
- },
- }
+local logo = {
+ type = "text",
+ val = {
+ " ",
+ " ███╗ ██╗███████╗ ██████╗ ██╗ ██╗██╗███╗ ███╗ ",
+ " ████╗ ██║██╔════╝██╔═══██╗██║ ██║██║████╗ ████║ ",
+ " ██╔██╗ ██║█████╗ ██║ ██║██║ ██║██║██╔████╔██║ ",
+ " ██║╚██╗██║██╔══╝ ██║ ██║╚██╗ ██╔╝██║██║╚██╔╝██║ ",
+ " ██║ ╚████║███████╗╚██████╔╝ ╚████╔╝ ██║██║ ╚═╝ ██║ ",
+ " ╚═╝ ╚═══╝╚══════╝ ╚═════╝ ╚═══╝ ╚═╝╚═╝ ╚═╝ ",
+ },
+ opts = {
+ position = M.position,
+ hl = "DevIconVim",
+ },
+}
- local function info_value()
- local total_plugins = #vim.tbl_keys(packer_plugins)
- local v = vim.version()
- return string.format("VIM: v%d.%d.%d PLUGINS: %d", v.major, v.minor, v.patch, total_plugins)
- end
+local function info_value()
+ local total_plugins = #vim.tbl_keys(packer_plugins)
+ local v = vim.F.if_nil(vim.version(), {})
+ return string.format("VIM: v%d.%d.%d PLUGINS: %d", v.major, v.minor, v.patch, total_plugins)
+end
- local info = {
- type = "text",
- val = info_value(),
- opts = {
- hl = "DevIconVim",
- position = M.position,
- },
- }
+local info = {
+ type = "text",
+ val = info_value(),
+ opts = {
+ hl = "DevIconVim",
+ position = M.position,
+ },
+}
- local message = {
- type = "text",
- val = fortune({ max_width = M.width }),
- opts = {
- position = M.position,
- hl = "Statement",
- },
- }
+local message = {
+ type = "text",
+ val = fortune({ max_width = M.width }),
+ opts = {
+ position = M.position,
+ hl = "Statement",
+ },
+}
- local header = {
- type = "group",
- val = {
- logo,
- info,
- message,
- },
- }
+local header = {
+ type = "group",
+ val = {
+ logo,
+ info,
+ message,
+ },
+}
- local mru = {
- type = "group",
- val = {
- {
- type = "text",
- val = M.format_string("MRU"),
- opts = {
- hl = "String",
- position = M.position,
- },
- },
- {
- type = "group",
- val = M.mru,
+local mru = {
+ type = "group",
+ val = {
+ {
+ type = "text",
+ val = M.format_string("MRU"),
+ opts = {
+ hl = "String",
+ position = M.position,
},
},
- }
+ {
+ type = "group",
+ val = M.mru,
+ },
+ },
+}
- local actions = {
- type = "group",
- val = {
- {
- type = "text",
- val = M.format_string("CMD"),
- opts = {
- hl = "String",
- position = M.position,
- },
- },
- {
- type = "group",
- val = M.actions,
+local actions = {
+ type = "group",
+ val = {
+ {
+ type = "text",
+ val = M.format_string("CMD"),
+ opts = {
+ hl = "String",
+ position = M.position,
},
},
- }
-
- local config = {
- layout = {
- header,
- { type = "padding", val = 1 },
- mru,
- { type = "padding", val = 1 },
- actions,
+ {
+ type = "group",
+ val = M.actions,
},
- }
+ },
+}
- alpha.setup(config)
+local config = {
+ layout = {
+ header,
+ { type = "padding", val = 1 },
+ mru,
+ { type = "padding", val = 1 },
+ actions,
+ },
+}
- vim.api.nvim_create_autocmd("User", {
- group = vim.api.nvim_create_augroup("alpha_user", { clear = true }),
- pattern = "BDeleteLast",
- callback = function(args)
- local bufnr = vim.F.if_nil(args.data.buf, args.buf)
- if vim.api.nvim_buf_get_option(bufnr, "filetype") ~= "alpha" then
- alpha.start(false)
- end
- end,
- desc = "Run Alpha when last buffer closed",
- })
-end
+alpha.setup(config)
+
+vim.api.nvim_create_autocmd("User", {
+ group = vim.api.nvim_create_augroup("alpha_user", { clear = true }),
+ pattern = "BDeleteLast",
+ callback = function(args)
+ local bufnr = vim.F.if_nil(args.data.buf, args.buf)
+ if vim.api.nvim_buf_get_option(bufnr, "filetype") ~= "alpha" then
+ alpha.start(false)
+ end
+ end,
+ desc = "Run Alpha when last buffer closed",
+})
return M
diff --git a/nvim/.config/nvim/lua/tobyvin/plugins/cmp-git.lua b/nvim/.config/nvim/lua/tobyvin/plugins/cmp-git.lua
index 04cff8b..44cb82f 100644
--- a/nvim/.config/nvim/lua/tobyvin/plugins/cmp-git.lua
+++ b/nvim/.config/nvim/lua/tobyvin/plugins/cmp-git.lua
@@ -1,13 +1,7 @@
-local M = {}
-
-M.setup = function()
- local status_ok, cmp_git = pcall(require, "cmp_git")
- if not status_ok then
- vim.notify("Failed to load module 'cmp_git'", vim.log.levels.ERROR)
- return
- end
-
- cmp_git.setup()
+local status_ok, cmp_git = pcall(require, "cmp_git")
+if not status_ok then
+ vim.notify("Failed to load module 'cmp_git'", vim.log.levels.ERROR)
+ return
end
-return M
+cmp_git.setup()
diff --git a/nvim/.config/nvim/lua/tobyvin/plugins/cmp-npm.lua b/nvim/.config/nvim/lua/tobyvin/plugins/cmp-npm.lua
index 58e428b..3205ba0 100644
--- a/nvim/.config/nvim/lua/tobyvin/plugins/cmp-npm.lua
+++ b/nvim/.config/nvim/lua/tobyvin/plugins/cmp-npm.lua
@@ -1,13 +1,7 @@
-local M = {}
-
-M.setup = function()
- local status_ok, cmp_npm = pcall(require, "cmp-npm")
- if not status_ok then
- vim.notify("Failed to load module 'cmp-npm'", vim.log.levels.ERROR)
- return
- end
-
- cmp_npm.setup()
+local status_ok, cmp_npm = pcall(require, "cmp-npm")
+if not status_ok then
+ vim.notify("Failed to load module 'cmp-npm'", vim.log.levels.ERROR)
+ return
end
-return M
+cmp_npm.setup()
diff --git a/nvim/.config/nvim/lua/tobyvin/plugins/cmp.lua b/nvim/.config/nvim/lua/tobyvin/plugins/cmp.lua
index d21ec7a..c296c0b 100644
--- a/nvim/.config/nvim/lua/tobyvin/plugins/cmp.lua
+++ b/nvim/.config/nvim/lua/tobyvin/plugins/cmp.lua
@@ -1,7 +1,12 @@
+local status_ok, cmp = pcall(require, "cmp")
+if not status_ok then
+ vim.notify("Failed to load module 'cmd'", vim.log.levels.ERROR)
+ return
+end
+
local lsp = require("tobyvin.lsp")
-local M = {}
-M.enabled = function()
+local enabled = function()
local ctx = require("cmp.config.context")
local enabled = require("cmp.config.default")().enabled() or require("cmp_dap").is_dap_buffer()
if vim.api.nvim_get_mode().mode ~= "c" then
@@ -11,110 +16,100 @@ M.enabled = function()
return enabled
end
-M.expand_snip = function(args)
+local expand_snip = function(args)
require("luasnip").lsp_expand(args.body)
end
-M.setup = function()
- local status_ok, cmp = pcall(require, "cmp")
- if not status_ok then
- vim.notify("Failed to load module 'cmd'", vim.log.levels.ERROR)
- return
- end
-
- lsp.default_config = vim.tbl_extend("force", lsp.default_config, {
- capabilities = require("cmp_nvim_lsp").default_capabilities(),
- })
-
- cmp.setup({
- enabled = M.enabled,
- window = {
- completion = cmp.config.window.bordered({ border = "single" }),
- documentation = cmp.config.window.bordered({ border = "single" }),
- },
- snippet = {
- expand = M.expand_snip,
- },
- mapping = cmp.mapping.preset.cmdline({
- ["<C-p>"] = cmp.mapping(cmp.mapping.select_prev_item(), { "i", "s" }),
- ["<C-n>"] = cmp.mapping(cmp.mapping.select_next_item(), { "i", "s" }),
- ["<S-Tab>"] = cmp.mapping(cmp.mapping.select_prev_item(), { "i", "s" }),
- ["<Tab>"] = cmp.mapping(cmp.mapping.select_next_item(), { "i", "s" }),
- ["<C-d>"] = cmp.mapping(cmp.mapping.scroll_docs(4), { "i", "s" }),
- ["<C-u>"] = cmp.mapping(cmp.mapping.scroll_docs(-4), { "i", "s" }),
- ["<C-Space>"] = cmp.mapping(cmp.mapping.complete(), { "i", "s" }),
- ["<C-e>"] = cmp.mapping(cmp.mapping.close(), { "i", "s" }),
- ["<CR>"] = cmp.mapping(
- cmp.mapping.confirm({
- behavior = cmp.ConfirmBehavior.Insert,
- -- select = true,
- }),
- { "i", "s" }
- ),
- }),
- ghost_text = true,
- sources = {
- { name = "nvim_lsp", group_index = 1 },
- { name = "nvim_lua", group_index = 1 },
- { name = "path", group_index = 1 },
- { name = "luasnip", group_index = 1 },
- { name = "dap", group_index = 1 },
- { name = "buffer", keyword_length = 3, group_index = 2 },
- },
- })
+lsp.default_config = vim.tbl_extend("force", lsp.default_config, {
+ capabilities = require("cmp_nvim_lsp").default_capabilities(),
+})
- cmp.setup.filetype({ "tex", "bib" }, {
- sources = {
- { name = "latex_symbols" },
- },
- })
+cmp.setup({
+ enabled = enabled,
+ window = {
+ completion = cmp.config.window.bordered({ border = "single" }),
+ documentation = cmp.config.window.bordered({ border = "single" }),
+ },
+ snippet = {
+ expand = expand_snip,
+ },
+ mapping = cmp.mapping.preset.cmdline({
+ ["<C-p>"] = cmp.mapping(cmp.mapping.select_prev_item(), { "i", "s" }),
+ ["<C-n>"] = cmp.mapping(cmp.mapping.select_next_item(), { "i", "s" }),
+ ["<S-Tab>"] = cmp.mapping(cmp.mapping.select_prev_item(), { "i", "s" }),
+ ["<Tab>"] = cmp.mapping(cmp.mapping.select_next_item(), { "i", "s" }),
+ ["<C-d>"] = cmp.mapping(cmp.mapping.scroll_docs(4), { "i", "s" }),
+ ["<C-u>"] = cmp.mapping(cmp.mapping.scroll_docs(-4), { "i", "s" }),
+ ["<C-Space>"] = cmp.mapping(cmp.mapping.complete(), { "i", "s" }),
+ ["<C-e>"] = cmp.mapping(cmp.mapping.close(), { "i", "s" }),
+ ["<CR>"] = cmp.mapping(
+ cmp.mapping.confirm({
+ behavior = cmp.ConfirmBehavior.Insert,
+ -- select = true,
+ }),
+ { "i", "s" }
+ ),
+ }),
+ ghost_text = true,
+ sources = {
+ { name = "nvim_lsp", group_index = 1 },
+ { name = "nvim_lua", group_index = 1 },
+ { name = "path", group_index = 1 },
+ { name = "luasnip", group_index = 1 },
+ { name = "dap", group_index = 1 },
+ { name = "buffer", keyword_length = 3, group_index = 2 },
+ },
+})
- cmp.setup.filetype("gitcommit", {
- sources = {
- { name = "git" },
- { name = "commit" },
- { name = "conventionalcommits" },
- },
- })
+cmp.setup.filetype({ "tex", "bib" }, {
+ sources = {
+ { name = "latex_symbols" },
+ },
+})
- cmp.setup.filetype("json", {
- sources = {
- { name = "npm" },
- },
- })
+cmp.setup.filetype("gitcommit", {
+ sources = {
+ { name = "git" },
+ { name = "commit" },
+ { name = "conventionalcommits" },
+ },
+})
- cmp.setup.filetype("toml", {
- sources = {
- { name = "crates" },
- },
- })
+cmp.setup.filetype("json", {
+ sources = {
+ { name = "npm" },
+ },
+})
- cmp.setup.cmdline(":", {
- sources = {
- { name = "cmdline_history", max_item_count = 10 },
- { name = "cmdline", max_item_count = 10 },
- },
- })
+cmp.setup.filetype("toml", {
+ sources = {
+ { name = "crates" },
+ },
+})
- cmp.setup.cmdline("/", {
- sources = {
- { name = "buffer", max_item_count = 10 },
- { name = "cmdline_history", max_item_count = 10 },
- },
- })
+cmp.setup.cmdline(":", {
+ sources = {
+ { name = "cmdline_history", max_item_count = 10 },
+ { name = "cmdline", max_item_count = 10 },
+ },
+})
- cmp.setup.cmdline("?", {
- sources = {
- { name = "buffer", max_item_count = 10 },
- { name = "cmdline_history", max_item_count = 10 },
- },
- })
+cmp.setup.cmdline("/", {
+ sources = {
+ { name = "buffer", max_item_count = 10 },
+ { name = "cmdline_history", max_item_count = 10 },
+ },
+})
- cmp.setup.cmdline("@", {
- sources = {
- { name = "cmdline_history", max_item_count = 10 },
- },
- })
-end
+cmp.setup.cmdline("?", {
+ sources = {
+ { name = "buffer", max_item_count = 10 },
+ { name = "cmdline_history", max_item_count = 10 },
+ },
+})
-return M
+cmp.setup.cmdline("@", {
+ sources = {
+ { name = "cmdline_history", max_item_count = 10 },
+ },
+})
diff --git a/nvim/.config/nvim/lua/tobyvin/plugins/comment.lua b/nvim/.config/nvim/lua/tobyvin/plugins/comment.lua
index 1071a42..8fc8ef1 100644
--- a/nvim/.config/nvim/lua/tobyvin/plugins/comment.lua
+++ b/nvim/.config/nvim/lua/tobyvin/plugins/comment.lua
@@ -1,20 +1,14 @@
-local M = {}
-
-M.setup = function()
- local status_ok, comment = pcall(require, "Comment")
- if not status_ok then
- vim.notify("Failed to load module 'Comment'", vim.log.levels.ERROR)
- return
- end
-
- comment.setup({
- toggler = {
- block = "gCc",
- },
- opleader = {
- block = "gC",
- },
- })
+local status_ok, comment = pcall(require, "Comment")
+if not status_ok then
+ vim.notify("Failed to load module 'Comment'", vim.log.levels.ERROR)
+ return
end
-return M
+comment.setup({
+ toggler = {
+ block = "gCc",
+ },
+ opleader = {
+ block = "gC",
+ },
+})
diff --git a/nvim/.config/nvim/lua/tobyvin/plugins/crates.lua b/nvim/.config/nvim/lua/tobyvin/plugins/crates.lua
index 841f04a..9e41d5b 100644
--- a/nvim/.config/nvim/lua/tobyvin/plugins/crates.lua
+++ b/nvim/.config/nvim/lua/tobyvin/plugins/crates.lua
@@ -1,33 +1,28 @@
-local utils = require("tobyvin.utils")
-local M = {}
-
-M.setup = function()
- local status_ok, crates = pcall(require, "crates")
- if not status_ok then
- vim.notify("Failed to load module 'crates'", vim.log.levels.ERROR)
- return
- end
+local status_ok, crates = pcall(require, "crates")
+if not status_ok then
+ vim.notify("Failed to load module 'crates'", vim.log.levels.ERROR)
+ return
+end
- crates.setup({
- null_ls = {
- enabled = true,
- },
- })
+local utils = require("tobyvin.utils")
- vim.api.nvim_create_autocmd("LspAttach", {
- group = vim.api.nvim_create_augroup("tobyvin_crates", { clear = true }),
- pattern = "*/Cargo.toml",
- desc = "setup crates",
- callback = function(args)
- utils.documentation.register("toml", crates.open_documentation)
- utils.hover.register(crates.show_popup, {
- enabled = crates.popup_available,
- desc = "crates",
- buffer = args.buf,
- priority = 10,
- })
- end,
- })
-end
+crates.setup({
+ null_ls = {
+ enabled = true,
+ },
+})
-return M
+vim.api.nvim_create_autocmd("LspAttach", {
+ group = vim.api.nvim_create_augroup("tobyvin_crates", { clear = true }),
+ pattern = "*/Cargo.toml",
+ desc = "setup crates",
+ callback = function(args)
+ utils.documentation.register("toml", crates.open_documentation)
+ utils.hover.register(crates.show_popup, {
+ enabled = crates.popup_available,
+ desc = "crates",
+ buffer = args.buf,
+ priority = 10,
+ })
+ end,
+})
diff --git a/nvim/.config/nvim/lua/tobyvin/plugins/dap.lua b/nvim/.config/nvim/lua/tobyvin/plugins/dap.lua
index 9be0d8d..9126e33 100644
--- a/nvim/.config/nvim/lua/tobyvin/plugins/dap.lua
+++ b/nvim/.config/nvim/lua/tobyvin/plugins/dap.lua
@@ -1,4 +1,3 @@
-local utils = require("tobyvin.utils")
local M = {
configs = require("tobyvin.plugins.dap.configs"),
adapters = require("tobyvin.plugins.dap.adapters"),
@@ -6,6 +5,14 @@ local M = {
hover = require("tobyvin.plugins.dap.hover"),
}
+local status_ok, dap = pcall(require, "dap")
+if not status_ok then
+ vim.notify("Failed to load module 'dap'", vim.log.levels.ERROR)
+ return
+end
+
+local utils = require("tobyvin.utils")
+
local set_custom_breakpoint = function()
vim.ui.input({ prompt = "Condition: " }, function(condition)
vim.ui.input({ prompt = "Hit condition: " }, function(hit_condition)
@@ -50,82 +57,74 @@ local make_config = function(config)
return config
end
-M.setup = function()
- local status_ok, dap = pcall(require, "dap")
- if not status_ok then
- vim.notify("Failed to load module 'dap'", vim.log.levels.ERROR)
- return
- end
-
- dap.defaults.fallback.focus_terminal = true
- dap.defaults.fallback.terminal_win_cmd = "15split new"
+dap.defaults.fallback.focus_terminal = true
+dap.defaults.fallback.terminal_win_cmd = "15split new"
- M.events.setup()
- M.hover.setup()
+M.events.setup()
+M.hover.setup()
- for name, config in pairs(M.configs) do
- if dap.configurations[name] == nil then
- dap.configurations[name] = make_config(config)
- end
+for name, config in pairs(M.configs) do
+ if dap.configurations[name] == nil then
+ dap.configurations[name] = make_config(config)
end
-
- require("dap-python").setup()
- require("dap-go").setup()
-
- require("nvim-dap-virtual-text").setup({
- -- only_first_definition = false,
- -- all_references = true,
- virt_text_pos = "right_align",
- })
-
- require("telescope").load_extension("dap")
- local telescope = require("telescope").extensions.dap
-
- vim.keymap.set("n", "<leader>db", dap.toggle_breakpoint, { desc = "toggle breakpoint" })
- vim.keymap.set("n", "<leader>dB", set_custom_breakpoint, { desc = "custom breakpoint" })
- vim.keymap.set("n", "<leader>dC", telescope.commands, { desc = "commands" })
- vim.keymap.set("n", "<leader>dd", telescope.configurations, { desc = "configurations" })
- vim.keymap.set("n", "<leader>dl", telescope.list_breakpoints, { desc = "list breakpoints" })
-
- vim.api.nvim_create_autocmd("User", {
- pattern = "DapAttach",
- callback = function()
- vim.keymap.set("n", "<F5>", dap.continue, { desc = "continue" })
- vim.keymap.set("n", "<F10>", dap.step_over, { desc = "step over" })
- vim.keymap.set("n", "<F11>", dap.step_into, { desc = "step into" })
- vim.keymap.set("n", "<F12>", dap.step_out, { desc = "step out" })
- vim.keymap.set("n", "<leader>dc", dap.continue, { desc = "continue" })
- vim.keymap.set("n", "<leader>da", dap.step_over, { desc = "step over" })
- vim.keymap.set("n", "<leader>di", dap.step_into, { desc = "step into" })
- vim.keymap.set("n", "<leader>do", dap.step_out, { desc = "step out" })
- vim.keymap.set("n", "<leader>dq", dap.terminate, { desc = "terminate" })
- vim.keymap.set("n", "<leader>dv", telescope.variables, { desc = "variables" })
- vim.keymap.set("n", "<leader>df", telescope.frames, { desc = "frames" })
- end,
- })
-
- vim.api.nvim_create_autocmd("User", {
- pattern = "DapDetach",
- callback = function()
- vim.keymap.del("n", "<leader>dv")
- vim.keymap.del("n", "<leader>df")
- vim.keymap.del("n", "<leader>dc")
- vim.keymap.del("n", "<leader>da")
- vim.keymap.del("n", "<leader>di")
- vim.keymap.del("n", "<leader>do")
- vim.keymap.del("n", "<leader>dq")
- vim.keymap.del("n", "<F5>")
- vim.keymap.del("n", "<F10>")
- vim.keymap.del("n", "<F11>")
- vim.keymap.del("n", "<F12>")
- end,
- })
-
- vim.fn.sign_define("DapBreakpoint", utils.debug.signs.breakpoint)
- vim.fn.sign_define("DapBreakpointCondition", utils.debug.signs.condition)
- vim.fn.sign_define("DapBreakpointRejected", utils.debug.signs.rejected)
- vim.fn.sign_define("DapStopped", utils.debug.signs.stopped)
- vim.fn.sign_define("DapLogPoint", utils.debug.signs.logpoint)
end
+require("dap-python").setup()
+require("dap-go").setup()
+
+require("nvim-dap-virtual-text").setup({
+ -- only_first_definition = false,
+ -- all_references = true,
+ virt_text_pos = "right_align",
+})
+
+require("telescope").load_extension("dap")
+local telescope = require("telescope").extensions.dap
+
+vim.keymap.set("n", "<leader>db", dap.toggle_breakpoint, { desc = "toggle breakpoint" })
+vim.keymap.set("n", "<leader>dB", set_custom_breakpoint, { desc = "custom breakpoint" })
+vim.keymap.set("n", "<leader>dC", telescope.commands, { desc = "commands" })
+vim.keymap.set("n", "<leader>dd", telescope.configurations, { desc = "configurations" })
+vim.keymap.set("n", "<leader>dl", telescope.list_breakpoints, { desc = "list breakpoints" })
+
+vim.api.nvim_create_autocmd("User", {
+ pattern = "DapAttach",
+ callback = function()
+ vim.keymap.set("n", "<F5>", dap.continue, { desc = "continue" })
+ vim.keymap.set("n", "<F10>", dap.step_over, { desc = "step over" })
+ vim.keymap.set("n", "<F11>", dap.step_into, { desc = "step into" })
+ vim.keymap.set("n", "<F12>", dap.step_out, { desc = "step out" })
+ vim.keymap.set("n", "<leader>dc", dap.continue, { desc = "continue" })
+ vim.keymap.set("n", "<leader>da", dap.step_over, { desc = "step over" })
+ vim.keymap.set("n", "<leader>di", dap.step_into, { desc = "step into" })
+ vim.keymap.set("n", "<leader>do", dap.step_out, { desc = "step out" })
+ vim.keymap.set("n", "<leader>dq", dap.terminate, { desc = "terminate" })
+ vim.keymap.set("n", "<leader>dv", telescope.variables, { desc = "variables" })
+ vim.keymap.set("n", "<leader>df", telescope.frames, { desc = "frames" })
+ end,
+})
+
+vim.api.nvim_create_autocmd("User", {
+ pattern = "DapDetach",
+ callback = function()
+ vim.keymap.del("n", "<leader>dv")
+ vim.keymap.del("n", "<leader>df")
+ vim.keymap.del("n", "<leader>dc")
+ vim.keymap.del("n", "<leader>da")
+ vim.keymap.del("n", "<leader>di")
+ vim.keymap.del("n", "<leader>do")
+ vim.keymap.del("n", "<leader>dq")
+ vim.keymap.del("n", "<F5>")
+ vim.keymap.del("n", "<F10>")
+ vim.keymap.del("n", "<F11>")
+ vim.keymap.del("n", "<F12>")
+ end,
+})
+
+vim.fn.sign_define("DapBreakpoint", utils.debug.signs.breakpoint)
+vim.fn.sign_define("DapBreakpointCondition", utils.debug.signs.condition)
+vim.fn.sign_define("DapBreakpointRejected", utils.debug.signs.rejected)
+vim.fn.sign_define("DapStopped", utils.debug.signs.stopped)
+vim.fn.sign_define("DapLogPoint", utils.debug.signs.logpoint)
+
return M
diff --git a/nvim/.config/nvim/lua/tobyvin/plugins/dapui.lua b/nvim/.config/nvim/lua/tobyvin/plugins/dapui.lua
deleted file mode 100644
index 59ce5f5..0000000
--- a/nvim/.config/nvim/lua/tobyvin/plugins/dapui.lua
+++ /dev/null
@@ -1,84 +0,0 @@
-local M = {
- dapui_win = nil,
- dapui_tab = nil,
-}
-
-M.eval = function()
- vim.ui.input({ prompt = "Expr: " }, function(input)
- require("dapui").eval(input, {})
- end)
-end
-
-M.open = function()
- if M.dapui_win and vim.api.nvim_win_is_valid(M.dapui_win) then
- vim.api.nvim_set_current_win(M.dapui_win)
- return
- end
-
- local dap = require("dap")
- local dapui = require("dapui")
-
- vim.cmd("tabedit %")
- M.dapui_win = vim.fn.win_getid()
- M.dapui_tab = vim.api.nvim_win_get_tabpage(M.dapui_win)
-
- dapui.open({})
-
- dap.listeners.before.event_terminated["dapui_config"] = M.close
- dap.listeners.before.event_exited["dapui_config"] = M.close
- dap.listeners.before.disconnect["dapui_config"] = M.close
-
- vim.api.nvim_create_autocmd("TabClosed", {
- group = vim.api.nvim_create_augroup("DapAU", { clear = true }),
- callback = function()
- dap.terminate()
- return true
- end,
- })
-end
-
-M.close = function()
- local dapui = require("dapui")
-
- dapui.close({})
-
- if M.dapui_tab and vim.api.nvim_tabpage_is_valid(M.dapui_tab) then
- local tabnr = vim.api.nvim_tabpage_get_number(M.dapui_tab)
- vim.cmd("tabclose " .. tabnr)
- end
-
- M.dapui_win = nil
- M.dapui_tab = nil
-end
-
-M.setup = function()
- local status_ok, dapui = pcall(require, "dapui")
- if not status_ok then
- vim.notify("Failed to load module 'dapui'", vim.log.levels.ERROR)
- return
- end
-
- vim.keymap.set("n", "<leader>de", M.eval, { desc = "eval" })
- vim.keymap.set("n", "<leader>du", dapui.open, { desc = "dapui" })
-
- vim.api.nvim_set_hl(0, "DapUIVariable", { link = "TSVariable" })
- vim.api.nvim_set_hl(0, "DapUIScope", { link = "TSNamespace" })
- vim.api.nvim_set_hl(0, "DapUIType", { link = "Type" })
- vim.api.nvim_set_hl(0, "DapUIModifiedValue", { link = "Keyword" })
- vim.api.nvim_set_hl(0, "DapUIDecoration", { link = "PreProc" })
- vim.api.nvim_set_hl(0, "DapUIThread", { link = "String" })
- vim.api.nvim_set_hl(0, "DapUIStoppedThread", { link = "Special" })
- vim.api.nvim_set_hl(0, "DapUIFrameName", { link = "Normal" })
- vim.api.nvim_set_hl(0, "DapUISource", { link = "TSKeyword" })
- vim.api.nvim_set_hl(0, "DapUILineNumber", { link = "TSOperator" })
- vim.api.nvim_set_hl(0, "DapUIFloatBorder", { link = "FloatBorder" })
- vim.api.nvim_set_hl(0, "DapUIWatchesEmpty", { link = "LspDiagnosticsError" })
- vim.api.nvim_set_hl(0, "DapUIWatchesValue", { link = "String" })
- vim.api.nvim_set_hl(0, "DapUIWatchesError", { link = "LspDiagnosticsError" })
- vim.api.nvim_set_hl(0, "DapUIBreakpointsPath", { link = "Keyword" })
- vim.api.nvim_set_hl(0, "DapUIBreakpointsInfo", { link = "LspDiagnosticsInfo" })
- vim.api.nvim_set_hl(0, "DapUIBreakpointsCurrentLine", { link = "DapStopped" })
- vim.api.nvim_set_hl(0, "DapUIBreakpointsLine", { link = "DapUILineNumber" })
-end
-
-return M
diff --git a/nvim/.config/nvim/lua/tobyvin/plugins/diffview.lua b/nvim/.config/nvim/lua/tobyvin/plugins/diffview.lua
index 9f400ad..470c360 100644
--- a/nvim/.config/nvim/lua/tobyvin/plugins/diffview.lua
+++ b/nvim/.config/nvim/lua/tobyvin/plugins/diffview.lua
@@ -1,4 +1,8 @@
-local M = {}
+local status_ok, diffview = pcall(require, "diffview")
+if not status_ok then
+ vim.notify("Failed to load module 'diffview'", vim.log.levels.ERROR)
+ return
+end
local file_history = function()
require("diffview").file_history(nil, vim.fn.bufname())
@@ -14,19 +18,9 @@ local selection_history = function()
require("diffview").file_history({ first, last })
end
-M.setup = function()
- local status_ok, diffview = pcall(require, "diffview")
- if not status_ok then
- vim.notify("Failed to load module 'diffview'", vim.log.levels.ERROR)
- return
- end
-
- diffview.setup()
-
- vim.keymap.set("n", "<leader>gd", diffview.open, { desc = "diffview" })
- vim.keymap.set("n", "<leader>gh", file_history, { desc = "file history" })
- vim.keymap.set("n", "<leader>gH", workspace_history, { desc = "workspace history" })
- vim.keymap.set("v", "<leader>gh", selection_history, { desc = "selection history" })
-end
+diffview.setup()
-return M
+vim.keymap.set("n", "<leader>gd", diffview.open, { desc = "diffview" })
+vim.keymap.set("n", "<leader>gh", file_history, { desc = "file history" })
+vim.keymap.set("n", "<leader>gH", workspace_history, { desc = "workspace history" })
+vim.keymap.set("v", "<leader>gh", selection_history, { desc = "selection history" })
diff --git a/nvim/.config/nvim/lua/tobyvin/plugins/dressing.lua b/nvim/.config/nvim/lua/tobyvin/plugins/dressing.lua
index 50f5fd0..e9ddbaa 100644
--- a/nvim/.config/nvim/lua/tobyvin/plugins/dressing.lua
+++ b/nvim/.config/nvim/lua/tobyvin/plugins/dressing.lua
@@ -1,7 +1,11 @@
local themes = require("telescope.themes")
-local M = {}
+local status_ok, dressing = pcall(require, "dressing")
+if not status_ok then
+ vim.notify("Failed to load module 'dressing'", vim.log.levels.ERROR)
+ return
+end
-M.format_item_override = {
+local format_item_override = {
["rust-tools/debuggables"] = function(item)
item = item:gsub(" %-%-no%-run", "")
item = item:gsub(" %-%-package", " -p")
@@ -13,7 +17,7 @@ M.format_item_override = {
end,
}
-M.config_overrides = {
+local config_overrides = {
select = {
["Ring history"] = {
telescope = themes.get_dropdown({ preview = true }),
@@ -27,48 +31,28 @@ M.config_overrides = {
},
}
-M.get_config = function(type, opts)
- local overrides = M.config_overrides[type]
-
- if overrides[opts.kind] ~= nil then
- return overrides[opts.kind]
- elseif overrides[opts.prompt] ~= nil then
- return overrides[opts.prompt]
- end
-end
-
-M.setup = function()
- local status_ok, dressing = pcall(require, "dressing")
- if not status_ok then
- vim.notify("Failed to load module 'dressing'", vim.log.levels.ERROR)
- return
- end
-
- dressing.setup({
- input = {
- get_config = function(opts)
- local overrides = M.config_overrides.input
-
- if overrides[opts.kind] ~= nil then
- return overrides[opts.kind]
- elseif overrides[opts.prompt] ~= nil then
- return overrides[opts.prompt]
- end
- end,
- },
- select = {
- get_config = function(opts)
- local overrides = M.config_overrides.select
-
- if overrides[opts.kind] ~= nil then
- return overrides[opts.kind]
- elseif overrides[opts.prompt] ~= nil then
- return overrides[opts.prompt]
- end
- end,
- format_item_override = M.format_item_override,
- },
- })
-end
-
-return M
+dressing.setup({
+ input = {
+ get_config = function(opts)
+ local overrides = config_overrides.input
+
+ if overrides[opts.kind] ~= nil then
+ return overrides[opts.kind]
+ elseif overrides[opts.prompt] ~= nil then
+ return overrides[opts.prompt]
+ end
+ end,
+ },
+ select = {
+ get_config = function(opts)
+ local overrides = config_overrides.select
+
+ if overrides[opts.kind] ~= nil then
+ return overrides[opts.kind]
+ elseif overrides[opts.prompt] ~= nil then
+ return overrides[opts.prompt]
+ end
+ end,
+ format_item_override = format_item_override,
+ },
+})
diff --git a/nvim/.config/nvim/lua/tobyvin/plugins/fidget.lua b/nvim/.config/nvim/lua/tobyvin/plugins/fidget.lua
index c1ecb27..ac4bcca 100644
--- a/nvim/.config/nvim/lua/tobyvin/plugins/fidget.lua
+++ b/nvim/.config/nvim/lua/tobyvin/plugins/fidget.lua
@@ -1,20 +1,15 @@
-local utils = require("tobyvin.utils")
-local M = {}
-
-M.setup = function()
- local status_ok, fidget = pcall(require, "fidget")
- if not status_ok then
- vim.notify("Failed to load module 'fidget'", vim.log.levels.ERROR)
- return
- end
-
- fidget.setup({
- text = {
- spinner = utils.status.signs.spinner.text,
- done = vim.trim(utils.status.signs.completed.text),
- },
- window = { blend = 0 },
- })
+local status_ok, fidget = pcall(require, "fidget")
+if not status_ok then
+ vim.notify("Failed to load module 'fidget'", vim.log.levels.ERROR)
+ return
end
-return M
+local utils = require("tobyvin.utils")
+
+fidget.setup({
+ text = {
+ spinner = utils.status.signs.spinner.text,
+ done = vim.trim(utils.status.signs.completed.text),
+ },
+ window = { blend = 0 },
+})
diff --git a/nvim/.config/nvim/lua/tobyvin/plugins/git-conflict.lua b/nvim/.config/nvim/lua/tobyvin/plugins/git-conflict.lua
index c175542..efc7618 100644
--- a/nvim/.config/nvim/lua/tobyvin/plugins/git-conflict.lua
+++ b/nvim/.config/nvim/lua/tobyvin/plugins/git-conflict.lua
@@ -1,19 +1,13 @@
-local M = {}
-
-M.setup = function()
- local status_ok, git_conflict = pcall(require, "git-conflict")
- if not status_ok then
- vim.notify("Failed to load module 'git_conflict'", vim.log.levels.ERROR)
- return
- end
-
- git_conflict.setup({
- disable_diagnostics = true,
- highlights = {
- incoming = "diffText",
- current = "diffAdd",
- },
- })
+local status_ok, git_conflict = pcall(require, "git-conflict")
+if not status_ok then
+ vim.notify("Failed to load module 'git_conflict'", vim.log.levels.ERROR)
+ return
end
-return M
+git_conflict.setup({
+ disable_diagnostics = true,
+ highlights = {
+ incoming = "diffText",
+ current = "diffAdd",
+ },
+})
diff --git a/nvim/.config/nvim/lua/tobyvin/plugins/gitsigns.lua b/nvim/.config/nvim/lua/tobyvin/plugins/gitsigns.lua
index 67c4be9..a2b97ae 100644
--- a/nvim/.config/nvim/lua/tobyvin/plugins/gitsigns.lua
+++ b/nvim/.config/nvim/lua/tobyvin/plugins/gitsigns.lua
@@ -1,5 +1,10 @@
+local status_ok, gitsigns = pcall(require, "gitsigns")
+if not status_ok then
+ vim.notify("Failed to load module 'gitsigns'", vim.log.levels.ERROR)
+ return
+end
+
local utils = require("tobyvin.utils")
-local M = {}
local with_range = function(callback)
return function()
@@ -8,14 +13,14 @@ local with_range = function(callback)
end
local show_blameline = function()
- require("gitsigns").blame_line({ full = true })
+ gitsigns.blame_line({ full = true })
end
local toggle_blameline = function()
- require("gitsigns").toggle_current_line_blame()
+ gitsigns.toggle_current_line_blame()
end
+
local next_hunk = function()
- local gitsigns = package.loaded.gitsigns
if vim.wo.diff then
return "]c"
end
@@ -26,7 +31,6 @@ local next_hunk = function()
end
local prev_hunk = function()
- local gitsigns = package.loaded.gitsigns
if vim.wo.diff then
return "[c"
end
@@ -36,8 +40,7 @@ local prev_hunk = function()
return "<Ignore>"
end
-M.on_attach = function(bufnr)
- local gitsigns = package.loaded.gitsigns
+local on_attach = function(bufnr)
vim.keymap.set("n", "]c", next_hunk, { expr = true, desc = "next hunk", buffer = bufnr })
vim.keymap.set("n", "[c", prev_hunk, { expr = true, desc = "previous hunk", buffer = bufnr })
@@ -62,24 +65,14 @@ M.on_attach = function(bufnr)
vim.api.nvim_exec_autocmds("User", { pattern = "GitAttach", data = { buf = bufnr } })
end
-M.setup = function()
- local status_ok, gitsigns = pcall(require, "gitsigns")
- if not status_ok then
- vim.notify("Failed to load module 'gitsigns'", vim.log.levels.ERROR)
- return
- end
-
- gitsigns.setup({
- signs = {
- add = { text = "▎" },
- change = { text = "▎" },
- delete = { text = "契" },
- topdelete = { text = "契" },
- changedelete = { text = "▎" },
- },
- preview_config = { border = "single" },
- on_attach = M.on_attach,
- })
-end
-
-return M
+gitsigns.setup({
+ signs = {
+ add = { text = "▎" },
+ change = { text = "▎" },
+ delete = { text = "契" },
+ topdelete = { text = "契" },
+ changedelete = { text = "▎" },
+ },
+ preview_config = { border = "single" },
+ on_attach = on_attach,
+})
diff --git a/nvim/.config/nvim/lua/tobyvin/plugins/gruvbox.lua b/nvim/.config/nvim/lua/tobyvin/plugins/gruvbox.lua
index cce679d..973e302 100644
--- a/nvim/.config/nvim/lua/tobyvin/plugins/gruvbox.lua
+++ b/nvim/.config/nvim/lua/tobyvin/plugins/gruvbox.lua
@@ -1,47 +1,41 @@
-local M = {}
-
-M.setup = function()
- local status_ok, gruvbox = pcall(require, "gruvbox")
- if not status_ok then
- vim.notify("Failed to load module 'gruvbox'", vim.log.levels.ERROR)
- return
- end
-
- local colors = require("gruvbox.palette")
- gruvbox.setup({
- contrast = "hard",
- transparent_mode = true,
- overrides = {
- GruvboxRedSign = { bg = "" },
- GruvboxGreenSign = { bg = "" },
- GruvboxYellowSign = { bg = "" },
- GruvboxBlueSign = { bg = "" },
- GruvboxPurpleSign = { bg = "" },
- GruvboxAquaSign = { bg = "" },
- GruvboxOrangeSign = { bg = "" },
- NormalFloat = { bg = "" },
- FloatBorder = { bg = "" },
- ColorColumn = { bg = "" },
- CursorLine = { bg = "" },
- CursorLineNr = { bg = "" },
- SignColumn = { bg = "" },
- DiffDelete = { reverse = false },
- DiffAdd = { reverse = false },
- DiffChange = { reverse = false },
- DiffText = { reverse = false },
- StatusLine = { fg = colors.light1, bg = colors.dark2, reverse = false },
- StatusLineNC = { fg = colors.light4, bg = colors.dark1, reverse = false },
- WinBar = { link = "StatusLineNC" },
- WinBarNC = { fg = colors.light4, bg = "" },
- QuickFixLine = { fg = "", bg = "" },
+local status_ok, gruvbox = pcall(require, "gruvbox")
+if not status_ok then
+ vim.notify("Failed to load module 'gruvbox'", vim.log.levels.ERROR)
+ return
+end
- -- TODO: workaround for weird highlights in lsp hover/signature
- -- SEE: https://github.com/neovim/neovim/issues/13746
- markdownError = { link = "Normal" },
- },
- })
+local colors = require("gruvbox.palette")
+gruvbox.setup({
+ contrast = "hard",
+ transparent_mode = true,
+ overrides = {
+ GruvboxRedSign = { bg = "" },
+ GruvboxGreenSign = { bg = "" },
+ GruvboxYellowSign = { bg = "" },
+ GruvboxBlueSign = { bg = "" },
+ GruvboxPurpleSign = { bg = "" },
+ GruvboxAquaSign = { bg = "" },
+ GruvboxOrangeSign = { bg = "" },
+ NormalFloat = { bg = "" },
+ FloatBorder = { bg = "" },
+ ColorColumn = { bg = "" },
+ CursorLine = { bg = "" },
+ CursorLineNr = { bg = "" },
+ SignColumn = { bg = "" },
+ DiffDelete = { reverse = false },
+ DiffAdd = { reverse = false },
+ DiffChange = { reverse = false },
+ DiffText = { reverse = false },
+ StatusLine = { fg = colors.light1, bg = colors.dark2, reverse = false },
+ StatusLineNC = { fg = colors.light4, bg = colors.dark1, reverse = false },
+ WinBar = { link = "StatusLineNC" },
+ WinBarNC = { fg = colors.light4, bg = "" },
+ QuickFixLine = { fg = "", bg = "" },
- vim.cmd([[colorscheme gruvbox]])
-end
+ -- TODO: workaround for weird highlights in lsp hover/signature
+ -- SEE: https://github.com/neovim/neovim/issues/13746
+ markdownError = { link = "Normal" },
+ },
+})
-return M
+vim.cmd([[colorscheme gruvbox]])
diff --git a/nvim/.config/nvim/lua/tobyvin/plugins/indent_blankline.lua b/nvim/.config/nvim/lua/tobyvin/plugins/indent_blankline.lua
index 1287d22..f151011 100644
--- a/nvim/.config/nvim/lua/tobyvin/plugins/indent_blankline.lua
+++ b/nvim/.config/nvim/lua/tobyvin/plugins/indent_blankline.lua
@@ -1,34 +1,28 @@
-local M = {}
-
-M.setup = function()
- local status_ok, indent_blankline = pcall(require, "indent_blankline")
- if not status_ok then
- vim.notify("Failed to load module 'indent_blankline'", vim.log.levels.ERROR)
- return
- end
-
- vim.api.nvim_set_hl(0, "IndentBlanklineIndent1", { fg = "#E06C75", nocombine = true })
- vim.api.nvim_set_hl(0, "IndentBlanklineIndent2", { fg = "#E5C07B", nocombine = true })
- vim.api.nvim_set_hl(0, "IndentBlanklineIndent3", { fg = "#98C379", nocombine = true })
- vim.api.nvim_set_hl(0, "IndentBlanklineIndent4", { fg = "#56B6C2", nocombine = true })
- vim.api.nvim_set_hl(0, "IndentBlanklineIndent5", { fg = "#61AFEF", nocombine = true })
- vim.api.nvim_set_hl(0, "IndentBlanklineIndent6", { fg = "#C678DD", nocombine = true })
-
- indent_blankline.setup({
- context_highlight_list = {
- "IndentBlanklineIndent1",
- "IndentBlanklineIndent2",
- "IndentBlanklineIndent3",
- "IndentBlanklineIndent4",
- "IndentBlanklineIndent5",
- "IndentBlanklineIndent6",
- },
- space_char_blankline = " ",
- show_end_of_line = true,
- show_current_context = true,
- use_treesitter = true,
- use_treesitter_scope = true,
- })
+local status_ok, indent_blankline = pcall(require, "indent_blankline")
+if not status_ok then
+ vim.notify("Failed to load module 'indent_blankline'", vim.log.levels.ERROR)
+ return
end
-return M
+vim.api.nvim_set_hl(0, "IndentBlanklineIndent1", { fg = "#E06C75", nocombine = true })
+vim.api.nvim_set_hl(0, "IndentBlanklineIndent2", { fg = "#E5C07B", nocombine = true })
+vim.api.nvim_set_hl(0, "IndentBlanklineIndent3", { fg = "#98C379", nocombine = true })
+vim.api.nvim_set_hl(0, "IndentBlanklineIndent4", { fg = "#56B6C2", nocombine = true })
+vim.api.nvim_set_hl(0, "IndentBlanklineIndent5", { fg = "#61AFEF", nocombine = true })
+vim.api.nvim_set_hl(0, "IndentBlanklineIndent6", { fg = "#C678DD", nocombine = true })
+
+indent_blankline.setup({
+ context_highlight_list = {
+ "IndentBlanklineIndent1",
+ "IndentBlanklineIndent2",
+ "IndentBlanklineIndent3",
+ "IndentBlanklineIndent4",
+ "IndentBlanklineIndent5",
+ "IndentBlanklineIndent6",
+ },
+ space_char_blankline = " ",
+ show_end_of_line = true,
+ show_current_context = true,
+ use_treesitter = true,
+ use_treesitter_scope = true,
+})
diff --git a/nvim/.config/nvim/lua/tobyvin/plugins/lspconfig.lua b/nvim/.config/nvim/lua/tobyvin/plugins/lspconfig.lua
index 80efb8e..3549fe2 100644
--- a/nvim/.config/nvim/lua/tobyvin/plugins/lspconfig.lua
+++ b/nvim/.config/nvim/lua/tobyvin/plugins/lspconfig.lua
@@ -1,32 +1,27 @@
-local lsp = require("tobyvin.lsp")
-local M = {}
+local status_ok, lspconfig = pcall(require, "lspconfig")
+if not status_ok then
+ vim.notify("Failed to load module 'lspconfig'", vim.log.levels.ERROR)
+ return
+end
-M.setup = function()
- local status_ok, lspconfig = pcall(require, "lspconfig")
- if not status_ok then
- vim.notify("Failed to load module 'lspconfig'", vim.log.levels.ERROR)
- return
- end
+local lsp = require("tobyvin.lsp")
- require("lspconfig.ui.windows").default_options.border = "single"
+require("lspconfig.ui.windows").default_options.border = "single"
- lspconfig.util.default_config = vim.tbl_extend("force", lspconfig.util.default_config, lsp.default_config)
+lspconfig.util.default_config = vim.tbl_extend("force", lspconfig.util.default_config, lsp.default_config)
- local available = lspconfig.util.available_servers()
- for name, config in pairs(lsp.configs) do
- if not vim.tbl_contains(available, name) then
- lspconfig[name].setup(config)
- end
+local available = lspconfig.util.available_servers()
+for name, config in pairs(lsp.configs) do
+ if not vim.tbl_contains(available, name) then
+ lspconfig[name].setup(config)
end
-
- vim.api.nvim_create_autocmd("LspAttach", {
- group = vim.api.nvim_create_augroup("tobyvin_lsp_config", { clear = true }),
- desc = "lsp",
- callback = function(args)
- local lspinfo = require("lspconfig.ui.lspinfo")
- vim.keymap.set("n", "<leader>li", lspinfo, { desc = "lsp info", buffer = args.buf })
- end,
- })
end
-return M
+vim.api.nvim_create_autocmd("LspAttach", {
+ group = vim.api.nvim_create_augroup("tobyvin_lsp_config", { clear = true }),
+ desc = "lsp",
+ callback = function(args)
+ local lspinfo = require("lspconfig.ui.lspinfo")
+ vim.keymap.set("n", "<leader>li", lspinfo, { desc = "lsp info", buffer = args.buf })
+ end,
+})
diff --git a/nvim/.config/nvim/lua/tobyvin/plugins/lspkind.lua b/nvim/.config/nvim/lua/tobyvin/plugins/lspkind.lua
index bf65dfa..ffca80b 100644
--- a/nvim/.config/nvim/lua/tobyvin/plugins/lspkind.lua
+++ b/nvim/.config/nvim/lua/tobyvin/plugins/lspkind.lua
@@ -1,11 +1,6 @@
-local M = {}
-
-M.setup = function()
- local status_ok, lspkind = pcall(require, "lspkind")
- if not status_ok then
- return
- end
- lspkind.init()
+local status_ok, lspkind = pcall(require, "lspkind")
+if not status_ok then
+ return
end
-return M
+lspkind.init()
diff --git a/nvim/.config/nvim/lua/tobyvin/plugins/lualine.lua b/nvim/.config/nvim/lua/tobyvin/plugins/lualine.lua
index a165811..aace592 100644
--- a/nvim/.config/nvim/lua/tobyvin/plugins/lualine.lua
+++ b/nvim/.config/nvim/lua/tobyvin/plugins/lualine.lua
@@ -1,151 +1,147 @@
+local status_ok, lualine = pcall(require, "lualine")
+if not status_ok then
+ vim.notify("Failed to load module 'lualine'", vim.log.levels.ERROR)
+ return
+end
+
local utils = require("tobyvin.utils")
-local M = {}
-local function get_short_cwd()
+local get_short_cwd = function()
return vim.fn.fnamemodify(vim.fn.getcwd(), ":~")
end
-M.to_char = function(str)
+local to_char = function(str)
return str:sub(1, 1)
end
-M.setup = function()
- local status_ok, lualine = pcall(require, "lualine")
- if not status_ok then
- return
- end
+local winbar_cond = function()
+ return vim.bo.buflisted
+end
- local winbar_cond = function()
- return vim.bo.buflisted
- end
+local git = {
+ "branch",
+ {
+ "diff",
+ source = function()
+ local gitsigns = vim.b.gitsigns_status_dict
+ if gitsigns then
+ return {
+ added = gitsigns.added,
+ modified = gitsigns.changed,
+ removed = gitsigns.removed,
+ }
+ end
+ end,
+ padding = { left = 0, right = 1 },
+ },
+}
- local git = {
- "branch",
- {
- "diff",
- source = function()
- local gitsigns = vim.b.gitsigns_status_dict
- if gitsigns then
- return {
- added = gitsigns.added,
- modified = gitsigns.changed,
- removed = gitsigns.removed,
- }
- end
- end,
- padding = { left = 0, right = 1 },
- },
- }
-
- local workspace = {
- {
- function()
- return utils.diagnostic
- .indicator(nil)
- :gsub("DiagnosticSignError", "lualine_b_diagnostics_error_normal")
- :gsub("DiagnosticSignWarn", "lualine_b_diagnostics_warn_normal")
- :gsub("DiagnosticSignInfo", "lualine_b_diagnostics_info_normal")
- :gsub("DiagnosticSignHint", "lualine_b_diagnostics_hint_normal")
- end,
- padding = { left = 1, right = 0 },
- color = "StatusLineNC",
- },
- {
- "filename",
- path = 1,
- },
- }
+local workspace = {
+ {
+ function()
+ return utils.diagnostic
+ .indicator(nil)
+ :gsub("DiagnosticSignError", "lualine_b_diagnostics_error_normal")
+ :gsub("DiagnosticSignWarn", "lualine_b_diagnostics_warn_normal")
+ :gsub("DiagnosticSignInfo", "lualine_b_diagnostics_info_normal")
+ :gsub("DiagnosticSignHint", "lualine_b_diagnostics_hint_normal")
+ end,
+ padding = { left = 1, right = 0 },
+ color = "StatusLineNC",
+ },
+ {
+ "filename",
+ path = 1,
+ },
+}
- local buffer = {
- {
- "filename",
- color = "WinBar",
- cond = winbar_cond,
- },
- {
- "diagnostics",
- source = { utils.diagnostic.buf_count },
- symbols = {
- error = utils.diagnostic.signs.error.text,
- warn = utils.diagnostic.signs.warn.text,
- info = utils.diagnostic.signs.info.text,
- hint = utils.diagnostic.signs.hint.text,
- },
- update_in_insert = true,
- color = "WinBar",
- padding = { left = 0, right = 1 },
- cond = winbar_cond,
+local buffer = {
+ {
+ "filename",
+ color = "WinBar",
+ cond = winbar_cond,
+ },
+ {
+ "diagnostics",
+ source = { utils.diagnostic.buf_count },
+ symbols = {
+ error = utils.diagnostic.signs.error.text,
+ warn = utils.diagnostic.signs.warn.text,
+ info = utils.diagnostic.signs.info.text,
+ hint = utils.diagnostic.signs.hint.text,
},
- }
+ update_in_insert = true,
+ color = "WinBar",
+ padding = { left = 0, right = 1 },
+ cond = winbar_cond,
+ },
+}
- lualine.setup({
- options = {
- component_separators = "",
- section_separators = "",
- disabled_filetypes = {
- "netrw",
- "alpha",
- winbar = vim.fn.getcompletion("Neogit*", "filetype"),
- },
+lualine.setup({
+ options = {
+ component_separators = "",
+ section_separators = "",
+ disabled_filetypes = {
+ "netrw",
+ "alpha",
+ winbar = vim.fn.getcompletion("Neogit*", "filetype"),
},
+ },
- sections = {
- lualine_a = { { "mode", fmt = M.to_char } },
- lualine_b = git,
- lualine_c = workspace,
- lualine_x = {
- "encoding",
- "fileformat",
- "filetype",
- },
+ sections = {
+ lualine_a = { { "mode", fmt = to_char } },
+ lualine_b = git,
+ lualine_c = workspace,
+ lualine_x = {
+ "encoding",
+ "fileformat",
+ "filetype",
},
+ },
- inactive_sections = {
- lualine_c = { "filename" },
- lualine_x = {
- "filetype",
- "location",
- },
+ inactive_sections = {
+ lualine_c = { "filename" },
+ lualine_x = {
+ "filetype",
+ "location",
},
+ },
- winbar = {
- lualine_b = buffer,
- lualine_c = {
- {
- -- Hack to prevent lualine_b from taking over the lualine_c when navic has no results
- function()
- return require("nvim-navic").get_location():gsub("^$", " ")
- end,
- color = "WinBarNC",
- cond = winbar_cond,
- },
+ winbar = {
+ lualine_b = buffer,
+ lualine_c = {
+ {
+ -- Hack to prevent lualine_b from taking over the lualine_c when navic has no results
+ function()
+ return require("nvim-navic").get_location():gsub("^$", " ")
+ end,
+ color = "WinBarNC",
+ cond = winbar_cond,
},
},
+ },
- tabline = {
- lualine_b = { { "buffers", mode = 4 } },
- lualine_y = { "tabs" },
- },
+ tabline = {
+ lualine_b = { { "buffers", mode = 4 } },
+ lualine_y = { "tabs" },
+ },
- extensions = {
- "fzf",
- "man",
- "nvim-dap-ui",
- "symbols-outline",
- "quickfix",
- "toggleterm",
- {
- sections = {
- lualine_c = {
- get_short_cwd,
- },
- },
- filetypes = {
- "netrw",
+ extensions = {
+ "fzf",
+ "man",
+ "nvim-dap-ui",
+ "symbols-outline",
+ "quickfix",
+ "toggleterm",
+ {
+ sections = {
+ lualine_c = {
+ get_short_cwd,
},
},
+ filetypes = {
+ "netrw",
+ },
},
- })
-end
-
-return M
+ },
+})
diff --git a/nvim/.config/nvim/lua/tobyvin/plugins/luasnip.lua b/nvim/.config/nvim/lua/tobyvin/plugins/luasnip.lua
index 4a94226..c0c56d5 100644
--- a/nvim/.config/nvim/lua/tobyvin/plugins/luasnip.lua
+++ b/nvim/.config/nvim/lua/tobyvin/plugins/luasnip.lua
@@ -1,18 +1,12 @@
-local M = {}
-
-M.setup = function()
- local status_ok, luasnip = pcall(require, "luasnip")
- if not status_ok then
- return
- end
-
- luasnip.config.set_config({
- updateevents = "TextChanged,TextChangedI",
- })
+local status_ok, luasnip = pcall(require, "luasnip")
+if not status_ok then
+ return
+end
- luasnip.snippets = require("luasnip_snippets").load_snippets()
+luasnip.config.set_config({
+ updateevents = "TextChanged,TextChangedI",
+})
- require("luasnip.loaders.from_vscode").lazy_load()
-end
+luasnip.snippets = require("luasnip_snippets").load_snippets()
-return M
+require("luasnip.loaders.from_vscode").lazy_load()
diff --git a/nvim/.config/nvim/lua/tobyvin/plugins/mason.lua b/nvim/.config/nvim/lua/tobyvin/plugins/mason.lua
index 163917c..53d345b 100644
--- a/nvim/.config/nvim/lua/tobyvin/plugins/mason.lua
+++ b/nvim/.config/nvim/lua/tobyvin/plugins/mason.lua
@@ -1,4 +1,8 @@
-local M = {}
+local status_ok, mason = pcall(require, "mason")
+if not status_ok then
+ vim.notify("Failed to load module 'mason'", vim.log.levels.ERROR)
+ return
+end
local nil_wrap = function(func)
return function(opts)
@@ -6,47 +10,37 @@ local nil_wrap = function(func)
end
end
-M.setup = function()
- local status_ok, mason = pcall(require, "mason")
- if not status_ok then
- vim.notify("Failed to load module 'mason'", vim.log.levels.ERROR)
- return
- end
-
- mason.setup({
- ui = {
- border = "single",
- icons = {
- package_installed = "✓",
- package_pending = "➜",
- package_uninstalled = "✗",
- },
+mason.setup({
+ ui = {
+ border = "single",
+ icons = {
+ package_installed = "✓",
+ package_pending = "➜",
+ package_uninstalled = "✗",
},
- })
+ },
+})
- local mason_update_all = require("mason-update-all")
- local mason_lspconfig = require("mason-lspconfig.api.command")
- local mason_null_ls = require("mason-null-ls.api.command")
- local mason_nvim_dap = require("mason-nvim-dap.api.command")
+local mason_update_all = require("mason-update-all")
+local mason_lspconfig = require("mason-lspconfig.api.command")
+local mason_null_ls = require("mason-null-ls.api.command")
+local mason_nvim_dap = require("mason-nvim-dap.api.command")
- local api = require("mason.api.command")
- api.UpdateAll = mason_update_all.update_all
- api.LspInstall = nil_wrap(mason_lspconfig.LspInstall)
- api.LspUninstall = nil_wrap(mason_lspconfig.LspUninstall)
- api.NullLsInstall = nil_wrap(mason_null_ls.NullLsInstall)
- api.NullLsUninstall = nil_wrap(mason_null_ls.NullLsUninstall)
- api.DapInstall = nil_wrap(mason_nvim_dap.DapInstall)
- api.DapUninstall = nil_wrap(mason_nvim_dap.DapUninstall)
-
- vim.keymap.set("n", "<leader>ii", api.Mason, { desc = "mason" })
- vim.keymap.set("n", "<leader>iI", api.MasonLog, { desc = "log" })
- vim.keymap.set("n", "<leader>iu", api.UpdateAll, { desc = "update all" })
- vim.keymap.set("n", "<leader>il", api.LspInstall, { desc = "lsp install" })
- vim.keymap.set("n", "<leader>iL", api.LspUninstall, { desc = "lsp uninstall" })
- vim.keymap.set("n", "<leader>in", api.NullLsInstall, { desc = "null-ls install" })
- vim.keymap.set("n", "<leader>iN", api.NullLsUninstall, { desc = "null-ls uninstall" })
- vim.keymap.set("n", "<leader>id", api.DapInstall, { desc = "dap install" })
- vim.keymap.set("n", "<leader>iD", api.DapUninstall, { desc = "dap uninstall" })
-end
+local api = require("mason.api.command")
+api.UpdateAll = mason_update_all.update_all
+api.LspInstall = nil_wrap(mason_lspconfig.LspInstall)
+api.LspUninstall = nil_wrap(mason_lspconfig.LspUninstall)
+api.NullLsInstall = nil_wrap(mason_null_ls.NullLsInstall)
+api.NullLsUninstall = nil_wrap(mason_null_ls.NullLsUninstall)
+api.DapInstall = nil_wrap(mason_nvim_dap.DapInstall)
+api.DapUninstall = nil_wrap(mason_nvim_dap.DapUninstall)
-return M
+vim.keymap.set("n", "<leader>ii", api.Mason, { desc = "mason" })
+vim.keymap.set("n", "<leader>iI", api.MasonLog, { desc = "log" })
+vim.keymap.set("n", "<leader>iu", api.UpdateAll, { desc = "update all" })
+vim.keymap.set("n", "<leader>il", api.LspInstall, { desc = "lsp install" })
+vim.keymap.set("n", "<leader>iL", api.LspUninstall, { desc = "lsp uninstall" })
+vim.keymap.set("n", "<leader>in", api.NullLsInstall, { desc = "null-ls install" })
+vim.keymap.set("n", "<leader>iN", api.NullLsUninstall, { desc = "null-ls uninstall" })
+vim.keymap.set("n", "<leader>id", api.DapInstall, { desc = "dap install" })
+vim.keymap.set("n", "<leader>iD", api.DapUninstall, { desc = "dap uninstall" })
diff --git a/nvim/.config/nvim/lua/tobyvin/plugins/neodev.lua b/nvim/.config/nvim/lua/tobyvin/plugins/neodev.lua
index a2f0477..a3b1f40 100644
--- a/nvim/.config/nvim/lua/tobyvin/plugins/neodev.lua
+++ b/nvim/.config/nvim/lua/tobyvin/plugins/neodev.lua
@@ -1,29 +1,23 @@
-local M = {}
-
-M.setup = function()
- local status_ok, neodev = pcall(require, "neodev")
- if not status_ok then
- vim.notify("Failed to load module 'neodev'", vim.log.levels.ERROR)
- return
- end
-
- neodev.setup({
- library = {
- enabled = true,
- runtime = true,
- types = true,
- plugins = { "nvim-treesitter", "plenary.nvim", "telescope.nvim" },
- },
- override = function(root_dir, library)
- local lua_dev_utils = require("lua-dev.util")
- if lua_dev_utils.has_file(root_dir, lua_dev_utils.fqn("~/.dotfiles/nvim/.config/nvim")) then
- library.enabled = true
- library.runtime = true
- library.types = true
- library.plugins = { "nvim-treesitter", "plenary.nvim", "telescope.nvim" }
- end
- end,
- })
+local status_ok, neodev = pcall(require, "neodev")
+if not status_ok then
+ vim.notify("Failed to load module 'neodev'", vim.log.levels.ERROR)
+ return
end
-return M
+neodev.setup({
+ library = {
+ enabled = true,
+ runtime = true,
+ types = true,
+ plugins = { "nvim-treesitter", "plenary.nvim", "telescope.nvim" },
+ },
+ override = function(root_dir, library)
+ local lua_dev_utils = require("lua-dev.util")
+ if lua_dev_utils.has_file(root_dir, lua_dev_utils.fqn("~/.dotfiles/nvim/.config/nvim")) then
+ library.enabled = true
+ library.runtime = true
+ library.types = true
+ library.plugins = { "nvim-treesitter", "plenary.nvim", "telescope.nvim" }
+ end
+ end,
+})
diff --git a/nvim/.config/nvim/lua/tobyvin/plugins/neogit.lua b/nvim/.config/nvim/lua/tobyvin/plugins/neogit.lua
index 0bdd828..f9dfd43 100644
--- a/nvim/.config/nvim/lua/tobyvin/plugins/neogit.lua
+++ b/nvim/.config/nvim/lua/tobyvin/plugins/neogit.lua
@@ -1,21 +1,15 @@
-local M = {}
-
-M.setup = function()
- local status_ok, neogit = pcall(require, "neogit")
- if not status_ok then
- vim.notify("Failed to load module 'neogit'", vim.log.levels.ERROR)
- return
- end
-
- neogit.setup({
- disable_commit_confirmation = true,
- disable_signs = true,
- integrations = {
- diffview = true,
- },
- })
-
- vim.keymap.set("n", "<leader>gg", neogit.open, { desc = "neogit" })
+local status_ok, neogit = pcall(require, "neogit")
+if not status_ok then
+ vim.notify("Failed to load module 'neogit'", vim.log.levels.ERROR)
+ return
end
-return M
+neogit.setup({
+ disable_commit_confirmation = true,
+ disable_signs = true,
+ integrations = {
+ diffview = true,
+ },
+})
+
+vim.keymap.set("n", "<leader>gg", neogit.open, { desc = "neogit" })
diff --git a/nvim/.config/nvim/lua/tobyvin/plugins/notify.lua b/nvim/.config/nvim/lua/tobyvin/plugins/notify.lua
index 9f7cc7a..d102e7f 100644
--- a/nvim/.config/nvim/lua/tobyvin/plugins/notify.lua
+++ b/nvim/.config/nvim/lua/tobyvin/plugins/notify.lua
@@ -1,28 +1,22 @@
-local M = {}
-
-M.setup = function()
- local status_ok, notify = pcall(require, "notify")
- if not status_ok then
- vim.notify("Failed to load module 'notify'", vim.log.levels.ERROR)
- return
- end
+local status_ok, notify = pcall(require, "notify")
+if not status_ok then
+ vim.notify("Failed to load module 'notify'", vim.log.levels.ERROR)
+ return
+end
- vim.notify.use_console = false
- vim.api.nvim_create_autocmd("User", {
- group = vim.api.nvim_create_augroup("tobyvin_nvim-notify", { clear = true }),
- pattern = "Notify",
- callback = function(args)
- notify.notify(unpack(args.data))
- end,
- })
+vim.notify.use_console = false
+vim.api.nvim_create_autocmd("User", {
+ group = vim.api.nvim_create_augroup("tobyvin_nvim-notify", { clear = true }),
+ pattern = "Notify",
+ callback = function(args)
+ notify.notify(unpack(args.data))
+ end,
+})
- vim.api.nvim_set_hl(0, "NotifyBackground", { link = "WinBar" })
+vim.api.nvim_set_hl(0, "NotifyBackground", { link = "WinBar" })
- local telescope_ok, telescope = pcall(require, "telescope")
- if telescope_ok then
- telescope.load_extension("notify")
- vim.keymap.set("n", "<leader>fn", telescope.extensions.notify.notify, { desc = "notifications" })
- end
+local telescope_ok, telescope = pcall(require, "telescope")
+if telescope_ok then
+ telescope.load_extension("notify")
+ vim.keymap.set("n", "<leader>fn", telescope.extensions.notify.notify, { desc = "notifications" })
end
-
-return M
diff --git a/nvim/.config/nvim/lua/tobyvin/plugins/null-ls.lua b/nvim/.config/nvim/lua/tobyvin/plugins/null-ls.lua
index 9b2d547..4f008fc 100644
--- a/nvim/.config/nvim/lua/tobyvin/plugins/null-ls.lua
+++ b/nvim/.config/nvim/lua/tobyvin/plugins/null-ls.lua
@@ -1,35 +1,29 @@
-local M = {}
-
-M.setup = function()
- local status_ok, null_ls = pcall(require, "null-ls")
- if not status_ok then
- vim.notify("Failed to load module 'null-ls'", vim.log.levels.ERROR)
- return
- end
-
- local info = require("null-ls.info")
+local status_ok, null_ls = pcall(require, "null-ls")
+if not status_ok then
+ vim.notify("Failed to load module 'null-ls'", vim.log.levels.ERROR)
+ return
+end
- null_ls.setup({
- sources = {
- -- Disabled until sorting for code_actions gets pushed. See: https://github.com/stevearc/dressing.nvim/issues/22
- -- null_ls.builtins.code_actions.gitsigns,
- null_ls.builtins.code_actions.gitrebase,
- null_ls.builtins.code_actions.shellcheck,
+local info = require("null-ls.info")
- null_ls.builtins.diagnostics.markdownlint,
+null_ls.setup({
+ sources = {
+ -- Disabled until sorting for code_actions gets pushed. See: https://github.com/stevearc/dressing.nvim/issues/22
+ -- null_ls.builtins.code_actions.gitsigns,
+ null_ls.builtins.code_actions.gitrebase,
+ null_ls.builtins.code_actions.shellcheck,
- null_ls.builtins.formatting.prettier.with({
- extra_args = { "--prose-wrap=always" },
- }),
- null_ls.builtins.formatting.black,
- null_ls.builtins.formatting.stylua,
- null_ls.builtins.formatting.shfmt,
- null_ls.builtins.formatting.cbfmt,
- },
- on_attach = function(_, bufnr)
- vim.keymap.set("n", "<leader>ln", info.show_window, { desc = "null-ls info", buffer = bufnr })
- end,
- })
-end
+ null_ls.builtins.diagnostics.markdownlint,
-return M
+ null_ls.builtins.formatting.prettier.with({
+ extra_args = { "--prose-wrap=always" },
+ }),
+ null_ls.builtins.formatting.black,
+ null_ls.builtins.formatting.stylua,
+ null_ls.builtins.formatting.shfmt,
+ null_ls.builtins.formatting.cbfmt,
+ },
+ on_attach = function(_, bufnr)
+ vim.keymap.set("n", "<leader>ln", info.show_window, { desc = "null-ls info", buffer = bufnr })
+ end,
+})
diff --git a/nvim/.config/nvim/lua/tobyvin/plugins/nvim-bqf.lua b/nvim/.config/nvim/lua/tobyvin/plugins/nvim-bqf.lua
index af7da0d..54de37e 100644
--- a/nvim/.config/nvim/lua/tobyvin/plugins/nvim-bqf.lua
+++ b/nvim/.config/nvim/lua/tobyvin/plugins/nvim-bqf.lua
@@ -1,26 +1,20 @@
-local M = {}
-
-M.setup = function()
- local status_ok, bqf = pcall(require, "bqf")
- if not status_ok then
- vim.notify("Failed to load module 'bqf'", vim.log.levels.ERROR)
- return
- end
-
- bqf.setup({
- auto_resize_height = true,
- preview = {
- border_chars = { "│", "│", "─", "─", "┌", "┐", "└", "┘", "█" },
- },
- func_map = {
- open = "o",
- openc = "<cr>",
- tabc = "t",
- tab = "<C-t>",
- pscrollup = "<C-u>",
- pscrolldown = "<C-d>",
- },
- })
+local status_ok, bqf = pcall(require, "bqf")
+if not status_ok then
+ vim.notify("Failed to load module 'bqf'", vim.log.levels.ERROR)
+ return
end
-return M
+bqf.setup({
+ auto_resize_height = true,
+ preview = {
+ border_chars = { "│", "│", "─", "─", "┌", "┐", "└", "┘", "█" },
+ },
+ func_map = {
+ open = "o",
+ openc = "<cr>",
+ tabc = "t",
+ tab = "<C-t>",
+ pscrollup = "<C-u>",
+ pscrolldown = "<C-d>",
+ },
+})
diff --git a/nvim/.config/nvim/lua/tobyvin/plugins/nvim-dap-virtual-text.lua b/nvim/.config/nvim/lua/tobyvin/plugins/nvim-dap-virtual-text.lua
index ba1a7d4..a31c244 100644
--- a/nvim/.config/nvim/lua/tobyvin/plugins/nvim-dap-virtual-text.lua
+++ b/nvim/.config/nvim/lua/tobyvin/plugins/nvim-dap-virtual-text.lua
@@ -1,13 +1,7 @@
-local M = {}
-
-M.setup = function()
- local status_ok, nvim_dap_virtual_text = pcall(require, "nvim-dap-virtual-text")
- if not status_ok then
- vim.notify("Failed to load module 'dap-virtual-text'", vim.log.levels.ERROR)
- return
- end
-
- nvim_dap_virtual_text.setup({})
+local status_ok, nvim_dap_virtual_text = pcall(require, "nvim-dap-virtual-text")
+if not status_ok then
+ vim.notify("Failed to load module 'dap-virtual-text'", vim.log.levels.ERROR)
+ return
end
-return M
+nvim_dap_virtual_text.setup({})
diff --git a/nvim/.config/nvim/lua/tobyvin/plugins/nvim-navic.lua b/nvim/.config/nvim/lua/tobyvin/plugins/nvim-navic.lua
index 720d79e..4b2d3de 100644
--- a/nvim/.config/nvim/lua/tobyvin/plugins/nvim-navic.lua
+++ b/nvim/.config/nvim/lua/tobyvin/plugins/nvim-navic.lua
@@ -1,33 +1,27 @@
-local M = {}
-
-M.setup = function()
- local status_ok, nvim_navic = pcall(require, "nvim-navic")
- if not status_ok then
- vim.notify("Failed to load module 'nvim-navic'", vim.log.levels.ERROR)
- return
- end
-
- local icons = require("lspkind").symbol_map
- for i, _ in pairs(icons) do
- icons[i] = icons[i] .. " "
- end
+local status_ok, nvim_navic = pcall(require, "nvim-navic")
+if not status_ok then
+ vim.notify("Failed to load module 'nvim-navic'", vim.log.levels.ERROR)
+ return
+end
- nvim_navic.setup({
- icons = icons,
- })
+local icons = require("lspkind").symbol_map
+for i, _ in pairs(icons) do
+ icons[i] = icons[i] .. " "
+end
- vim.api.nvim_create_autocmd("LspAttach", {
- group = vim.api.nvim_create_augroup("tobyvin_nvim-navic", { clear = true }),
- desc = "setup nvim-navic",
- callback = function(args)
- local bufnr = args.buf
- local client = vim.lsp.get_client_by_id(args.data.client_id)
+nvim_navic.setup({
+ icons = icons,
+})
- if client.name ~= "cssls" and client.server_capabilities.documentSymbolProvider then
- require("nvim-navic").attach(client, bufnr)
- end
- end,
- })
-end
+vim.api.nvim_create_autocmd("LspAttach", {
+ group = vim.api.nvim_create_augroup("tobyvin_nvim-navic", { clear = true }),
+ desc = "setup nvim-navic",
+ callback = function(args)
+ local bufnr = args.buf
+ local client = vim.lsp.get_client_by_id(args.data.client_id)
-return M
+ if client.name ~= "cssls" and client.server_capabilities.documentSymbolProvider then
+ require("nvim-navic").attach(client, bufnr)
+ end
+ end,
+})
diff --git a/nvim/.config/nvim/lua/tobyvin/plugins/rust-tools.lua b/nvim/.config/nvim/lua/tobyvin/plugins/rust-tools.lua
index 51602f5..18a0124 100644
--- a/nvim/.config/nvim/lua/tobyvin/plugins/rust-tools.lua
+++ b/nvim/.config/nvim/lua/tobyvin/plugins/rust-tools.lua
@@ -1,91 +1,86 @@
+local status_ok, rust_tools = pcall(require, "rust-tools")
+if not status_ok then
+ vim.notify("Failed to load module 'rust-tools'", vim.log.levels.ERROR)
+ return
+end
+
local utils = require("tobyvin.utils")
local lsp = require("tobyvin.lsp")
local dap = require("tobyvin.plugins.dap")
-local M = {}
-
-M.setup = function()
- local status_ok, rust_tools = pcall(require, "rust-tools")
- if not status_ok then
- vim.notify("Failed to load module 'rust-tools'", vim.log.levels.ERROR)
- return
- end
- local function parse_lines(t)
- local ret = {}
+local function parse_lines(t)
+ local ret = {}
- local name = t.name
- local text = "// Recursive expansion of the " .. name .. " macro"
- table.insert(ret, "// " .. string.rep("=", string.len(text) - 3))
- table.insert(ret, text)
- table.insert(ret, "// " .. string.rep("=", string.len(text) - 3))
- table.insert(ret, "")
+ local name = t.name
+ local text = "// Recursive expansion of the " .. name .. " macro"
+ table.insert(ret, "// " .. string.rep("=", string.len(text) - 3))
+ table.insert(ret, text)
+ table.insert(ret, "// " .. string.rep("=", string.len(text) - 3))
+ table.insert(ret, "")
- local expansion = t.expansion
- for string in string.gmatch(expansion, "([^\n]+)") do
- table.insert(ret, string)
- end
-
- return ret
+ local expansion = t.expansion
+ for string in string.gmatch(expansion, "([^\n]+)") do
+ table.insert(ret, string)
end
- local handler = function(_, result)
- if result == nil then
- vim.api.nvim_out_write("No macro under cursor!\n")
- return
- end
+ return ret
+end
- local contents = parse_lines(result)
- local opts = {
- focus_id = "expand_macro",
- close_events = { "BufLeave", "CursorMoved", "InsertEnter", "FocusLost" },
- border = "single",
- scope = "cursor",
- }
- vim.lsp.util.open_floating_preview(contents, "rust", opts)
+local handler = function(_, result)
+ if result == nil then
+ vim.api.nvim_out_write("No macro under cursor!\n")
+ return
end
- require("rust-tools.expand_macro").expand_macro = function()
- ---@diagnostic disable-next-line: missing-parameter
- local params = vim.lsp.util.make_position_params()
- rust_tools.utils.request(0, "rust-analyzer/expandMacro", params, handler)
- end
+ local contents = parse_lines(result)
+ local opts = {
+ focus_id = "expand_macro",
+ close_events = { "BufLeave", "CursorMoved", "InsertEnter", "FocusLost" },
+ border = "single",
+ scope = "cursor",
+ }
+ vim.lsp.util.open_floating_preview(contents, "rust", opts)
+end
- vim.api.nvim_create_autocmd("LspAttach", {
- group = vim.api.nvim_create_augroup("tobyvin_rust-tools", { clear = true }),
- desc = "setup rust-tools",
- callback = function(args)
- local bufnr = args.buf
- local client = vim.lsp.get_client_by_id(args.data.client_id)
- if client.name ~= "rust_analyzer" then
- return
- end
+require("rust-tools.expand_macro").expand_macro = function()
+ ---@diagnostic disable-next-line: missing-parameter
+ local params = vim.lsp.util.make_position_params()
+ rust_tools.utils.request(0, "rust-analyzer/expandMacro", params, handler)
+end
- local runnables = rust_tools.runnables.runnables
- local debuggables = rust_tools.debuggables.debuggables
- local open_cargo_toml = rust_tools.open_cargo_toml.open_cargo_toml
- local external_docs = rust_tools.external_docs.open_external_docs
- local expand_macro = rust_tools.expand_macro.expand_macro
- local hover_actions = rust_tools.hover_actions.hover_actions
+rust_tools.setup({
+ tools = {
+ hover_actions = {
+ border = "single",
+ },
+ },
+ server = lsp.configs.rust_analyzer,
+ dap = { adapter = dap.adapters.codelldb },
+})
- vim.keymap.set("n", "<leader>dd", debuggables, { desc = "debug", buffer = bufnr })
- vim.keymap.set("n", "<leader>tt", runnables, { desc = "test", buffer = bufnr })
- vim.keymap.set("n", "<leader>lo", open_cargo_toml, { desc = "open Cargo.toml", buffer = bufnr })
- vim.keymap.set("n", "<leader>le", expand_macro, { desc = "expand macro", buffer = bufnr })
+vim.api.nvim_create_autocmd("LspAttach", {
+ group = vim.api.nvim_create_augroup("tobyvin_rust-tools", { clear = true }),
+ desc = "setup rust-tools",
+ callback = function(args)
+ local bufnr = args.buf
+ local client = vim.lsp.get_client_by_id(args.data.client_id)
+ if client.name ~= "rust_analyzer" then
+ return
+ end
- utils.documentation.register("rust", external_docs)
- utils.hover.register(hover_actions, { desc = "rust-tools hover actions", buffer = bufnr, priority = 10 })
- end,
- })
+ local runnables = rust_tools.runnables.runnables
+ local debuggables = rust_tools.debuggables.debuggables
+ local open_cargo_toml = rust_tools.open_cargo_toml.open_cargo_toml
+ local external_docs = rust_tools.external_docs.open_external_docs
+ local expand_macro = rust_tools.expand_macro.expand_macro
+ local hover_actions = rust_tools.hover_actions.hover_actions
- rust_tools.setup({
- tools = {
- hover_actions = {
- border = "single",
- },
- },
- server = lsp.configs.rust_analyzer,
- dap = { adapter = dap.adapters.codelldb },
- })
-end
+ vim.keymap.set("n", "<leader>dd", debuggables, { desc = "debug", buffer = bufnr })
+ vim.keymap.set("n", "<leader>tt", runnables, { desc = "test", buffer = bufnr })
+ vim.keymap.set("n", "<leader>lo", open_cargo_toml, { desc = "open Cargo.toml", buffer = bufnr })
+ vim.keymap.set("n", "<leader>le", expand_macro, { desc = "expand macro", buffer = bufnr })
-return M
+ utils.documentation.register("rust", external_docs)
+ utils.hover.register(hover_actions, { desc = "rust-tools hover actions", buffer = bufnr, priority = 10 })
+ end,
+})
diff --git a/nvim/.config/nvim/lua/tobyvin/plugins/session_manager.lua b/nvim/.config/nvim/lua/tobyvin/plugins/session_manager.lua
index c181ff7..feb9ee3 100644
--- a/nvim/.config/nvim/lua/tobyvin/plugins/session_manager.lua
+++ b/nvim/.config/nvim/lua/tobyvin/plugins/session_manager.lua
@@ -1,21 +1,15 @@
-local M = {}
-
-M.setup = function()
- local status_ok, session_manager = pcall(require, "session_manager")
- if not status_ok then
- vim.notify("Failed to load module 'session_manager'", vim.log.levels.ERROR)
- return
- end
-
- session_manager.setup({
- autoload_mode = require("session_manager.config").AutoloadMode.Disabled,
- })
-
- vim.keymap.set("n", "<leader>ss", session_manager.save_current_session, { desc = "save session" })
- vim.keymap.set("n", "<leader>sl", session_manager.load_current_dir_session, { desc = "load current session" })
- vim.keymap.set("n", "<leader>sL", session_manager.load_session, { desc = "load session" })
- vim.keymap.set("n", "<leader>sr", session_manager.load_last_session, { desc = "load last session" })
- vim.keymap.set("n", "<leader>sd", session_manager.delete_session, { desc = "delete session" })
+local status_ok, session_manager = pcall(require, "session_manager")
+if not status_ok then
+ vim.notify("Failed to load module 'session_manager'", vim.log.levels.ERROR)
+ return
end
-return M
+session_manager.setup({
+ autoload_mode = require("session_manager.config").AutoloadMode.Disabled,
+})
+
+vim.keymap.set("n", "<leader>ss", session_manager.save_current_session, { desc = "save session" })
+vim.keymap.set("n", "<leader>sl", session_manager.load_current_dir_session, { desc = "load current session" })
+vim.keymap.set("n", "<leader>sL", session_manager.load_session, { desc = "load session" })
+vim.keymap.set("n", "<leader>sr", session_manager.load_last_session, { desc = "load last session" })
+vim.keymap.set("n", "<leader>sd", session_manager.delete_session, { desc = "delete session" })
diff --git a/nvim/.config/nvim/lua/tobyvin/plugins/surround.lua b/nvim/.config/nvim/lua/tobyvin/plugins/surround.lua
index c9ff090..fa080ae 100644
--- a/nvim/.config/nvim/lua/tobyvin/plugins/surround.lua
+++ b/nvim/.config/nvim/lua/tobyvin/plugins/surround.lua
@@ -1,16 +1,10 @@
-local M = {}
-
-M.setup = function()
- local status_ok, surround = pcall(require, "surround")
- if not status_ok then
- vim.notify("Failed to load module 'surround'", vim.log.levels.ERROR)
- return
- end
-
- surround.setup({
- map_insert_mode = false,
- prefix = "<C-s>",
- })
+local status_ok, surround = pcall(require, "surround")
+if not status_ok then
+ vim.notify("Failed to load module 'surround'", vim.log.levels.ERROR)
+ return
end
-return M
+surround.setup({
+ map_insert_mode = false,
+ prefix = "<C-s>",
+})
diff --git a/nvim/.config/nvim/lua/tobyvin/plugins/telescope.lua b/nvim/.config/nvim/lua/tobyvin/plugins/telescope.lua
index ac3391d..1341c98 100644
--- a/nvim/.config/nvim/lua/tobyvin/plugins/telescope.lua
+++ b/nvim/.config/nvim/lua/tobyvin/plugins/telescope.lua
@@ -1,133 +1,94 @@
-local M = {}
-
-M.frecency_sorter = function()
- local ext = require("telescope._extensions")
- local _ = require("telescope.builtin")
- local frecency_db = require("telescope._extensions.frecency.db_client")
-
- local fzf = ext.manager.fzf
- local fzf_sorter = fzf.native_fzf_sorter()
-
- fzf_sorter.default_scoring_function = fzf_sorter.scoring_function
- fzf_sorter.default_start = fzf_sorter.start
-
- fzf_sorter.scoring_function = function(self, prompt, line, entry)
- if prompt == nil or prompt == "" then
- for _, file_entry in ipairs(self.state.frecency) do
- local filepath = entry.cwd .. "/" .. entry.value
- if file_entry.filename == filepath then
- return 9999 - file_entry.score
- end
- end
- return 9999
- end
- return self.default_scoring_function(self, prompt, line, entry)
- end
-
- fzf_sorter.start = function(self, prompt)
- self.default_start(self, prompt)
- if not self.state.frecency then
- self.state.frecency = frecency_db.get_file_scores()
- end
- end
- return fzf_sorter
+local status_ok, telescope = pcall(require, "telescope")
+if not status_ok then
+ vim.notify("Failed to load module 'telescope'", vim.log.levels.ERROR)
+ return
end
-M.setup = function()
- local status_ok, telescope = pcall(require, "telescope")
- if not status_ok then
- vim.notify("Failed to load module 'telescope'", vim.log.levels.ERROR)
- return
- end
+local actions = require("telescope.actions")
- local actions = require("telescope.actions")
-
- telescope.setup({
- defaults = {
- borderchars = { "─", "│", "─", "│", "┌", "┐", "┘", "└" },
- mappings = {
- i = {
- ["<esc>"] = actions.close,
- ["<C-h>"] = actions.which_key,
- },
- },
- file_ignore_patterns = { "^.git/", "^target/" },
- vimgrep_arguments = {
- "rg",
- "--color=never",
- "--no-heading",
- "--with-filename",
- "--line-number",
- "--column",
- "--hidden",
- "--smart-case",
- "--trim",
- },
- history = {
- path = vim.fn.stdpath("data") .. "/databases/telescope_history.sqlite3",
- limit = 100,
- },
- cache_picker = {
- num_pickers = 10,
+telescope.setup({
+ defaults = {
+ borderchars = { "─", "│", "─", "│", "┌", "┐", "┘", "└" },
+ mappings = {
+ i = {
+ ["<esc>"] = actions.close,
+ ["<C-h>"] = actions.which_key,
},
},
- pickers = {
- find_files = {
- find_command = { "fd", "--type", "f", "--hidden", "--strip-cwd-prefix" },
- },
- live_grep = { theme = "ivy" },
- buffers = {
- show_all_buffers = true,
- sort_lastused = true,
- },
+ file_ignore_patterns = { "^.git/", "^target/" },
+ vimgrep_arguments = {
+ "rg",
+ "--color=never",
+ "--no-heading",
+ "--with-filename",
+ "--line-number",
+ "--column",
+ "--hidden",
+ "--smart-case",
+ "--trim",
},
- extensions = {
- live_grep_args = {
- theme = "ivy",
- },
+ history = {
+ path = vim.fn.stdpath("data") .. "/databases/telescope_history.sqlite3",
+ limit = 100,
},
- })
-
- -- Extensions
- telescope.load_extension("fzf")
- telescope.load_extension("file_browser")
- telescope.load_extension("live_grep_args")
+ cache_picker = {
+ num_pickers = 10,
+ },
+ },
+ pickers = {
+ find_files = {
+ find_command = { "fd", "--type", "f", "--hidden", "--strip-cwd-prefix" },
+ },
+ live_grep = { theme = "ivy" },
+ buffers = {
+ show_all_buffers = true,
+ sort_lastused = true,
+ },
+ },
+ extensions = {
+ live_grep_args = {
+ theme = "ivy",
+ },
+ },
+})
- local builtins = require("telescope.builtin")
- local extensions = telescope.extensions
+-- Extensions
+telescope.load_extension("fzf")
+telescope.load_extension("file_browser")
+telescope.load_extension("live_grep_args")
- vim.keymap.set("n", "<leader>fa", builtins.autocommands, { desc = "autocommands" })
- vim.keymap.set("n", "<leader>fb", builtins.buffers, { desc = "buffers" })
- vim.keymap.set("n", "<leader>fc", builtins.commands, { desc = "commands" })
- vim.keymap.set("n", "<leader>fC", builtins.command_history, { desc = "command history" })
- vim.keymap.set("n", "<leader>fd", extensions.file_browser.file_browser, { desc = "file browser" })
- vim.keymap.set("n", "<leader>fe", builtins.diagnostics, { desc = "diagnostics" })
- vim.keymap.set("n", "<leader>ff", builtins.find_files, { desc = "find files" })
- vim.keymap.set("n", "<leader>fF", builtins.filetypes, { desc = "filetypes" })
- vim.keymap.set("n", "<leader>fg", extensions.live_grep_args.live_grep_args, { desc = "live grep" })
- vim.keymap.set("n", "<leader>fh", builtins.help_tags, { desc = "help" })
- vim.keymap.set("n", "<leader>fH", builtins.highlights, { desc = "highlights" })
- vim.keymap.set("n", "<leader>fj", builtins.jumplist, { desc = "jumplist" })
- vim.keymap.set("n", "<leader>fk", builtins.keymaps, { desc = "keymaps" })
- vim.keymap.set("n", "<leader>fl", builtins.loclist, { desc = "loclist" })
- vim.keymap.set("n", "<leader>fm", builtins.marks, { desc = "marks" })
- vim.keymap.set("n", "<leader>fM", builtins.man_pages, { desc = "man pages" })
- vim.keymap.set("n", "<leader>fo", builtins.oldfiles, { desc = "old files" })
- vim.keymap.set("n", "<leader>fp", builtins.pickers, { desc = "pickers" })
- vim.keymap.set("n", "<leader>fr", builtins.resume, { desc = "resume" })
- vim.keymap.set("n", "<leader>fR", builtins.reloader, { desc = "reloader" })
- vim.keymap.set("n", "<leader>fs", builtins.spell_suggest, { desc = "spell suggest" })
- vim.keymap.set("n", "<leader>fS", builtins.search_history, { desc = "search history" })
- vim.keymap.set("n", "<leader>ft", builtins.tags, { desc = "tags" })
- vim.keymap.set("n", "<leader>ft", builtins.colorscheme, { desc = "colorscheme" })
- vim.keymap.set("n", "<leader>fv", builtins.vim_options, { desc = "vim options" })
- vim.keymap.set("n", "<leader>f'", builtins.registers, { desc = "registers" })
- vim.keymap.set("n", "<leader>gb", builtins.git_branches, { desc = "branches" })
- vim.keymap.set("n", "<leader>gc", builtins.git_bcommits, { desc = "bcommits" })
- vim.keymap.set("n", "<leader>gC", builtins.git_commits, { desc = "commits" })
- vim.keymap.set("n", "<leader>gf", builtins.git_files, { desc = "files" })
- vim.keymap.set("n", "<leader>gt", builtins.git_status, { desc = "status" })
- vim.keymap.set("n", "<leader>gT", builtins.git_stash, { desc = "stash" })
-end
+local builtins = require("telescope.builtin")
+local extensions = telescope.extensions
-return M
+vim.keymap.set("n", "<leader>fa", builtins.autocommands, { desc = "autocommands" })
+vim.keymap.set("n", "<leader>fb", builtins.buffers, { desc = "buffers" })
+vim.keymap.set("n", "<leader>fc", builtins.commands, { desc = "commands" })
+vim.keymap.set("n", "<leader>fC", builtins.command_history, { desc = "command history" })
+vim.keymap.set("n", "<leader>fd", extensions.file_browser.file_browser, { desc = "file browser" })
+vim.keymap.set("n", "<leader>fe", builtins.diagnostics, { desc = "diagnostics" })
+vim.keymap.set("n", "<leader>ff", builtins.find_files, { desc = "find files" })
+vim.keymap.set("n", "<leader>fF", builtins.filetypes, { desc = "filetypes" })
+vim.keymap.set("n", "<leader>fg", extensions.live_grep_args.live_grep_args, { desc = "live grep" })
+vim.keymap.set("n", "<leader>fh", builtins.help_tags, { desc = "help" })
+vim.keymap.set("n", "<leader>fH", builtins.highlights, { desc = "highlights" })
+vim.keymap.set("n", "<leader>fj", builtins.jumplist, { desc = "jumplist" })
+vim.keymap.set("n", "<leader>fk", builtins.keymaps, { desc = "keymaps" })
+vim.keymap.set("n", "<leader>fl", builtins.loclist, { desc = "loclist" })
+vim.keymap.set("n", "<leader>fm", builtins.marks, { desc = "marks" })
+vim.keymap.set("n", "<leader>fM", builtins.man_pages, { desc = "man pages" })
+vim.keymap.set("n", "<leader>fo", builtins.oldfiles, { desc = "old files" })
+vim.keymap.set("n", "<leader>fp", builtins.pickers, { desc = "pickers" })
+vim.keymap.set("n", "<leader>fr", builtins.resume, { desc = "resume" })
+vim.keymap.set("n", "<leader>fR", builtins.reloader, { desc = "reloader" })
+vim.keymap.set("n", "<leader>fs", builtins.spell_suggest, { desc = "spell suggest" })
+vim.keymap.set("n", "<leader>fS", builtins.search_history, { desc = "search history" })
+vim.keymap.set("n", "<leader>ft", builtins.tags, { desc = "tags" })
+vim.keymap.set("n", "<leader>ft", builtins.colorscheme, { desc = "colorscheme" })
+vim.keymap.set("n", "<leader>fv", builtins.vim_options, { desc = "vim options" })
+vim.keymap.set("n", "<leader>f'", builtins.registers, { desc = "registers" })
+vim.keymap.set("n", "<leader>gb", builtins.git_branches, { desc = "branches" })
+vim.keymap.set("n", "<leader>gc", builtins.git_bcommits, { desc = "bcommits" })
+vim.keymap.set("n", "<leader>gC", builtins.git_commits, { desc = "commits" })
+vim.keymap.set("n", "<leader>gf", builtins.git_files, { desc = "files" })
+vim.keymap.set("n", "<leader>gt", builtins.git_status, { desc = "status" })
+vim.keymap.set("n", "<leader>gT", builtins.git_stash, { desc = "stash" })
diff --git a/nvim/.config/nvim/lua/tobyvin/plugins/tokyonight.lua b/nvim/.config/nvim/lua/tobyvin/plugins/tokyonight.lua
index f7ca961..51bfc81 100644
--- a/nvim/.config/nvim/lua/tobyvin/plugins/tokyonight.lua
+++ b/nvim/.config/nvim/lua/tobyvin/plugins/tokyonight.lua
@@ -1,19 +1,13 @@
-local M = {}
-
-M.setup = function()
- local status_ok, tokyonight = pcall(require, "tokyonight")
- if not status_ok then
- vim.notify("Failed to load module 'tokyonight'", vim.log.levels.ERROR)
- return
- end
-
- tokyonight.setup({
- styles = {
- sidebars = "transparent",
- floats = "transparent",
- },
- transparent = true,
- })
+local status_ok, tokyonight = pcall(require, "tokyonight")
+if not status_ok then
+ vim.notify("Failed to load module 'tokyonight'", vim.log.levels.ERROR)
+ return
end
-return M
+tokyonight.setup({
+ styles = {
+ sidebars = "transparent",
+ floats = "transparent",
+ },
+ transparent = true,
+})
diff --git a/nvim/.config/nvim/lua/tobyvin/plugins/treesitter.lua b/nvim/.config/nvim/lua/tobyvin/plugins/treesitter.lua
index a7b3224..00139f3 100644
--- a/nvim/.config/nvim/lua/tobyvin/plugins/treesitter.lua
+++ b/nvim/.config/nvim/lua/tobyvin/plugins/treesitter.lua
@@ -1,66 +1,58 @@
-local M = {}
-
-M.attached_keymaps = {}
-
-M.setup = function()
- local status_ok, treesitter = pcall(require, "nvim-treesitter.configs")
- if not status_ok then
- vim.notify("Failed to load module 'nvim-treesitter'", vim.log.levels.ERROR)
- return
- end
+local status_ok, treesitter = pcall(require, "nvim-treesitter.configs")
+if not status_ok then
+ vim.notify("Failed to load module 'nvim-treesitter'", vim.log.levels.ERROR)
+ return
+end
- treesitter.setup({
- ensure_installed = "all",
- indent = {
- enable = true,
- },
- highlight = {
- enable = true,
- additional_vim_regex_highlighting = { "markdown" },
- disable = function(_, bufnr)
- -- TODO: temp solution to ts highlighting screwing up formatting
- return vim.api.nvim_buf_line_count(bufnr) > 2500 or vim.bo[bufnr].filetype == "help"
- end,
- },
- playground = {
+treesitter.setup({
+ ensure_installed = "all",
+ indent = {
+ enable = true,
+ },
+ highlight = {
+ enable = true,
+ additional_vim_regex_highlighting = { "markdown" },
+ disable = function(_, bufnr)
+ -- TODO: temp solution to ts highlighting screwing up formatting
+ return vim.api.nvim_buf_line_count(bufnr) > 2500 or vim.bo[bufnr].filetype == "help"
+ end,
+ },
+ playground = {
+ enable = true,
+ },
+ textobjects = {
+ select = {
enable = true,
- },
- textobjects = {
- select = {
- enable = true,
- lookahead = true,
- keymaps = {
- ["ia"] = "@attribute.inner",
- ["aa"] = "@attribute.outer",
- ["ib"] = "@block.inner",
- ["ab"] = "@block.outer",
- ["ic"] = "@class.inner",
- ["ac"] = "@class.outer",
- ["ie"] = "@statement.inner",
- ["ae"] = "@statement.outer",
- ["if"] = "@function.inner",
- ["af"] = "@function.outer",
- ["iF"] = "@frame.inner",
- ["aF"] = "@frame.outer",
- ["ii"] = "@conditional.inner",
- ["ai"] = "@conditional.outer",
- ["il"] = "@loop.inner",
- ["al"] = "@loop.outer",
- ["in"] = "@scopename.inner",
- ["an"] = "@scopename.outer",
- ["ix"] = "@call.inner",
- ["ax"] = "@call.outer",
- ["iv"] = "@parameter.inner",
- ["av"] = "@parameter.outer",
- ["i/"] = "@comment.inner",
- ["a/"] = "@comment.outer",
- },
+ lookahead = true,
+ keymaps = {
+ ["ia"] = "@attribute.inner",
+ ["aa"] = "@attribute.outer",
+ ["ib"] = "@block.inner",
+ ["ab"] = "@block.outer",
+ ["ic"] = "@class.inner",
+ ["ac"] = "@class.outer",
+ ["ie"] = "@statement.inner",
+ ["ae"] = "@statement.outer",
+ ["if"] = "@function.inner",
+ ["af"] = "@function.outer",
+ ["iF"] = "@frame.inner",
+ ["aF"] = "@frame.outer",
+ ["ii"] = "@conditional.inner",
+ ["ai"] = "@conditional.outer",
+ ["il"] = "@loop.inner",
+ ["al"] = "@loop.outer",
+ ["in"] = "@scopename.inner",
+ ["an"] = "@scopename.outer",
+ ["ix"] = "@call.inner",
+ ["ax"] = "@call.outer",
+ ["iv"] = "@parameter.inner",
+ ["av"] = "@parameter.outer",
+ ["i/"] = "@comment.inner",
+ ["a/"] = "@comment.outer",
},
},
- context_commentstring = {
- enable = true,
- },
- })
-end
-
-return M
+ },
+ context_commentstring = {
+ enable = true,
+ },
+})
diff --git a/nvim/.config/nvim/lua/tobyvin/plugins/undotree.lua b/nvim/.config/nvim/lua/tobyvin/plugins/undotree.lua
index c312c4b..e21db0d 100644
--- a/nvim/.config/nvim/lua/tobyvin/plugins/undotree.lua
+++ b/nvim/.config/nvim/lua/tobyvin/plugins/undotree.lua
@@ -1,17 +1,11 @@
-local M = {}
-
-M.setup = function()
- local status_ok, undotree = pcall(require, "undotree")
- if not status_ok then
- vim.notify("Failed to load module 'undotree'", vim.log.levels.ERROR)
- return
- end
-
- undotree.setup({
- window = {
- winblend = 0,
- },
- })
+local status_ok, undotree = pcall(require, "undotree")
+if not status_ok then
+ vim.notify("Failed to load module 'undotree'", vim.log.levels.ERROR)
+ return
end
-return M
+undotree.setup({
+ window = {
+ winblend = 0,
+ },
+})
diff --git a/nvim/.config/nvim/lua/tobyvin/plugins/yanky.lua b/nvim/.config/nvim/lua/tobyvin/plugins/yanky.lua
index 81d374d..0393924 100644
--- a/nvim/.config/nvim/lua/tobyvin/plugins/yanky.lua
+++ b/nvim/.config/nvim/lua/tobyvin/plugins/yanky.lua
@@ -1,25 +1,19 @@
-local M = {}
-
-M.setup = function()
- local status_ok, yanky = pcall(require, "yanky")
- if not status_ok then
- vim.notify("Failed to load module 'yanky'", vim.log.levels.ERROR)
- return
- end
-
- yanky.setup({
- highlight = {
- on_put = false,
- on_yank = false,
- },
- preserve_cursor_position = {
- enabled = false,
- },
- })
-
- local picker = require("yanky.picker")
- picker.setup()
- vim.keymap.set({ "n", "x" }, "<C-p>", picker.select_in_history, { desc = "yank history" })
+local status_ok, yanky = pcall(require, "yanky")
+if not status_ok then
+ vim.notify("Failed to load module 'yanky'", vim.log.levels.ERROR)
+ return
end
-return M
+yanky.setup({
+ highlight = {
+ on_put = false,
+ on_yank = false,
+ },
+ preserve_cursor_position = {
+ enabled = false,
+ },
+})
+
+local picker = require("yanky.picker")
+picker.setup()
+vim.keymap.set({ "n", "x" }, "<C-p>", picker.select_in_history, { desc = "yank history" })
diff --git a/nvim/.config/nvim/lua/tobyvin/utils/log.lua b/nvim/.config/nvim/lua/tobyvin/utils/log.lua
new file mode 100644
index 0000000..d9ea285
--- /dev/null
+++ b/nvim/.config/nvim/lua/tobyvin/utils/log.lua
@@ -0,0 +1,33 @@
+local log = {}
+
+local status_ok, Log = pcall(require, "plenary.log")
+if status_ok then
+ log = Log.new({ plugin = "notify" })
+end
+
+local levels = {}
+
+for k, v in pairs(vim.log.levels) do
+ levels[v] = k:lower()
+ levels[k] = k:lower()
+ levels[k:lower()] = k:lower()
+end
+
+setmetatable(log, {
+ __call = function(t, m, l, o)
+ local msg = m
+ if o and o.title then
+ msg = string.format("%s: %s", o.title, msg)
+ end
+
+ local level = vim.F.if_nil(levels[l], "info")
+ pcall(t[level], msg)
+
+ vim.api.nvim_exec_autocmds("User", {
+ pattern = "Notify",
+ data = { m, l, o },
+ })
+ end,
+})
+
+vim.notify = log