diff --git a/aspects/dotfiles/files/.local/share/autojump/autojump.txt b/aspects/dotfiles/files/.local/share/autojump/autojump.txt index b5a17f9f..449d07b2 100644 Binary files a/aspects/dotfiles/files/.local/share/autojump/autojump.txt and b/aspects/dotfiles/files/.local/share/autojump/autojump.txt differ diff --git a/aspects/dotfiles/files/.local/share/autojump/autojump.txt.bak b/aspects/dotfiles/files/.local/share/autojump/autojump.txt.bak index d1c8ec37..b5a17f9f 100644 Binary files a/aspects/dotfiles/files/.local/share/autojump/autojump.txt.bak and b/aspects/dotfiles/files/.local/share/autojump/autojump.txt.bak differ diff --git a/aspects/nvim/files/.config/nvim/ftplugin/tex.lua b/aspects/nvim/files/.config/nvim/ftplugin/tex.lua index d61030f9..4c02ed9a 100644 --- a/aspects/nvim/files/.config/nvim/ftplugin/tex.lua +++ b/aspects/nvim/files/.config/nvim/ftplugin/tex.lua @@ -2,13 +2,7 @@ if vim.g.isInkscape then return function(_use) end end -vim.cmd([[ - setlocal fillchars=fold:\ - setlocal foldlevel=0 - setlocal foldmethod=expr - setlocal foldexpr=vimtex#fold#level(v:lnum) - setlocal foldtext=vimtex#fold#text() -]]) +require("config.options").tex() local which_key = require("which-key") local options = require("config.global").which_key_vars.options diff --git a/aspects/nvim/files/.config/nvim/lua/config/autocmds.lua b/aspects/nvim/files/.config/nvim/lua/config/autocmds.lua index 9a4a95c0..55489fa4 100644 --- a/aspects/nvim/files/.config/nvim/lua/config/autocmds.lua +++ b/aspects/nvim/files/.config/nvim/lua/config/autocmds.lua @@ -13,7 +13,7 @@ vim.api.nvim_create_autocmd("FileType", { vim.api.nvim_create_autocmd("BufReadPost", { group = augroup("last_loc"), callback = function() - local mark = vim.api.nvim_buf_get_mark(0, "\"") + local mark = vim.api.nvim_buf_get_mark(0, '"') local lcount = vim.api.nvim_buf_line_count(0) if mark[1] > 0 and mark[1] <= lcount then pcall(vim.api.nvim_win_set_cursor, 0, mark) @@ -51,12 +51,12 @@ vim.api.nvim_create_autocmd("FileType", { end, }) --- disable folds when opening a latex file -vim.api.nvim_create_autocmd("FileType", { - group = augroup("folds"), - pattern = { "tex" }, +-- Highlight when yanking (copying) text +vim.api.nvim_create_autocmd("TextYankPost", { + desc = "Highlight when yanking (copying) text", + group = augroup("highlight-yank"), callback = function() - vim.o.foldenable = false + vim.highlight.on_yank() end, }) diff --git a/aspects/nvim/files/.config/nvim/lua/config/config.lua b/aspects/nvim/files/.config/nvim/lua/config/config.lua deleted file mode 100644 index 9997eeb5..00000000 --- a/aspects/nvim/files/.config/nvim/lua/config/config.lua +++ /dev/null @@ -1,24 +0,0 @@ -local function load(name) - local Util = require("lazy.core.util") - -- always load lazyvim, then user file - for _, mod in ipairs({ "config." .. name, "config." .. name }) do - Util.try(function() - require(mod) - end, { - msg = "Failed loading " .. mod, - on_error = function(msg) - local modpath = require("lazy.core.cache").find(mod) - if modpath then - Util.error(msg) - end - end, - }) - end -end - --- load options here, before lazy init while sourcing plugin modules --- this is needed to make sure options will be correctly applied --- after installing missing plugins -load("options") -load("autocmds") -load("keymaps") diff --git a/aspects/nvim/files/.config/nvim/lua/config/init.lua b/aspects/nvim/files/.config/nvim/lua/config/init.lua index 149d5f71..16e51b7a 100644 --- a/aspects/nvim/files/.config/nvim/lua/config/init.lua +++ b/aspects/nvim/files/.config/nvim/lua/config/init.lua @@ -34,14 +34,14 @@ local disable_distribution_plugins = function() vim.g.loaded_2html_plugin = 1 vim.g.loaded_logiPat = 1 vim.g.loaded_rrhelper = 1 - -- vim.g.loaded_netrw = 1 - -- vim.g.loaded_netrwPlugin = 1 - -- vim.g.loaded_netrwSettings = 1 - -- vim.g.loaded_netrwFileHandlers = 1 + vim.g.loaded_netrw = 1 + vim.g.loaded_netrwPlugin = 1 + vim.g.loaded_netrwSettings = 1 + vim.g.loaded_netrwFileHandlers = 1 end local load_core = function() - -- require("config.helper").init() + require("config.helper").init() createdir() disable_distribution_plugins() @@ -54,12 +54,12 @@ local load_core = function() vim.api.nvim_set_hl(0, "SignColumn", { bg = "None" }) vim.api.nvim_set_hl(0, "FoldColumn", { bg = "None" }) - require("config.options") + require("config.options").general() + require("config.autocmds") require("config.keymaps") require("config.lazy_nvim"):boot_strap() vim.defer_fn(function() - -- require("config.colorscheme").load_colorscheme() require("config.lazy") end, 5) end diff --git a/aspects/nvim/files/.config/nvim/lua/config/options.lua b/aspects/nvim/files/.config/nvim/lua/config/options.lua index d6895e2f..ab136d7f 100644 --- a/aspects/nvim/files/.config/nvim/lua/config/options.lua +++ b/aspects/nvim/files/.config/nvim/lua/config/options.lua @@ -1,69 +1,83 @@ -- This file is automatically loaded by plugins.config +local M = {} local opt = vim.opt local g = vim.g -g.mapleader = " " -- Set the leader key -g.maplocalleader = " " -- Set the local leader key -g.netrw_banner = 0 -- Remove the banner above netrw -g.markdown_recommended_style = 0 -- Fix markdown indentation settings +M.general = function() + g.mapleader = " " -- Set the leader key + g.maplocalleader = " " -- Set the local leader key + g.netrw_banner = 0 -- Remove the banner above netrw + g.markdown_recommended_style = 0 -- Fix markdown indentation settings -opt.autowrite = true -- Enable auto write -opt.clipboard = "unnamedplus" -- Sync with system clipboard -opt.completeopt = "menu,menuone,noselect" -opt.conceallevel = 2 -- Hide * markup for bold and italic -opt.confirm = true -- Confirm to save changes before exiting modified buffer -opt.cursorline = true -- Enable highlighting of the current line -opt.expandtab = true -- Use spaces instead of tabs -opt.formatoptions = "jcroqlnt" -- Tcqj -opt.grepformat = "%f:%l:%c:%m" -- Format -opt.grepprg = "rg --vimgrep" -- For searching -opt.ignorecase = true -- Ignore case -opt.inccommand = "nosplit" -- Preview incremental substitute -opt.laststatus = 3 -- Make statusbar cover entire area -opt.list = true -- Show some invisible characters (tabs... -opt.mouse = "a" -- Enable mouse mode -opt.number = true -- Print line number -opt.pumblend = 10 -- Popup blend -opt.pumheight = 10 -- Maximum number of entries in a popup -opt.relativenumber = true -- Relative line numbers -opt.scrolloff = 4 -- Lines of context -opt.sessionoptions = { "buffers", "curdir", "tabpages", "winsize" } -opt.shiftround = true -- Round indent -opt.shiftwidth = 2 -- Size of an indent -opt.shortmess:append { W = true, I = true, c = true } -opt.showmode = false -- Dont show mode since we have a statusline -opt.sidescrolloff = 8 -- Columns of context -opt.smartcase = true -- Don't ignore case with capitals -opt.smartindent = true -- Insert indents automatically -opt.spelllang = { "en" } -- Languages used for spell check -opt.splitbelow = true -- Put new windows below current -opt.splitright = true -- Put new windows right of current -opt.tabstop = 2 -- Number of spaces tabs count for -opt.termguicolors = true -- True color support -opt.timeoutlen = 300 -- Timeout in milliseconds before which key pops up -opt.undofile = true -- Keep undo files -opt.undolevels = 10000 -- Level of undo times -opt.updatetime = 200 -- Save swap file and trigger CursorHold -opt.wildmode = "longest:full,full" -- Command-line completion mode -opt.winminwidth = 5 -- Minimum window width -opt.wrap = false -- Disable line wrap -opt.foldenable = false -- Disable Folds -opt.foldmethod = "manual" -- "manual" for manual folds; "expr" -opt.foldexpr = "nvim_treesitter#foldexpr()" -- use treesitter to generate folds -opt.foldcolumn = "1" -opt.foldlevel = 2 -- Fold levels opened at file opens -opt.foldlevelstart = 99 -opt.foldnestmax = 3 -- Max level of fold -opt.signcolumn = "yes" -- Always show the signcolumn, otherwise it would shift the text each time + opt.autowrite = true -- Enable auto write + opt.clipboard = "unnamedplus" -- Sync with system clipboard + opt.completeopt = "menu,menuone,noselect" + opt.conceallevel = 2 -- Hide * markup for bold and italic + opt.confirm = true -- Confirm to save changes before exiting modified buffer + opt.cursorline = true -- Enable highlighting of the current line + opt.expandtab = true -- Use spaces instead of tabs + opt.formatoptions = "jcroqlnt" -- Tcqj + opt.grepformat = "%f:%l:%c:%m" -- Format + opt.grepprg = "rg --vimgrep" -- For searching + opt.ignorecase = true -- Ignore case + opt.inccommand = "nosplit" -- Preview incremental substitute + opt.laststatus = 3 -- Make statusbar cover entire area + opt.list = true -- Show some invisible characters (tabs... + opt.mouse = "a" -- Enable mouse mode + opt.number = true -- Print line number + opt.pumblend = 10 -- Popup blend + opt.pumheight = 10 -- Maximum number of entries in a popup + opt.relativenumber = true -- Relative line numbers + opt.scrolloff = 4 -- Lines of context + opt.sessionoptions = { "buffers", "curdir", "tabpages", "winsize" } + opt.shiftround = true -- Round indent + opt.shiftwidth = 2 -- Size of an indent + opt.shortmess:append({ W = true, I = true, c = true }) + opt.showmode = false -- Dont show mode since we have a statusline + opt.sidescrolloff = 8 -- Columns of context + opt.smartcase = true -- Don't ignore case with capitals + opt.smartindent = true -- Insert indents automatically + opt.spelllang = { "en" } -- Languages used for spell check + opt.splitbelow = true -- Put new windows below current + opt.splitright = true -- Put new windows right of current + opt.tabstop = 2 -- Number of spaces tabs count for + opt.termguicolors = true -- True color support + opt.timeoutlen = 300 -- Timeout in milliseconds before which key pops up + opt.undofile = true -- Keep undo files + opt.undolevels = 10000 -- Level of undo times + opt.updatetime = 200 -- Save swap file and trigger CursorHold + opt.wildmode = "longest:full,full" -- Command-line completion mode + opt.winminwidth = 5 -- Minimum window width + opt.wrap = false -- Disable line wrap + opt.foldenable = false -- Disable Folds + opt.foldmethod = "manual" -- "manual" for manual folds; "expr" + opt.foldexpr = "nvim_treesitter#foldexpr()" -- use treesitter to generate folds + opt.foldcolumn = "1" + opt.foldlevel = 2 -- Fold levels opened at file opens + opt.foldlevelstart = 99 + opt.foldnestmax = 3 -- Max level of fold + opt.signcolumn = "yes" -- Always show the signcolumn, otherwise it would shift the text each time -local fcs = vim.opt.fillchars:get() + if vim.fn.has("nvim-0.9.0") == 1 then + opt.splitkeep = "screen" + opt.shortmess:append({ C = true }) + end -if vim.fn.has("nvim-0.9.0") == 1 then - opt.splitkeep = "screen" - opt.shortmess:append { C = true } + -- DO NOT INCLUDE THIS + vim.cmd("set rtp+=~/Documents/school-notes/current-course") + -- DO NOT INCLUDE THIS end --- DO NOT INCLUDE THIS -vim.cmd("set rtp+=~/Documents/school-notes/current-course") --- DO NOT INCLUDE THIS +-- Function for setting tex options +M.tex = function() + opt.spell = true + opt.tw = 80 + opt.fillchars = { fold = " ", vert = "│" } + opt.foldlevel = 0 + opt.foldmethod = "expr" + opt.foldexpr = "vimtex#fold#level(v:lnum)" + opt.foldtext = "vimtex#fold#text()" +end + +return M diff --git a/aspects/nvim/files/.config/nvim/lua/modules/editor/config.lua b/aspects/nvim/files/.config/nvim/lua/modules/editor/config.lua index 47b5158c..ad956b5f 100644 --- a/aspects/nvim/files/.config/nvim/lua/modules/editor/config.lua +++ b/aspects/nvim/files/.config/nvim/lua/modules/editor/config.lua @@ -57,8 +57,29 @@ function config.telescope() local telescope = require("telescope") local actions = require("telescope.actions") + local action_state = require("telescope.actions.state") local icons = require("config.global").icons + -- Insert filename into the current buffer and keeping the insert mode. + actions.insert_name_i = function(prompt_bufnr) + local symbol = action_state.get_selected_entry().ordinal + actions.close(prompt_bufnr) + vim.schedule(function() + vim.cmd([[startinsert]]) + vim.api.nvim_put({ symbol }, "", true, true) + end) + end + + -- Insert file path and name into the current buffer and keeping the insert mode. + actions.insert_name_and_path_i = function(prompt_bufnr) + local symbol = action_state.get_selected_entry().value + actions.close(prompt_bufnr) + vim.schedule(function() + vim.cmd([[startinsert]]) + vim.api.nvim_put({ symbol }, "", true, true) + end) + end + telescope.setup({ defaults = { prompt_prefix = icons.ui.Telescope .. " ", @@ -142,7 +163,7 @@ function config.telescope() [""] = actions.send_selected_to_qflist + actions.open_qflist, [""] = actions.complete_tag, [""] = actions.which_key, - [""] = actions.close, + -- [""] = actions.close, }, n = { @@ -452,7 +473,7 @@ function config.neo_tree() { "container", content = { - { "name", zindex = 10 }, + { "name", zindex = 10 }, { "symlink_target", zindex = 10, @@ -482,17 +503,17 @@ function config.neo_tree() "container", content = { { "name", zindex = 10 }, - { "clipboard", zindex = 10 }, - { "bufnr", zindex = 10 }, - { "modified", zindex = 20, align = "right" }, + { "clipboard", zindex = 10 }, + { "bufnr", zindex = 10 }, + { "modified", zindex = 20, align = "right" }, { "diagnostics", zindex = 20, align = "right" }, - { "git_status", zindex = 15, align = "right" }, + { "git_status", zindex = 15, align = "right" }, }, }, }, message = { { "indent", with_markers = false }, - { "name", highlight = "NeoTreeMessage" }, + { "name", highlight = "NeoTreeMessage" }, }, terminal = { { "indent" }, diff --git a/aspects/nvim/files/.config/nvim/lua/modules/lang/treesitter.lua b/aspects/nvim/files/.config/nvim/lua/modules/lang/treesitter.lua index ff381bb1..aa2c3339 100644 --- a/aspects/nvim/files/.config/nvim/lua/modules/lang/treesitter.lua +++ b/aspects/nvim/files/.config/nvim/lua/modules/lang/treesitter.lua @@ -78,13 +78,6 @@ local treesitter_obj = function() swap_next = { ["[n"] = "@parameter.inner" }, swap_previous = { ["]p"] = "@parameter.inner" }, }, - lsp_interop = { - enable = true, - border = "rounded", - peek_definition_code = { - ["J"] = "@class.outer", - }, - }, }, }) end @@ -205,6 +198,7 @@ vim.api.nvim_create_autocmd({ "FileType" }, { end end, }) + return { treesitter = treesitter, treesitter_obj = treesitter_obj, diff --git a/aspects/nvim/files/.config/nvim/lua/modules/lsp/handlers.lua b/aspects/nvim/files/.config/nvim/lua/modules/lsp/handlers.lua index bca9168b..0f20d73c 100644 --- a/aspects/nvim/files/.config/nvim/lua/modules/lsp/handlers.lua +++ b/aspects/nvim/files/.config/nvim/lua/modules/lsp/handlers.lua @@ -57,6 +57,12 @@ lsp.attach_mappings = function(_, bufnr) d = { name = "Definition", d = { "Glance definitions", "Definition" }, + p = { + function() + require("nvim-treesitter.textobjects.lsp_interop").peek_definition_code("@function.outer", nil, "textDocument/typeDefinition") + end, + "Preview Definition" + }, r = { "Glance references", "References" }, t = { "Glance type_definitions", "Type Definition" }, i = { "Glance implementations", "Implementation" }, diff --git a/aspects/nvim/files/.config/nvim/lua/modules/lsp/settings/lua_ls.lua b/aspects/nvim/files/.config/nvim/lua/modules/lsp/settings/lua_ls.lua index 7b73a3ef..92333c5d 100644 --- a/aspects/nvim/files/.config/nvim/lua/modules/lsp/settings/lua_ls.lua +++ b/aspects/nvim/files/.config/nvim/lua/modules/lsp/settings/lua_ls.lua @@ -35,8 +35,10 @@ return { }, workspace = { library = { - [vim.fn.expand("$VIMRUNTIME/lua")] = true, - [vim.fn.stdpath("config") .. "/lua"] = true, + "${3rd}/luv/library", + unpack(vim.api.nvim_get_runtime_file('', true)), + vim.fn.expand("$VIMRUNTIME/lua"), + vim.fn.stdpath("config") .. "/lua", }, }, telemetry = { diff --git a/aspects/nvim/files/.config/nvim/lua/modules/ui/which-key.lua b/aspects/nvim/files/.config/nvim/lua/modules/ui/which-key.lua index 179ba6e5..9b9b9183 100644 --- a/aspects/nvim/files/.config/nvim/lua/modules/ui/which-key.lua +++ b/aspects/nvim/files/.config/nvim/lua/modules/ui/which-key.lua @@ -52,6 +52,11 @@ local setup = { local vars = require("config.global").which_key_vars +local function search_config_files() + local builtin = require("telescope.builtin") + builtin.find_files({ cwd = vim.fn.stdpath("config") }) +end + vars.vmappings["/"] = { "lua require('Comment.api').toggle.linewise(vim.fn.visualmode())", "Comment", @@ -132,12 +137,16 @@ vars.mappings["s"] = { l = { "Telescope live_grep", "Fuzzy find words" }, s = { "Telescope symbols", "Fuzzy find symbols" }, d = { "Telescope diagnostics", "Fuzzy find diagnostics" }, - c = { function() - require("telescope.builtin").current_buffer_fuzzy_find(require("telescope.themes").get_dropdown { - winblend = 10, - previewer = false, - }) - end, "Fuzzily search in current buffer" } + n = { search_config_files, "Fuzzy find config files" }, + c = { + function() + require("telescope.builtin").current_buffer_fuzzy_find(require("telescope.themes").get_dropdown({ + winblend = 10, + previewer = false, + })) + end, + "Fuzzily search in current buffer", + }, } vars.mappings["m"] = { @@ -154,7 +163,10 @@ vars.mappings["n"] = { a = { "lua require('neotest').run.attach()", "Attach to the nearest test" }, c = { "lua require('neotest').run.run(vim.fn.expand('%'))", "Run the current file" }, d = { "lua require('neotest').run.run({strategy = 'dap'})", "Debug the nearest test" }, - e = { "lua require('neotest').output.open({ enter = true, auto_close = true })", "Open the output of a test result" }, + e = { + "lua require('neotest').output.open({ enter = true, auto_close = true })", + "Open the output of a test result", + }, j = { "lua require('neotest').jump.prev({ status = 'failed' })", "Jump to next error" }, k = { "lua require('neotest').jump.next({ status = 'failed' })", "Jump to previous error" }, n = { "lua require('neotest').run.run()", "Run the nearest test" }, diff --git a/aspects/nvim/files/.config/nvim/lua/modules/util/plugins.lua b/aspects/nvim/files/.config/nvim/lua/modules/util/plugins.lua index 82bc40df..8b0023d5 100644 --- a/aspects/nvim/files/.config/nvim/lua/modules/util/plugins.lua +++ b/aspects/nvim/files/.config/nvim/lua/modules/util/plugins.lua @@ -1,14 +1,24 @@ if vim.g.isInkscape then - return function(use) end + return function(_use) end end return function(use) use({ "ray-x/guihua.lua", - build = "cd lua/fzy && make" + build = "cd lua/fzy && make", }) use({ "nvim-lua/plenary.nvim" }) use({ "ray-x/guihua.lua" }) use({ "wincent/pinnacle" }) + + use({ + "Aityz/usage.nvim", + config = function() + require("usage").setup({ + mode = "float", + }) + end, + event = "VeryLazy", + }) end