From f343b1a76dab43d92cb23c33bf111187c78d4e96 Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Thu, 15 Jun 2023 10:31:55 +0200 Subject: [PATCH 1/4] # This is a combination of 4 commits. # This is the 1st commit message: nvim: Restructure lua dir Moved plugins into individual component module files which are automatically required by lazy.nvim. Should make everything a tiny bit more modular, or at least prepare the way for true modularity if I ever have the time on my hands to ensure everything works with missing modules. Moved core settings into their own directory (`core`), and created a `personal` folder which contains functions/plugins I wrote that do not necessarily have to be their own imported plugin yet. Finally, extended the utility functions a little, so we can detect if a plugin exists and change e.g. key maps based on that (once again, extending modularity a little more). Some simple attempts have been made at that in the `mappings.lua` file, though it is nowhere near extensive yet - most keymaps are still set regardless of plugin availability. However, with this slimmer base to work off of, I feel more confident in changing future things about this setup a little more ad-hoc without having as many ripple repercussions as before. # This is the commit message #2: Update settings file with 0.9 options # This is the commit message #3: Move lazy.nvim setup into core module # This is the commit message #4: Rename maps.lua to mappings.lua --- nvim/.config/nvim/init.lua | 35 ++++++----------- nvim/.config/nvim/lua/{ => core}/autocmds.lua | 0 nvim/.config/nvim/lua/core/lazy.lua | 38 +++++++++++++++++++ nvim/.config/nvim/lua/{ => core}/look.lua | 0 .../nvim/lua/{maps.lua => core/mappings.lua} | 0 nvim/.config/nvim/lua/{ => core}/plugins.lua | 0 nvim/.config/nvim/lua/{ => core}/settings.lua | 30 ++++++++++++--- 7 files changed, 74 insertions(+), 29 deletions(-) rename nvim/.config/nvim/lua/{ => core}/autocmds.lua (100%) create mode 100644 nvim/.config/nvim/lua/core/lazy.lua rename nvim/.config/nvim/lua/{ => core}/look.lua (100%) rename nvim/.config/nvim/lua/{maps.lua => core/mappings.lua} (100%) rename nvim/.config/nvim/lua/{ => core}/plugins.lua (100%) rename nvim/.config/nvim/lua/{ => core}/settings.lua (79%) diff --git a/nvim/.config/nvim/init.lua b/nvim/.config/nvim/init.lua index 6684b1e..7525255 100644 --- a/nvim/.config/nvim/init.lua +++ b/nvim/.config/nvim/init.lua @@ -4,31 +4,18 @@ local api = vim.api api.nvim_exec2("runtime abbrev.vim", {}) -local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" -if not vim.loop.fs_stat(lazypath) then - vim.fn.system({ - "git", - "clone", - "--filter=blob:none", - "https://github.com/folke/lazy.nvim.git", - "--branch=stable", -- latest stable release - lazypath, - }) +for _, source in ipairs({ + "core.settings", + "core.lazy", + "core.autocmds", + "core.mappings", + "core.look", +}) do + local status_ok, fault = pcall(require, source) + if not status_ok then + vim.api.nvim_err_writeln("Failed to load " .. source .. "\n\n" .. fault) + end end -vim.opt.rtp:prepend(lazypath) - --- set our leader key to space since with hjkl, space is largely useless --- needs to be set before lazy.nvim is loaded -vim.g.mapleader = " " - -require("settings") -require("autocmds") -require("lazy").setup("plugins", { - defaults = { version = "*" }, - performance = { rtp = { disabled_plugins = { "netrw", "netrwPlugin" } } }, -}) -require("look") -require("maps") -- to include e.g. the spell dictionaries for vim vim.opt.rtp:append(vim.fn.stdpath("data") .. "/site") diff --git a/nvim/.config/nvim/lua/autocmds.lua b/nvim/.config/nvim/lua/core/autocmds.lua similarity index 100% rename from nvim/.config/nvim/lua/autocmds.lua rename to nvim/.config/nvim/lua/core/autocmds.lua diff --git a/nvim/.config/nvim/lua/core/lazy.lua b/nvim/.config/nvim/lua/core/lazy.lua new file mode 100644 index 0000000..840f4e2 --- /dev/null +++ b/nvim/.config/nvim/lua/core/lazy.lua @@ -0,0 +1,38 @@ +local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" +-- inspired from astronvim lazy bootstrapping +if not vim.loop.fs_stat(lazypath) then + local output = vim.fn.system({ + "git", + "clone", + "--filter=blob:none", + "https://github.com/folke/lazy.nvim.git", + "--branch=stable", + lazypath, + }) + if vim.api.nvim_get_vvar("shell_error") ~= 0 then + vim.api.nvim_err_writeln("Error cloning lazy.nvim repository...\n\n" .. output) + end + local oldcmdheight = vim.opt.cmdheight:get() + vim.opt.cmdheight = 1 + vim.notify("Please wait while plugins are installed...") + vim.api.nvim_create_autocmd("User", { + desc = "Load Mason and Treesitter after Lazy installs plugins", + once = true, + pattern = "LazyInstall", + callback = function() + vim.cmd.bw() + vim.opt.cmdheight = oldcmdheight + vim.tbl_map(function(module) + pcall(require, module) + end, { "nvim-treesitter", "mason" }) + vim.notify("Mason is installing packages if configured, check status with :Mason") + end, + }) +end +vim.opt.rtp:prepend(lazypath) + +require("lazy").setup({ + spec = { { import = "plugins" } }, + defaults = { lazy = true, version = "*" }, + performance = { rtp = { disabled_plugins = { "netrw", "netrwPlugin" } } }, +}) diff --git a/nvim/.config/nvim/lua/look.lua b/nvim/.config/nvim/lua/core/look.lua similarity index 100% rename from nvim/.config/nvim/lua/look.lua rename to nvim/.config/nvim/lua/core/look.lua diff --git a/nvim/.config/nvim/lua/maps.lua b/nvim/.config/nvim/lua/core/mappings.lua similarity index 100% rename from nvim/.config/nvim/lua/maps.lua rename to nvim/.config/nvim/lua/core/mappings.lua diff --git a/nvim/.config/nvim/lua/plugins.lua b/nvim/.config/nvim/lua/core/plugins.lua similarity index 100% rename from nvim/.config/nvim/lua/plugins.lua rename to nvim/.config/nvim/lua/core/plugins.lua diff --git a/nvim/.config/nvim/lua/settings.lua b/nvim/.config/nvim/lua/core/settings.lua similarity index 79% rename from nvim/.config/nvim/lua/settings.lua rename to nvim/.config/nvim/lua/core/settings.lua index 34108de..a225dbd 100644 --- a/nvim/.config/nvim/lua/settings.lua +++ b/nvim/.config/nvim/lua/core/settings.lua @@ -4,8 +4,13 @@ local disable_builtins = function(builtins) vim.g["loaded_" .. plugin] = 1 end end +disable_builtins(default_builtins_disabled) -local o = { +if vim.fn.has("nvim-0.9") == 1 then + vim.opt.diffopt:append("linematch:60") +end + +local options = { termguicolors = true, -- sets tabs to be 2 characters, expanded into spaces, but still removable with -- one press of backspace. @@ -47,6 +52,7 @@ local o = { -- set to use treesitter in treesitter config foldlevel = 2, conceallevel = 2, + foldcolumn = vim.fn.has("nvim-0.9") == 1 and "auto:1" or nil, -- enable mouse, doesn't bug me and might come in useful at some point mouse = "a", -- pump all clippings into the system clipboard @@ -60,11 +66,25 @@ local o = { splitbelow = true, -- remove command line if no command is currently present cmdheight = 0, + -- try to cleverly manage indents by preserving them from line to line + breakindent = true, + copyindent = true, + preserveindent = true, + smartindent = true, } -for k, v in pairs(o) do - vim.opt[k] = v +for o, v in pairs(options) do + vim.opt[o] = v end +vim.opt.shortmess:append({ s = true, I = true }) +vim.opt.backspace:append({ "nostop" }) -vim.api.nvim_set_var("tex_flavor", "latex") -disable_builtins(default_builtins_disabled) +local globals = { + mapleader = " ", + maplocalleader = ",", + tex_flavor = "latex", +} + +for o, v in pairs(globals) do + vim.g[o] = v +end From f33b4c9c37a693371c241ede41534cebc42b4db7 Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Thu, 15 Jun 2023 15:45:21 +0200 Subject: [PATCH 2/4] nvim: Restructure lua dir Moved plugins into individual component module files which are automatically required by lazy.nvim. Should make everything a tiny bit more modular, or at least prepare the way for true modularity if I ever have the time on my hands to ensure everything works with missing modules. Moved core settings into their own directory (`core`), and created a `personal` folder which contains functions/plugins I wrote that do not necessarily have to be their own imported plugin yet. Finally, extended the utility functions a little, so we can detect if a plugin exists and change e.g. key maps based on that (once again, extending modularity a little more). Some simple attempts have been made at that in the `mappings.lua` file, though it is nowhere near extensive yet - most keymaps are still set regardless of plugin availability. However, with this slimmer base to work off of, I feel more confident in changing future things about this setup a little more ad-hoc without having as many ripple repercussions as before. --- desktop/.config/user-dirs.dirs | 15 + nvim/.config/nvim/init.lua | 1 + nvim/.config/nvim/lazy-lock.json | 30 +- nvim/.config/nvim/lua/core/autocmds.lua | 45 +-- nvim/.config/nvim/lua/core/mappings.lua | 12 +- nvim/.config/nvim/lua/core/plugins.lua | 321 ----------------- nvim/.config/nvim/lua/core/settings.lua | 2 + .../lua/personal/format_on_save_toggle.lua | 33 ++ nvim/.config/nvim/lua/personal/init.lua | 1 + .../nvim/lua/personal/pandoc_complete.lua | 11 - nvim/.config/nvim/lua/plug/_gitsigns.lua | 56 --- nvim/.config/nvim/lua/plug/_lsp.lua | 329 ------------------ nvim/.config/nvim/lua/plug/_telescope.lua | 64 ---- nvim/.config/nvim/lua/plug/_toggleterm.lua | 18 - nvim/.config/nvim/lua/plug/_treesitter.lua | 21 -- nvim/.config/nvim/lua/plugins/config/cmp.lua | 142 ++++++++ nvim/.config/nvim/lua/plugins/config/lsp.lua | 168 +++++++++ .../config/lualine.lua} | 0 .../_mini.lua => plugins/config/mini.lua} | 2 +- .../nvim/lua/plugins/config/toggleterm.lua | 55 +++ nvim/.config/nvim/lua/plugins/core.lua | 46 +++ .../nvim/lua/plugins/data_analysis.lua | 55 +++ nvim/.config/nvim/lua/plugins/editing.lua | 52 +++ .../.config/nvim/lua/plugins/filebrowsers.lua | 18 + nvim/.config/nvim/lua/plugins/git.lua | 64 ++++ nvim/.config/nvim/lua/plugins/ide.lua | 73 ++++ nvim/.config/nvim/lua/plugins/languages.lua | 5 + nvim/.config/nvim/lua/plugins/prose.lua | 56 +++ nvim/.config/nvim/lua/plugins/telescope.lua | 77 ++++ nvim/.config/nvim/lua/plugins/treesitter.lua | 73 ++++ nvim/.config/nvim/lua/plugins/ui.lua | 53 +++ nvim/.config/nvim/lua/util/init.lua | 12 + .../nvim/plugin/personal/makescratch.vim | 15 - .../nvim/plugin/personal/searchnotes.vim | 8 - nvim/.config/nvim/plugin/thesaurus_query.vim | 18 - nvim/.config/nvim/plugin/vifm.vim | 4 - writing/.config/pubs/pubsrc | 166 +++++++++ writing/.config/sh/alias.d/pubs.sh | 8 + 38 files changed, 1221 insertions(+), 908 deletions(-) create mode 100644 desktop/.config/user-dirs.dirs delete mode 100644 nvim/.config/nvim/lua/core/plugins.lua create mode 100644 nvim/.config/nvim/lua/personal/format_on_save_toggle.lua create mode 100644 nvim/.config/nvim/lua/personal/init.lua delete mode 100644 nvim/.config/nvim/lua/personal/pandoc_complete.lua delete mode 100644 nvim/.config/nvim/lua/plug/_gitsigns.lua delete mode 100644 nvim/.config/nvim/lua/plug/_lsp.lua delete mode 100644 nvim/.config/nvim/lua/plug/_telescope.lua delete mode 100644 nvim/.config/nvim/lua/plug/_toggleterm.lua delete mode 100644 nvim/.config/nvim/lua/plug/_treesitter.lua create mode 100644 nvim/.config/nvim/lua/plugins/config/cmp.lua create mode 100644 nvim/.config/nvim/lua/plugins/config/lsp.lua rename nvim/.config/nvim/lua/{plug/_lualine.lua => plugins/config/lualine.lua} (100%) rename nvim/.config/nvim/lua/{plug/_mini.lua => plugins/config/mini.lua} (94%) create mode 100644 nvim/.config/nvim/lua/plugins/config/toggleterm.lua create mode 100644 nvim/.config/nvim/lua/plugins/core.lua create mode 100644 nvim/.config/nvim/lua/plugins/data_analysis.lua create mode 100644 nvim/.config/nvim/lua/plugins/editing.lua create mode 100644 nvim/.config/nvim/lua/plugins/filebrowsers.lua create mode 100644 nvim/.config/nvim/lua/plugins/git.lua create mode 100644 nvim/.config/nvim/lua/plugins/ide.lua create mode 100644 nvim/.config/nvim/lua/plugins/languages.lua create mode 100644 nvim/.config/nvim/lua/plugins/prose.lua create mode 100644 nvim/.config/nvim/lua/plugins/telescope.lua create mode 100644 nvim/.config/nvim/lua/plugins/treesitter.lua create mode 100644 nvim/.config/nvim/lua/plugins/ui.lua create mode 100644 nvim/.config/nvim/lua/util/init.lua delete mode 100644 nvim/.config/nvim/plugin/personal/makescratch.vim delete mode 100644 nvim/.config/nvim/plugin/personal/searchnotes.vim delete mode 100644 nvim/.config/nvim/plugin/thesaurus_query.vim delete mode 100644 nvim/.config/nvim/plugin/vifm.vim create mode 100644 writing/.config/pubs/pubsrc create mode 100644 writing/.config/sh/alias.d/pubs.sh diff --git a/desktop/.config/user-dirs.dirs b/desktop/.config/user-dirs.dirs new file mode 100644 index 0000000..1379551 --- /dev/null +++ b/desktop/.config/user-dirs.dirs @@ -0,0 +1,15 @@ +# This file is written by xdg-user-dirs-update +# If you want to change or add directories, just edit the line you're +# interested in. All local changes will be retained on the next run. +# Format is XDG_xxx_DIR="$HOME/yyy", where yyy is a shell-escaped +# homedir-relative path, or XDG_xxx_DIR="/yyy", where /yyy is an +# absolute path. No other format is supported. +# +XDG_DESKTOP_DIR="$HOME/desktop" +XDG_DOCUMENTS_DIR="$HOME/documents" +XDG_DOWNLOAD_DIR="$HOME/downloads" +XDG_MUSIC_DIR="$HOME/media/audio/music" +XDG_PICTURES_DIR="$HOME/pictures" +XDG_PUBLICSHARE_DIR="$HOME/" +XDG_TEMPLATES_DIR="$HOME/" +XDG_VIDEOS_DIR="$HOME/" diff --git a/nvim/.config/nvim/init.lua b/nvim/.config/nvim/init.lua index 7525255..7abf033 100644 --- a/nvim/.config/nvim/init.lua +++ b/nvim/.config/nvim/init.lua @@ -10,6 +10,7 @@ for _, source in ipairs({ "core.autocmds", "core.mappings", "core.look", + "personal", }) do local status_ok, fault = pcall(require, source) if not status_ok then diff --git a/nvim/.config/nvim/lazy-lock.json b/nvim/.config/nvim/lazy-lock.json index f541e4b..bf2bda1 100644 --- a/nvim/.config/nvim/lazy-lock.json +++ b/nvim/.config/nvim/lazy-lock.json @@ -7,7 +7,7 @@ "cmp-beancount": { "branch": "main", "commit": "da154ea94d598e6649d6ad01efa0a8611eff460d" }, "cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" }, "cmp-calc": { "branch": "main", "commit": "50792f34a628ea6eb31d2c90e8df174671e4e7a0" }, - "cmp-cmdline": { "branch": "main", "commit": "5af1bb7d722ef8a96658f01d6eb219c4cf746b32" }, + "cmp-cmdline": { "branch": "main", "commit": "8ee981b4a91f536f52add291594e89fb6645e451" }, "cmp-digraphs": { "branch": "master", "commit": "5efc1f0078d7c5f3ea1c8e3aad04da3fd6e081a9" }, "cmp-latex-symbols": { "branch": "main", "commit": "165fb66afdbd016eaa1570e41672c4c557b57124" }, "cmp-nvim-lsp": { "branch": "main", "commit": "0e6b2ed705ddcff9738ec4ea838141654f12eeef" }, @@ -24,36 +24,35 @@ "dressing.nvim": { "branch": "master", "commit": "f16d7586fcdd8b2e3850d0abb7e46f944125cc25" }, "easyread.nvim": { "branch": "main", "commit": "0b07e315a4cd7d700c4a794bdddbec79fdc2628b" }, "fidget.nvim": { "branch": "main", "commit": "0ba1e16d07627532b6cae915cc992ecac249fb97" }, - "friendly-snippets": { "branch": "main", "commit": "b471f5419155ce832eff71ad8920ea8cfbd54840" }, + "friendly-snippets": { "branch": "main", "commit": "b3cd8d77feb7871d8b04bb45bcd8154120a796a1" }, "fwatch.nvim": { "branch": "main", "commit": "a691f7349dc66285cd75a1a698dd28bca45f2bf8" }, "gitsigns.nvim": { "branch": "main", "commit": "bb808fc7376ed7bac0fbe8f47b83d4bf01738167" }, "jupyter-kernel.nvim": { "branch": "main", "commit": "5b409598033884a3d819e2a3bcd1fe340bc8d783" }, - "lazy.nvim": { "branch": "main", "commit": "f145e6f42a56306c5536e9efbfe41f7efbec285d" }, + "lazy.nvim": { "branch": "main", "commit": "6b2311a46a3808e366bb251270f4cc04afb421ed" }, "lightspeed.nvim": { "branch": "main", "commit": "299eefa6a9e2d881f1194587c573dad619fdb96f" }, - "lsp-zero.nvim": { "branch": "v2.x", "commit": "8fda9a849d6ab4196ecf129905764ddefdfb64b5" }, + "lsp-setup.nvim": { "branch": "main", "commit": "4656a1882546b702b18a84f5de209a2f8aa43dee" }, "lsp_signature.nvim": { "branch": "master", "commit": "4665921ff8e30601c7c1328625b3abc1427a6143" }, "lualine.nvim": { "branch": "master", "commit": "05d78e9fd0cdfb4545974a5aa14b1be95a86e9c9" }, - "magma-nvim-goose": { "branch": "main", "commit": "5d916c39c1852e09fcd39eab174b8e5bbdb25f8f" }, + "magma-nvim-goose": { "branch": "main", "commit": "d7931d773efcedc9c92337b8d500e32a3725fe26" }, "markdown-preview.nvim": { "branch": "master", "commit": "9becceee5740b7db6914da87358a183ad11b2049" }, "mason-lspconfig.nvim": { "branch": "main", "commit": "5230617372e656d4a2e1e236e03bf7e7b4b97273" }, "mason-null-ls.nvim": { "branch": "main", "commit": "cfbd83909cbc56e2f07cb3f8a03157e069c5c91c" }, - "mason.nvim": { "branch": "main", "commit": "7d7efc738e08fc5bee822857db45cb6103f0b0c1" }, - "mini.nvim": { "branch": "main", "commit": "889be69623395ad183ae6f3c21c8efe006350226" }, + "mason.nvim": { "branch": "main", "commit": "4be1226f48bc2011024110f37b17f5ee468df58f" }, + "mini.nvim": { "branch": "main", "commit": "296ebbbd3e5ba5e43f5125efe18ad76fe3b632cc" }, "nabla.nvim": { "branch": "master", "commit": "8c143ad2b3ab3b8ffbd51e238ccfcbd246452a7e" }, - "neural": { "branch": "main", "commit": "155618730b87a67655bdde373ee27bfce8b07ac9" }, - "nui.nvim": { "branch": "main", "commit": "7a524120a7a70761b5a65b602fd235a65cb005aa" }, "null-ls.nvim": { "branch": "main", "commit": "a138b14099e9623832027ea12b4631ddd2a49256" }, "nvim-base16": { "branch": "master", "commit": "4f3aa29f49b38edb6db1c52cea57e64ce3de2373" }, - "nvim-cmp": { "branch": "main", "commit": "fc0f694af1a742ada77e5b1c91ff405c746f4a26" }, + "nvim-cmp": { "branch": "main", "commit": "b8c2a62b3bd3827aa059b43be3dd4b5c45037d65" }, "nvim-colorizer.lua": { "branch": "master", "commit": "dde3084106a70b9a79d48f426f6d6fec6fd203f7" }, - "nvim-lspconfig": { "branch": "master", "commit": "458fa2ee2115c693ca48a04afa65f6de6b40a2db" }, + "nvim-lspconfig": { "branch": "master", "commit": "295c646488d5baa63c6c4da68fe61171b9257375" }, "nvim-notify": { "branch": "master", "commit": "ea9c8ce7a37f2238f934e087c255758659948e0f" }, "nvim-surround": { "branch": "main", "commit": "211eaad7c6d01ef4ac02cba9052b3082ec232101" }, "nvim-toggleterm.lua": { "branch": "main", "commit": "95204ece0f2a54c89c4395295432f9aeedca7b5f" }, - "nvim-tree.lua": { "branch": "master", "commit": "f5d970d4506f385b29534252d8c15a782fa53034" }, + "nvim-tree.lua": { "branch": "master", "commit": "f873625d0636889af4cd47a01e486beb865db205" }, "nvim-treesitter": { "branch": "master", "commit": "cc360a9beb1b30d172438f640e2c3450358c4086" }, - "nvim-treesitter-context": { "branch": "master", "commit": "e2ea37627c0681421ccf4a3cf19d68bb958e1817" }, + "nvim-treesitter-context": { "branch": "master", "commit": "efe87061af560847679fca93697991e474f049e2" }, "nvim-treesitter-textsubjects": { "branch": "master", "commit": "b913508f503527ff540f7fe2dcf1bf1d1f259887" }, + "nvim-ts-autotag": { "branch": "main", "commit": "e254b306fb81ed69049cce526e7906150d73e0d1" }, "nvim-ts-context-commentstring": { "branch": "main", "commit": "0bf8fbc2ca8f8cdb6efbd0a9e32740d7a991e4c3" }, "nvim-ts-rainbow2": { "branch": "master", "commit": "c00d61ab7517530c49457ba49186776e6611a3e1" }, "nvim-web-devicons": { "branch": "master", "commit": "2a125024a137677930efcfdf720f205504c97268" }, @@ -62,11 +61,10 @@ "plenary.nvim": { "branch": "master", "commit": "253d34830709d690f013daf2853a9d21ad7accab" }, "popup.nvim": { "branch": "master", "commit": "b7404d35d5d3548a82149238289fa71f7f6de4ac" }, "quarto-nvim": { "branch": "main", "commit": "b299266c6287d74b60480fae348d629ec1dc02bb" }, - "significant.nvim": { "branch": "main", "commit": "5450e9d5917dc6aa9afb0fcbe32355799b8303fb" }, "smartcolumn.nvim": { "branch": "main", "commit": "0c572e3eae48874f25b74394a486f38cadb5c958" }, "symbols-outline.nvim": { "branch": "master", "commit": "512791925d57a61c545bc303356e8a8f7869763c" }, "telescope-fzf-native.nvim": { "branch": "main", "commit": "9bc8237565ded606e6c366a71c64c0af25cd7a50" }, - "telescope.nvim": { "branch": "master", "commit": "c1a2af0af69e80e14e6b226d3957a064cd080805" }, + "telescope.nvim": { "branch": "master", "commit": "776b509f80dd49d8205b9b0d94485568236d1192" }, "twilight.nvim": { "branch": "main", "commit": "8bb7fa7b918baab1ca81b977102ddb54afa63512" }, "vifm.vim": { "branch": "master", "commit": "a8130c37d144b51d84bee19f0532abcd3583383f" }, "vim-criticmarkup": { "branch": "master", "commit": "d15dc134eb177a170c79f6377f81eb02a9d20b02" }, @@ -81,4 +79,4 @@ "zen-mode.nvim": { "branch": "main", "commit": "6e6c963d70a8e47854fa656987666bfb863f9c4e" }, "zettelkasten.nvim": { "branch": "main", "commit": "0e77624689b470410f5355b613d45219c9350264" }, "zk-nvim": { "branch": "main", "commit": "5ddb53688035d115f941f0c8255f6e6618e608ac" } -} \ No newline at end of file +} diff --git a/nvim/.config/nvim/lua/core/autocmds.lua b/nvim/.config/nvim/lua/core/autocmds.lua index d4f08ab..6f72b9e 100644 --- a/nvim/.config/nvim/lua/core/autocmds.lua +++ b/nvim/.config/nvim/lua/core/autocmds.lua @@ -1,37 +1,38 @@ -- Highlight whatever is being yanked vim.api.nvim_create_autocmd({ "TextYankPost" }, { - command = 'silent! lua require"vim.highlight".on_yank{timeout=500}', - desc = "Highlight yanked text whenevery yanking something", - group = vim.api.nvim_create_augroup("highlightyanks", { clear = true }), + command = 'silent! lua require"vim.highlight".on_yank{timeout=500}', + desc = "Highlight yanked text whenevery yanking something", + group = vim.api.nvim_create_augroup("highlightyanks", { clear = true }), }) -- Special setting for editing gopass files - make sure nothing leaks outside the directories it is supposed to vim.api.nvim_create_autocmd({ "BufNewFile", "BufRead" }, { - pattern = { - "/dev/shm/gopass.*", - "/dev/shm/pass.?*/?*.txt", - "$TMPDIR/pass.?*/?*.txt", - "/tmp/pass.?*/?*.txt", - }, - command = "setlocal noswapfile nobackup noundofile nowritebackup viminfo=", - desc = "Don't leak any information when editing potential password files", - group = vim.api.nvim_create_augroup("passnoleak", { clear = true }), + pattern = { + "/dev/shm/gopass.*", + "/dev/shm/pass.?*/?*.txt", + "$TMPDIR/pass.?*/?*.txt", + "/tmp/pass.?*/?*.txt", + }, + command = "setlocal noswapfile nobackup noundofile nowritebackup viminfo=", + desc = "Don't leak any information when editing potential password files", + group = vim.api.nvim_create_augroup("passnoleak", { clear = true }), }) -- fixing neovim opening up at same moment as alacritty (see https://github.com/neovim/neovim/issues/11330) vim.api.nvim_create_autocmd({ "VimEnter" }, { - callback = function() - local pid, WINCH = vim.fn.getpid(), vim.loop.constants.SIGWINCH - vim.defer_fn(function() - vim.loop.kill(pid, WINCH) - end, 20) - end, - desc = "Fix neovim sizing issues if opening same time as alacritty", - group = vim.api.nvim_create_augroup("alacritty_fixsize", { clear = true }), + callback = function() + local pid, WINCH = vim.fn.getpid(), vim.loop.constants.SIGWINCH + vim.defer_fn(function() + vim.loop.kill(pid, WINCH) + end, 20) + end, + desc = "Fix neovim sizing issues if opening same time as alacritty", + group = vim.api.nvim_create_augroup("alacritty_fixsize", { clear = true }), }) -- remove line numbers from terminal buffers vim.api.nvim_create_autocmd({ "TermOpen" }, { - pattern = "*", - command = "setlocal nonumber norelativenumber", + desc = "Hide buffer numbers for terminals", + pattern = "*", + command = "setlocal nonumber norelativenumber", }) diff --git a/nvim/.config/nvim/lua/core/mappings.lua b/nvim/.config/nvim/lua/core/mappings.lua index 307e49a..40dd082 100644 --- a/nvim/.config/nvim/lua/core/mappings.lua +++ b/nvim/.config/nvim/lua/core/mappings.lua @@ -1,5 +1,6 @@ local map = vim.keymap.set local prefix = require("which-key").register +local is_available = require("util").is_available -- The general ideas behind these mappings: -- @@ -102,8 +103,6 @@ map("n", "/", ":noh", { desc = "remove highlights" }) -- tmux setup) map("n", "-", ":sp", { desc = "open horiz split" }) map("n", "\\", ":vsp", { desc = "open vert split" }) --- 'open new buffer' with leader-t (opens new buffer containing current dir and switches to it) -map("n", "t", ":vsp | Vifm", { desc = "open buffer" }) -- open actual new tab with leader-T map("n", "T", ":tabedit | Vifm", { desc = "open tab" }) @@ -251,8 +250,13 @@ map("v", "nN", ":ZkNewFromContentSelection", { desc = "content map("v", "nf", ":ZkMatch", { desc = "find note from selection" }) -- PLUGIN: toggleterm.nvim --- create a lazygit window, set up in toggleterm settings -map("n", "G", ":Lazygit") +-- create a lazygit or python window, set up in toggleterm settings +-- TODO create ability to go into python environment when in poetry venv and/or euporie/jupyter notebook +if require("util").is_available("nvim-toggleterm.lua") then + map("n", "G", ":Lazygit") + map("n", "tg", ":Lazygit") + map("n", "tp", ":Pythonterm") +end prefix({ ["s"] = { name = "+set" } }) -- PLUGIN: wrapping.nvim diff --git a/nvim/.config/nvim/lua/core/plugins.lua b/nvim/.config/nvim/lua/core/plugins.lua deleted file mode 100644 index c20fd0e..0000000 --- a/nvim/.config/nvim/lua/core/plugins.lua +++ /dev/null @@ -1,321 +0,0 @@ -local writing_ft = { "quarto", "pandoc", "markdown", "text", "tex" } - -return { - -- essential - { "numToStr/Navigator.nvim", branch = "master", config = true }, -- allow seamless navigation between vim buffers and tmux/wezterm splits - { "jeffkreeftmeijer/vim-numbertoggle", event = "BufEnter" }, -- toggles numbers to absolute for all buffers but the current which is relative - { "ojroques/vim-oscyank", event = "VeryLazy" }, -- yank from *anywhere* (even ssh session) to clipboard, using :OSCYank - { "ggandor/lightspeed.nvim", event = "VeryLazy" }, -- jump between letters with improved fFtT quicksearch, mimics sneak - { - "lewis6991/gitsigns.nvim", -- show vcs changes on left-hand gutter - config = function() - require("plug._gitsigns") - end, - event = "BufRead", - }, - { "m4xshen/smartcolumn.nvim", config = true }, -- auto-hiding colorcolumn - -- files - { "vifm/vifm.vim" }, -- integrate file manager - { - "nvim-tree/nvim-tree.lua", -- integrate file tree - config = true, - dependencies = { "nvim-tree/nvim-web-devicons", config = true }, - cmd = "NvimTreeToggle", - }, -- colors - { - "RRethy/nvim-base16", - event = "BufWinEnter", - dependencies = { "rktjmp/fwatch.nvim" }, - }, - { - "NvChad/nvim-colorizer.lua", -- color hex, named colors in the correct preview scheme - config = function() - require("colorizer").setup({ - user_default_options = { mode = "virtualtext" }, - }) - end, - event = "VeryLazy", - }, -- editing - { "kylechui/nvim-surround", version = "*", config = true, event = "VeryLazy" }, -- surround things with other things using ys/cs/ds - { - "monaqa/dial.nvim", -- extend the ^a / ^x possibilities to dates, hex, alphabets, markdown headers - config = function() - local augend = require("dial.augend") - require("dial.config").augends:register_group({ - -- default augends used when no group name is specified - default = { - augend.integer.alias.decimal, - augend.integer.alias.hex, - augend.date.alias["%Y/%m/%d"], - augend.date.alias["%Y-%m-%d"], - augend.date.alias["%m/%d"], - augend.date.alias["%H:%M:%S"], - augend.date.alias["%H:%M"], - augend.constant.alias.de_weekday_full, - augend.constant.alias.de_weekday, - augend.constant.alias.bool, - augend.semver.alias.semver, - augend.constant.alias.Alpha, - augend.constant.alias.alpha, - augend.hexcolor.new({ case = "lower" }), - augend.constant.new({ - elements = { "and", "or" }, - word = true, -- if false, "sand" is incremented into "sor", "doctor" into "doctand", etc. - cyclic = true, -- "or" is incremented into "and". - }), - augend.constant.new({ - elements = { "&&", "||" }, - word = false, - cyclic = true, - }), - }, - }) - end, - event = "VeryLazy", - }, - { - "tommcdo/vim-exchange", -- adds exchange operator with cx. common use: cxiw . on 2 words to switch - event = "VeryLazy", - }, - { - "junegunn/vim-easy-align", -- Align tables and other alignable things - event = "VeryLazy", - }, - { "edKotinsky/Arduino.nvim", ft = "arduino", config = true }, -- statusline - { - "nvim-lualine/lualine.nvim", - requires = { "nvim-tree/nvim-web-devicons", config = true }, - config = function() - require("plug._lualine") - end, - }, -- writing - { "vim-pandoc/vim-criticmarkup", ft = writing_ft }, - { - "jbyuki/nabla.nvim", - ft = writing_ft, - config = function() - require("nabla").enable_virt({ autogen = true, silent = true }) - end, - }, - { - "mickael-menu/zk-nvim", - config = function() - require("zk").setup({ picker = "telescope" }) - end, - }, - { - "andrewferrier/wrapping.nvim", - config = function() - require("wrapping").setup({ - create_keymappings = false, - notify_on_switch = false, - }) - end, - }, - { - "quarto-dev/quarto-nvim", - dependencies = { - "jmbuhr/otter.nvim", - "neovim/nvim-lspconfig", - "vim-pandoc/vim-pandoc-syntax", - "hrsh7th/nvim-cmp", - "nvim-treesitter/nvim-treesitter", - }, - config = function() - require("quarto").setup({ - lspFeatures = { - enabled = true, - languages = { "r", "python", "julia" }, - diagnostics = { enabled = true, triggers = { "BufWrite" } }, - completion = { enabled = true }, - }, - }) - end, - ft = "quarto", - }, - { - "lkhphuc/jupyter-kernel.nvim", - config = true, - cmd = "JupyterAttach", - build = ":UpdateRemotePlugins", - keys = { - { - "ck", - "JupyterInspect", - desc = "Inspect object in kernel", - }, - }, - }, - { "micarmst/vim-spellsync", event = "VeryLazy" }, -- personal dict improvements for git sync - { "folke/zen-mode.nvim", config = true, event = "VeryLazy" }, -- provide distraction free writing - { "folke/twilight.nvim", event = "VeryLazy" }, -- provide even distraction free-er writing (lowlight paragraphs) - { - "JellyApple102/easyread.nvim", - config = true, - ft = writing_ft, - cmd = "EasyreadToggle", - }, -- enable 'speed-reading' mode (bionic reading) - { "marty-oehme/zettelkasten.nvim", ft = writing_ft, event = "VeryLazy" }, -- simple static markdown linking - { - "iamcco/markdown-preview.nvim", -- generate an auto-updating html preview for md files - build = function() - vim.fn["mkdp#util#install"]() - end, - ft = writing_ft, - }, -- languages - { "euclidianAce/BetterLua.vim", ft = "lua" }, -- better syntax highlighting for lua - { "aliou/bats.vim", ft = { "bash", "sh", "zsh", "bats" } }, -- enable syntax for bats shell-code testing library - - -- REPL work - { - "WhiteBlackGoose/magma-nvim-goose", - build = ":UpdateRemotePlugins", - config = function() - vim.g.magma_image_provider = "kitty" - vim.g.magma_automatically_open_output = false - end, - }, - { - "echasnovski/mini.nvim", - version = "*", - config = function() - require("plug._mini") - end, - }, - { - "akinsho/nvim-toggleterm.lua", -- simpler, programmable and multiple terminal toggling for nvim - config = function() - require("plug._toggleterm") - end, - }, - { - "folke/which-key.nvim", - config = function() - require("which-key").setup({}) - end, - }, -- fuzzy matching - { "nvim-telescope/telescope-fzf-native.nvim", build = "make" }, - { - "nvim-telescope/telescope.nvim", - dependencies = { "nvim-lua/popup.nvim", "nvim-lua/plenary.nvim" }, - config = function() - require("plug._telescope") - end, - }, - { - "dense-analysis/neural", - dependencies = { "MunifTanjim/nui.nvim", "elpiloto/significant.nvim" }, - config = function() - require("neural").setup({ - source = { openai = { api_key = vim.env.OPENAI_API_KEY } }, - }) - end, - }, -- treesitter - { - "nvim-treesitter/nvim-treesitter", - build = ":TSUpdate", - config = function() - require("plug._treesitter") - end, - event = "BufReadPre", - -- rainbow brackets using treesitter - -- show current cursor context at top of buffer - -- improves commenting plugin above by using ts - dependencies = { - "https://gitlab.com/HiPhish/nvim-ts-rainbow2.git", - { "romgrk/nvim-treesitter-context", config = true }, - "JoosepAlviste/nvim-ts-context-commentstring", - }, - }, - { "nvim-treesitter/playground", cmd = "TSPlaygroundToggle" }, -- interactively view and query the treesitter tree - { - "RRethy/nvim-treesitter-textsubjects", -- allows using . and ; to target treesitter branches - config = function() - require("nvim-treesitter.configs").setup({ - textsubjects = { - enable = true, - keymaps = { - ["."] = "textsubjects-smart", - [";"] = "textsubjects-container-outer", - }, - }, - }) - end, - event = "BufReadPre", - }, - { - -- lsp - "VonHeikemen/lsp-zero.nvim", - dependencies = { - { "neovim/nvim-lspconfig", branch = "master" }, - "williamboman/mason.nvim", - "williamboman/mason-lspconfig.nvim", - { - "hrsh7th/nvim-cmp", - branch = "main", - dependencies = { - "andersevenrud/cmp-tmux", - "cbarrete/completion-vcard", - "f3fora/cmp-spell", - "hrsh7th/cmp-nvim-lsp", - "hrsh7th/cmp-path", - "hrsh7th/cmp-buffer", - "hrsh7th/cmp-calc", - "hrsh7th/cmp-cmdline", - "hrsh7th/cmp-nvim-lua", - "dmitmel/cmp-digraphs", - "jc-doyle/cmp-pandoc-references", - "kdheepak/cmp-latex-symbols", - "lukas-reineke/cmp-rg", - "crispgm/cmp-beancount", - "ray-x/cmp-treesitter", - "saadparwaiz1/cmp_luasnip", - }, - }, - "L3MON4D3/LuaSnip", - "rafamadriz/friendly-snippets", - -- { "lukas-reineke/lsp-format.nvim", config = true }, - { "j-hui/fidget.nvim", config = true }, -- loading animations for some LSP - { - "jay-babu/mason-null-ls.nvim", - event = { "BufReadPre", "BufNewFile" }, - dependencies = { - "williamboman/mason.nvim", - "jose-elias-alvarez/null-ls.nvim", - }, - }, - }, - config = function() - require("plug._lsp") - end, - branch = "v2.x", - }, - { "simrat39/symbols-outline.nvim", config = true, event = "VeryLazy" }, -- vista-like outline view for code - { "ray-x/lsp_signature.nvim", config = true }, -- UI improvements - { "stevearc/dressing.nvim", config = true }, - { - "rcarriga/nvim-notify", - config = function() - vim.notify = require("notify") - end, - }, - -- { -- REQUIRES custom `yay -S --asdeps lua51-lyaml invocation` AND is suuper slow - -- "jghauser/papis.nvim", - -- after = { "telescope.nvim", "nvim-cmp" }, - -- dependencies = { - -- "kkharji/sqlite.lua", "nvim-lua/plenary.nvim", - -- "MunifTanjim/nui.nvim", "nvim-treesitter/nvim-treesitter" - -- }, - -- ft = writing_ft, - -- rocks = { "lyaml" }, - -- config = function() - -- require('papis').setup({ - -- papis_python = { - -- dir = "/home/marty/documents/library/academia", - -- info_name = "info.yaml", - -- notes_name = [[notes.qmd]] - -- } - -- }) - -- end - -- } -} diff --git a/nvim/.config/nvim/lua/core/settings.lua b/nvim/.config/nvim/lua/core/settings.lua index a225dbd..391f01e 100644 --- a/nvim/.config/nvim/lua/core/settings.lua +++ b/nvim/.config/nvim/lua/core/settings.lua @@ -83,6 +83,8 @@ local globals = { mapleader = " ", maplocalleader = ",", tex_flavor = "latex", + + format_on_save = true, -- from personal toggle function } for o, v in pairs(globals) do diff --git a/nvim/.config/nvim/lua/personal/format_on_save_toggle.lua b/nvim/.config/nvim/lua/personal/format_on_save_toggle.lua new file mode 100644 index 0000000..04b7c9d --- /dev/null +++ b/nvim/.config/nvim/lua/personal/format_on_save_toggle.lua @@ -0,0 +1,33 @@ +local function stop_formatting() + vim.api.nvim_del_augroup_by_name("LspFormat") +end + +local function start_formatting() + for _, client in pairs(vim.lsp.get_active_clients()) do + require("lsp-setup.utils").format_on_save(client) + end +end + +local function _toggle(opts) + if opts.args == "" then + vim.g.format_on_save = not vim.g.format_on_save + elseif opts.args == "on" or opts.args == "1" then + vim.g.format_on_save = true + elseif opts.args == "off" or opts.args == "0" then + vim.g.format_on_save = false + else + vim.notify("Please provide arguments 'on' or 'off' or non arguments to toggle.") + end + + if vim.g.format_on_save == true then + start_formatting() + else + stop_formatting() + end +end + +vim.api.nvim_create_user_command( + "FormatOnSave", + _toggle, + { desc = "toggle automatically formatting on save", nargs = "?" } +) diff --git a/nvim/.config/nvim/lua/personal/init.lua b/nvim/.config/nvim/lua/personal/init.lua new file mode 100644 index 0000000..8c2b568 --- /dev/null +++ b/nvim/.config/nvim/lua/personal/init.lua @@ -0,0 +1 @@ +require("personal.format_on_save_toggle") diff --git a/nvim/.config/nvim/lua/personal/pandoc_complete.lua b/nvim/.config/nvim/lua/personal/pandoc_complete.lua deleted file mode 100644 index 6ebfb56..0000000 --- a/nvim/.config/nvim/lua/personal/pandoc_complete.lua +++ /dev/null @@ -1,11 +0,0 @@ -local M = {} - -function M.getCompletionItems(prefix) - -- define your total completion items - local items = vim.api.nvim_call_function("pandoc#completion#Complete", { 0, prefix }) - return items -end - -M.complete_item = { item = M.getCompletionItems } - -return M diff --git a/nvim/.config/nvim/lua/plug/_gitsigns.lua b/nvim/.config/nvim/lua/plug/_gitsigns.lua deleted file mode 100644 index 06ff500..0000000 --- a/nvim/.config/nvim/lua/plug/_gitsigns.lua +++ /dev/null @@ -1,56 +0,0 @@ -require("gitsigns").setup({ - numhl = true, - signcolumn = false, - on_attach = function(bufnr) - local gs = package.loaded.gitsigns - - local function map(mode, l, r, opts) - opts = opts or {} - opts.buffer = bufnr - vim.keymap.set(mode, l, r, opts) - end - - -- Navigation - map("n", "]h", function() - if vim.wo.diff then - return "]h" - end - vim.schedule(function() - gs.next_hunk() - end) - return "" - end, { expr = true }) - - map("n", "[h", function() - if vim.wo.diff then - return "[h" - end - vim.schedule(function() - gs.prev_hunk() - end) - return "" - end, { expr = true }) - - -- Actions - require("which-key").register({ ["h"] = { name = "+git" } }) - map({ "n", "v" }, "hs", ":Gitsigns stage_hunk", { desc = "stage hunk" }) - map({ "n", "v" }, "hr", ":Gitsigns reset_hunk", { desc = "reset hunk" }) - map("n", "hS", gs.stage_buffer, { desc = "stage buffer" }) - map("n", "hu", gs.undo_stage_hunk, { desc = "undo stage hunk" }) - map("n", "hR", gs.reset_buffer, { desc = "reset buffer" }) - map("n", "hp", gs.preview_hunk, { desc = "preview hunk" }) - map("n", "hb", function() - gs.blame_line({ full = true }) - end, { desc = "blame line" }) - map("n", "hB", gs.toggle_current_line_blame, { desc = "toggle blame" }) - map("n", "hd", gs.diffthis, { desc = "diffthis" }) - map("n", "hD", function() - gs.diffthis("~") - end, { desc = "diffbase" }) - map("n", "ht", gs.toggle_deleted, { desc = "toggle deleted" }) - - -- Text object - map({ "o", "x" }, "ih", ":Gitsigns select_hunk") - map({ "o", "x" }, "ah", ":Gitsigns select_hunk") - end, -}) diff --git a/nvim/.config/nvim/lua/plug/_lsp.lua b/nvim/.config/nvim/lua/plug/_lsp.lua deleted file mode 100644 index f86153f..0000000 --- a/nvim/.config/nvim/lua/plug/_lsp.lua +++ /dev/null @@ -1,329 +0,0 @@ -local lsp = require("lsp-zero") - -vim.diagnostic.config({ virtual_text = true }) -vim.fn.sign_define("DiagnosticSignError", { text = "✘", texthl = "DiagnosticSignError" }) -vim.fn.sign_define("DiagnosticSignWarn", { text = "", texthl = "DiagnosticSignWarn" }) -vim.fn.sign_define("DiagnosticSignInfo", { text = "", texthl = "DiagnosticSignInfo" }) -vim.fn.sign_define("DiagnosticSignHint", { text = "", texthl = "DiagnosticSignHint" }) - -lsp.ensure_installed({ - "astro", - "arduino_language_server", - "bashls", - "beancount", - "clangd", - "dockerls", - "docker_compose_language_service", - "lua_ls", - "pyright", - "ruff_lsp", - "taplo", - "yamlls", - "tsserver", - "cssls", - "tailwindcss", -}) -lsp.preset({ name = "recommended", set_lsp_keymaps = false }) -lsp.on_attach(function(client, bufnr) - local map = vim.keymap.set - map("n", "[d", "lua vim.diagnostic.goto_prev()", { buffer = bufnr, desc = "Previous diagnostic" }) - map("n", "]d", "lua vim.diagnostic.goto_next()", { buffer = bufnr, desc = "Next diagnostic" }) - map( - "n", - "[e", - "lua vim.diagnostic.goto_prev({severity = vim.diagnostic.severity.ERROR})", - { buffer = bufnr, desc = "Previous error" } - ) - map( - "n", - "]e", - "lua vim.diagnostic.goto_next({severity = vim.diagnostic.severity.ERROR})", - { buffer = bufnr, desc = "Next error" } - ) - - local prefix = require("which-key").register - prefix({ ["l"] = { name = "+lsp" } }) - map("n", "li", "LspInfo", { buffer = bufnr, desc = "Lsp Info" }) - map( - "n", - "ld", - "lua vim.diagnostic.open_float()", - { buffer = bufnr, desc = "Line diagnostics" } - ) - map("n", "la", "lua vim.lsp.buf.code_action()", { buffer = bufnr, desc = "Codeactions" }) - map("n", "ln", "lua vim.lsp.buf.rename()", { buffer = bufnr, desc = "Rename element" }) - if vim.fn.exists(":Telescope") then - map("n", "lr", "Telescope lsp_references()", { buffer = bufnr, desc = "References" }) - map("n", "lf", "Telescope lsp_definitions", { buffer = bufnr, desc = "Definition" }) - map( - "n", - "lt", - "Telescope lsp_type_definitions", - { buffer = bufnr, desc = "Type definition" } - ) - map( - "n", - "lm", - "Telescope lsp_implementations", - { buffer = bufnr, desc = "Implementation" } - ) - else - map("n", "lr", "lua vim.lsp.buf.references()", { buffer = bufnr, desc = "References" }) - map("n", "lf", "lua vim.lsp.buf.definition()", { buffer = bufnr, desc = "Definition" }) - map( - "n", - "lt", - "lua vim.lsp.buf.type_definition()", - { buffer = bufnr, desc = "Type definition" } - ) - map( - "n", - "lm", - "lua vim.lsp.buf.implementation()", - { buffer = bufnr, desc = "Implementation" } - ) - end - if client.server_capabilities.document_formatting then - map( - "n", - "lf", - "lua vim.lsp.buf.formatting()", - { buffer = bufnr, desc = "Format document" } - ) - end - - map("n", "K", "lua vim.lsp.buf.hover()", { buffer = bufnr, desc = "Hover definition" }) - map("n", "lc", "lua vim.lsp.buf.declaration()", { buffer = bufnr, desc = "Declaration" }) - map( - "n", - "ls", - "lua vim.lsp.buf.signature_help()", - { buffer = bufnr, desc = "Signature help" } - ) -end) -lsp.nvim_workspace() --- ensure python virtualenv is determined automatically on lsp start -require("lspconfig").pyright.setup({ - on_attach = function(client, _) - local python_path, msg = require("util.pyenv").get_path(client.config.root_dir) - vim.notify(string.format("%s\n%s", msg, python_path)) - client.config.settings.python.pythonPath = python_path - end, -}) --- set up arduino with the help of arduino.nvim plugin -require("lspconfig").arduino_language_server.setup({ - on_new_config = require("arduino").on_new_config, -}) -require("lspconfig").lua_ls.setup(lsp.nvim_lua_ls()) - --- map filetypes (rhs) to individual servers (lhs) --- most will presumably use null_ls however -local format_servers = { - ["null-ls"] = { - "astro", - "javascript", - "javascriptreact", - "typescript", - "typescriptreact", - "vue", - "css", - "scss", - "less", - "html", - "json", - "jsonc", - "yaml", - "markdown", - "markdown.mdx", - "graphql", - "handlebars", - "python", - "sh", - "zsh", - "bash", - "lua", - "luau", - }, -} -lsp.format_on_save({ - format_opts = { - async = true, - }, - servers = format_servers, -}) -lsp.format_mapping("gq", { - format_opts = { - async = false, - }, - servers = format_servers, -}) - -lsp.setup() - -local null_ls = require("null-ls") -null_ls.setup({}) -require("mason-null-ls").setup({ - ensure_installed = { "black", "prettier", "shfmt", "eslint-lsp", "stylua", "jq" }, - automatic_installation = false, - handlers = { - shfmt = function(_, _) - null_ls.register(null_ls.builtins.formatting.shfmt.with({ - extra_filetypes = { "bash", "zsh" }, - })) - end, - prettier = function(_, _) - null_ls.register(null_ls.builtins.formatting.prettier.with({ - extra_filetypes = { "astro" }, - })) - end, - eslint = function(_, _) - null_ls.register(null_ls.builtins.diagnostics.eslint.with({ - extra_filetypes = { "astro" }, - })) - null_ls.register(null_ls.builtins.code_actions.eslint.with({ - extra_filetypes = { "astro" }, - })) - end, - }, -}) - -local luasnip = require("luasnip") -local has_words_before = function() - local line, col = unpack(vim.api.nvim_win_get_cursor(0)) - return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil -end - -local kind_icons = { - Text = "", - Method = "", - Function = "", - Constructor = "", - Field = "", - Variable = "", - Class = "ﴯ", - Interface = "", - Module = "", - Property = "ﰠ", - Unit = "", - Value = "", - Enum = "", - Keyword = "", - Snippet = "", - Color = "", - File = "", - Reference = "", - Folder = "", - EnumMember = "", - Constant = "", - Struct = "", - Event = "", - Operator = "", - TypeParameter = "", -} -local cmp = require("cmp") -cmp.setup({ - window = { documentation = cmp.config.window.bordered() }, - snippet = { - expand = function(args) - require("luasnip").lsp_expand(args.body) - end, - }, - sources = { - { name = "nvim_lsp" }, - { name = "otter" }, - { name = "luasnip", keyword_length = 2 }, - { name = "pandoc_references" }, - { name = "nvim_lua" }, - { - name = "beancount", - option = { - account = vim.env["HOME"] .. "/documents/records/budget/main.beancount", -- TODO implement dynamically - }, - }, - { name = "calc" }, - { name = "path" }, - { name = "buffer", keyword_length = 3 }, - { name = "digraphs" }, - { name = "latex_symbols" }, - { name = "spell", keyword_length = 3 }, - { name = "tmux" }, -- { name = 'rg', keyword_length = 5 }, - { name = "vCard" }, - }, - mapping = cmp.mapping.preset.insert({ - [""] = cmp.mapping.scroll_docs(-4), - [""] = cmp.mapping.scroll_docs(4), - [""] = cmp.mapping({ - i = function(fallback) - if cmp.visible() and cmp.get_active_entry() then - cmp.confirm({ - behavior = cmp.ConfirmBehavior.Replace, - select = false, - }) - else - fallback() - end - end, - s = cmp.mapping.confirm({ select = true }), - c = cmp.mapping.confirm({ - behavior = cmp.ConfirmBehavior.Replace, - select = false, - }), -- disable selection in cmd mode - }), - [""] = cmp.mapping(function(fallback) - if cmp.visible() then - cmp.select_next_item() - -- You could replace the expand_or_jumpable() calls with expand_or_locally_jumpable() - -- they way you will only jump inside the snippet region - elseif luasnip.expand_or_jumpable() then - luasnip.expand_or_jump() - elseif has_words_before() then - cmp.complete() - else - fallback() - end - end, { "i", "s" }), - [""] = cmp.mapping(function(fallback) - if cmp.visible() then - cmp.select_prev_item() - elseif luasnip.jumpable(-1) then - luasnip.jump(-1) - else - fallback() - end - end, { "i", "s" }), - }), - formatting = { - fields = { "kind", "abbr", "menu" }, - format = function(entry, vim_item) - -- Kind icons, removing kind text leaving only icon - -- vim_item.kind = string.format('%s %s', kind_icons[vim_item.kind], vim_item.kind) - vim_item.kind = string.format("%s", kind_icons[vim_item.kind]) - -- Source - vim_item.menu = ({ - buffer = "[Buf]", - calc = "[Cal]", - digraphs = "[Dig]", - latex_symbols = "[LaTeX]", - luasnip = "[Snip]", - nvim_lsp = "[Lsp]", - nvim_lua = "[Lua]", - pandoc_references = "[Bib]", - spell = "[Spl]", - vCard = "[vCrd]", - })[entry.source.name] - return vim_item - end, - }, -}) --- `/` cmdline setup. -cmp.setup.cmdline("/", { - mapping = cmp.mapping.preset.cmdline(), - sources = { { name = "buffer" } }, -}) --- `:` cmdline setup. -cmp.setup.cmdline(":", { - mapping = cmp.mapping.preset.cmdline(), - sources = cmp.config.sources({ { name = "path" } }, { - { name = "cmdline", option = { ignore_cmds = { "Man", "!" } } }, - }), -}) diff --git a/nvim/.config/nvim/lua/plug/_telescope.lua b/nvim/.config/nvim/lua/plug/_telescope.lua deleted file mode 100644 index cb70f13..0000000 --- a/nvim/.config/nvim/lua/plug/_telescope.lua +++ /dev/null @@ -1,64 +0,0 @@ --- Setup up telescope fuzzy finding settings --- --- Makes use of optionally installed external programs to work fully: --- rg (ripgrep) for in-text searches --- fd for quicker directory structure searches --- lsp for a variety of lsp queries -require("telescope").setup({ - defaults = { - vimgrep_arguments = { - "rg", - "--ignore-vcs", - "--hidden", - "--color=never", - "--no-heading", - "--with-filename", - "--line-number", - "--column", - "--smart-case", - }, - generic_sorter = require("mini.fuzzy").get_telescope_sorter, - }, - defaults = { - -- Appearance - prompt_prefix = " ", - selection_caret = "󰳟 ", - color_devicons = true, - }, - pickers = { - buffers = { theme = "ivy" }, - oldfiles = { theme = "ivy" }, - find_files = { - theme = "dropdown", - -- nice minimal picker design - borderchars = { - { "─", "│", "─", "│", "┌", "┐", "┘", "└" }, - prompt = { "─", "│", " ", "│", "┌", "┐", "│", "│" }, - results = { - "─", - "│", - "─", - "│", - "├", - "┤", - "┘", - "└", - }, - preview = { - "─", - "│", - "─", - "│", - "┌", - "┐", - "┘", - "└", - }, - }, - width = 0.8, - previewer = false, - prompt_title = false, - }, - }, -}) -require("telescope").load_extension("fzf") diff --git a/nvim/.config/nvim/lua/plug/_toggleterm.lua b/nvim/.config/nvim/lua/plug/_toggleterm.lua deleted file mode 100644 index 9ffc6b7..0000000 --- a/nvim/.config/nvim/lua/plug/_toggleterm.lua +++ /dev/null @@ -1,18 +0,0 @@ -require("toggleterm").setup({ - open_mapping = [[=]], - insert_mappings = false, -- don't map the key in insert mode -}) - -local Terminal = require("toggleterm.terminal").Terminal --- create a lazygit window with the lazygit command -local lazygit = Terminal:new({ - cmd = "lazygit", - hidden = true, - direction = "float", - float_opts = { border = "curved" }, -}) -function _Lazygit_toggle() - lazygit:toggle() -end - -vim.cmd([[command! Lazygit :lua _Lazygit_toggle()]]) diff --git a/nvim/.config/nvim/lua/plug/_treesitter.lua b/nvim/.config/nvim/lua/plug/_treesitter.lua deleted file mode 100644 index 4c80ceb..0000000 --- a/nvim/.config/nvim/lua/plug/_treesitter.lua +++ /dev/null @@ -1,21 +0,0 @@ -local rainbow = require("ts-rainbow") -require("nvim-treesitter.configs").setup({ - -- one of "all", "maintained" (parsers with maintainers), or a list of languages - ensure_installed = "all", - highlight = { enable = true }, - incremental_selection = { enable = true }, - textobjects = { enable = true }, - indent = { enable = true }, - - -- enable rainbow brackets, needs p00f/nvim-ts-rainbow - rainbow = { - enable = true, - strategy = { rainbow.strategy.global }, - }, - - -- for improved commentstrings, needs corresponding plugin - context_commentstring = { - enable = true, - enable_autocmd = false, -- since we run it as a hook from the mini.comment plugin - }, -}) diff --git a/nvim/.config/nvim/lua/plugins/config/cmp.lua b/nvim/.config/nvim/lua/plugins/config/cmp.lua new file mode 100644 index 0000000..938f923 --- /dev/null +++ b/nvim/.config/nvim/lua/plugins/config/cmp.lua @@ -0,0 +1,142 @@ +local luasnip = require("luasnip") +local cmp = require("cmp") + +local has_words_before = function() + local line, col = unpack(vim.api.nvim_win_get_cursor(0)) + return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil +end + +local kind_icons = { + Text = "", + Method = "", + Function = "", + Constructor = "", + Field = "", + Variable = "", + Class = "ﴯ", + Interface = "", + Module = "", + Property = "ﰠ", + Unit = "", + Value = "", + Enum = "", + Keyword = "", + Snippet = "", + Color = "", + File = "", + Reference = "", + Folder = "", + EnumMember = "", + Constant = "", + Struct = "", + Event = "", + Operator = "", + TypeParameter = "", +} + +cmp.setup({ + window = { documentation = cmp.config.window.bordered() }, + snippet = { + expand = function(args) + require("luasnip").lsp_expand(args.body) + end, + }, + sources = { + { name = "nvim_lsp" }, + { name = "otter" }, + { name = "luasnip", keyword_length = 2 }, + { name = "pandoc_references" }, + { name = "nvim_lua" }, + { + name = "beancount", + option = { + account = vim.env["HOME"] .. "/documents/records/budget/main.beancount", -- TODO implement dynamically + }, + }, + { name = "calc" }, + { name = "path" }, + { name = "buffer", keyword_length = 3 }, + { name = "digraphs" }, + { name = "latex_symbols" }, + { name = "spell", keyword_length = 3 }, + { name = "tmux" }, -- { name = 'rg', keyword_length = 5 }, + { name = "vCard" }, + }, + mapping = cmp.mapping.preset.insert({ + [""] = cmp.mapping.scroll_docs(-4), + [""] = cmp.mapping.scroll_docs(4), + [""] = cmp.mapping({ + i = function(fallback) + if cmp.visible() and cmp.get_active_entry() then + cmp.confirm({ + behavior = cmp.ConfirmBehavior.Replace, + select = false, + }) + else + fallback() + end + end, + s = cmp.mapping.confirm({ select = true }), + c = cmp.mapping.confirm({ + behavior = cmp.ConfirmBehavior.Replace, + select = false, + }), -- disable selection in cmd mode + }), + [""] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_next_item() + -- You could replace the expand_or_jumpable() calls with expand_or_locally_jumpable() + -- they way you will only jump inside the snippet region + elseif luasnip.expand_or_jumpable() then + luasnip.expand_or_jump() + elseif has_words_before() then + cmp.complete() + else + fallback() + end + end, { "i", "s" }), + [""] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_prev_item() + elseif luasnip.jumpable(-1) then + luasnip.jump(-1) + else + fallback() + end + end, { "i", "s" }), + }), + formatting = { + fields = { "kind", "abbr", "menu" }, + format = function(entry, vim_item) + -- Kind icons, removing kind text leaving only icon + -- vim_item.kind = string.format('%s %s', kind_icons[vim_item.kind], vim_item.kind) + vim_item.kind = string.format("%s", kind_icons[vim_item.kind]) + -- Source + vim_item.menu = ({ + buffer = "[Buf]", + calc = "[Cal]", + digraphs = "[Dig]", + latex_symbols = "[LaTeX]", + luasnip = "[Snip]", + nvim_lsp = "[Lsp]", + nvim_lua = "[Lua]", + pandoc_references = "[Bib]", + spell = "[Spl]", + vCard = "[vCrd]", + })[entry.source.name] + return vim_item + end, + }, +}) +-- `/` cmdline setup. +cmp.setup.cmdline("/", { + mapping = cmp.mapping.preset.cmdline(), + sources = { { name = "buffer" } }, +}) +-- `:` cmdline setup. +cmp.setup.cmdline(":", { + mapping = cmp.mapping.preset.cmdline(), + sources = cmp.config.sources({ { name = "path" } }, { + { name = "cmdline", option = { ignore_cmds = { "Man", "!" } } }, + }), +}) diff --git a/nvim/.config/nvim/lua/plugins/config/lsp.lua b/nvim/.config/nvim/lua/plugins/config/lsp.lua new file mode 100644 index 0000000..645c640 --- /dev/null +++ b/nvim/.config/nvim/lua/plugins/config/lsp.lua @@ -0,0 +1,168 @@ +vim.diagnostic.config({ virtual_text = true }) +vim.fn.sign_define("DiagnosticSignError", { text = "✘", texthl = "DiagnosticSignError" }) +vim.fn.sign_define("DiagnosticSignWarn", { text = "", texthl = "DiagnosticSignWarn" }) +vim.fn.sign_define("DiagnosticSignInfo", { text = "", texthl = "DiagnosticSignInfo" }) +vim.fn.sign_define("DiagnosticSignHint", { text = "", texthl = "DiagnosticSignHint" }) + +local lsp = require("lsp-setup") + +local servers = { + ansiblels = {}, + arduino_language_server = {}, + astro = {}, + bashls = {}, + beancount = {}, + clangd = {}, + cssls = {}, + docker_compose_language_service = {}, + dockerls = {}, + emmet_ls = {}, + gopls = {}, + julials = {}, + lua_ls = { + settings = { + Lua = { + diagnostics = { globals = { "vim" } }, + -- enable when working on neovim stuff. Takes *long* to load + -- workspace = { library = vim.api.nvim_get_runtime_file("", true) }, + telemetry = { enable = false }, + }, + }, + }, + marksman = {}, + pyright = {}, + ruff_lsp = {}, + tailwindcss = {}, + taplo = {}, + texlab = {}, + tsserver = {}, + yamlls = {}, + zk = {}, +} + +local function on_attach(client, bufnr) + local map = vim.keymap.set + map("n", "[d", "lua vim.diagnostic.goto_prev()", { buffer = bufnr, desc = "Previous diagnostic" }) + map("n", "]d", "lua vim.diagnostic.goto_next()", { buffer = bufnr, desc = "Next diagnostic" }) + map( + "n", + "[e", + "lua vim.diagnostic.goto_prev({severity = vim.diagnostic.severity.ERROR})", + { buffer = bufnr, desc = "Previous error" } + ) + map( + "n", + "]e", + "lua vim.diagnostic.goto_next({severity = vim.diagnostic.severity.ERROR})", + { buffer = bufnr, desc = "Next error" } + ) + + local prefix = require("which-key").register + prefix({ ["l"] = { name = "+lsp" } }) + map("n", "li", "LspInfo", { buffer = bufnr, desc = "Lsp Info" }) + map( + "n", + "ld", + "lua vim.diagnostic.open_float()", + { buffer = bufnr, desc = "Line diagnostics" } + ) + map("n", "la", "lua vim.lsp.buf.code_action()", { buffer = bufnr, desc = "Codeactions" }) + map("n", "ln", "lua vim.lsp.buf.rename()", { buffer = bufnr, desc = "Rename element" }) + if vim.fn.exists(":Telescope") then + map("n", "lr", "Telescope lsp_references", { buffer = bufnr, desc = "References" }) + map("n", "lf", "Telescope lsp_definitions", { buffer = bufnr, desc = "Definition" }) + map( + "n", + "lt", + "Telescope lsp_type_definitions", + { buffer = bufnr, desc = "Type definition" } + ) + map( + "n", + "lm", + "Telescope lsp_implementations", + { buffer = bufnr, desc = "Implementation" } + ) + else + map("n", "lr", "lua vim.lsp.buf.references()", { buffer = bufnr, desc = "References" }) + map("n", "lf", "lua vim.lsp.buf.definition()", { buffer = bufnr, desc = "Definition" }) + map( + "n", + "lt", + "lua vim.lsp.buf.type_definition()", + { buffer = bufnr, desc = "Type definition" } + ) + map( + "n", + "lm", + "lua vim.lsp.buf.implementation()", + { buffer = bufnr, desc = "Implementation" } + ) + end + map("n", "ll", "lua vim.lsp.buf.format()", { buffer = bufnr, desc = "Format document" }) + map("n", "K", "lua vim.lsp.buf.hover()", { buffer = bufnr, desc = "Hover definition" }) + map("n", "lc", "lua vim.lsp.buf.declaration()", { buffer = bufnr, desc = "Declaration" }) + map( + "n", + "ls", + "lua vim.lsp.buf.signature_help()", + { buffer = bufnr, desc = "Signature help" } + ) + + if vim.g.format_on_save then + require("lsp-setup.utils").format_on_save(client) + end +end + +lsp.setup({ + default_mappings = false, + servers = servers, + on_attach = on_attach, + inlay_hints = { + enabled = vim.fn.has("nvim-0.10") == true and true or false, + }, +}) + +local lspconfig = require("lspconfig") + +-- ensure python virtualenv is determined automatically on lsp start +lspconfig.pyright.setup({ + on_attach = function(client, _) + local python_path, msg = require("util.pyenv").get_path(client.config.root_dir) + vim.notify(string.format("%s\n%s", msg, python_path)) + client.config.settings.python.pythonPath = python_path + end, +}) +-- set up arduino with the help of arduino.nvim plugin +if require("util").is_available("arduino") then + lspconfig.arduino_language_server.setup({ + on_new_config = require("arduino").on_new_config, + }) +end + +local null_ls = require("null-ls") +null_ls.setup({}) +require("mason-null-ls").setup({ + ensure_installed = { "black", "prettier", "shfmt", "eslint-lsp", "stylua", "jq" }, + automatic_installation = false, + handlers = { + shfmt = function(_, _) + null_ls.register(null_ls.builtins.formatting.shfmt.with({ + extra_filetypes = { "bash", "zsh" }, + })) + end, + prettier = function(_, _) + null_ls.register(null_ls.builtins.formatting.prettier.with({ + extra_filetypes = { "astro" }, + })) + end, + eslint = function(_, _) + null_ls.register(null_ls.builtins.diagnostics.eslint.with({ + extra_filetypes = { "astro" }, + })) + null_ls.register(null_ls.builtins.code_actions.eslint.with({ + extra_filetypes = { "astro" }, + })) + end, + }, +}) diff --git a/nvim/.config/nvim/lua/plug/_lualine.lua b/nvim/.config/nvim/lua/plugins/config/lualine.lua similarity index 100% rename from nvim/.config/nvim/lua/plug/_lualine.lua rename to nvim/.config/nvim/lua/plugins/config/lualine.lua diff --git a/nvim/.config/nvim/lua/plug/_mini.lua b/nvim/.config/nvim/lua/plugins/config/mini.lua similarity index 94% rename from nvim/.config/nvim/lua/plug/_mini.lua rename to nvim/.config/nvim/lua/plugins/config/mini.lua index d9194e8..114fa6b 100644 --- a/nvim/.config/nvim/lua/plug/_mini.lua +++ b/nvim/.config/nvim/lua/plugins/config/mini.lua @@ -14,7 +14,7 @@ require("mini.indentscope").setup({ options = { indent_at_cursor = false }, }) require("mini.map").setup() --- require('mini.move').setup() -- has not hit stable yet +require("mini.move").setup() -- has not hit stable yet require("mini.pairs").setup() require("mini.trailspace").setup() diff --git a/nvim/.config/nvim/lua/plugins/config/toggleterm.lua b/nvim/.config/nvim/lua/plugins/config/toggleterm.lua new file mode 100644 index 0000000..b60b436 --- /dev/null +++ b/nvim/.config/nvim/lua/plugins/config/toggleterm.lua @@ -0,0 +1,55 @@ +require("toggleterm").setup({ + open_mapping = [[=]], + insert_mappings = false, -- don't map the key in insert mode +}) + +local Terminal = require("toggleterm.terminal").Terminal + +-- need to disable indentlines since they obscure first line of terminal +if require("util").is_available("mini.nvim") then + vim.api.nvim_create_autocmd({ "TermOpen" }, { + pattern = "*", + callback = function() + vim.b.miniindentscope_disable = true + end, + }) +end + +-- create a lazygit window with the lazygit command +local lazygit = Terminal:new({ + cmd = "lazygit", + hidden = true, + direction = "float", + float_opts = { border = "curved" }, +}) +function _Lazygit_toggle() + lazygit:toggle() +end + +-- create python window +local function get_python_cmd() + if vim.fn.executable("ptipython") then + return "ptipython" + end + if vim.fn.executable("ipython") then + return "ipython" + end + if vim.fn.executable("ptpython") then + return "ptpython" + end + if vim.fn.executable("python") then + return "python" + end +end +local pythonterm = Terminal:new({ + cmd = get_python_cmd(), + hidden = true, + direction = "float", + float_opts = { border = "curved" }, +}) +function _Pythonterm_toggle() + pythonterm:toggle() +end + +vim.cmd([[command! Lazygit :lua _Lazygit_toggle()]]) +vim.cmd([[command! Pythonterm :lua _Pythonterm_toggle()]]) diff --git a/nvim/.config/nvim/lua/plugins/core.lua b/nvim/.config/nvim/lua/plugins/core.lua new file mode 100644 index 0000000..4aed166 --- /dev/null +++ b/nvim/.config/nvim/lua/plugins/core.lua @@ -0,0 +1,46 @@ +return { + -- allow seamless navigation between vim buffers and tmux/wezterm splits + { + "numToStr/Navigator.nvim", + branch = "master", + config = true, + event = "VeryLazy", + }, + -- jump between letters with improved fFtT quicksearch, mimics sneak + { "ggandor/lightspeed.nvim", event = "VeryLazy" }, + + -- yank from *anywhere* (even ssh session) to clipboard, using :OSCYank + { "ojroques/vim-oscyank", event = "VeryLazy" }, + -- personal dict improvements for git sync + { "micarmst/vim-spellsync", event = "VeryLazy" }, + { + "folke/which-key.nvim", + config = true, + event = "VeryLazy", + }, + -- collection of plugins + { + "echasnovski/mini.nvim", + version = "*", + config = function() + require("plugins.config.mini") + end, + event = "VimEnter", -- need to load pretty soon for Starter screen + }, + -- simpler, programmable and multiple terminal toggling for nvim + { + "akinsho/nvim-toggleterm.lua", + config = function() + require("plugins.config.toggleterm") + end, + lazy = false, + cmd = { "ToggleTerm", "TermExec", "Lazygit", "Pythonterm" }, + }, + -- colorschemes + { + "RRethy/nvim-base16", + lazy = false, + priority = 1000, + dependencies = { "rktjmp/fwatch.nvim" }, + }, +} diff --git a/nvim/.config/nvim/lua/plugins/data_analysis.lua b/nvim/.config/nvim/lua/plugins/data_analysis.lua new file mode 100644 index 0000000..5043ac2 --- /dev/null +++ b/nvim/.config/nvim/lua/plugins/data_analysis.lua @@ -0,0 +1,55 @@ +return { + { + "quarto-dev/quarto-nvim", + dependencies = { + "jmbuhr/otter.nvim", + "neovim/nvim-lspconfig", + "vim-pandoc/vim-pandoc-syntax", + "hrsh7th/nvim-cmp", + "nvim-treesitter/nvim-treesitter", + }, + config = function() + require("quarto").setup({ + lspFeatures = { + enabled = true, + languages = { "r", "python", "julia" }, + diagnostics = { enabled = true, triggers = { "BufWrite" } }, + completion = { enabled = true }, + }, + }) + end, + ft = "quarto", + }, + + { + "lkhphuc/jupyter-kernel.nvim", + config = true, + cmd = "JupyterAttach", + build = ":UpdateRemotePlugins", + keys = { + { + "ck", + "JupyterInspect", + desc = "Inspect object in kernel", + }, + }, + }, + + -- REPL work + { + "WhiteBlackGoose/magma-nvim-goose", + build = ":UpdateRemotePlugins", + config = function() + vim.g.magma_image_provider = "kitty" + vim.g.magma_automatically_open_output = false + end, + cmd = { + "MagmaInit", + "MagmaEvaluateOperator", + "MagmaEvaluateLine", + "MagmaEvaluateVisual", + "MagmaRestart", + }, + ft = { "quarto", "python" }, + }, +} diff --git a/nvim/.config/nvim/lua/plugins/editing.lua b/nvim/.config/nvim/lua/plugins/editing.lua new file mode 100644 index 0000000..0a02199 --- /dev/null +++ b/nvim/.config/nvim/lua/plugins/editing.lua @@ -0,0 +1,52 @@ +return { + -- adds exchange operator with cx. common use: cxiw . on 2 words to switch + { + "tommcdo/vim-exchange", + event = "VeryLazy", + }, + -- Align tables and other alignable things + { + "junegunn/vim-easy-align", + event = "VeryLazy", + }, + -- surround things with other things using ys/cs/ds + { "kylechui/nvim-surround", version = "*", config = true, event = "VeryLazy" }, + + -- extend the ^a / ^x possibilities to dates, hex, alphabets, markdown headers + { + "monaqa/dial.nvim", + config = function() + local augend = require("dial.augend") + require("dial.config").augends:register_group({ + -- default augends used when no group name is specified + default = { + augend.integer.alias.decimal, + augend.integer.alias.hex, + augend.date.alias["%Y/%m/%d"], + augend.date.alias["%Y-%m-%d"], + augend.date.alias["%m/%d"], + augend.date.alias["%H:%M:%S"], + augend.date.alias["%H:%M"], + augend.constant.alias.de_weekday_full, + augend.constant.alias.de_weekday, + augend.constant.alias.bool, + augend.semver.alias.semver, + augend.constant.alias.Alpha, + augend.constant.alias.alpha, + augend.hexcolor.new({ case = "lower" }), + augend.constant.new({ + elements = { "and", "or" }, + word = true, -- if false, "sand" is incremented into "sor", "doctor" into "doctand", etc. + cyclic = true, -- "or" is incremented into "and". + }), + augend.constant.new({ + elements = { "&&", "||" }, + word = false, + cyclic = true, + }), + }, + }) + end, + event = "VeryLazy", + }, +} diff --git a/nvim/.config/nvim/lua/plugins/filebrowsers.lua b/nvim/.config/nvim/lua/plugins/filebrowsers.lua new file mode 100644 index 0000000..476f17d --- /dev/null +++ b/nvim/.config/nvim/lua/plugins/filebrowsers.lua @@ -0,0 +1,18 @@ +return { + { + "vifm/vifm.vim", + config = function() + vim.g.loaded_netrw = 1 + vim.g.loaded_netrwPlugin = 1 + vim.g.vifm_replace_netrw = 1 + vim.g.vifm_exec_args = '-c "set vifminfo=" -c "set statusline=" -c "only"' + end, + cmd = "Vifm", + }, -- integrate file manager + { + "nvim-tree/nvim-tree.lua", -- integrate file tree + config = true, + dependencies = { "nvim-tree/nvim-web-devicons", config = true }, + cmd = "NvimTreeToggle", + }, +} diff --git a/nvim/.config/nvim/lua/plugins/git.lua b/nvim/.config/nvim/lua/plugins/git.lua new file mode 100644 index 0000000..165e5d2 --- /dev/null +++ b/nvim/.config/nvim/lua/plugins/git.lua @@ -0,0 +1,64 @@ +return { + { + "lewis6991/gitsigns.nvim", -- show vcs changes on left-hand gutter + event = "VeryLazy", + config = function() + require("gitsigns").setup({ + numhl = true, + signcolumn = false, + on_attach = function(bufnr) + local gs = package.loaded.gitsigns + + local function map(mode, l, r, opts) + opts = opts or {} + opts.buffer = bufnr + vim.keymap.set(mode, l, r, opts) + end + + -- Navigation + map("n", "]h", function() + if vim.wo.diff then + return "]h" + end + vim.schedule(function() + gs.next_hunk() + end) + return "" + end, { expr = true }) + + map("n", "[h", function() + if vim.wo.diff then + return "[h" + end + vim.schedule(function() + gs.prev_hunk() + end) + return "" + end, { expr = true }) + + -- Actions + require("which-key").register({ ["h"] = { name = "+git" } }) + map({ "n", "v" }, "hs", ":Gitsigns stage_hunk", { desc = "stage hunk" }) + map({ "n", "v" }, "hr", ":Gitsigns reset_hunk", { desc = "reset hunk" }) + map("n", "hS", gs.stage_buffer, { desc = "stage buffer" }) + map("n", "hu", gs.undo_stage_hunk, { desc = "undo stage hunk" }) + map("n", "hR", gs.reset_buffer, { desc = "reset buffer" }) + map("n", "hp", gs.preview_hunk, { desc = "preview hunk" }) + map("n", "hb", function() + gs.blame_line({ full = true }) + end, { desc = "blame line" }) + map("n", "hB", gs.toggle_current_line_blame, { desc = "toggle blame" }) + map("n", "hd", gs.diffthis, { desc = "diffthis" }) + map("n", "hD", function() + gs.diffthis("~") + end, { desc = "diffbase" }) + map("n", "ht", gs.toggle_deleted, { desc = "toggle deleted" }) + + -- Text object + map({ "o", "x" }, "ih", ":Gitsigns select_hunk") + map({ "o", "x" }, "ah", ":Gitsigns select_hunk") + end, + }) + end, + }, +} diff --git a/nvim/.config/nvim/lua/plugins/ide.lua b/nvim/.config/nvim/lua/plugins/ide.lua new file mode 100644 index 0000000..49deea4 --- /dev/null +++ b/nvim/.config/nvim/lua/plugins/ide.lua @@ -0,0 +1,73 @@ +return { + -- vista-like outline view for code + { "simrat39/symbols-outline.nvim", config = true, cmd = "SymbolsOutline" }, + -- show a signature whenever editing a function or similar + { "ray-x/lsp_signature.nvim", config = true, event = "VeryLazy" }, + { + "junnplus/lsp-setup.nvim", + dependencies = { + "neovim/nvim-lspconfig", + { + "williamboman/mason.nvim", + cmd = { + "Mason", + "MasonInstall", + "MasonUninstall", + "MasonUninstallAll", + "MasonLog", + "MasonUpdate", + }, + build = ":MasonUpdate", + }, + { + "williamboman/mason-lspconfig.nvim", + cmd = { "LspInstall", "LspUninstall" }, + }, + { + "jose-elias-alvarez/null-ls.nvim", + dependencies = { + "nvim-lua/plenary.nvim", + "jay-babu/mason-null-ls.nvim", + }, + event = "VeryLazy", + }, + }, + event = "BufReadPost", + config = function() + require("plugins.config.lsp") + end, + }, + { + "hrsh7th/nvim-cmp", + branch = "main", + dependencies = { + "andersevenrud/cmp-tmux", + "cbarrete/completion-vcard", + "f3fora/cmp-spell", + "hrsh7th/cmp-nvim-lsp", + "hrsh7th/cmp-path", + "hrsh7th/cmp-buffer", + "hrsh7th/cmp-calc", + "hrsh7th/cmp-cmdline", + "hrsh7th/cmp-nvim-lua", + "dmitmel/cmp-digraphs", + "jc-doyle/cmp-pandoc-references", + "kdheepak/cmp-latex-symbols", + "lukas-reineke/cmp-rg", + "crispgm/cmp-beancount", + "ray-x/cmp-treesitter", + "saadparwaiz1/cmp_luasnip", + { + "L3MON4D3/LuaSnip", + dependencies = { "rafamadriz/friendly-snippets" }, + }, + }, + config = function() + require("plugins.config.cmp") + end, + event = { "InsertEnter", "CmdlineEnter", "VeryLazy" }, + }, + -- loading animations for some LSP + { "j-hui/fidget.nvim", config = true, tag = "legacy", event = "VeryLazy" }, + -- a pretend-lsp for formatters and linters +} diff --git a/nvim/.config/nvim/lua/plugins/languages.lua b/nvim/.config/nvim/lua/plugins/languages.lua new file mode 100644 index 0000000..073ef4d --- /dev/null +++ b/nvim/.config/nvim/lua/plugins/languages.lua @@ -0,0 +1,5 @@ +return { + { "edKotinsky/Arduino.nvim", ft = "arduino", config = true }, -- statusline + { "euclidianAce/BetterLua.vim", ft = "lua" }, -- better syntax highlighting for lua + { "aliou/bats.vim", ft = { "bash", "sh", "zsh", "bats" } }, -- enable syntax for bats shell-code testing library +} diff --git a/nvim/.config/nvim/lua/plugins/prose.lua b/nvim/.config/nvim/lua/plugins/prose.lua new file mode 100644 index 0000000..cc7dc2d --- /dev/null +++ b/nvim/.config/nvim/lua/plugins/prose.lua @@ -0,0 +1,56 @@ +local writing_ft = { "quarto", "pandoc", "markdown", "text", "tex" } + +return { + -- UI improvements + -- provide distraction free writing + { "folke/zen-mode.nvim", config = true, event = "VeryLazy" }, + -- provide even distraction free-er writing (lowlight paragraphs) + { "folke/twilight.nvim", event = "VeryLazy" }, + -- enable 'speed-reading' mode (bionic reading) + { + "JellyApple102/easyread.nvim", + config = true, + ft = writing_ft, + cmd = "EasyreadToggle", + }, + { + "andrewferrier/wrapping.nvim", + config = function() + require("wrapping").setup({ + create_keymappings = false, + notify_on_switch = false, + }) + end, + }, + -- generate an auto-updating html preview for md files + { + "iamcco/markdown-preview.nvim", + build = function() + vim.fn["mkdp#util#install"]() + end, + ft = writing_ft, + }, + + -- bring zettelkasten commands + { + "mickael-menu/zk-nvim", + config = function() + require("zk").setup({ picker = "telescope" }) + end, + }, + -- simple static markdown linking and link following using zettel IDs + { "marty-oehme/zettelkasten.nvim", ft = writing_ft, event = "VeryLazy" }, + + -- syntax highlighting for markdown criticmarkup (comments, additions, ...) + { "vim-pandoc/vim-criticmarkup", ft = writing_ft }, + -- inline display of latex formulas + -- TODO always demands latex treesitter to be installed even if it is + -- TODO always turns softwrapped lines off on exiting insert mode + --{ + --"jbyuki/nabla.nvim", + --ft = writing_ft, + --config = function() + --require("nabla").enable_virt({ autogen = true, silent = true }) + --end, + --}, +} diff --git a/nvim/.config/nvim/lua/plugins/telescope.lua b/nvim/.config/nvim/lua/plugins/telescope.lua new file mode 100644 index 0000000..722df29 --- /dev/null +++ b/nvim/.config/nvim/lua/plugins/telescope.lua @@ -0,0 +1,77 @@ +return { + -- fuzzy matching + { + "nvim-telescope/telescope.nvim", + dependencies = { + "nvim-lua/popup.nvim", + "nvim-lua/plenary.nvim", + { "nvim-telescope/telescope-fzf-native.nvim", build = "make" }, + }, + event = "VeryLazy", + cmd = "Telescope", + config = function() + -- Setup up telescope fuzzy finding settings + -- + -- Makes use of optionally installed external programs to work fully: + -- rg (ripgrep) for in-text searches + -- fd for quicker directory structure searches + -- lsp for a variety of lsp queries + require("telescope").setup({ + defaults = { + vimgrep_arguments = { + "rg", + "--ignore-vcs", + "--hidden", + "--color=never", + "--no-heading", + "--with-filename", + "--line-number", + "--column", + "--smart-case", + }, + generic_sorter = require("mini.fuzzy").get_telescope_sorter, + -- Appearance + prompt_prefix = " ", + selection_caret = "󰳟 ", + color_devicons = true, + }, + pickers = { + buffers = { theme = "ivy" }, + oldfiles = { theme = "ivy" }, + find_files = { + theme = "dropdown", + -- nice minimal picker design + borderchars = { + { "─", "│", "─", "│", "┌", "┐", "┘", "└" }, + prompt = { "─", "│", " ", "│", "┌", "┐", "│", "│" }, + results = { + "─", + "│", + "─", + "│", + "├", + "┤", + "┘", + "└", + }, + preview = { + "─", + "│", + "─", + "│", + "┌", + "┐", + "┘", + "└", + }, + }, + width = 0.8, + previewer = false, + prompt_title = false, + }, + }, + }) + require("telescope").load_extension("fzf") + end, + }, +} diff --git a/nvim/.config/nvim/lua/plugins/treesitter.lua b/nvim/.config/nvim/lua/plugins/treesitter.lua new file mode 100644 index 0000000..1951c5b --- /dev/null +++ b/nvim/.config/nvim/lua/plugins/treesitter.lua @@ -0,0 +1,73 @@ +return { + { + "nvim-treesitter/nvim-treesitter", + build = ":TSUpdate", + config = function() + local rainbow = require("ts-rainbow") + require("nvim-treesitter.configs").setup({ + -- one of "all", "maintained" (parsers with maintainers), or a list of languages + ensure_installed = "all", + highlight = { + enable = true, + disable = function(_, bufnr) + return vim.api.nvim_buf_line_count(bufnr) > 7000 + end, + }, + incremental_selection = { enable = true }, + textobjects = { enable = true }, + indent = { enable = true }, + autotag = { enable = true }, + + -- enable rainbow brackets, needs p00f/nvim-ts-rainbow + rainbow = { + enable = true, + strategy = { rainbow.strategy.global }, + }, + + -- for improved commentstrings, needs corresponding plugin + context_commentstring = { + enable = true, + enable_autocmd = false, -- since we run it as a hook from the mini.comment plugin + }, + -- allows using . and ; to target treesitter branches + textsubjects = { + enable = true, + keymaps = { + ["."] = "textsubjects-smart", + [";"] = "textsubjects-container-outer", + }, + }, + }) + end, + event = "BufReadPost", + cmd = { + "TSBufDisable", + "TSBufEnable", + "TSBufToggle", + "TSDisable", + "TSEnable", + "TSToggle", + "TSInstall", + "TSInstallInfo", + "TSInstallSync", + "TSModuleInfo", + "TSUninstall", + "TSUpdate", + "TSUpdateSync", + }, + + -- rainbow brackets using treesitter + -- show current cursor context at top of buffer + -- improves commenting plugin above by using ts + dependencies = { + "https://gitlab.com/HiPhish/nvim-ts-rainbow2.git", + { "romgrk/nvim-treesitter-context", config = true }, + "JoosepAlviste/nvim-ts-context-commentstring", + { + "RRethy/nvim-treesitter-textsubjects", + }, + "windwp/nvim-ts-autotag", + }, + }, + { "nvim-treesitter/playground", cmd = "TSPlaygroundToggle" }, -- interactively view and query the treesitter tree +} diff --git a/nvim/.config/nvim/lua/plugins/ui.lua b/nvim/.config/nvim/lua/plugins/ui.lua new file mode 100644 index 0000000..1b156b0 --- /dev/null +++ b/nvim/.config/nvim/lua/plugins/ui.lua @@ -0,0 +1,53 @@ +return { + -- statusline + { + "nvim-lualine/lualine.nvim", + requires = { "nvim-tree/nvim-web-devicons", config = true }, + config = function() + require("plugins.config.lualine") + end, + event = "VeryLazy", + }, + -- create a pretty pop-up notification + { + "rcarriga/nvim-notify", + config = function() + vim.notify = require("notify") + end, + event = "VeryLazy", + }, + -- make all vim.ui interfaces prettyy + { "stevearc/dressing.nvim", config = true, event = "VeryLazy" }, + + -- numbers to absolute for all buffers but the current which is relative + { "jeffkreeftmeijer/vim-numbertoggle", event = "VeryLazy" }, + -- auto-hiding colorcolumn + { + "m4xshen/smartcolumn.nvim", + event = "VeryLazy", + opts = { + colorcolumn = { "100" }, + scope = "window", + disabled_filetypes = { + "help", + "text", + "markdown", + "NvimTree", + "lazy", + "mason", + "help", + "quarto", + }, + }, + }, + -- display pretty colors when they are mentioned in buffer + { + "NvChad/nvim-colorizer.lua", -- color hex, named colors in the correct preview scheme + config = function() + require("colorizer").setup({ + user_default_options = { mode = "virtualtext" }, + }) + end, + event = "VeryLazy", + }, +} diff --git a/nvim/.config/nvim/lua/util/init.lua b/nvim/.config/nvim/lua/util/init.lua new file mode 100644 index 0000000..89b2668 --- /dev/null +++ b/nvim/.config/nvim/lua/util/init.lua @@ -0,0 +1,12 @@ +local T = {} + +-- from astronvim util function +--- Check if a plugin is defined in lazy. Useful with lazy loading when a plugin is not necessarily loaded yet +---@param plugin string The plugin to search for +---@return boolean available # Whether the plugin is available +function T.is_available(plugin) + local lazy_config_avail, lazy_config = pcall(require, "lazy.core.config") + return lazy_config_avail and lazy_config.plugins[plugin] ~= nil +end + +return T diff --git a/nvim/.config/nvim/plugin/personal/makescratch.vim b/nvim/.config/nvim/plugin/personal/makescratch.vim deleted file mode 100644 index 600b406..0000000 --- a/nvim/.config/nvim/plugin/personal/makescratch.vim +++ /dev/null @@ -1,15 +0,0 @@ -" --[[ scratchpad.lua -" -" creates a 'scratch' buffer which is ephemeral -- -" it will disappear when vim closes, does not save to anything and does not -" appear in the buffer list. Useful for e.g. jotting down quick notes and thoughts. -" -" If called with bang, will replace the current buffer with the scratch -" window, otherwise opens a new split. -" -" The buffer, by default is set to the pandoc filetype. -" This can be changed by setting the `g:scratchpad_ft` variable or the `b:scratchpad_ft` -" variable to the intended filetype. -" ]]-- - -command! -nargs=? -bang ScratchPad :lua require("personal.scratchpad").create("","") diff --git a/nvim/.config/nvim/plugin/personal/searchnotes.vim b/nvim/.config/nvim/plugin/personal/searchnotes.vim deleted file mode 100644 index 030bc0f..0000000 --- a/nvim/.config/nvim/plugin/personal/searchnotes.vim +++ /dev/null @@ -1,8 +0,0 @@ -function! SearchNotes() - let l:curpath=getcwd() - :execute(":cd " . g:wiki_root) - let l:texttofind=input("Search in Notes: ") - :execute(":CtrlSF " . l:texttofind) - :CtrlSFFocus - :execute(":cd " . l:curpath) -endfunction diff --git a/nvim/.config/nvim/plugin/thesaurus_query.vim b/nvim/.config/nvim/plugin/thesaurus_query.vim deleted file mode 100644 index 9dfa309..0000000 --- a/nvim/.config/nvim/plugin/thesaurus_query.vim +++ /dev/null @@ -1,18 +0,0 @@ -" remove default keymappings -let g:tq_map_keys=0 - -" set custom mthesaur file if we have it -if exists('$XDG_DATA_HOME') - let g:tq_mthesaur_file='$XDG_DATA_HOME' . '/nvim/thesaurus/mthesaur.txt' -else - let g:tq_mthesaur_file=expand('~/.local/share/nvim/thesaurus/mthesaur.txt') -endif - -" download if we don't -if !filereadable(glob(g:tq_mthesaur_file)) - echom 'No thesaurus file found, attempting to download in background...' - execute '!curl -fLo ' . expand(g:tq_mthesaur_file) . ' --create-dirs - \ http://www.gutenberg.org/files/3202/files/mthesaur.txt' -endif - -let g:tq_language=['en', 'de'] diff --git a/nvim/.config/nvim/plugin/vifm.vim b/nvim/.config/nvim/plugin/vifm.vim deleted file mode 100644 index 7ab5941..0000000 --- a/nvim/.config/nvim/plugin/vifm.vim +++ /dev/null @@ -1,4 +0,0 @@ -let g:loaded_netrw = 1 -let g:loaded_netrwPlugin = 1 -let g:vifm_replace_netrw = 1 -let g:vifm_exec_args = '-c "set vifminfo=''''" -c "set statusline=''''" -c "only"' diff --git a/writing/.config/pubs/pubsrc b/writing/.config/pubs/pubsrc new file mode 100644 index 0000000..018dddd --- /dev/null +++ b/writing/.config/pubs/pubsrc @@ -0,0 +1,166 @@ + +[main] + +# Where the pubs repository files (bibtex, metadata, notes) are located +pubsdir = ~/documents/library + +# Where the documents files are located (default: $(pubsdir)/doc/) +docsdir = ~/documents/library/doc + +# Specify if a document should be copied or moved in the docdir, or only +# linked when adding a publication. +doc_add = copy + +# the command to use when opening document files +open_cmd = xdg-open + +# which editor to use when editing bibtex files. +# if using a graphical editor, use the --wait or --block option, i.e.: +# "atom --wait" +# "kate --block" +# If set to an empty string (default) pubs uses the value of the environment +# variable $EDITOR. +edit_cmd = "" + +# Which default extension to use when creating a note file. +note_extension = md + +# How many authors to display when displaying a citation. If there are more +# authors, only the first author is diplayed followed by 'et al.'. +max_authors = 3 + +# If true debug mode is on which means exceptions are not catched and +# the full python stack is printed. +debug = False + +# If true the citekey is normalized using the 'citekey_format' on adding new publications. +normalize_citekey = False + +# String specifying how to format the citekey. All strings of +# the form '{substitution:modifier}' and '{substitution}' will +# be substituted with their appropriate values. The following +# substitutions are used: +# author_last_name: last name of the first author +# year: year of publication +# short_title: first word of the title (excluding words such as "the", "an", ...) +# modifiers: +# l: converts the text to lowercase +# u: converts the text to uppercase +# examples: +# {author_last_name:l}{year} generates 'yang2020' +# {author_last_name}{year}{short_title} generates 'Yang2020Towards' +# {author_last_name:l}{year}{short_title:l} generates 'yang2020towards' +# {author_last_name:u}{year} generates 'YANG2020' +# +citekey_format = {author_last_name}{year} + +# which bibliographic fields to exclude from bibtex files. By default, none. +# Please note that excluding critical fields such as `title` or `author` +# will break many commands of pubs. +exclude_bibtex_fields = , + +[formating] + +# Enable bold formatting, if the terminal supports it. +bold = True + +# Enable italics, if the terminal supports it. +italics = True + +# Enable colors, if the terminal supports it. +color = True + + +[theme] + +# Here you can define the color theme used by pubs, if enabled in the +# 'formating' section. Predefined theme are available at: +# https://github.com/pubs/pubs/blob/master/extra/themes.md + +# Available colors are: 'black', 'red', 'green', 'yellow', 'blue', 'purple', +# 'cyan', and 'grey'. Bold colors are available by prefixing 'b' in front of +# the color name ('bblack', 'bred', etc.), italic colors by prefixing 'i', +# and bold italic by prefixing 'bi'. Finally, 'bold', 'italic' and +# 'bolditalic' can be used to apply formatting without changing the color. +# For no color, use an empty string '' + +# messages +ok = green +warning = yellow +error = red + +# ui elements +filepath = bold +citekey = purple +tag = cyan + +# bibliographic fields +author = bold +title = "" +publisher = "" +year = bold +volume = bold +pages = "" + + +[plugins] +# Comma-separated list of the plugins to load. +# Currently pubs comes with built-in plugins alias and git. +active = alias,git + +[[alias]] +# new subcommands can be defined, e.g.: +# print = open --with lp +# evince = open --with evince + +# shell commands can also be defined, by prefixing them with a bang `!`, e.g: +# count = !pubs list -k | wc -l + +# aliases can also be defined with descriptions using the following configobj +# subsectioning. NOTE: any aliases defined this way should come after all other +# aliases, otherwise simple aliases will be ignored. +# [[[count]]] +# command = !pubs list -k | wc -l +# description = lists number of pubs in repo +# new subcommands can be defined, e.g.: +# print = open --with lp +# evince = open --with evince + +# shell commands can also be defined, by prefixing them with a bang `!`, e.g: +# count = !pubs list -k | wc -l + +# aliases can also be defined with descriptions using the following configobj +# subsectioning. NOTE: any aliases defined this way should come after all other +# aliases, otherwise simple aliases will be ignored. +# [[[count]]] +# command = !pubs list -k | wc -l +# description = lists number of pubs in repo + +# To use commas in the description, wrap them in a "" string. For example: +# description = "lists number of pubs in repo, greets the user afterward" + +[[git]] +# The git plugin will commit changes to the repository in a git repository +# created at the root of the pubs directory. All detected changes will be +# commited every time a change is made by a pubs command. +# The plugin also propose the `pubs git` subcommand, to directly send git +# commands to the pubs repository. Therefore, `pubs git status` is equivalent +# to `git -C status`, with the `-C` flag instructing +# to invoke git as if the current directory was . Note that a +# limitation of the subcommand is that you cannot use git commands with the +# `-c` option (pubs will interpret it first.) + +# if False, will display git output when automatic commit are made. +# Invocation of `pubs git` will always have output displayed. +quiet = True +# if True, git will not automatically commit changes +manual = False +# if True, color will be conserved from git output (this add `-c color:always` +# to the git invocation). +force_color = True + + +[internal] +# The version of this configuration file. Do not edit. +version = 0.9.0 + diff --git a/writing/.config/sh/alias.d/pubs.sh b/writing/.config/sh/alias.d/pubs.sh new file mode 100644 index 0000000..bb06ec3 --- /dev/null +++ b/writing/.config/sh/alias.d/pubs.sh @@ -0,0 +1,8 @@ +#!/usr/bin/env bash + +pubs() { + command pubs --config "$XDG_CONFIG_HOME/pubs/pubsrc" "${@}" + if [ -f "$BIBFILE" ]; then + command pubs export > "$BIBFILE" + fi +} From b9de8b39146f0ce13179a3ee7b944fa858826ff1 Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Sat, 17 Jun 2023 21:58:04 +0200 Subject: [PATCH 3/4] nvim: Add undotree plugin Lua implementation of the undo tree plugin, mapped to be reachable with su (for show undo). --- nvim/.config/nvim/lazy-lock.json | 1 + nvim/.config/nvim/lua/core/mappings.lua | 7 +++++++ nvim/.config/nvim/lua/plugins/ui.lua | 7 +++++++ 3 files changed, 15 insertions(+) diff --git a/nvim/.config/nvim/lazy-lock.json b/nvim/.config/nvim/lazy-lock.json index bf2bda1..826f508 100644 --- a/nvim/.config/nvim/lazy-lock.json +++ b/nvim/.config/nvim/lazy-lock.json @@ -66,6 +66,7 @@ "telescope-fzf-native.nvim": { "branch": "main", "commit": "9bc8237565ded606e6c366a71c64c0af25cd7a50" }, "telescope.nvim": { "branch": "master", "commit": "776b509f80dd49d8205b9b0d94485568236d1192" }, "twilight.nvim": { "branch": "main", "commit": "8bb7fa7b918baab1ca81b977102ddb54afa63512" }, + "undotree": { "branch": "main", "commit": "2685ce282702ab0b79c65916f352db2265b245dd" }, "vifm.vim": { "branch": "master", "commit": "a8130c37d144b51d84bee19f0532abcd3583383f" }, "vim-criticmarkup": { "branch": "master", "commit": "d15dc134eb177a170c79f6377f81eb02a9d20b02" }, "vim-easy-align": { "branch": "master", "commit": "0db4ea6132110631ec678a99a82aa49a0686ae65" }, diff --git a/nvim/.config/nvim/lua/core/mappings.lua b/nvim/.config/nvim/lua/core/mappings.lua index 40dd082..16e52da 100644 --- a/nvim/.config/nvim/lua/core/mappings.lua +++ b/nvim/.config/nvim/lua/core/mappings.lua @@ -284,3 +284,10 @@ map( 'lua require("colorizer").attach_to_buffer(0, {mode = "background"} )', { silent = true, desc = "colorize background" } ) + +-- PLUGIN: undotree +if is_available("undotree") then + map("n", "su", function() + require("undotree").toggle() + end, { silent = true, desc = "toggle undotree" }) +end diff --git a/nvim/.config/nvim/lua/plugins/ui.lua b/nvim/.config/nvim/lua/plugins/ui.lua index 1b156b0..bb0e19e 100644 --- a/nvim/.config/nvim/lua/plugins/ui.lua +++ b/nvim/.config/nvim/lua/plugins/ui.lua @@ -50,4 +50,11 @@ return { end, event = "VeryLazy", }, + { + "jiaoshijie/undotree", + dependencies = { + "nvim-lua/plenary.nvim", + }, + config = true, event = "VeryLazy", + }, } From ca3d4ef97be73b1b53af1647b04387a3c02a8566 Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Sat, 17 Jun 2023 22:02:22 +0200 Subject: [PATCH 4/4] nvim: Make utility terminals dockable and hidable The utility terminals (lazygit and python repl for now) can now be hidden even from terminal insert mode (i.e. when interacting with them) with . They can be invoked through their usual chords (tg and tp respectively) again and will pick right up where you left off. Insert mode in terminals can also be left slightly easier should it be needed: Instead of the chord you can use j\. Lastly, the utility terminals can be started in a vertically docked mode instead of floating. This is done by adding a bang to their commands, `Lazygit!` and `Pythonterm!`, or using capital versions of their mappings: tG and tP. --- nvim/.config/nvim/lua/core/mappings.lua | 7 +- .../nvim/lua/plugins/config/toggleterm.lua | 68 +++++++++++++------ 2 files changed, 55 insertions(+), 20 deletions(-) diff --git a/nvim/.config/nvim/lua/core/mappings.lua b/nvim/.config/nvim/lua/core/mappings.lua index 16e52da..10ba70b 100644 --- a/nvim/.config/nvim/lua/core/mappings.lua +++ b/nvim/.config/nvim/lua/core/mappings.lua @@ -96,6 +96,9 @@ if vim.g.maplocalleader == "," then vim.keymap.del("", ",,", { silent = true }) end +-- get out of terminal mode a little easier by double tapping backslash +map("t", "\\\\", [[]], { desc = "exit terminal mode" }) + -- remove search highlights by pressing space+/ map("n", "/", ":noh", { desc = "remove highlights" }) @@ -252,10 +255,12 @@ map("v", "nf", ":ZkMatch", { desc = "find note from selection" -- PLUGIN: toggleterm.nvim -- create a lazygit or python window, set up in toggleterm settings -- TODO create ability to go into python environment when in poetry venv and/or euporie/jupyter notebook -if require("util").is_available("nvim-toggleterm.lua") then +if is_available("nvim-toggleterm.lua") then map("n", "G", ":Lazygit") map("n", "tg", ":Lazygit") + map("n", "tG", ":Lazygit!") map("n", "tp", ":Pythonterm") + map("n", "tP", ":Pythonterm!") end prefix({ ["s"] = { name = "+set" } }) diff --git a/nvim/.config/nvim/lua/plugins/config/toggleterm.lua b/nvim/.config/nvim/lua/plugins/config/toggleterm.lua index b60b436..6bbd56d 100644 --- a/nvim/.config/nvim/lua/plugins/config/toggleterm.lua +++ b/nvim/.config/nvim/lua/plugins/config/toggleterm.lua @@ -1,6 +1,7 @@ require("toggleterm").setup({ open_mapping = [[=]], insert_mappings = false, -- don't map the key in insert mode + terminal_mappings = false, }) local Terminal = require("toggleterm.terminal").Terminal @@ -15,15 +16,10 @@ if require("util").is_available("mini.nvim") then }) end --- create a lazygit window with the lazygit command -local lazygit = Terminal:new({ - cmd = "lazygit", - hidden = true, - direction = "float", - float_opts = { border = "curved" }, -}) -function _Lazygit_toggle() - lazygit:toggle() +local function custom_term_set_toggle_key(term) + vim.keymap.set("t", "", function() + term:toggle() + end, { silent = true, buffer = true }) end -- create python window @@ -41,15 +37,49 @@ local function get_python_cmd() return "python" end end -local pythonterm = Terminal:new({ - cmd = get_python_cmd(), - hidden = true, - direction = "float", - float_opts = { border = "curved" }, -}) -function _Pythonterm_toggle() - pythonterm:toggle() +local terms = { + lazygit = Terminal:new({ + cmd = "lazygit", + hidden = true, + direction = "float", + float_opts = { border = "curved" }, + on_open = custom_term_set_toggle_key, + }), + python = Terminal:new({ + cmd = get_python_cmd(), + hidden = true, + direction = "float", + float_opts = { border = "curved" }, + on_open = custom_term_set_toggle_key, + }), +} +-- create a lazygit window with the lazygit command +local function toggle_custom_term(term, bang, vertsize) + vertsize = vertsize or vim.o.columns * 0.4 + if not bang then + term.direction = "float" + term:toggle() + else + term.direction = "vertical" + term:resize(vertsize) + term:toggle() + end end -vim.cmd([[command! Lazygit :lua _Lazygit_toggle()]]) -vim.cmd([[command! Pythonterm :lua _Pythonterm_toggle()]]) +local function _Pythonterm_toggle(opts) + toggle_custom_term(terms.python, opts.bang) +end +local function _Lazygit_toggle(opts) + toggle_custom_term(terms.lazygit, opts.bang, vim.o.columns * 0.6) +end + +vim.api.nvim_create_user_command( + "Lazygit", + _Lazygit_toggle, + { desc = "Toggle floating Lazygit terminal", bang = true } +) +vim.api.nvim_create_user_command( + "Pythonterm", + _Pythonterm_toggle, + { desc = "Toggle floating Python terminal", bang = true } +)