From 1c21e3552b09bb4b0ca0a392639a0334497080b1 Mon Sep 17 00:00:00 2001 From: th3r00t Date: Fri, 29 Aug 2025 00:40:20 -0400 Subject: [PATCH] Iniital upload Removing from my nixos config to add congruency with all nvim installs --- lua/autocmds.lua | 9 ++ lua/completion.lua | 112 +++++++++++++++++++ lua/diagnostics.lua | 60 ++++++++++ lua/functions.lua | 166 ++++++++++++++++++++++++++++ lua/keymaps.lua | 112 +++++++++++++++++++ lua/lsp.lua | 57 ++++++++++ lua/options.lua | 55 ++++++++++ lua/plugins.lua | 138 +++++++++++++++++++++++ lua/telescope_configuration.lua | 32 ++++++ lua/terminal.lua | 11 ++ lua/treesitter.lua | 11 ++ lua/utils/reload.lua | 11 ++ lua/utils/t3_functions.lua | 187 ++++++++++++++++++++++++++++++++ lua/utils/t3_overrides.lua | 5 + lua/vimwiki.lua | 155 ++++++++++++++++++++++++++ 15 files changed, 1121 insertions(+) create mode 100644 lua/autocmds.lua create mode 100644 lua/completion.lua create mode 100644 lua/diagnostics.lua create mode 100644 lua/functions.lua create mode 100644 lua/keymaps.lua create mode 100644 lua/lsp.lua create mode 100644 lua/options.lua create mode 100644 lua/plugins.lua create mode 100644 lua/telescope_configuration.lua create mode 100644 lua/terminal.lua create mode 100644 lua/treesitter.lua create mode 100644 lua/utils/reload.lua create mode 100644 lua/utils/t3_functions.lua create mode 100644 lua/utils/t3_overrides.lua create mode 100644 lua/vimwiki.lua diff --git a/lua/autocmds.lua b/lua/autocmds.lua new file mode 100644 index 0000000..bc71e2e --- /dev/null +++ b/lua/autocmds.lua @@ -0,0 +1,9 @@ +local vim = vim + +vim.api.nvim_create_autocmd({ "BufEnter", "BufWritePost" }, { + group = vim.api.nvim_create_augroup("TWTask", { clear = true }), + pattern = "*.wiki", -- Pattern to match Markdown files + callback = function() + vim.cmd('TWSyncTasks') + end, +}) diff --git a/lua/completion.lua b/lua/completion.lua new file mode 100644 index 0000000..b9a5df0 --- /dev/null +++ b/lua/completion.lua @@ -0,0 +1,112 @@ +local cmp = require("cmp") + +cmp.setup({ + snippet = { + expand = function(args) + require('luasnip').lsp_expand(args.body) -- For `luasnip` users. + end, + }, + window = { + completion = cmp.config.window.bordered(), + documentation = cmp.config.window.bordered(), + }, + mapping = cmp.mapping.preset.insert({ + [""] = cmp.mapping.scroll_docs(-4), + [""] = cmp.mapping.scroll_docs(4), + [""] = cmp.mapping.complete(), + [""] = cmp.mapping.abort(), + [""] = cmp.mapping.confirm({ select = false }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items. + [""] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_next_item() + else + fallback() + end + end, { "i", "s" }), + + [""] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_prev_item() + else + fallback() + end + end, { "i", "s" }), + }), + sources = cmp.config.sources({ + { name = "nvim_lua" }, + { name = "copilot", group_index = 3 }, + { name = "nvim_lsp", group_index = 1 }, + { name = "path", group_index = 3 }, + { name = "luasnip", group_index = 2 }, + { name = "buffer" }, + { name = "calc" }, + { name = 'orgmode' }, + -- { name = 'vsnip' }, -- For vsnip users. + -- { name = 'luasnip' }, -- For luasnip users. + -- { name = 'ultisnips' }, -- For ultisnips users. + -- { name = 'snippy' }, -- For snippy users. + { name = "crates" }, + -- { name = 'cmdline' }, + -- { name = 'neorg' }, + }), +}) + +-- Set configuration for specific filetype. +cmp.setup.filetype("gitcommit", { + sources = cmp.config.sources({ + { name = "cmp_git" }, -- You can specify the `cmp_git` source if you were installed it. + }, { + { name = "buffer" }, + }), +}) + +-- Use buffer source for `/` and `?` (if you enabled `native_menu`, this won't work anymore). +cmp.setup.cmdline({ "/", "?" }, { + mapping = cmp.mapping.preset.cmdline(), + sources = { + { name = "buffer" }, + { name = "cmdline" }, + }, +}) + +-- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore). +cmp.setup.cmdline(":", { + mapping = cmp.mapping.preset.cmdline(), + sources = cmp.config.sources({ + { name = "path" }, + }, { + { name = "cmdline" }, + }), +}) + +-- Set up lspconfig. +-- require("cmp_nvim_lsp").default_capabilities() +local capabilities = require("cmp_nvim_lsp").default_capabilities() +-- Replace with each lsp server you've enabled. +-- require('lspconfig')[''].setup { +-- capabilities = capabilities +-- } +require("lspconfig").clangd.setup({ + capabilities = capabilities, +}) +require("lspconfig").taplo.setup({ + capabilities = capabilities, +}) +require("lspconfig").marksman.setup({ + capabilities = capabilities, +}) +require("lspconfig").lua_ls.setup({ + capabilities = capabilities, +}) +require("lspconfig").rust_analyzer.setup({ + capabilities = capabilities, +}) +require("lspconfig").zls.setup({ + capabilities = capabilities, +}) +require("lspconfig").pyright.setup({ + capabilities = capabilities, +}) +-- require'lspconfig'.jedi_language_server.setup { +-- capabilities = capabilities, +-- } diff --git a/lua/diagnostics.lua b/lua/diagnostics.lua new file mode 100644 index 0000000..5310947 --- /dev/null +++ b/lua/diagnostics.lua @@ -0,0 +1,60 @@ +require("tiny-inline-diagnostic").setup({ + -- Style preset for diagnostic messages + -- Available options: + -- "modern", "classic", "minimal", "powerline", + -- "ghost", "simple", "nonerdfont", "amongus" + preset = "modern", + transparent_bg = false, -- Set the background of the diagnostic to transparent + transparent_cursorline = false, -- Set the background of the cursorline to transparent (only one the first diagnostic) + hi = { + error = "DiagnosticError", -- Highlight group for error messages + warn = "DiagnosticWarn", -- Highlight group for warning messages + info = "DiagnosticInfo", -- Highlight group for informational messages + hint = "DiagnosticHint", -- Highlight group for hint or suggestion messages + arrow = "NonText", -- Highlight group for diagnostic arrows + background = "CursorLine", + mixing_color = "None", + }, + + options = { + show_source = { + enabled = false, + if_many = false, + }, + use_icons_from_diagnostic = false, + set_arrow_to_diag_color = false, + add_messages = true, + throttle = 20, + softwrap = 30, + multilines = { + enabled = false, + always_show = false, + trim_whitespaces = false, + tabstop = 4, + }, + show_all_diags_on_cursorline = false, + enable_on_insert = false, + enable_on_select = false, + + overflow = { + mode = "wrap", + padding = 0, + }, + break_line = { + enabled = false, + after = 30, + }, + format = nil, + virt_texts = { + priority = 2048, + }, + severity = { + vim.diagnostic.severity.ERROR, + vim.diagnostic.severity.WARN, + vim.diagnostic.severity.INFO, + vim.diagnostic.severity.HINT, + }, + overwrite_events = nil, + }, + disabled_ft = {} -- List of filetypes to disable the plugin +}) diff --git a/lua/functions.lua b/lua/functions.lua new file mode 100644 index 0000000..00c2dd8 --- /dev/null +++ b/lua/functions.lua @@ -0,0 +1,166 @@ +local vim = vim +local fzflua = require("fzf-lua") +local Job = require'plenary.job' + +function t3_find_file() + -- local file_name = vim.fn.input("Find File: ", "", "file") + fzflua.files() +end + +function t3_recent_files() + fzflua.oldfiles() +end + +function t3_org_files() + fzflua.files({ cwd = '~/org/'}) +end + +function t3_project_files() + fzflua.files({ cwd = '~/Projects/'}) +end + +function t3_dot_files() + fzflua.files({ cwd = '~/.dotfiles/'}) +end + +function t3_config_files() + fzflua.files({ cwd = '~/.dotfiles/'}) +end + +function t3_snip_capture(name) + if type(name) ~= "string" or name == "" then + print("Error: Invalid snippet name") + return + end + -- local timestamp = os.date("%Y%m%d%H%M%S") + local snippet_path = "~/.config/nvim/snippets/" + local filename = snippet_path .. name:gsub("%s+", "_") .. ".lua" + local file = io.open(vim.fn.expand(filename), "w") + if file == nil then + print("Error: Could not open file for editing.") + return + end + local previous_buffer = vim.api.nvim_get_current_buf() + file:write("local ls = require('luasnip')\n\nls.add_snippets(\"{}\", {\n\tls.parser.parse_snippet(\n\t\t'{}',\n\t\t'{}'),\n})") + file:close() + vim.cmd("e " .. filename) + vim.bo.filetype = 'lua' + -- vim.cmd("Neorg inject-metadata") + -- Set an autocmd to return to the previous buffer when the note buffer is closed + vim.api.nvim_create_autocmd("BufLeave", { + buffer = 0, -- Current buffer (the note buffer) + callback = function() + load_snippets_from_directory(snippet_path) + vim.cmd("buffer " .. previous_buffer) + end, + }) + print("Captured snippet: " .. filename) +end + +function t3_org_capture(name) + if type(name) ~= "string" or name == "" then + print("Error: Invalid note name") + return + end + local timestamp = os.date("%Y%m%d%H%M%S") + local org_path = "~/org/.org-roam/" + local filename = org_path .. timestamp .. "-" .. name:gsub("%s+", "_") .. ".norg" + local file = io.open(vim.fn.expand(filename), "w") + if file == nil then + print("Error: Could not open file for editing.") + return + end + local previous_buffer = vim.api.nvim_get_current_buf() + file:write("* " .. name .. "\n\n") + file:close() + vim.cmd("e " .. filename) + vim.bo.filetype = 'norg' + vim.cmd("Neorg inject-metadata") + -- Set an autocmd to return to the previous buffer when the note buffer is closed + vim.api.nvim_create_autocmd("BufLeave", { + buffer = 0, -- Current buffer (the note buffer) + callback = function() + vim.cmd("buffer " .. previous_buffer) + end, + }) + print("Captured note: " .. filename) +end + +vim.api.nvim_create_user_command( + 'NeorgCapture', + function() + -- local title = vim.fn.input("Title: ") + local current_workspace = vim.g.neorg_workspace_name + if not current_workspace then + vim.cmd("Neorg workspace default") + end + vim.ui.input({ prompt = "Enter note name: "}, function(note_name) + if not note_name or note_name == "" then + print("Error: Note name required!") + return + end + t3_org_capture(note_name) + end + ) + end, + { nargs = 0, desc = "Capture a Neorg note" } +) + +vim.api.nvim_create_user_command( + 'CaptureSnip', + function() + -- local title = vim.fn.input("Title: ") + -- local current_workspace = vim.g.neorg_workspace_name + -- if not current_workspace then + -- vim.cmd("Neorg workspace default") + -- end + vim.ui.input({ prompt = "Enter snippet name: "}, function(snip_name) + if not snip_name or snip_name == "" then + print("Error: Snippet name required!") + return + end + t3_snip_capture(snip_name) + end + ) + end, + { nargs = 0, desc = "Capture a Neorg note" } +) +function t3_buffers() + fzflua.buffers() +end + +function t3_tabs() + fzflua.tabs() +end + +function t3_live_grep(state) + state = state or 0 + if state == 0 then + fzflua.live_grep() + else + fzflua.live_grep_resume() + end +end + +function t3_grep(state) + state = state or 0 + if state == 0 then + fzflua.grep_project() + else + fzflua.grep() + end +end +function t3_make_ctags() + Job:new({ + command = 'ctags', + args = { '-R .' }, + }) +end + +vim.api.nvim_create_autocmd("FileType", { + pattern = { "markdown", "norg", "md", "wiki" }, -- Set for markdown file type + callback = function() + vim.api.nvim_buf_set_keymap(0, "n", "", "o* [ ] ", { noremap = true, silent = true }) + vim.api.nvim_buf_set_keymap(0, "i", "", "0wi* [ ] ", { noremap = true, silent = true }) + end, +}) diff --git a/lua/keymaps.lua b/lua/keymaps.lua new file mode 100644 index 0000000..5491e5e --- /dev/null +++ b/lua/keymaps.lua @@ -0,0 +1,112 @@ +local vim = vim + +vim.keymap.set("n", "s", function() + vim.cmd("split") + vim.cmd("wincmd j") +end, { noremap = true }) + +vim.keymap.set("n", "v", function() + vim.cmd("vsplit") + vim.cmd("wincmd l") +end, { noremap = true }) + +-- Leader Maps +vim.keymap.set("n", "f", "", { desc = "Files"}) +vim.keymap.set("n", "ff", ":FzfLua files", { desc = "File Finder"}) +-- vim.keymap.set("n", "fe", ":Pick files", { desc = "File Picker"}) +vim.keymap.set("n", "ft", t3_toggle_netrw, { desc = "File Tree"}) + +vim.keymap.set("n", "b", "", { desc = "Buffers"}) +vim.keymap.set("n", "bb", ":Pick buffers", { desc = "Buffer Picker"}) +vim.keymap.set("n", "bp", ":bp", { desc = "Previous"}) +vim.keymap.set("n", "bn", ":bn", { desc = "Next"}) +vim.keymap.set("n", "bd", ":bd", { desc = "Delete"}) + +vim.keymap.set("n", "g", "", { desc = "Grep"}) +vim.keymap.set("n", "gg", ":FzfLua grep", { desc = "Grep"}) +vim.keymap.set("n", "gr", ":FzfLua grep resume=true", { desc = "Resume Grep"}) + +vim.keymap.set("n", "G", "", { desc = "Git"}) +vim.keymap.set("n", "Gg", ":LazyGit", { desc = "LazyGit"}) +vim.keymap.set("n", "GC", ":LazyGitConfig", { desc = "LazyGit Config"}) +vim.keymap.set("n", "Gc", ":LazyGitFilter", { desc = "Commits"}) +vim.keymap.set("n", "Gl", ":LazyGitLog", { desc = "Log"}) + +vim.keymap.set("n", "", "", { desc = "Tabs"}) +vim.keymap.set("n", "", ":tabnew", { desc = "New Tab"}) +vim.keymap.set("n", "p", ":tabprevious", { desc = "Previous Tab"}) +vim.keymap.set("n", "n", ":tabnext", { desc = "Next Tab"}) +vim.keymap.set("n", "d", ":tabclose", { desc = "Delete Tab"}) +vim.keymap.set("n", "l", ":tablast", { desc = "Last Tab"}) +vim.keymap.set("n", "f", ":tabfirst", { desc = "First Tab"}) +vim.keymap.set("n", "m", ":tabmove", { desc = "Move Tab"}) +vim.keymap.set("n", "r", ":tabrenumber", { desc = "Renumber Tabs"}) +vim.keymap.set("n", "c", ":tabclose!", { desc = "Force Close Tab"}) + +vim.keymap.set("n", "gR", "Glance references", { desc = "Glance References" }) +vim.keymap.set("n", "gD", "Glance definitions", { desc = "Glance Definitions" }) +vim.keymap.set("n", "gY", "Glance type_definitions", { desc = "Glance Type Definitions" }) +vim.keymap.set("n", "gM", "Glance implementations", { desc = "Glance Implementations" }) + +vim.keymap.set("n", "", ":b#", { desc = "Switch to Last Buffer" }) +vim.keymap.set("n", "", ":bprevious", { desc = "Previous Buffer" }) +vim.keymap.set("n", "", ":bnext", { desc = "Next Buffer" }) +vim.keymap.set("n", "", ":tabprevious", { desc = "Previous Tab" }) +vim.keymap.set("n", "", ":tabnext", { desc = "Next Tab" }) +vim.keymap.set("n", "", "BufferGoto 1", { desc = "Go to Buffer 1" }) +vim.keymap.set("n", "", "BufferGoto 2", { desc = "Go to Buffer 2" }) +vim.keymap.set("n", "", "BufferGoto 3", { desc = "Go to Buffer 3" }) +vim.keymap.set("n", "", "BufferGoto 4", { desc = "Go to Buffer 4" }) +vim.keymap.set("n", "", "BufferGoto 5", { desc = "Go to Buffer 5" }) +vim.keymap.set("n", "", "BufferGoto 6", { desc = "Go to Buffer 6" }) +vim.keymap.set("n", "", "BufferGoto 7", { desc = "Go to Buffer 7" }) +vim.keymap.set("n", "", "BufferGoto 8", { desc = "Go to Buffer 8" }) +vim.keymap.set("n", "", "BufferGoto 9", { desc = "Go to Buffer 9" }) +vim.keymap.set("n", "", "BufferLast", { desc = "Go to Last Buffer" }) + +-- Meta X Maps +vim.keymap.set("n", "", ":Telescope commands", { desc = "Commands"}) +vim.keymap.set("n", "b", ":Telescope buffers", { desc = "Buffers"}) +vim.keymap.set("n", "f", ":Telescope find_files", { desc = "Find Files"}) +vim.keymap.set("n", "g", ":Telescope live_grep", { desc = "Live Grep"}) +vim.keymap.set("n", "h", ":Telescope help_tags", { desc = "Help Tags"}) +vim.keymap.set("n", "p", ":Telescope project", { desc = "Projects"}) +vim.keymap.set("n", "l", ":Telescope resume", { desc = "Resume Last Search"}) +vim.keymap.set("n", "c", ":Telescope colorscheme", { desc = "Colorschemes"}) +vim.keymap.set("n", "n", ":enew", { desc = "New File"}) +vim.keymap.set("n", "s", ":w", { desc = "Save File"}) +vim.keymap.set("n", "q", ":q", { desc = "Quit"}) +vim.keymap.set("n", "w", ":bd", { desc = "Close Buffer"}) +vim.keymap.set("n", "a", "ggVG", { desc = "Select All"}) +vim.keymap.set("n", "z", "u", { desc = "Undo"}) +vim.keymap.set("n", "y", "", { desc = "Redo"}) +vim.keymap.set("n", "/", ":nohlsearch", { desc = "Clear Search Highlight"}) +vim.keymap.set("n", "=", ":vertical resize +5", { desc = "Increase Window Width"}) +vim.keymap.set("n", "-"," :vertical resize -5", { desc = "Decrease Window Width"}) +vim.keymap.set("n", "+", ":resize +5", { desc = "Increase Window Height"}) +vim.keymap.set("n", "_", ":resize -5", { desc = "Decrease Window Height"}) +vim.keymap.set("n", "Left", ":vertical resize -5", { desc = "Decrease Window Width"}) +vim.keymap.set("n", "Right"," :vertical resize +5", { desc = "Increase Window Width"}) +vim.keymap.set("n", "Up", ":resize +5", { desc = "Increase Window Height"}) +vim.keymap.set("n", "Down", ":resize -5", { desc = "Decrease Window Height"}) +vim.keymap.set("n", "Enter", ":ToggleTerm", { desc = "Toggle Terminal"}) + + +-- CTRL X Maps +vim.keymap.set("n", "", ":Pick buffers", { desc = "Buffer Picker"}) +vim.keymap.set("n", "", ":Pick files", { desc = "File Picker"}) +vim.keymap.set("n", "", ":Pick help", { desc = "Help Picker"}) +vim.keymap.set("n", "", "", { desc = "Grep"}) +vim.keymap.set("n", "g", ":Pick grep", { desc = "Grep"}) +vim.keymap.set("n", "l", ":Pick grep_live", { desc = "Live Grep"}) +vim.keymap.set("n", "", "", { desc = "Notes"}) +vim.keymap.set("n", "e", "TWEditTask", { desc = "TaskWarrior Edit", noremap = true, silent = true }) +vim.keymap.set("n", "v", "TWView", { desc = "View Tasks", noremap = true, silent = true }) +vim.keymap.set("n", "u", "TWUpdateCurrent", { desc="Update Tasks", noremap = true, silent = true }) +vim.keymap.set("n", "s", "TWSyncTasks", { desc = "Sync Tasks", noremap = true, silent = true }) +vim.keymap.set("n", "", "TWToggle", { desc = "Toggle Taskwarrior", silent = true }) + +vim.keymap.set("v", "", ":'<,'>SnipRun", { silent = true, desc = "Run Selection" }) +vim.keymap.set("n", "", ":SnipRun", { desc = "Run Current Line" }) +vim.keymap.set("n", "", ":%SnipRun", { desc = "Run Buffer" }) +vim.keymap.set("n", "", "SnipReset", { desc = "Run Buffer" }) diff --git a/lua/lsp.lua b/lua/lsp.lua new file mode 100644 index 0000000..943f4c5 --- /dev/null +++ b/lua/lsp.lua @@ -0,0 +1,57 @@ +local vim = vim +-- vim.cmd [[ +-- augroup LspCompletion +-- autocmd! +-- autocmd InsertEnter * setlocal omnifunc=v:lua.vim.lsp.omnifunc +-- autocmd TextChangedI * if pumvisible() == 0 | silent! lua vim.fn.complete(vim.fn.col('.'), vim.fn["vim.lsp.omnifunc"]()) | endif +-- augroup END +-- ]] +vim.lsp.enable('lua_ls') +vim.lsp.enable('gopls', { + settings = { + gopls = { + analyses = { + unusedparams = true, + unusedwrite = true, + shadow = true, + }, + staticcheck = true, + usePlaceholders = true, + hints = { + assignVariableTypes = true, + compositeLiteralFields = true, + compositeLiteralTypes = true, + functionTypeParameters = true, + parameterNames = true, + rangeVariableTypes = true, + }, + }, + }, +}) +require("lsp_signature").setup({ + debug = false, + bind = true, -- registers signature handler + doc_lines = 10, + max_height = 12, + max_width = function() return math.floor(vim.api.nvim_win_get_width(0) * 0.8) end, + wrap = true, + floating_window = true, -- show the popup + floating_window_above_cur_line = true, + floating_window_off_x = 1, + floating_window_off_y = 0, + + -- IMPORTANT: don’t inline (you can change later if you want) + hint_enable = true, + hint_inline = function() return false end, + + hint_prefix = "🐼 ", + hint_scheme = "String", + hi_parameter = "LspSignatureActiveParameter", + handler_opts = { border = "rounded" }, + + always_trigger = false, + extra_trigger_chars = { "(", "," }, -- good default + zindex = 200, + padding = "", + timer_interval = 200, +}) diff --git a/lua/options.lua b/lua/options.lua new file mode 100644 index 0000000..3f92afa --- /dev/null +++ b/lua/options.lua @@ -0,0 +1,55 @@ +local vim = vim + +vim.o.number = true +vim.o.relativenumber = true +vim.o.tabstop = 2 +vim.o.shiftwidth = 2 +vim.o.wrap = false +vim.o.scrolloff = 5 +vim.o.colorcolumn = "80" +vim.o.wildmenu = true +vim.o.wildmode = "longest:full,full" +vim.o.wildoptions = "pum" +vim.g.mapleader = " " +vim.o.termguicolors = true +vim.o.winborder = "shadow" +vim.o.clipboard = "unnamedplus" +vim.o.completeopt = "menuone" +-- vim.o.completeopt = "menuone,noinsert,noselect" +vim.o.cursorline = true +vim.o.sessionoptions="blank,buffers,curdir,folds,help,tabpages,winsize,winpos,terminal,localoptions" +vim.g.netrw_keepdir = 1 +vim.g.netrw_winsize = 20 +vim.g.netrw_banner = 0 +vim.g.netrw_localcopydircmd = 'cp -avr' +vim.g.netrw_liststyle = 3 +vim.g.netrw_browse_split = 4 + +vim.o.foldmethod = "expr" +vim.o.foldexpr = "nvim_treesitter#foldexpr()" +vim.o.foldlevel = 1 +vim.o.foldenable = true + +vim.o.undofile = true +vim.o.undodir = vim.fn.stdpath("data") .. "/undo" + +vim.api.nvim_create_autocmd("FileType", { + pattern = "help", + callback = function() + vim.opt_local.wrap = true + end, +}) + +vim.api.nvim_create_autocmd("FileType", { + pattern = "markdown", + callback = function() + vim.opt_local.wrap = true + end, +}) + +vim.api.nvim_create_autocmd("BufWritePost", { + pattern = ".wiki", + callback = function() + vim.cmd("VimwikiGenerateLinks") + end, +}) diff --git a/lua/plugins.lua b/lua/plugins.lua new file mode 100644 index 0000000..95c7646 --- /dev/null +++ b/lua/plugins.lua @@ -0,0 +1,138 @@ +local vim = vim +local host = vim.loop.os_gethostname() + +vim.pack.add({ + { src = "https://github.com/folke/tokyonight.nvim" }, + { src = "https://github.com/nvim-tree/nvim-web-devicons" }, + { src = "https://github.com/ibhagwan/fzf-lua" }, + { src = "https://github.com/echasnovski/mini.pick" }, + { src = "https://github.com/echasnovski/mini.icons" }, + { src = "https://github.com/echasnovski/mini.files" }, + { src = "https://github.com/echasnovski/mini.pairs" }, + { src = "https://github.com/echasnovski/mini.notify" }, + { src = "https://github.com/echasnovski/mini.surround" }, + { src = "https://github.com/echasnovski/mini.indentscope" }, + { src = "https://github.com/echasnovski/mini.fuzzy" }, + { src = "https://github.com/echasnovski/mini.tabline" }, + { src = "https://github.com/nvim-lualine/lualine.nvim" }, + { src = "https://github.com/folke/which-key.nvim" }, + { src = "https://github.com/L3MON4D3/LuaSnip" }, + { src = "https://github.com/neovim/nvim-lspconfig" }, + { src = "https://github.com/hrsh7th/nvim-cmp" }, + { src = "https://github.com/hrsh7th/cmp-nvim-lsp" }, + { src = "https://github.com/hrsh7th/cmp-buffer" }, + { src = "https://github.com/hrsh7th/cmp-path" }, + { src = "https://github.com/hrsh7th/cmp-cmdline" }, + { src = "https://github.com/hrsh7th/cmp-nvim-lua" }, + { src = "https://github.com/saadparwaiz1/cmp_luasnip" }, + { src = "https://github.com/github/copilot.vim" }, + { src = "https://github.com/pysan3/pathlib.nvim" }, + { src = "https://github.com/nvim-orgmode/org-bullets.nvim" }, + { src = "https://github.com/lukas-reineke/headlines.nvim" }, + { src = "https://github.com/michaelb/sniprun", run = "bash install.sh 1" }, + { src = "https://github.com/akinsho/toggleterm.nvim" }, + { src = "https://github.com/kdheepak/lazygit.nvim" }, + { src = "https://github.com/saecki/crates.nvim" }, + { src = "https://github.com/nvim-treesitter/nvim-treesitter" }, + { src = "https://github.com/folke/trouble.nvim" }, + { src = "https://github.com/folke/todo-comments.nvim" }, + { src = "https://github.com/MunifTanjim/nui.nvim" }, + { src = "https://github.com/huantrinh1802/m_taskwarrior_d.nvim" }, + { src = "https://github.com/rmagatti/auto-session" }, + { src = "https://github.com/romgrk/barbar.nvim" }, + { src = "https://github.com/christoomey/vim-tmux-navigator" }, + { src = "https://github.com/rachartier/tiny-inline-diagnostic.nvim" }, + { src = "https://github.com/zeioth/garbage-day.nvim" }, + { src = "https://github.com/ray-x/lsp_signature.nvim" }, + { src = "https://github.com/DNLHC/glance.nvim" }, + { src = "https://github.com/rmagatti/logger.nvim" }, + { src = "https://github.com/rmagatti/goto-preview" }, + { src = "https://github.com/norcalli/nvim-colorizer.lua" }, + { src = "https://github.com/nvim-lua/plenary.nvim" }, + { src = "https://github.com/nvim-telescope/telescope.nvim" }, + { src = "https://github.com/nvim-telescope/telescope-project.nvim"}, + { src = "https://github.com/nvim-telescope/telescope-ui-select.nvim" }, + { src = "https://github.com/luckasRanarison/nvim-devdocs" }, + { src = "https://github.com/folke/noice.nvim" }, + { src = "https://github.com/mbbill/undotree.git" }, +}) + +if host == "xps13" then +end + +require('mini.icons').setup({}) +require('mini.pick').setup({}) +require('mini.pairs').setup({}) +require('mini.notify').setup({}) +require('mini.surround').setup({}) +require('mini.indentscope').setup({}) +require('mini.tabline').setup({}) +require('mini.fuzzy').setup({}) +require('lualine').setup({ options = { theme = 'tokyonight' } }) +require('which-key').setup({}) +require('fzf-lua').setup({}) +require('crates').setup({}) +require('todo-comments').setup({ + options = { + keywords = { + FIX = { + icon = "ο†ˆ ", -- icon used for the sign, and in search results + color = "error", -- can be a hex color, or a named color (see below) + alt = { "FIXME", "BUG", "FIXIT", "ISSUE" }, -- a set of other keywords that all map to this FIX keywords + -- signs = false, -- configure signs for some keywords individually + }, + TODO = { icon = "ο€Œ ", color = "info" }, + HACK = { icon = " ", color = "warning" }, + WARN = { icon = " ", color = "warning", alt = { "WARNING", "XXX" } }, + PERF = { icon = " ", alt = { "OPTIM", "PERFORMANCE", "OPTIMIZE" } }, + NOTE = { icon = "ξ©΄ ", color = "hint", alt = { "INFO" } }, + TEST = { icon = "⏲ ", color = "test", alt = { "TESTING", "PASSED", "FAILED" } }, + }, + } +}) +require('trouble').setup({}) +require('org-bullets').setup({}) +require('headlines').setup({}) +require('sniprun').setup({ + binary_path = '/home/th3r00t/.local/share/nvim/site/pack/core/opt/sniprun/\ + target/release/sniprun' +}) +require('toggleterm').setup({ + size = 20, + open_mapping = [[]], + hide_numbers = true, + shade_filetypes = {}, + shading_factor = 2, + start_in_insert = true, + insert_mappings = true, + persist_size = true, + direction = 'horizontal', + close_on_exit = true, + shell = vim.o.shell, +}) +require('m_taskwarrior_d').setup({}) +require("auto-session").setup({ + suppressed_dirs = { "~/Downloads", "~/Documents", "~/Projects", "~/" }, +}) +require('barbar').setup({}) +require('goto-preview').setup({ default_mappings = true }) +require('colorizer').setup({}) +require('telescope').setup({}) +require('nvim-devdocs').setup({}) +require('noice').setup({ + lsp = { + override = { + ["vim.lsp.util.convert_input_to_markdown_lines"] = true, + ["vim.lsp.util.stylize_markdown"] = true, + ["cmp.entry.get_documentation"] = true, -- requires hrsh7th/nvim-cmp + }, + }, + presets = { + bottom_search = true, -- use a classic bottom cmdline for search + command_palette = true, -- position the cmdline and popupmenu together + long_message_to_split = true, -- long messages will be sent to a split + inc_rename = false, -- enables an input dialog for inc-rename.nvim + lsp_doc_border = false, -- add a border to hover docs and signature help + }, +}) + diff --git a/lua/telescope_configuration.lua b/lua/telescope_configuration.lua new file mode 100644 index 0000000..309e139 --- /dev/null +++ b/lua/telescope_configuration.lua @@ -0,0 +1,32 @@ +local vim = vim +local host = vim.loop.os_gethostname() + +require('telescope').load_extension('project') +require('telescope').load_extension('ui-select') + +require('telescope').setup{ + defaults = { + mappings = { + i = { + [""] = false, + [""] = false, + }, + }, + }, + pickers = { + -- Default configuration for builtin pickers goes here: + -- picker_name = { + -- picker_config_key = value, + -- ... + -- } + -- Now the picker_config_key will be applied every time you call this + -- builtin picker + }, + extensions = { + ["ui-select"] = { + require("telescope.themes").get_dropdown { + -- even more opts + } + }, + } +} diff --git a/lua/terminal.lua b/lua/terminal.lua new file mode 100644 index 0000000..1dd5cfb --- /dev/null +++ b/lua/terminal.lua @@ -0,0 +1,11 @@ +function _G.set_terminal_keymaps() + local opts = { buffer = 0 } + vim.keymap.set('t', '', [[]], opts) + vim.keymap.set('t', 'jk', [[]], opts) + vim.keymap.set('t', '', [[wincmd h]], opts) + vim.keymap.set('t', '', [[wincmd j]], opts) + vim.keymap.set('t', '', [[wincmd k]], opts) + vim.keymap.set('t', '', [[wincmd l]], opts) +end + +vim.cmd('autocmd! TermOpen term://* lua set_terminal_keymaps()') diff --git a/lua/treesitter.lua b/lua/treesitter.lua new file mode 100644 index 0000000..938e1e0 --- /dev/null +++ b/lua/treesitter.lua @@ -0,0 +1,11 @@ +local configs = require('nvim-treesitter.configs') +configs.setup({ + -- ensure_installed = { + -- "ini", "bash", "c", "lua", "vim", "vimdoc", "query", "python", + -- "rust", "zig", "typescript", "svelte", "css", "html", "nix" + -- }, + sync_install = false, + highlight = { enable = true }, + indent = { enable = true, disable = { "norg" }, }, + incremental_selection = { enable = true }, +}) diff --git a/lua/utils/reload.lua b/lua/utils/reload.lua new file mode 100644 index 0000000..db23d5f --- /dev/null +++ b/lua/utils/reload.lua @@ -0,0 +1,11 @@ +for name,_ in pairs(package.loaded) do + if name:match("^t3") + or name:match("^options") + or name:match("^overrides") + or name:match("^plugins") + or name:match("keymaps") + or name:match("^reload") + then + package.loaded[name] = nil + end +end diff --git a/lua/utils/t3_functions.lua b/lua/utils/t3_functions.lua new file mode 100644 index 0000000..fcb3181 --- /dev/null +++ b/lua/utils/t3_functions.lua @@ -0,0 +1,187 @@ +local vim = vim +local fzflua = require("fzf-lua") + +function t3_find_file() + -- local file_name = vim.fn.input("Find File: ", "", "file") + fzflua.files() +end + +function t3_recent_files() + fzflua.oldfiles() +end + +function t3_org_files() + fzflua.files({ cwd = '~/org/'}) +end + +function t3_project_files() + fzflua.files({ cwd = '~/Projects/'}) +end + +function t3_dot_files() + fzflua.files({ cwd = '~/.dotfiles/'}) +end + +function t3_config_files() + fzflua.files({ cwd = '~/.dotfiles/'}) +end + +function t3_snip_capture(name) + if type(name) ~= "string" or name == "" then + print("Error: Invalid snippet name") + return + end + -- local timestamp = os.date("%Y%m%d%H%M%S") + local snippet_path = "~/.config/nvim/snippets/" + local filename = snippet_path .. name:gsub("%s+", "_") .. ".lua" + local file = io.open(vim.fn.expand(filename), "w") + if file == nil then + print("Error: Could not open file for editing.") + return + end + local previous_buffer = vim.api.nvim_get_current_buf() + file:write("local ls = require('luasnip')\n\nls.add_snippets(\"{}\", {\n\tls.parser.parse_snippet(\n\t\t'{}',\n\t\t'{}'),\n})") + file:close() + vim.cmd("e " .. filename) + vim.bo.filetype = 'lua' + -- vim.cmd("Neorg inject-metadata") + -- Set an autocmd to return to the previous buffer when the note buffer is closed + vim.api.nvim_create_autocmd("BufLeave", { + buffer = 0, -- Current buffer (the note buffer) + callback = function() + load_snippets_from_directory(snippet_path) + vim.cmd("buffer " .. previous_buffer) + end, + }) + print("Captured snippet: " .. filename) +end + +function t3_org_capture(name) + if type(name) ~= "string" or name == "" then + print("Error: Invalid note name") + return + end + local timestamp = os.date("%Y%m%d%H%M%S") + local org_path = "~/org/.org-roam/" + local filename = org_path .. timestamp .. "-" .. name:gsub("%s+", "_") .. ".norg" + local file = io.open(vim.fn.expand(filename), "w") + if file == nil then + print("Error: Could not open file for editing.") + return + end + local previous_buffer = vim.api.nvim_get_current_buf() + file:write("* " .. name .. "\n\n") + file:close() + vim.cmd("e " .. filename) + vim.bo.filetype = 'norg' + vim.cmd("Neorg inject-metadata") + -- Set an autocmd to return to the previous buffer when the note buffer is closed + vim.api.nvim_create_autocmd("BufLeave", { + buffer = 0, -- Current buffer (the note buffer) + callback = function() + vim.cmd("buffer " .. previous_buffer) + end, + }) + print("Captured note: " .. filename) +end + +vim.api.nvim_create_user_command( + 'NeorgCapture', + function() + -- local title = vim.fn.input("Title: ") + local current_workspace = vim.g.neorg_workspace_name + if not current_workspace then + vim.cmd("Neorg workspace default") + end + vim.ui.input({ prompt = "Enter note name: "}, function(note_name) + if not note_name or note_name == "" then + print("Error: Note name required!") + return + end + t3_org_capture(note_name) + end + ) + end, + { nargs = 0, desc = "Capture a Neorg note" } +) + +vim.api.nvim_create_user_command( + 'CaptureSnip', + function() + -- local title = vim.fn.input("Title: ") + -- local current_workspace = vim.g.neorg_workspace_name + -- if not current_workspace then + -- vim.cmd("Neorg workspace default") + -- end + vim.ui.input({ prompt = "Enter snippet name: "}, function(snip_name) + if not snip_name or snip_name == "" then + print("Error: Snippet name required!") + return + end + t3_snip_capture(snip_name) + end + ) + end, + { nargs = 0, desc = "Capture a Neorg note" } +) +function t3_buffers() + fzflua.buffers() +end + +function t3_tabs() + fzflua.tabs() +end + +function t3_live_grep(state) + state = state or 0 + if state == 0 then + fzflua.live_grep() + else + fzflua.live_grep_resume() + end +end + +function t3_grep(state) + state = state or 0 + if state == 0 then + fzflua.grep_project() + else + fzflua.grep() + end +end + +local function is_netrw_open() + for _, win in ipairs(vim.api.nvim_tabpage_list_wins(0)) do + local buf = vim.api.nvim_win_get_buf(win) + if vim.bo[buf].filetype == "netrw" then + return true, win + end + end + return false, nil +end + +function t3_toggle_netrw() + local is_open, win = is_netrw_open() + if is_open then + vim.api.nvim_win_close(win, true) + else + vim.cmd("Lexplore") + end +end + +vim.api.nvim_create_autocmd("FileType", { + pattern = { "markdown", "norg", "md", "wiki" }, -- Set for markdown file type + callback = function() + vim.api.nvim_buf_set_keymap(0, "n", "", "o* [ ] ", { noremap = true, silent = true }) + vim.api.nvim_buf_set_keymap(0, "i", "", "0wi* [ ] ", { noremap = true, silent = true }) + end, +}) +vim.api.nvim_create_user_command("Split", function() + vim.cmd("split") + vim.cmd("wincmd j") +end, {}) + +vim.api.nvim_create_user_command("Vsplit", function() + vim.cmd("vsplit") + vim.cmd("wincmd l") +end, {}) diff --git a/lua/utils/t3_overrides.lua b/lua/utils/t3_overrides.lua new file mode 100644 index 0000000..0dc4cdc --- /dev/null +++ b/lua/utils/t3_overrides.lua @@ -0,0 +1,5 @@ +-- vim.api.nvim_create_autocmd("winNew", { +-- callback = function() +-- vim.cmd("wincmd w") +-- end, +-- }) diff --git a/lua/vimwiki.lua b/lua/vimwiki.lua new file mode 100644 index 0000000..6de8b66 --- /dev/null +++ b/lua/vimwiki.lua @@ -0,0 +1,155 @@ +local vim = vim +local opt = vim.opt +-- opt.wildmenu = true +-- vim.g.netrw_keepdir = 0 +-- vim.treesitter.language.register("markdown", "vimwiki") +-- vim.g.vimwiki_folding = 'expr' +-- vim.g.vimwiki_header_type = "=" + +-- vim.api.nvim_create_autocmd({ "BufWritePost" }, { +-- pattern = "*.wiki", -- Adjust this pattern if your Vimwiki files have a different extension +-- callback = function() +-- vim.cmd("TWSyncTasks") +-- end, +-- }) +-- Sync the current wiki's assets directory into its path_html/assets +-- local function sync_assets_for_current_wiki() +-- local vget = vim.fn['vimwiki#vars#get_wikilocal'] +-- local wiki_root = vim.fn.expand(vget('path')) +-- local html_root = vim.fn.expand(vget('path_html')) +-- if wiki_root == '' or html_root == '' then return end +-- +-- local src = wiki_root .. "/assets" +-- local dst = html_root .. "/assets" +-- +-- -- Ensure dst exists; prefer rsync if available, else shell cp -a +-- vim.fn.mkdir(dst, "p") +-- local has_rsync = vim.fn.executable("rsync") == 1 +-- +-- local cmd +-- if has_rsync then +-- cmd = { "rsync", "-a", "--delete", src .. "/", dst .. "/" } +-- else +-- -- cp -a keeps tree; the dot copies contents, not the dir itself +-- cmd = { "sh", "-lc", string.format("mkdir -p %q && cp -a %q. %q", dst, src .. "/", dst .. "/") } +-- end +-- +-- vim.fn.jobstart(cmd, { detach = true }) +-- end +-- +-- -- After each wiki page save, give Vimwiki a moment to write HTML, then sync assets +-- vim.api.nvim_create_autocmd("BufWritePost", { +-- pattern = "*.wiki", +-- callback = function() +-- vim.defer_fn(sync_assets_for_current_wiki, 150) +-- end, +-- }) +-- +-- -- Also sync when you edit files under the wiki's assets dir (js/css/images) +-- -- Adjust the glob if your wiki path differs +-- vim.api.nvim_create_autocmd("BufWritePost", { +-- pattern = { +-- vim.fn.expand("~/wiki/assets/*"), +-- vim.fn.expand("~/wiki/assets/**/*"), +-- }, +-- callback = function() +-- sync_assets_for_current_wiki() +-- end, +-- }) +-- +-- -- Optional: a manual command you can run anytime +-- vim.api.nvim_create_user_command("VimwikiSyncAssets", sync_assets_for_current_wiki, {}) + +-- Autocommand to trigger LuaSnip snippet expansion for new diary files +vim.api.nvim_create_autocmd("BufNewFile", { + pattern = "diary/*.wiki", -- Adjust this path to match your diary directory + callback = function() + -- Expand the 'diary_template' snippet automatically + ls.snip_expand(ls.snippets.diary_template[1]) + end, +}) +vim.g.vimwiki_automatic_nested_syntaxes = 1 +vim.g.vimwiki_list = { + { + name = "PersonalWiki", + path = '~/wiki/', + path_html = '~/Public/html/', + syntax = 'default', + ext = '.wiki', + diary_rel_path = 'diary/', + diary_index = "diary_index", + auto_tags = 1, + auto_toc = 1, + auto_export = 1, + template_path = "~/wiki/templates/", + template_default = "default", + template_ext = ".html", + css_name = "main.css", + maxhi = 1, -- BUG: Can be a source of lag. + diary_caption_level = 1, + bullet_types = { "-", "*", "#", "β†’" }, + cycle_bullets = 1, + generated_links_caption = 1, + listsyms = 'βœ—β—‹β—β—βœ“', + -- listsym_rejected = 'βœ—', + auto_diary_index = 1, + auto_generate_links = 1, + auto_generate_tags = 1, + exclude_files = { "**/README.md" }, + rss_name = "feed.rss", + base_url = "https://th3r00t.net", + } +} +vim.g.vimwiki_syntax_plugins = { + codeblock = { + ["```lua"] = { parser = "lua" }, + ["```python"] = { parser = "python" }, + ["```javascript"] = { parser = "javascript" }, + ["```bash"] = { parser = "bash" }, + ["```html"] = { parser = "html" }, + ["```css"] = { parser = "css" }, + ["```c"] = { parser = "c" }, + ["```zig"] = { parser = "zig" }, + }, +} +vim.g.vimwiki_toc_header = "Nav" +vim.g.vimwiki_toc_header_level = 2 +vim.g.vimwiki_hl_cb_checked = 1 +vim.g.vimwiki_global_ext = 1 +vim.g.vimwiki_auto_chdir = 1 +vim.g.wimwiki_markdown_link_ext = 1 +-- vim.g.vimwiki_folding = 'list' +vim.g.vimwiki_folding = 'expr' +vim.g.vimwiki_use_calendar = 1 +vim.api.nvim_set_keymap('n', 'ww', 'VimwikiIndex', { noremap = true, silent = true }) +vim.api.nvim_set_keymap('n', 'wt', 'VimwikiTabIndex', { noremap = true, silent = true }) +vim.api.nvim_set_keymap('n', 'ws', 'VimwikiUISelect', { noremap = true, silent = true }) +local function setup_vimwiki_highlights() + -- Define color scheme mappings + local colors = { + header1 = "#81a1c1", -- Tokyo Night blue + header2 = "#88c0d0", -- Tokyo Night light blue + header3 = "#8fbcbb", -- Tokyo Night greenish blue + bold = "#eceff4", -- Tokyo Night bright white + italic = "#5e81ac", -- Tokyo Night dark blue + link = "#b48ead", -- Tokyo Night purple + list = "#d08770", -- Tokyo Night orange + } + + -- Apply highlights for vimwiki syntax elements + vim.api.nvim_set_hl(0, "VimwikiHeader1", { fg = colors.header1, bold = true }) + vim.api.nvim_set_hl(0, "VimwikiHeader2", { fg = colors.header2, bold = true }) + vim.api.nvim_set_hl(0, "VimwikiHeader3", { fg = colors.header3, bold = true }) + vim.api.nvim_set_hl(0, "VimwikiBold", { fg = colors.bold, bold = true }) + vim.api.nvim_set_hl(0, "VimwikiItalic", { fg = colors.italic, italic = true }) + vim.api.nvim_set_hl(0, "VimwikiLink", { fg = colors.link, underline = true }) + vim.api.nvim_set_hl(0, "VimwikiList", { fg = colors.list }) +end +setup_vimwiki_highlights() +-- Define the Lua function for generating the diary template +-- +vim.pack.add({ + { src = "https://github.com/vimwiki/vimwiki", opt = true }, +}) + +vim.cmd.packadd("vimwiki")