From c306e302192545521544543e83147275c22b10aa Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Wed, 8 Feb 2023 18:53:18 +0100 Subject: [PATCH 1/8] writing: Add papis configuration --- writing/.config/papis/config | 35 ++++++++++++++++++++++ writing/.config/papis/headerformat | 3 ++ writing/.config/papis/scripts/papis-reload | 16 ++++++++++ writing/.config/papis/scripts/papis-show | 6 ++++ 4 files changed, 60 insertions(+) create mode 100644 writing/.config/papis/config create mode 100644 writing/.config/papis/headerformat create mode 100755 writing/.config/papis/scripts/papis-reload create mode 100755 writing/.config/papis/scripts/papis-show diff --git a/writing/.config/papis/config b/writing/.config/papis/config new file mode 100644 index 0000000..9b7bf01 --- /dev/null +++ b/writing/.config/papis/config @@ -0,0 +1,35 @@ +[settings] +#opentool = zathura +#picktool = fzf +default-library = master +file-browser = vifm +ref-format = {doc[author_list][0][surname]}{doc[year]} + +# edit info.yaml as new papers are added +add-edit = True +add-folder-name = {doc[ref]}-{doc[title]} +add-file-name = {doc[author_list][0][family]}{doc[year]} +header-format-file = ~/.config/papis/headerformat +extra-bibtex-keys = ["tags", "readstatus"] + +database-backend = whoosh +whoosh-schema-fields = ["doi", "ref", "author", "year", "title", "publisher", "tags", "readstatus", "date", "isbn", "type", "keyword", "qualityassured"] +# to make whoosh list everything by default +default-query-string = * + +notes-name = notes.qmd +notes-template = {doc[author_list][0][family]}{doc[year]}--{doc[title]} + +mark-opener = zathura -P {mark[value]} + +[tui] +editmore = vi + +[master] +dir = ~/documents/library + +[academia] +dir = ~/documents/library/academia + +[cs] +dir = ~/documents/library/cs diff --git a/writing/.config/papis/headerformat b/writing/.config/papis/headerformat new file mode 100644 index 0000000..fb86095 --- /dev/null +++ b/writing/.config/papis/headerformat @@ -0,0 +1,3 @@ +{doc.html_escape[title]} +{doc.html_escape[author]} +({doc.html_escape[year]}) [{doc.html_escape[tags]}] [{doc.html_escape[readstatus]}] diff --git a/writing/.config/papis/scripts/papis-reload b/writing/.config/papis/scripts/papis-reload new file mode 100755 index 0000000..35a6640 --- /dev/null +++ b/writing/.config/papis/scripts/papis-reload @@ -0,0 +1,16 @@ +#!/usr/bin/env python +# papis-short-help: Manually rebuild cache for all libraries +# +# This tiny script updates all libraries by rebuilding their caches. +# Useful to invoke after manual edits in one of your library folders +# so you don't have to think about which library you changed stuff in +# and just get everything updated. Might take a little time but +# should generally be a quick process (even with 1000s of entries). + +import papis.api + +libs = papis.api.get_libraries() + +for lib in libs: + papis.api.clear_lib_cache(lib) + papis.api.get_all_documents_in_lib() diff --git a/writing/.config/papis/scripts/papis-show b/writing/.config/papis/scripts/papis-show new file mode 100755 index 0000000..7c6779d --- /dev/null +++ b/writing/.config/papis/scripts/papis-show @@ -0,0 +1,6 @@ +#!/usr/bin/env bash +# papis-short-help: Display pretty human-readable document overview +# +# TODO strip {} from bibtex entries to really pretty print + +papis -l "${PAPIS_LIB}" list --format "{doc[author]} ({doc[year]}). {doc[title]}." "$@" From 0a137d14460986f6621e6b6813d34d0cb7ec2f38 Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Wed, 8 Feb 2023 19:36:12 +0100 Subject: [PATCH 2/8] zathura: Show double page for first page --- writing/.config/zathura/zathurarc | 1 + 1 file changed, 1 insertion(+) diff --git a/writing/.config/zathura/zathurarc b/writing/.config/zathura/zathurarc index d9a823a..e97241d 100644 --- a/writing/.config/zathura/zathurarc +++ b/writing/.config/zathura/zathurarc @@ -2,6 +2,7 @@ include colorscheme set recolor "true" set selection-clipboard "clipboard" +set first-page-column 1 map r reload map R rotate From f08fa474d6e1062b7af5ce563b0945d9b3ec4306 Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Thu, 9 Feb 2023 09:39:21 +0100 Subject: [PATCH 3/8] zsh: Remove double call of env scripts On startup zsh would call all zsh env scripts (situated in `zsh/env` or `zsh/env.d/*.zsh`) *and* all sh scripts (in `sh/env` or `sh/env.d/*.sh`). However, by that point, those scripts had already been sourced once - so they just double up startup time. --- terminal/.config/zsh/.zshenv | 9 --------- 1 file changed, 9 deletions(-) diff --git a/terminal/.config/zsh/.zshenv b/terminal/.config/zsh/.zshenv index be77cca..de79e24 100644 --- a/terminal/.config/zsh/.zshenv +++ b/terminal/.config/zsh/.zshenv @@ -1,15 +1,6 @@ #!/usr/bin/env zsh # -# load global sh env vars -[ -f "$XDG_CONFIG_HOME/sh/env" ] && source "$XDG_CONFIG_HOME/sh/env" -if [ -d "$XDG_CONFIG_HOME/sh/env.d" ]; then - for _env in "$XDG_CONFIG_HOME/sh/env.d"/*.sh; do - . "$_env" - done - unset _env -fi - # load zsh specific env vars if [ -d "$XDG_CONFIG_HOME/zsh/env.d" ]; then for _env in "$XDG_CONFIG_HOME/zsh/env.d"/*.zsh; do From cd0d519a28f3c9856eb0bbc1422491e78ca8a1d9 Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Fri, 10 Feb 2023 09:15:56 +0100 Subject: [PATCH 4/8] nvim: Move to lazy.nvim package manager Migrated from packer.nvim to lazy.nvim - it gives really fast loading times, easy lazy loading for any package and a snazzy package manager overview page (invoked through `:Lazy`) which, importantly, all do not rely on a compiled plugin list. In essence it feels like an easier to manage and robust packer replacement (even though packer is a really good manager as well) that is well worth to switch to. Migration was pretty painless as well. One thing I might do in the future is split up the plugin structure itself from a single plugin list (which invokes plugin settings files) to several files containing the plugins and their settings since it might give more structure. --- nvim/.config/nvim/init.lua | 28 +- nvim/.config/nvim/lazy-lock.json | 71 +++++ nvim/.config/nvim/lua/helpers/vimoptions.lua | 230 --------------- nvim/.config/nvim/lua/maps.lua | 22 +- nvim/.config/nvim/lua/plug/_autopair.lua | 33 --- nvim/.config/nvim/lua/plug/_cmp.lua | 2 +- nvim/.config/nvim/lua/plug/_mini.lua | 23 ++ nvim/.config/nvim/lua/plug/_telescope.lua | 6 + nvim/.config/nvim/lua/plugins.lua | 290 +++++++------------ nvim/.config/nvim/lua/settings.lua | 11 +- 10 files changed, 244 insertions(+), 472 deletions(-) create mode 100644 nvim/.config/nvim/lazy-lock.json delete mode 100644 nvim/.config/nvim/lua/helpers/vimoptions.lua delete mode 100644 nvim/.config/nvim/lua/plug/_autopair.lua diff --git a/nvim/.config/nvim/init.lua b/nvim/.config/nvim/init.lua index 1047d06..8a7789d 100644 --- a/nvim/.config/nvim/init.lua +++ b/nvim/.config/nvim/init.lua @@ -2,11 +2,6 @@ -- https://github.com/elianiva/dotfiles/ - with much gratitude local api = vim.api -require('settings') -require('plugins') -require('look') -require('maps') - -- Highlight whatever is being yanked vim.api.nvim_create_autocmd({ "TextYankPost" }, { command = 'silent! lua require"vim.highlight".on_yank{timeout=500}', @@ -36,3 +31,26 @@ vim.api.nvim_create_autocmd({ "VimEnter" }, { desc = "Fix neovim sizing issues if opening same time as alacritty", group = vim.api.nvim_create_augroup('alacritty_fixsize', { clear = true }) }) + +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, + }) +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("lazy").setup("plugins") +require('look') +require('maps') + diff --git a/nvim/.config/nvim/lazy-lock.json b/nvim/.config/nvim/lazy-lock.json new file mode 100644 index 0000000..01180be --- /dev/null +++ b/nvim/.config/nvim/lazy-lock.json @@ -0,0 +1,71 @@ +{ + "BetterLua.vim": { "branch": "master", "commit": "d2d6c115575d09258a794a6f20ac60233eee59d5" }, + "Navigator.nvim": { "branch": "master", "commit": "91d86506ac2a039504d5205d32a1d4bc7aa57072" }, + "bats.vim": { "branch": "master", "commit": "6a5d2ef22b0ede503d867770afd02ebb1f97b709" }, + "cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" }, + "cmp-cmdline": { "branch": "main", "commit": "23c51b2a3c00f6abc4e922dbd7c3b9aca6992063" }, + "cmp-latex-symbols": { "branch": "main", "commit": "165fb66afdbd016eaa1570e41672c4c557b57124" }, + "cmp-nvim-lsp": { "branch": "main", "commit": "0e6b2ed705ddcff9738ec4ea838141654f12eeef" }, + "cmp-nvim-lua": { "branch": "main", "commit": "f3491638d123cfd2c8048aefaf66d246ff250ca6" }, + "cmp-pandoc.nvim": { "branch": "main", "commit": "cb2980263e14fb3c1b776edbd2c7a312b67c65ae" }, + "cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" }, + "cmp-spell": { "branch": "master", "commit": "60584cb75e5e8bba5a0c9e4c3ab0791e0698bffa" }, + "cmp-tmux": { "branch": "main", "commit": "984772716f66d8ee88535a6bf3f94c4b4e1301f5" }, + "cmp-treesitter": { "branch": "master", "commit": "b40178b780d547bcf131c684bc5fd41af17d05f2" }, + "cmp-vsnip": { "branch": "main", "commit": "989a8a73c44e926199bfd05fa7a516d51f2d2752" }, + "completion-vcard": { "branch": "master", "commit": "2220fd517a985ececed1adcf0e5be8f2815564c7" }, + "dial.nvim": { "branch": "master", "commit": "5020da900cc5dfd7067f181ee2ebd872ca7c84e8" }, + "formatter.nvim": { "branch": "master", "commit": "8a4c961330cc4688087f23d18fa7d2f1af9a4902" }, + "friendly-snippets": { "branch": "main", "commit": "a6f7a1609addb4e57daa6bedc300f77f8d225ab7" }, + "gitsigns.nvim": { "branch": "main", "commit": "ec4742a7eebf68bec663041d359b95637242b5c3" }, + "guihua.lua": { "branch": "master", "commit": "d3f6d01639b52e6a83ea98dd6ca244c9aa98b79b" }, + "lazy.nvim": { "branch": "main", "commit": "273081443471cbc52c327bcb99614c32f247998d" }, + "lightspeed.nvim": { "branch": "main", "commit": "299eefa6a9e2d881f1194587c573dad619fdb96f" }, + "lsp_signature.nvim": { "branch": "master", "commit": "6f6252f63b0baf0f2224c4caea33819a27f3f550" }, + "lspkind-nvim": { "branch": "master", "commit": "c68b3a003483cf382428a43035079f78474cd11e" }, + "lualine.nvim": { "branch": "master", "commit": "0050b308552e45f7128f399886c86afefc3eb988" }, + "magma-nvim-goose": { "branch": "main", "commit": "94370733757d550594fe4a1d65643949d7485989" }, + "markdown-preview.nvim": { "branch": "master", "commit": "02cc3874738bc0f86e4b91f09b8a0ac88aef8e96" }, + "mini.nvim": { "branch": "main", "commit": "dc0ccf1b0499d649a6177d2a406babcfe73b97de" }, + "nabla.nvim": { "branch": "master", "commit": "ddbfc6e244e79db9280c535ee85c81388c5d1b46" }, + "navigator.lua": { "branch": "master", "commit": "66d84151e94052f710b1dfb0d1fce2faaca6dced" }, + "neorg": { "branch": "main", "commit": "36cc15300c0dfc19d483b0a4176cb89e94f4730a" }, + "notational-fzf-vim": { "branch": "master", "commit": "75c2c31e7cd77397018c5777804666d648557537" }, + "nui.nvim": { "branch": "main", "commit": "d147222a1300901656f3ebd5b95f91732785a329" }, + "nvim-base16.lua": { "branch": "master", "commit": "b336f40462b3ca1ad16a17c195b83731a2942d9a" }, + "nvim-cartographer": { "branch": "master", "commit": "fbe977c9529019376db9426cccf04bfdadeafc69" }, + "nvim-cmp": { "branch": "main", "commit": "cfafe0a1ca8933f7b7968a287d39904156f2c57d" }, + "nvim-colorizer.lua": { "branch": "master", "commit": "36c610a9717cc9ec426a07c8e6bf3b3abcb139d6" }, + "nvim-lspconfig": { "branch": "master", "commit": "aeb76066212b09c7c01a3abb42fe82f0130ef402" }, + "nvim-surround": { "branch": "main", "commit": "a06dea11e7fdcf338776fa51fa5277163ffb048d" }, + "nvim-toggleterm.lua": { "branch": "main", "commit": "19aad0f41f47affbba1274f05e3c067e6d718e1e" }, + "nvim-treesitter": { "branch": "master", "commit": "f6df07be122de665fb363476cc3680c90f5bdf05" }, + "nvim-treesitter-context": { "branch": "master", "commit": "cacee4828152dd3a83736169ae61bbcd29a3d213" }, + "nvim-treesitter-textsubjects": { "branch": "master", "commit": "bc047b20768845fd54340eb76272b2cf2f6fa3f3" }, + "nvim-ts-context-commentstring": { "branch": "main", "commit": "a0f89563ba36b3bacd62cf967b46beb4c2c29e52" }, + "nvim-ts-rainbow": { "branch": "master", "commit": "ef95c15a935f97c65a80e48e12fe72d49aacf9b9" }, + "otter.nvim": { "branch": "main", "commit": "e32e432988fddc7fc96f08300e56750a838f0893" }, + "papis.nvim": { "branch": "main", "commit": "4023d30b336c147b12a249ce103561d03fbedef8" }, + "playground": { "branch": "master", "commit": "c481c660fa903a0e295902b1765ecfbd6e76a556" }, + "plenary.nvim": { "branch": "master", "commit": "9a0d3bf7b832818c042aaf30f692b081ddd58bd9" }, + "popup.nvim": { "branch": "master", "commit": "b7404d35d5d3548a82149238289fa71f7f6de4ac" }, + "quarto-vim": { "branch": "master", "commit": "216247339470794e74a5fda5e5515008d6dc1057" }, + "spellsitter.nvim": { "branch": "master", "commit": "4af8640d9d706447e78c13150ef7475ea2c16b30" }, + "symbols-outline.nvim": { "branch": "master", "commit": "512791925d57a61c545bc303356e8a8f7869763c" }, + "telescope-fzf-native.nvim": { "branch": "main", "commit": "580b6c48651cabb63455e97d7e131ed557b8c7e2" }, + "telescope.nvim": { "branch": "master", "commit": "203bf5609137600d73e8ed82703d6b0e320a5f36" }, + "twilight.nvim": { "branch": "main", "commit": "9410252bed96887ca5a86bf16435a3a51a0e6ce5" }, + "vifm.vim": { "branch": "master", "commit": "199af91d6b1b4997450da2098e7e756627c6583b" }, + "vim-criticmarkup": { "branch": "master", "commit": "d15dc134eb177a170c79f6377f81eb02a9d20b02" }, + "vim-easy-align": { "branch": "master", "commit": "12dd6316974f71ce333e360c0260b4e1f81169c3" }, + "vim-exchange": { "branch": "master", "commit": "784d63083ad7d613aa96f00021cd0dfb126a781a" }, + "vim-numbertoggle": { "branch": "main", "commit": "075b7478777e694fbac330ee34a74590dad0fee1" }, + "vim-oscyank": { "branch": "main", "commit": "e6298736a7835bcb365dd45a8e8bfe86d935c1f8" }, + "vim-pandoc": { "branch": "master", "commit": "9f406d964ca70d959b7867f1b5cee3d4884d4d3c" }, + "vim-pandoc-syntax": { "branch": "master", "commit": "4268535e1d33117a680a91160d845cd3833dfe28" }, + "vim-spellsync": { "branch": "master", "commit": "27e103f2d283a1f6e24cc99dbdcd624713aff277" }, + "vim-vsnip": { "branch": "master", "commit": "8dde8c0ef10bb1afdbb301e2bd7eb1c153dd558e" }, + "which-key.nvim": { "branch": "main", "commit": "684e96c5e8477f1ee9b3f2e9a12d802fd12c5531" }, + "zen-mode.nvim": { "branch": "main", "commit": "3c92f503823088862ca2a7809d1c7edc90fb92fa" }, + "zettelkasten.nvim": { "branch": "main", "commit": "0e77624689b470410f5355b613d45219c9350264" } +} \ No newline at end of file diff --git a/nvim/.config/nvim/lua/helpers/vimoptions.lua b/nvim/.config/nvim/lua/helpers/vimoptions.lua deleted file mode 100644 index b318851..0000000 --- a/nvim/.config/nvim/lua/helpers/vimoptions.lua +++ /dev/null @@ -1,230 +0,0 @@ ---{{{ --- remove this when vim.opt got merged -local if_nil = function(a, b) - if a == nil then - return b - end - return a -end - -local singular_values = { - ['boolean'] = true, - ['number'] = true, - ['nil'] = true, -} - -local set_key_value = function(t, key_value_str) - assert(string.find(key_value_str, ":"), "Must have a :" .. tostring(key_value_str)) - - local key, value = unpack(vim.split(key_value_str, ":")) - key = vim.trim(key) - value = vim.trim(value) - - t[key] = value -end - -local convert_vimoption_to_lua = function(_, val) - -- Short circuit if we've already converted! - if type(val) == 'table' then - return val - end - - if singular_values[type(val)] then - return val - end - - if type(val) == "string" then - -- TODO: Bad hax I think - if string.find(val, ":") then - local result = {} - local items = vim.split(val, ",") - for _, item in ipairs(items) do - set_key_value(result, item) - end - - return result - else - return vim.split(val, ",") - end - end -end - --- local concat_keys = function(t, sep) --- return table.concat(vim.tbl_keys(t), sep) --- end - -local concat_key_values = function(t, sep, divider) - local final = {} - for k, v in pairs(t) do - table.insert(final, string.format('%s%s%s', k, divider, v)) - end - - table.sort(final) - return table.concat(final, sep) -end - -local remove_duplicate_values = function(t) - local result = {} - for _, v in ipairs(t) do - result[v] = true - end - - return vim.tbl_keys(result) -end - -local remove_value = function(t, val) - if vim.tbl_islist(t) then - local remove_index = nil - for i, v in ipairs(t) do - if v == val then - remove_index = i - end - end - - if remove_index then - table.remove(t, remove_index) - end - else - t[val] = nil - end - - return t -end - -local add_value = function(current, new) - if singular_values[type(current)] then - error( - "This is not possible to do. Please do something different: " - .. tostring(current) - .. " // " - .. tostring(new) - ) - end - - if type(new) == 'string' then - if vim.tbl_islist(current) then - table.insert(current, new) - else - set_key_value(current, new) - end - - return current - elseif type(new) == 'table' then - if vim.tbl_islist(current) then - assert(vim.tbl_islist(new)) - vim.list_extend(current, new) - else - assert(not vim.tbl_islist(new), vim.inspect(new) .. vim.inspect(current)) - current = vim.tbl_extend("force", current, new) - end - - return current - else - error("Unknown type") - end -end - -local convert_lua_to_vimoption = function(t) - if vim.tbl_islist(t) then - t = remove_duplicate_values(t) - - table.sort(t) - return table.concat(t, ',') - else - return concat_key_values(t, ',', ':') - end -end - -local clean_value = function(v) - if singular_values[type(v)] then - return v - end - - local result = v:gsub('^,', '') - - return result -end - -local opt_mt - -opt_mt = { - __index = function(t, k) - if k == '_value' then - return rawget(t, k) - end - - return setmetatable({ _option = k, }, opt_mt) - end, - - __newindex = function(t, k, v) - if k == '_value' then - return rawset(t, k, v) - end - - if type(v) == 'table' then - local new_value - if getmetatable(v) ~= opt_mt then - new_value = v - else - assert(v._value, "Must have a value to set this") - new_value = v._value - end - - vim.o[k] = convert_lua_to_vimoption(new_value) - return - end - - if v == nil then - v = '' - end - - -- TODO: Figure out why nvim_set_option doesn't override values the same way. - -- @bfredl said he will fix this for me, so I can just use nvim_set_option - if type(v) == 'boolean' then - vim.o[k] = clean_value(v) - if v then - vim.cmd(string.format("set %s", k)) - else - vim.cmd(string.format("set no%s", k)) - end - else - vim.cmd(string.format("set %s=%s", k, clean_value(v))) - end - end, - - __add = function(left, right) - --[[ - set.wildignore = set.wildignore + 'hello' - set.wildignore = set.wildignore + { '*.o', '*~', } - --]] - - assert(left._option, "must have an option key") - if left._option == 'foldcolumn' then - error("not implemented for foldcolumn.. use a string") - end - - local existing = if_nil(left._value, vim.o[left._option]) - local current = convert_vimoption_to_lua(left._option, existing) - if not current then - left._value = convert_vimoption_to_lua(right) - end - - left._value = add_value(current, right) - return left - end, - - __sub = function(left, right) - assert(left._option, "must have an option key") - - local existing = if_nil(left._value, vim.o[left._option]) - local current = convert_vimoption_to_lua(left._option, existing) - if not current then - return left - end - - left._value = remove_value(current, right) - return left - end -} - -vim.opt = setmetatable({}, opt_mt)--}}} diff --git a/nvim/.config/nvim/lua/maps.lua b/nvim/.config/nvim/lua/maps.lua index 06d0b24..44a9365 100644 --- a/nvim/.config/nvim/lua/maps.lua +++ b/nvim/.config/nvim/lua/maps.lua @@ -80,9 +80,6 @@ map.n.nore[']q'] = ':cnext' map.n.nore['[l'] = ':lprevious' map.n.nore[']l'] = ':lnext' --- set our leader key to space since with hjkl, space is largely useless -vim.g.mapleader = " " - -- maps the leader for buffer local mappings -- since we are (atm) using sneak to go fwd/bwd in fFtT searches, comma does -- not do too many useful things and can be taken up as localleader @@ -162,10 +159,6 @@ map.n.nore[''] = map.n.nore['z='] = [[:lua require 'telescope.builtin'.spell_suggest(require 'telescope.themes'.get_ivy())]] --- PLUGIN: betterdigraphs --- allow normal digraph insertion on c-k, telescope search on c-k c-k -map.i.nore[''] = 'lua require "betterdigraphs".digraphs("i")' - -- Note Searching -- PLUGIN: Notational-FZF -- set notational-fzf-vim keys for the NV window itself @@ -232,13 +225,16 @@ map.i.expr[''] = -- PLUGIN: symbols-outline.nvim map.n.nore.silent['o'] = "SymbolsOutline" +-- trim trailing whitespaces with mini.nvim trailspace +vim.keymap.set("n", "w", function() require("mini.trailspace").trim() end, {noremap = true}) + -- PLUGIN: dial-increment -map.n[''] = '(dial-increment)' -map.n[''] = '(dial-decrement)' -map.v[''] = '(dial-increment)' -map.v[''] = '(dial-decrement)' -map.v['g'] = 'g(dial-increment)' -map.v['g'] = 'g(dial-decrement)' +vim.keymap.set("n", "", require("dial.map").inc_normal(), {noremap = true}) +vim.keymap.set("n", "", require("dial.map").dec_normal(), {noremap = true}) +vim.keymap.set("v", "", require("dial.map").inc_visual(), {noremap = true}) +vim.keymap.set("v", "", require("dial.map").dec_visual(), {noremap = true}) +vim.keymap.set("v", "g",require("dial.map").inc_gvisual(), {noremap = true}) +vim.keymap.set("v", "g",require("dial.map").dec_gvisual(), {noremap = true}) -- PLUGIN: zettelkasten.nvim map.n.nore[''] = [[:silent lua require 'zettelkasten'.link_follow()]] diff --git a/nvim/.config/nvim/lua/plug/_autopair.lua b/nvim/.config/nvim/lua/plug/_autopair.lua deleted file mode 100644 index 7a645e0..0000000 --- a/nvim/.config/nvim/lua/plug/_autopair.lua +++ /dev/null @@ -1,33 +0,0 @@ -require('nvim-autopairs').setup({ check_ts = true }) - ---- Auto-space rules -local npairs = require 'nvim-autopairs' -local Rule = require 'nvim-autopairs.rule' - -npairs.setup({ - check_ts = true, - ts_config = { - lua = { 'string' }, -- it will not add a pair on that treesitter node - javascript = { 'template_string' }, - java = false -- don't check treesitter on java - } -}) - -local ts_conds = require('nvim-autopairs.ts-conds') - --- press % => %% only while inside a comment or string -npairs.add_rules({ - Rule("%", "%", "lua"):with_pair(ts_conds.is_ts_node({ 'string', 'comment' })), - Rule("$", "$", "lua"):with_pair(ts_conds.is_not_ts_node({ 'function' })) -}) - -npairs.add_rules { - Rule(' ', ' '):with_pair(function(opts) - local pair = opts.line:sub(opts.col, opts.col + 1) - return vim.tbl_contains({ '()', '[]', '{}' }, pair) - end) -} -local cmp_autopairs = require('nvim-autopairs.completion.cmp') -local cmp = require('cmp') -cmp.event:on('confirm_done', - cmp_autopairs.on_confirm_done({ map_char = { tex = '' } })) diff --git a/nvim/.config/nvim/lua/plug/_cmp.lua b/nvim/.config/nvim/lua/plug/_cmp.lua index b61ef7e..9518479 100644 --- a/nvim/.config/nvim/lua/plug/_cmp.lua +++ b/nvim/.config/nvim/lua/plug/_cmp.lua @@ -68,7 +68,7 @@ cmp.setup({ }, sources = cmp.config.sources({ { name = 'path' }, { name = 'nvim_lsp' }, { name = 'treesitter' }, - { name = 'cmp_pandoc' }, { name = 'tmux' }, { name = 'vsnip' }, + { name = 'tmux' }, { name = 'vsnip' }, { name = 'otter' }, { name = 'latex_symbols' }, { name = 'vCard' }, { name = 'nvim_lua' } }, { { name = 'buffer' }, { name = 'spell' } }) }) diff --git a/nvim/.config/nvim/lua/plug/_mini.lua b/nvim/.config/nvim/lua/plug/_mini.lua index c0e78c7..1391e19 100644 --- a/nvim/.config/nvim/lua/plug/_mini.lua +++ b/nvim/.config/nvim/lua/plug/_mini.lua @@ -1,7 +1,30 @@ +require('mini.ai').setup() require('mini.comment').setup() +require('mini.cursorword').setup({delay = 500}) +require('mini.fuzzy').setup() require('mini.indentscope').setup({ symbol = "│", draw = {animation = require('mini.indentscope').gen_animation('none')}, options = {indent_at_cursor = false} }) +require('mini.map').setup() +-- require('mini.move').setup() -- has not hit stable yet +require('mini.pairs').setup() require('mini.trailspace').setup() + +local starter = require('mini.starter') +starter.setup({ + evaluate_single = true, + items = { + starter.sections.builtin_actions(), + starter.sections.recent_files(10, false), + starter.sections.recent_files(10, true), + -- Use this if you set up 'mini.sessions' + starter.sections.telescope() + }, + content_hooks = { + starter.gen_hook.adding_bullet(), + starter.gen_hook.padding(3, 2), + starter.gen_hook.aligning('center', 'center') + } +}) diff --git a/nvim/.config/nvim/lua/plug/_telescope.lua b/nvim/.config/nvim/lua/plug/_telescope.lua index 62fae3c..e867e6b 100644 --- a/nvim/.config/nvim/lua/plug/_telescope.lua +++ b/nvim/.config/nvim/lua/plug/_telescope.lua @@ -12,6 +12,12 @@ require("telescope").setup { }, generic_sorter = require('mini.fuzzy').get_telescope_sorter }, + defaults = { + -- Appearance + prompt_prefix = ' ', + selection_caret = '󰳟 ', + color_devicons = true + }, pickers = { buffers = {theme = "ivy"}, oldfiles = {theme = "ivy"}, diff --git a/nvim/.config/nvim/lua/plugins.lua b/nvim/.config/nvim/lua/plugins.lua index 028aa7d..ef458d6 100644 --- a/nvim/.config/nvim/lua/plugins.lua +++ b/nvim/.config/nvim/lua/plugins.lua @@ -1,194 +1,112 @@ -local ensure_packer = function() - local fn = vim.fn - local install_path = fn.stdpath('data') .. - '/site/pack/packer/start/packer.nvim' - if fn.empty(fn.glob(install_path)) > 0 then - fn.system({ - 'git', 'clone', '--depth', '1', - 'https://github.com/wbthomason/packer.nvim', install_path - }) - vim.cmd [[packadd packer.nvim]] - return true - end - return false -end - -local packer_bootstrap = ensure_packer() - --- Compile on plugin edits -vim.api.nvim_create_autocmd({ "BufWritePost" }, { - pattern = "plugins.lua", - command = "PackerCompile", - desc = "Compile plugins after editing plugin list", - group = vim.api.nvim_create_augroup('compilepackages', { clear = true }) -}) - -local use = require("packer").use -require("packer").startup(function() - -- packer manages itself - use "wbthomason/packer.nvim" +local writing_ft = {"quarto", "pandoc", "markdown", "text", "tex"} +return { -- vim plugs -- essential - use { - 'numToStr/Navigator.nvim', - config = function() require('Navigator').setup() end - } -- allow seamless navigation between vim buffers and tmux/wezterm splits - use 'jeffkreeftmeijer/vim-numbertoggle' -- toggles numbers to absolute for all buffers but the current which is relative - use 'RRethy/vim-illuminate' -- highlight other occurences of the word under cursor - use 'ojroques/vim-oscyank' -- yank from *anywhere* (even ssh session) to clipboard, using :OSCYank - use 'ggandor/lightspeed.nvim' -- jump between letters with improved fFtT quicksearch, mimics sneak + {'numToStr/Navigator.nvim', 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 -- files - use 'vifm/vifm.vim' -- integrate file manager - use { + {'vifm/vifm.vim'}, -- integrate file manager + { 'lewis6991/gitsigns.nvim', -- show vcs changes on left-hand gutter - requires = { 'nvim-lua/plenary.nvim' }, - tag = 'release', - config = function() require('plug._gitsigns') end, + config = true, event = "BufRead" - } - use { + }, { 'norcalli/nvim-colorizer.lua', -- color hex, named colors in the correct preview scheme - config = function() require('colorizer').setup() end, - event = "BufRead" - } - use { + config = true, + event = "VeryLazy" + }, { 'mhartington/formatter.nvim', -- auto formatting on save config = function() require('plug._format') end, - event = "BufRead" - } - - -- editing - -- use {'machakann/vim-sandwich', event = "BufRead"} -- surround things with other things using sa/sd/sr - use { - 'kylechui/nvim-surround', - tag = '*', - config = function() require('nvim-surround').setup() end - } -- surround things with other things using ys/cs/ds - use { + 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 - event = "BufRead" - } - use { + event = "VeryLazy" + }, { 'tommcdo/vim-exchange', -- adds exchange operator with cx. common use: cxiw . on 2 words to switch - event = "BufRead" - } - use { - 'windwp/nvim-autopairs', - config = function() require('plug._autopair') end, - event = "BufRead" - } -- Auto close brackets and '' - use { + event = "VeryLazy" + }, { 'junegunn/vim-easy-align', -- Align tables and other alignable things - event = "BufRead" - } - use { - 'tversteeg/registers.nvim', -- Show the contents of regiseters on pasting from '', @, - event = "BufRead" - } - use { -- highlight where the cursor jumps to - 'edluffy/specs.nvim', - config = function() require('specs').setup {} end, - event = "BufRead" - } - - -- colorschemes - use 'norcalli/nvim-base16.lua' - + event = "VeryLazy" + }, -- colorschemes + {'norcalli/nvim-base16.lua'}, -- -- statusline - use { + { 'nvim-lualine/lualine.nvim', - requires = { 'kyazdani42/nvim-web-devicons', opt = true }, + requires = {'kyazdani42/nvim-web-devicons', opt = true}, config = function() require('plug._lualine') end - } - - -- writing - use { 'vim-pandoc/vim-pandoc-syntax' } - use { 'vim-pandoc/vim-pandoc' } - use { 'vim-pandoc/vim-criticmarkup' } - use { + }, -- writing + {'vim-pandoc/vim-pandoc-syntax', ft = writing_ft}, + {'vim-pandoc/vim-pandoc', ft = writing_ft}, + {'vim-pandoc/vim-criticmarkup', ft = writing_ft}, { "quarto-dev/quarto-vim", - requires = { { "vim-pandoc/vim-pandoc-syntax" } }, - ft = { "quarto" } - } - use 'micarmst/vim-spellsync' -- personal dict improvements for git sync - use { 'folke/zen-mode.nvim', config = require('zen-mode').setup() } -- provide distraction free writing - use 'folke/twilight.nvim' -- provide even distraction free-er writing (lowlight paragraphs) - use 'alok/notational-fzf-vim' -- quickly search through the wiki - use({ + dependencies = {"vim-pandoc/vim-pandoc-syntax"}, + ft = writing_ft + }, {'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) + {'alok/notational-fzf-vim', event = "VeryLazy"}, -- quickly search through the wiki + {'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 - run = function() vim.fn["mkdp#util#install"]() end - }) - - -- languages - use { 'euclidianAce/BetterLua.vim', ft = 'lua' } -- better syntax highlighting for lua - use 'aliou/bats.vim' -- enable syntax for bats shell-code testing library + build = function() vim.fn["mkdp#util#install"]() end, + event = "VeryLazy" + }, -- 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 - use { + { 'WhiteBlackGoose/magma-nvim-goose', - run = ":UpdateRemotePlugins", + build = ":UpdateRemotePlugins", config = function() vim.g.magma_image_provider = "kitty" vim.g.magma_automatically_open_output = false end - } - - -- nvim plugs - use { + }, -- nvim plugs + { 'echasnovski/mini.nvim', - branch = 'stable', + version = '*', config = function() require('plug._mini') end - } - use 'Iron-E/nvim-cartographer' -- makes it easier to set mappings through lua - use 'marty-oehme/zettelkasten.nvim' -- simple static markdown linking - use { + }, {'Iron-E/nvim-cartographer'}, -- makes it easier to set mappings through lua + { "akinsho/nvim-toggleterm.lua", -- simpler, programmable and multiple terminal toggling for nvim - event = "BufWinEnter", - config = function() require('plug._toggleterm') end - } - use { + config = function() require('plug._toggleterm') end, + event = "BufWinEnter" + }, + { "folke/which-key.nvim", config = function() require("which-key").setup {} end - } - -- extensive organization plugin mimicking orgmode - use { + }, { "nvim-neorg/neorg", config = function() require("plug._neorg") end, - requires = "nvim-lua/plenary.nvim", - tag = "*" - } - + dependencies = {"nvim-lua/plenary.nvim"}, + version = "*", + ft = "norg" + }, -- extensive organization plugin mimicking orgmode -- fuzzy matching - use { + {"nvim-telescope/telescope-fzf-native.nvim", build = 'make'}, { "nvim-telescope/telescope.nvim", - requires = { - { "nvim-lua/popup.nvim" }, { "nvim-lua/plenary.nvim" }, - { "nvim-telescope/telescope-fzf-native.nvim", run = 'make' } - }, + dependencies = {"nvim-lua/popup.nvim", "nvim-lua/plenary.nvim"}, config = function() require('plug._telescope') end - } - use { - 'protex/better-digraphs.nvim', - requires = { { "nvim-telescope/telescope.nvim" } } - } - - -- snippeting - use { "hrsh7th/vim-vsnip", event = "InsertEnter" } -- snippet engine - use { "rafamadriz/friendly-snippets", event = "InsertEnter" } -- many snippets - + }, -- snippeting + {"hrsh7th/vim-vsnip", event = "InsertEnter"}, -- snippet engine + {"rafamadriz/friendly-snippets", event = "InsertEnter"}, -- many snippets -- treesitter - use { + { 'nvim-treesitter/nvim-treesitter', - run = ':TSUpdate', + build = ':TSUpdate', config = function() require('plug._treesitter') end - } - use 'nvim-treesitter/playground' -- interactively view and query the treesitter tree - use 'romgrk/nvim-treesitter-context' -- show current cursor context at top of buffer - use { + }, {'nvim-treesitter/playground', cmd = "TSPlaygroundToggle"}, -- interactively view and query the treesitter tree + {'romgrk/nvim-treesitter-context', event = "BufReadPre", config = true}, -- show current cursor context at top of buffer + { 'RRethy/nvim-treesitter-textsubjects', -- allows using . and ; to target treesitter branches config = function() - require 'nvim-treesitter.configs'.setup { + require'nvim-treesitter.configs'.setup { textsubjects = { enable = true, keymaps = { @@ -197,45 +115,51 @@ require("packer").startup(function() } } } - end - } - use 'p00f/nvim-ts-rainbow' -- rainbow brackets using treesitter - use 'JoosepAlviste/nvim-ts-context-commentstring' -- improves commenting plugin above by using ts - use { + end, + event = "BufReadPre" + }, {'p00f/nvim-ts-rainbow', event = "BufReadPre"}, -- rainbow brackets using treesitter + {'JoosepAlviste/nvim-ts-context-commentstring', event = "BufReadPre"}, -- improves commenting plugin above by using ts + { 'lewis6991/spellsitter.nvim', -- uses treesitter to highlight spelling errors - config = function() require('spellsitter').setup() end - } - - -- lsp - use 'neovim/nvim-lspconfig' -- some commong language server configurations - use { + config = function() require('spellsitter').setup() end, + event = "BufReadPre" + }, -- lsp + {'neovim/nvim-lspconfig', event = "VeryLazy"}, -- some common language server configurations + { 'simrat39/symbols-outline.nvim', - config = function() require('symbols-outline').setup() end - } -- vista-like outline view for code - use 'ray-x/lsp_signature.nvim' - use { + config = function() require('symbols-outline').setup() end, + event = "VeryLazy" + }, -- vista-like outline view for code + {'ray-x/lsp_signature.nvim', event = "VeryLazy"}, + {'ray-x/guihua.lua', build = 'cd lua/fzy && make', event = "VeryLazy"}, { 'ray-x/navigator.lua', - requires = { 'ray-x/guihua.lua', run = 'cd lua/fzy && make' }, - config = function() require('plug._lsp') end - } - -- and completion - use { + config = function() require('plug._lsp') end, + event = "VeryLazy" + }, -- and completion + { 'hrsh7th/nvim-cmp', -- simple completion engine built specifically for nvim and lsp - requires = { + dependencies = { 'onsails/lspkind-nvim', 'andersevenrud/cmp-tmux', -- completion source from adjacent tmux panes 'hrsh7th/cmp-nvim-lsp', 'hrsh7th/cmp-buffer', 'hrsh7th/cmp-path', 'hrsh7th/cmp-cmdline', 'hrsh7th/cmp-vsnip', 'hrsh7th/cmp-nvim-lua', 'kdheepak/cmp-latex-symbols', 'ray-x/cmp-treesitter', 'f3fora/cmp-spell', 'cbarrete/completion-vcard' - } - } - use { + }, + event = "VeryLazy", + config = function() require('plug._cmp') end + }, { 'aspeddro/cmp-pandoc.nvim', - requires = { 'nvim-lua/plenary.nvim', 'jbyuki/nabla.nvim' } + dependencies = {'nvim-lua/plenary.nvim', 'jbyuki/nabla.nvim'}, + event = "VeryLazy" + }, { + "jghauser/papis.nvim", + after = {"telescope.nvim", "nvim-cmp"}, + dependencies = { + "kkharji/sqlite.lua", "nvim-lua/plenary.nvim", + "MunifTanjim/nui.nvim", "nvim-treesitter/nvim-treesitter" + }, + event = "VeryLazy", + rocks = {"lyaml"}, + config = function() require("papis").setup({}) end } - require('plug._cmp') - - -- Automatically set up your configuration after cloning packer.nvim - -- Put this at the end after all plugins - if packer_bootstrap then require('packer').sync() end -end) +} diff --git a/nvim/.config/nvim/lua/settings.lua b/nvim/.config/nvim/lua/settings.lua index 31b7ca5..2f07e1c 100644 --- a/nvim/.config/nvim/lua/settings.lua +++ b/nvim/.config/nvim/lua/settings.lua @@ -1,14 +1,8 @@ -require("helpers.vimoptions") - local default_builtins_disabled = {"netrw", "netrwPlugin"} local disable_builtins = function(builtins) for _, plugin in pairs(builtins) do vim.g["loaded_" .. plugin] = 1 end end -local apply_options = function(opts) - for k, v in pairs(opts) do vim.opt[k] = v end -end - local o = { termguicolors = true, -- sets tabs to be 2 characters, expanded into spaces, but still removable with @@ -72,6 +66,9 @@ local o = { } +for k, v in pairs(o) do + vim.opt[k] = v +end + vim.api.nvim_set_var('tex_flavor', 'latex') -apply_options(o) disable_builtins(default_builtins_disabled) From 08360ae7ffd89a757ff24ecd8eb5f764836af5b7 Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Fri, 10 Feb 2023 09:19:27 +0100 Subject: [PATCH 5/8] nvim: Switch from quarto-vim to quarto-nvim Switched to the neovim variant of quarto plugins since it may contain improved integration with lsp and cmp - and offers completion and diagnostics for code snippets *within* the overall markdown sources of quarto, which is very exciting. --- nvim/.config/nvim/lazy-lock.json | 3 ++- nvim/.config/nvim/lua/plugins.lua | 14 ++++++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/nvim/.config/nvim/lazy-lock.json b/nvim/.config/nvim/lazy-lock.json index 01180be..1cfd68a 100644 --- a/nvim/.config/nvim/lazy-lock.json +++ b/nvim/.config/nvim/lazy-lock.json @@ -49,8 +49,9 @@ "playground": { "branch": "master", "commit": "c481c660fa903a0e295902b1765ecfbd6e76a556" }, "plenary.nvim": { "branch": "master", "commit": "9a0d3bf7b832818c042aaf30f692b081ddd58bd9" }, "popup.nvim": { "branch": "master", "commit": "b7404d35d5d3548a82149238289fa71f7f6de4ac" }, - "quarto-vim": { "branch": "master", "commit": "216247339470794e74a5fda5e5515008d6dc1057" }, + "quarto-nvim": { "branch": "main", "commit": "a30db854054973ab8f140adf3e6b565bf2febf0f" }, "spellsitter.nvim": { "branch": "master", "commit": "4af8640d9d706447e78c13150ef7475ea2c16b30" }, + "sqlite.lua": { "branch": "master", "commit": "93ff5824682ecc874200e338fd8ca9ccd08508f8" }, "symbols-outline.nvim": { "branch": "master", "commit": "512791925d57a61c545bc303356e8a8f7869763c" }, "telescope-fzf-native.nvim": { "branch": "main", "commit": "580b6c48651cabb63455e97d7e131ed557b8c7e2" }, "telescope.nvim": { "branch": "master", "commit": "203bf5609137600d73e8ed82703d6b0e320a5f36" }, diff --git a/nvim/.config/nvim/lua/plugins.lua b/nvim/.config/nvim/lua/plugins.lua index ef458d6..78b1647 100644 --- a/nvim/.config/nvim/lua/plugins.lua +++ b/nvim/.config/nvim/lua/plugins.lua @@ -43,8 +43,18 @@ return { {'vim-pandoc/vim-pandoc-syntax', ft = writing_ft}, {'vim-pandoc/vim-pandoc', ft = writing_ft}, {'vim-pandoc/vim-criticmarkup', ft = writing_ft}, { - "quarto-dev/quarto-vim", - dependencies = {"vim-pandoc/vim-pandoc-syntax"}, + 'quarto-dev/quarto-nvim', + dependencies = {'jmbuhr/otter.nvim', 'neovim/nvim-lspconfig'}, + config = function() + require'quarto'.setup { + lspFeatures = { + enabled = true, + languages = {'r', 'python', 'julia'}, + diagnostics = {enabled = true, triggers = {"BufWrite"}}, + completion = {enabled = true} + } + } + end, ft = writing_ft }, {'micarmst/vim-spellsync', event = "VeryLazy"}, -- personal dict improvements for git sync {'folke/zen-mode.nvim', config = true, event = "VeryLazy"}, -- provide distraction free writing From fff6e6086280bfe672f32bf9e523fdeafa730312 Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Fri, 10 Feb 2023 11:13:53 +0100 Subject: [PATCH 6/8] nvim: Remove cartographer plugin Switch to use the nice new nvim-internal keymapping functions. Cartographer was a really useful plugin when they did not yet exist but now everything I wanted to do can be done without a mapping plugin, so it is time to remove it. --- nvim/.config/nvim/after/plugin/bibcite.vim | 52 ----- nvim/.config/nvim/lazy-lock.json | 1 - nvim/.config/nvim/lua/maps.lua | 243 +++++++++------------ nvim/.config/nvim/lua/plugins.lua | 2 +- 4 files changed, 103 insertions(+), 195 deletions(-) delete mode 100644 nvim/.config/nvim/after/plugin/bibcite.vim diff --git a/nvim/.config/nvim/after/plugin/bibcite.vim b/nvim/.config/nvim/after/plugin/bibcite.vim deleted file mode 100644 index 9b1b248..0000000 --- a/nvim/.config/nvim/after/plugin/bibcite.vim +++ /dev/null @@ -1,52 +0,0 @@ -" set up fzf-bibtex -let g:fzf_bibtex_cache = '~/.cache/' -let g:fzf_bibtex_sources = g:pandoc#biblio#bibs - -" prepare bibtex_ls function to look for bib files in cwd/parent/subdirs, -" attach the standard bibtex source file -" return the command with standard cache directory filled -function! s:bibtex_ls(...) - let bibfiles = ( - \ globpath('.', '*.bib', v:true, v:true) + - \ globpath('..', '*.bib', v:true, v:true) + - \ globpath('*/', '*.bib', v:true, v:true) - \ ) - let bibfiles = join(bibfiles, ' ') - let source_cmd = 'bibtex-ls -cache ' . g:fzf_bibtex_cache . ' ' .bibfiles . ' ' . join(g:fzf_bibtex_sources) - return source_cmd -endfunction - -" NORMAL MODE CITATION -" insert citation from normal mode at cursor (with brackets) -function! s:bibtex_cite_sink(lines) - let r=system("bibtex-cite ", a:lines) - execute ':normal! i[' . r . ']' -endfunction -command! -bang -nargs=* CiteRef call fzf#run(fzf#wrap({ - \ 'source': bibtex_ls(), - \ 'sink*': function('bibtex_cite_sink'), - \ 'up': '25%', - \ 'options': '--ansi --multi --prompt "Cite> "' - \ })) - -" INSERT MODE CITATION -" insert citation from insert mode at cursor (no brackets inserted) -function! s:bibtex_cite_sink_insert(lines) - let r=system("bibtex-cite ", a:lines) - execute ':normal! i' . r - call feedkeys('a', 'n') -endfunction - -" MARKDOWN CITATION -" insert markdown formatted reference -function! s:bibtex_markdown_sink(lines) - let r=system("bibtex-markdown -cache " . g:fzf_bibtex_cache . ' ' . join(g:fzf_bibtex_sources), a:lines) - echo join(a:lines, '; ') - execute ':normal! a' . r -endfunction -command! -bang -nargs=* CiteMarkdown call fzf#run(fzf#wrap({ - \ 'source': bibtex_ls(), - \ 'sink*': function('bibtex_markdown_sink'), - \ 'up': '25%', - \ 'options': '--ansi --multi --prompt "Markdown> "' - \ })) diff --git a/nvim/.config/nvim/lazy-lock.json b/nvim/.config/nvim/lazy-lock.json index 1cfd68a..7d87556 100644 --- a/nvim/.config/nvim/lazy-lock.json +++ b/nvim/.config/nvim/lazy-lock.json @@ -33,7 +33,6 @@ "notational-fzf-vim": { "branch": "master", "commit": "75c2c31e7cd77397018c5777804666d648557537" }, "nui.nvim": { "branch": "main", "commit": "d147222a1300901656f3ebd5b95f91732785a329" }, "nvim-base16.lua": { "branch": "master", "commit": "b336f40462b3ca1ad16a17c195b83731a2942d9a" }, - "nvim-cartographer": { "branch": "master", "commit": "fbe977c9529019376db9426cccf04bfdadeafc69" }, "nvim-cmp": { "branch": "main", "commit": "cfafe0a1ca8933f7b7968a287d39904156f2c57d" }, "nvim-colorizer.lua": { "branch": "master", "commit": "36c610a9717cc9ec426a07c8e6bf3b3abcb139d6" }, "nvim-lspconfig": { "branch": "master", "commit": "aeb76066212b09c7c01a3abb42fe82f0130ef402" }, diff --git a/nvim/.config/nvim/lua/maps.lua b/nvim/.config/nvim/lua/maps.lua index 44a9365..f9c8fe5 100644 --- a/nvim/.config/nvim/lua/maps.lua +++ b/nvim/.config/nvim/lua/maps.lua @@ -1,34 +1,30 @@ -local map = require 'cartographer' +local map = vim.keymap.set -- The general ideas behind these mappings: -- -- * Leader prefix is the generally preferred way to map new things, however --- only for those that affect all of vim +-- only for those that affect all of vim of work in a supra-buffer way. -- --- * Localleader prefix is used for mappings which only affect single buffers, --- in other words mostly filetype specific mappings --- --- many of these mapping ideas come from Tom Ryder who has them nicely --- documented +-- * Localleader prefix is used for mappings which only affect single buffers. +-- In other words mostly filetype specific mappings -- backspace to switch to alternate (last) buffer -map.n.nore[''] = '' +map('n', '', '') -- since u undoes, would it not make sense that U redoes? -map.n.nore['U'] = '' +map('n', 'U', '') -- d-motion puts the last 'deleted' thing into the default register to paste; -- use D-motion to truly delete something into nothingness and keep whatever -- you want in your register, ready to paste -map.n.nore['D'] = '"_d' +map('n', 'D', '"_d') --- I don't particularly need ex mode (at least, yet) but faster macro access --- is nice -map.n.nore['Q'] = '@' +-- I don't particularly need ex mode (at least, yet) but faster macro access is nice +map('n', 'Q', '@') -- stronger versions of left,right - move all the way to beginning/end of line -map.n.nore['H'] = '^' -map.n.nore['L'] = '$' +map('n', 'H', '^') +map('n', 'L', '$') -- when in softwrapped files, allow moving through the visible lines with j/k -- but when prepending a number jump *exactly* as many lines, wrapped or not @@ -44,41 +40,37 @@ local function wrap_down() return 'j' end -map.n.nore.expr['k'] = wrap_up -map.n.nore.expr['j'] = wrap_down +map('n', 'k', wrap_up, {expr = true}) +map('n', 'j', wrap_down, {expr = true}) -- move around between matching brackets with tab -map.n.nore[''] = '%' +map('n', '', '%') -- when in insertion mode, C-u uppercases the current word, C-l lowercases it, -map.i.nore[''] = 'gUiw`]a' -map.i.nore[''] = 'guiw`]a' - --- let me save stuff as sudo when I forget to call vim with it -map.c.nore['w!!'] = -[[execute 'silent! write !sudo tee % >/dev/null' edit!]] +map('i', '', 'gUiw`]a') +map('i', '', 'guiw`]a') -- yank current filename/filepath to f buffer -map.n.nore['yp'] = ':let @p = expand("%")' -map.n.nore['yP'] = ':let @p = expand("%:p")' +map('n', 'yp', ':let @p = expand("%")') +map('n', 'yP', ':let @p = expand("%:p")') -- repeat the last substitute command with all its flags preserved -map.n.nore['&'] = ':&&' +map('n', '&', ':&&') -- bracket pairings to go to the next/previous of: -- (works with count prefixes) -- Argument list -map.n.nore['[a'] = ':previous' -map.n.nore[']a'] = ':next' +map('n', '[a', ':previous') +map('n', ']a', ':next') -- Buffers -map.n.nore['[b'] = ':bprevious' -map.n.nore[']b'] = ':bnext' +map('n', '[b', ':bprevious') +map('n', ']b', ':bnext') -- Quickfix list -map.n.nore['[q'] = ':cprevious' -map.n.nore[']q'] = ':cnext' +map('n', '[q', ':cprevious') +map('n', ']q', ':cnext') -- Location list -map.n.nore['[l'] = ':lprevious' -map.n.nore[']l'] = ':lnext' +map('n', '[l', ':lprevious') +map('n', ']l', ':lnext') -- maps the leader for buffer local mappings -- since we are (atm) using sneak to go fwd/bwd in fFtT searches, comma does @@ -87,180 +79,149 @@ vim.g.maplocalleader = "," -- If we mapped localleader to comma, we can still get to its original function -- by douple-tapping it. +-- FIXME does this work still (and is it necessary)? if vim.g.maplocalleader == ',' then - map.nore[',,'] = ',' - map.s[',,'] = nil + map('', ',,', ',') + vim.keymap.del('', ',,', {silent=true}) end -- remove search highlights by pressing space+/ -map.n.nore['/'] = ':noh' +map('n', '/', ':noh') -- split buffers vertically/horizontally with the leader \ or - (mirrors my -- tmux setup) -map.n.nore['-'] = ':sp' -map.n.nore['\\'] = ':vsp' +map('n', '-', ':sp') +map('n', '\\', ':vsp') -- 'open new buffer' with leader-t (opens new buffer containing current dir and switches to it) -map.n.nore['t'] = ':vsp .' +map('n', 't', ':vsp .') -- open actual new tab with leader-T -map.n.nore['T'] = ':tabedit .' +map('n', 'T', ':tabedit .') -- select the whole buffer with -a -map.n.nore['a'] = 'ggVG' +map('n', 'a', 'ggVG') --- CONFIG EDITING --- quickly edit vimrc with leader+V -map.n.nore['V'] = ':vsp $MYVIMRC' --- source vimrc with keystroke combination -map.n.nore['VV'] = ':source $MYVIMRC' +-- PLUGIN: Navigator.nvim +map('n', 'h', 'lua require("Navigator").left()', {silent = true}) +map('n', 'k', 'lua require("Navigator").up()', {silent = true}) +map('n', 'l', 'lua require("Navigator").right()', {silent = true}) +map('n', 'j', 'lua require("Navigator").down()', {silent = true}) +map('n', 'p', 'lua require("Navigator").previous()', {silent = true}) -- PLUGIN: Vifm.vim -- open/close file tree with leader-e -map.n.nore['e'] = ':Vifm' +map('n', 'e', ':Vifm') -- open current file tree with current file directory -map.n.nore['E'] = ':Vifm getcwd()' +map('n', 'E', ':Vifm getcwd()') -- PLUGIN: Telescope GLOBAL FUZZY FINDING -- buffers and files in current workdir -map.n.nore['s'] = -[[:lua require 'telescope.builtin'.buffers(require 'telescope.themes'.get_ivy())]] +map('n', 's',":lua require 'telescope.builtin'.buffers(require 'telescope.themes'.get_ivy())") -- most recently used / MRU, bound to S since it is essentially a larger -- go-back intention than just buffers -map.n.nore['S'] = -[[:lua require 'telescope.builtin'.oldfiles(require 'telescope.themes'.get_ivy())]] +map('n', 'S',":lua require 'telescope.builtin'.oldfiles(require 'telescope.themes'.get_ivy())") -- fuzzy find files in cwd -map.n.nore['f'] = [[:lua require 'telescope.builtin'.find_files()]] +map('n', 'f',":lua require 'telescope.builtin'.find_files()") -- fuzzy find hidden files in cwd -map.n.nore[''] = -[[:lua require 'telescope.builtin'.find_files({hidden=true})]] +map('n', '',":lua require 'telescope.builtin'.find_files({hidden=true})") -- general full-text search in cwd with rg -map.n.nore['F'] = [[:lua require 'telescope.builtin'.live_grep()]] +map('n', 'F',":lua require 'telescope.builtin'.live_grep()") -- git status -map.n.nore['gs'] = [[:lua require 'telescope.builtin'.git_status()]] +map('n', 'gs',":lua require 'telescope.builtin'.git_status()") -- git buffercommits -map.n.nore['gb'] = -[[:lua require 'telescope.builtin'.git_bcommits()]] +map('n', 'gb',":lua require 'telescope.builtin'.git_bcommits()") -- git commitlog -map.n.nore['gl'] = -[[:lua require 'telescope.builtin'.git_commits()]] +map('n', 'gl',":lua require 'telescope.builtin'.git_commits()") -- helptags -map.n.nore[''] = -[[:lua require 'telescope.builtin'.help_tags()]] +map('n', '',":lua require 'telescope.builtin'.help_tags()") -- manpages -map.n.nore[''] = -[[:lua require 'telescope.builtin'.man_pages()]] +map('n', '',":lua require 'telescope.builtin'.man_pages()") -- colorschemes -map.n.nore[''] = -[[:lua require 'telescope.builtin'.colorscheme(require 'telescope.themes'.get_ivy())]] +map('n', '',":lua require 'telescope.builtin'.colorscheme(require 'telescope.themes'.get_ivy())") -- spell suggestions -map.n.nore['z='] = -[[:lua require 'telescope.builtin'.spell_suggest(require 'telescope.themes'.get_ivy())]] +map('n', 'z=',":lua require 'telescope.builtin'.spell_suggest(require 'telescope.themes'.get_ivy())") --- Note Searching --- PLUGIN: Notational-FZF --- set notational-fzf-vim keys for the NV window itself -vim.g.nv_fzf_binds = { - 'alt-a:select-all', 'alt-q:deselect-all', 'alt-p:toggle-preview', - 'alt-u:page-up', 'alt-d:page-down', 'ctrl-w:backward-kill-word' -} --- FZF note full-text search with notational-velocity like functions (in wiki --- directory) -map.n.nore['n'] = ':NV' -map.n.nore['N'] = ':NV!' -- Format current Paragraph (esp useful in prose writing) -map.n.nore.silent['q'] = 'gqap' -map.x.nore.silent['q'] = 'gq' -map.n.nore.silent['Q'] = 'vapJgqap' +map('n', 'q', 'gqap', {silent=true}) +map('x', 'q', 'gq', {silent=true}) +map('n', 'Q', 'vapJgqap', {silent=true}) -map.n.silent['mp'] = 'MarkdownPreviewToggle' +map('n', 'mp', 'MarkdownPreviewToggle') -- FORMAT code with -- PLUGIN: formatter.nvim -map.n.nore.silent['f'] = ':FormatLock' -map.n.nore.silent['F'] = ':FormatWriteLock' +map('n', 'f', ':FormatLock') +map('n', 'F', ':FormatWriteLock') -- Enter distraction free prose mode with F11 -map.n.nore.silent[''] = ':ZenMode' - --- PLUGIN: fzf-bibtex --- map @@ to automatically insert citation reference at cursor -map.i.nore.silent['@@'] = 'u:CiteRef' --- map cc to insert a complete citation at cursor +map('n', '', ':ZenMode', {silent=true}) -- SPELL CHECKING -- Move to the prev/next spelling error with [S ]S -- Move to the prev/next spelling error or suggestion with [s ]s -map.n.nore['ZZ'] = ':setlocal spell! spelllang=en_us,de_de' -map.n.nore['ZE'] = ':setlocal spell! spelllang=en_us' -map.n.nore['ZG'] = ':setlocal spell! spelllang=de_de' +map('n', 'ZZ', ':setlocal spell! spelllang=en_us,de_de') +map('n', 'ZE', ':setlocal spell! spelllang=en_us') +map('n', 'ZG', ':setlocal spell! spelllang=de_de') -- undo last spelling mistake from insert and normal mode -map.i.nore[''] = 'u[s1z=`]au' -map.n.nore['s'] = 'ms[s1z=`s' +map('i', '', 'u[s1z=`]au') +map('n', 's', 'ms[s1z=`s') -- PLUGIN: easy-align -- Start interactive EasyAlign in visual mode (e.g. vipga) -map.x['ga'] = '(EasyAlign)' +map('x', 'ga', '(EasyAlign)') -- Start interactive EasyAlign for a motion/text object (e.g. gaip) -map.n['ga'] = '(EasyAlign)' +map('n', 'ga', '(EasyAlign)') --- PLUGIN: Navigator.nvim -map.n.nore.silent['h'] = "lua require('Navigator').left()" -map.n.nore.silent['k'] = "lua require('Navigator').up()" -map.n.nore.silent['l'] = "lua require('Navigator').right()" -map.n.nore.silent['j'] = "lua require('Navigator').down()" -map.n.nore.silent['p'] = "lua require('Navigator').previous()" - --- PLUGIN: compe.nvim --- lsp keymaps are set in lsp settings, only for lsp buffers -map.i.nore.expr.silent[''] = 'compe#complete()' -map.i.expr[''] = -[[vsnip#jumpable(1) ? '(vsnip-jump-next)' : '']] -map.i.expr[''] = -[[vsnip#jumpable(-1) ? '(vsnip-jump-next)' : '']] +-- PLUGIN: vnsip +-- jump around in snippets +map('i', '', [[vsnip#jumpable(1) ? '(vsnip-jump-next)' : '']], {expr=true}) +map('i', '', [[vsnip#jumpable(-1) ? '(vsnip-jump-next)' : '']], {expr=true}) -- PLUGIN: symbols-outline.nvim -map.n.nore.silent['o'] = "SymbolsOutline" +map('n', 'o', 'SymbolsOutline', {silent=true}) -- trim trailing whitespaces with mini.nvim trailspace -vim.keymap.set("n", "w", function() require("mini.trailspace").trim() end, {noremap = true}) +map("n", "w", function() require("mini.trailspace").trim() end, {noremap = true}) -- PLUGIN: dial-increment -vim.keymap.set("n", "", require("dial.map").inc_normal(), {noremap = true}) -vim.keymap.set("n", "", require("dial.map").dec_normal(), {noremap = true}) -vim.keymap.set("v", "", require("dial.map").inc_visual(), {noremap = true}) -vim.keymap.set("v", "", require("dial.map").dec_visual(), {noremap = true}) -vim.keymap.set("v", "g",require("dial.map").inc_gvisual(), {noremap = true}) -vim.keymap.set("v", "g",require("dial.map").dec_gvisual(), {noremap = true}) +map("n", "", require("dial.map").inc_normal(), {noremap = true}) +map("n", "", require("dial.map").dec_normal(), {noremap = true}) +map("v", "", require("dial.map").inc_visual(), {noremap = true}) +map("v", "", require("dial.map").dec_visual(), {noremap = true}) +map("v", "g",require("dial.map").inc_gvisual(), {noremap = true}) +map("v", "g",require("dial.map").dec_gvisual(), {noremap = true}) -- PLUGIN: zettelkasten.nvim -map.n.nore[''] = [[:silent lua require 'zettelkasten'.link_follow()]] -map.v.nore[''] = [[:lua require 'zettelkasten'.link_follow(true)]] -map.n.nore['ww'] = [[:lua require 'zettelkasten'.index_open() ]] +map('n', '', [[:silent lua require 'zettelkasten'.link_follow()]]) +map('v', '', [[:lua require 'zettelkasten'.link_follow(true)]]) +map('n', 'ww', [[:lua require 'zettelkasten'.index_open() ]]) -- PLUGIN: toggleterm.nvim -- create a lazygit window, set up in toggleterm settings -map.n.nore['G'] = ':Lazygit' +map('n', 'G', ':Lazygit') -- PLUGIN: magma-nvim -- Operate jupyter notebooks from within vim -map.n.nore.silent['rr'] = ':MagmaEvaluateLine' -map.n.nore.silent['R'] = '?^```{jV/```k:MagmaEvaluateVisual' -map.x.nore.silent['r'] = ':MagmaEvaluateVisual' -map.n.nore.expr.silent['r'] = "nvim_exec('MagmaEvaluateOperator', v:true)" -map.n.nore.silent['re'] = ':MagmaReevaluateCell' -map.n.nore.silent['ro'] = ':MagmaShowOutput' -map.n.nore.silent['rq'] = ':noautocmd :MagmaEnterOutput' -map.n.nore.silent['rc'] = ':MagmaDelete' -map.n.nore.silent['rd'] = ':MagmaInterrupt' +map('n', 'mm', ':MagmaEvaluateLine', {silent=true}) +map('n', 'M', '?^```{jV/```k:MagmaEvaluateVisual', {silent=true}) +map('x', 'm', ':MagmaEvaluateVisual', {silent=true}) +map('n', 'm', "nvim_exec('MagmaEvaluateOperator', v:true)", {expr=true, silent=true}) +map('n', 'mr', ':MagmaReevaluateCell', {silent=true}) +map('n', 'ma', ':MagmaShowOutput', {silent=true}) +map('n', 'mq', ':noautocmd :MagmaEnterOutput', {silent=true}) +map('n', 'md', ':MagmaDelete', {silent=true}) +map('n', 'ms', ':MagmaInterrupt') +map('n', 'mI', ':MagmaInit ') +map('n', 'mD', ':MagmaDeinit') +map('n', 'mR', ':MagmaRestart') -map.n.nore.silent['rO'] = ':lua vim.g.magma_automatically_open_output = not(vim.g.magma_automatically_open_output)' -- jump to beginning of previous/ next cell code -map.n.nore[']r'] = '/^```{}:nohl' -map.n.nore['[r'] = '?^```n}:nohl' +map('n', ']c', '/^```{}:nohl') +map('n', '[c', '?^```n}:nohl') -- insert cell header above/below -map.n.nore['cO'] = ':IPythonCellInsertAbovea' -map.n.nore['co'] = ':IPythonCellInsertBelowa' +map('n', 'mo', 'o```{python}```k') +map('n', 'mO', 'O```{python}```k') diff --git a/nvim/.config/nvim/lua/plugins.lua b/nvim/.config/nvim/lua/plugins.lua index 78b1647..2653f71 100644 --- a/nvim/.config/nvim/lua/plugins.lua +++ b/nvim/.config/nvim/lua/plugins.lua @@ -82,7 +82,7 @@ return { 'echasnovski/mini.nvim', version = '*', config = function() require('plug._mini') end - }, {'Iron-E/nvim-cartographer'}, -- makes it easier to set mappings through lua + }, { "akinsho/nvim-toggleterm.lua", -- simpler, programmable and multiple terminal toggling for nvim config = function() require('plug._toggleterm') end, From e8d2183264df127fbd5967d2e071d22be1d07cbd Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Fri, 10 Feb 2023 11:15:38 +0100 Subject: [PATCH 7/8] nvim: Remove notational-fzf-vim plugin Removed the notation velocity plugin for vim. I have not been making use of it for ages and should I need a vim-internal way of digging through my wiki I can probably find easier (and more clear) ways of doing so. Nice plugin, but of no more use to me. --- nvim/.config/nvim/lazy-lock.json | 1 - nvim/.config/nvim/lua/plugins.lua | 3 +-- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/nvim/.config/nvim/lazy-lock.json b/nvim/.config/nvim/lazy-lock.json index 7d87556..925be37 100644 --- a/nvim/.config/nvim/lazy-lock.json +++ b/nvim/.config/nvim/lazy-lock.json @@ -30,7 +30,6 @@ "nabla.nvim": { "branch": "master", "commit": "ddbfc6e244e79db9280c535ee85c81388c5d1b46" }, "navigator.lua": { "branch": "master", "commit": "66d84151e94052f710b1dfb0d1fce2faaca6dced" }, "neorg": { "branch": "main", "commit": "36cc15300c0dfc19d483b0a4176cb89e94f4730a" }, - "notational-fzf-vim": { "branch": "master", "commit": "75c2c31e7cd77397018c5777804666d648557537" }, "nui.nvim": { "branch": "main", "commit": "d147222a1300901656f3ebd5b95f91732785a329" }, "nvim-base16.lua": { "branch": "master", "commit": "b336f40462b3ca1ad16a17c195b83731a2942d9a" }, "nvim-cmp": { "branch": "main", "commit": "cfafe0a1ca8933f7b7968a287d39904156f2c57d" }, diff --git a/nvim/.config/nvim/lua/plugins.lua b/nvim/.config/nvim/lua/plugins.lua index 2653f71..31abaf4 100644 --- a/nvim/.config/nvim/lua/plugins.lua +++ b/nvim/.config/nvim/lua/plugins.lua @@ -59,12 +59,11 @@ return { }, {'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) - {'alok/notational-fzf-vim', event = "VeryLazy"}, -- quickly search through the wiki {'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, - event = "VeryLazy" + 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 From 7965036eed43084ec210c0ffcad3d6b6779c8a04 Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Fri, 10 Feb 2023 11:47:09 +0100 Subject: [PATCH 8/8] nvim: Add mapping description for which-key --- nvim/.config/nvim/lua/maps.lua | 159 ++++++++++++++++++++------------- 1 file changed, 95 insertions(+), 64 deletions(-) diff --git a/nvim/.config/nvim/lua/maps.lua b/nvim/.config/nvim/lua/maps.lua index f9c8fe5..bb41f83 100644 --- a/nvim/.config/nvim/lua/maps.lua +++ b/nvim/.config/nvim/lua/maps.lua @@ -40,19 +40,19 @@ local function wrap_down() return 'j' end -map('n', 'k', wrap_up, {expr = true}) -map('n', 'j', wrap_down, {expr = true}) +map('n', 'k', wrap_up, { expr = true }) +map('n', 'j', wrap_down, { expr = true }) -- move around between matching brackets with tab map('n', '', '%') -- when in insertion mode, C-u uppercases the current word, C-l lowercases it, -map('i', '', 'gUiw`]a') -map('i', '', 'guiw`]a') +map('i', '', 'gUiw`]a') +map('i', '', 'guiw`]a') -- yank current filename/filepath to f buffer -map('n', 'yp', ':let @p = expand("%")') -map('n', 'yP', ':let @p = expand("%:p")') +map('n', 'yp', ':let @p = expand("%")', { desc = 'yank filename' }) +map('n', 'yP', ':let @p = expand("%:p")', { desc = 'yank filepath' }) -- repeat the last substitute command with all its flags preserved map('n', '&', ':&&') @@ -82,75 +82,94 @@ vim.g.maplocalleader = "," -- FIXME does this work still (and is it necessary)? if vim.g.maplocalleader == ',' then map('', ',,', ',') - vim.keymap.del('', ',,', {silent=true}) + vim.keymap.del('', ',,', { silent = true }) end -- remove search highlights by pressing space+/ -map('n', '/', ':noh') +map('n', '/', ':noh', { desc = 'remove highlights' }) -- split buffers vertically/horizontally with the leader \ or - (mirrors my -- tmux setup) -map('n', '-', ':sp') -map('n', '\\', ':vsp') +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 .') +map('n', 't', ':vsp | Vifm', { desc = 'open buffer' }) -- open actual new tab with leader-T -map('n', 'T', ':tabedit .') +map('n', 'T', ':tabedit | Vifm', { desc = 'open tab' }) -- select the whole buffer with -a -map('n', 'a', 'ggVG') +map('n', 'a', 'ggVG', { desc = 'select all' }) -- PLUGIN: Navigator.nvim -map('n', 'h', 'lua require("Navigator").left()', {silent = true}) -map('n', 'k', 'lua require("Navigator").up()', {silent = true}) -map('n', 'l', 'lua require("Navigator").right()', {silent = true}) -map('n', 'j', 'lua require("Navigator").down()', {silent = true}) -map('n', 'p', 'lua require("Navigator").previous()', {silent = true}) +map('n', 'h', 'lua require("Navigator").left()', { silent = true }) +map('n', 'k', 'lua require("Navigator").up()', { silent = true }) +map('n', 'l', 'lua require("Navigator").right()', { silent = true }) +map('n', 'j', 'lua require("Navigator").down()', { silent = true }) +map('n', 'p', 'lua require("Navigator").previous()', + { silent = true }) -- PLUGIN: Vifm.vim -- open/close file tree with leader-e -map('n', 'e', ':Vifm') +map('n', 'e', ':Vifm', { desc = 'browse files' }) -- open current file tree with current file directory -map('n', 'E', ':Vifm getcwd()') +map('n', 'E', ':Vifm getcwd()', { desc = 'browse project' }) -- PLUGIN: Telescope GLOBAL FUZZY FINDING -- buffers and files in current workdir -map('n', 's',":lua require 'telescope.builtin'.buffers(require 'telescope.themes'.get_ivy())") +map('n', 's', + ":lua require 'telescope.builtin'.buffers(require 'telescope.themes'.get_ivy())", + { desc = 'list buffers' }) -- most recently used / MRU, bound to S since it is essentially a larger -- go-back intention than just buffers -map('n', 'S',":lua require 'telescope.builtin'.oldfiles(require 'telescope.themes'.get_ivy())") +map('n', 'S', + ":lua require 'telescope.builtin'.oldfiles(require 'telescope.themes'.get_ivy())", + { desc = 'list old files' }) -- fuzzy find files in cwd -map('n', 'f',":lua require 'telescope.builtin'.find_files()") +map('n', 'f', ":lua require 'telescope.builtin'.find_files()", + { desc = 'find files' }) -- fuzzy find hidden files in cwd -map('n', '',":lua require 'telescope.builtin'.find_files({hidden=true})") +map('n', '', + ":lua require 'telescope.builtin'.find_files({hidden=true})", + { desc = 'find hidden files' }) -- general full-text search in cwd with rg -map('n', 'F',":lua require 'telescope.builtin'.live_grep()") +map('n', 'F', ":lua require 'telescope.builtin'.live_grep()", + { desc = 'grep search' }) -- git status -map('n', 'gs',":lua require 'telescope.builtin'.git_status()") +map('n', 'gs', ":lua require 'telescope.builtin'.git_status()", + { desc = 'git status' }) -- git buffercommits -map('n', 'gb',":lua require 'telescope.builtin'.git_bcommits()") +map('n', 'gb', ":lua require 'telescope.builtin'.git_bcommits()", + { desc = 'git buffer commits' }) -- git commitlog -map('n', 'gl',":lua require 'telescope.builtin'.git_commits()") +map('n', 'gl', ":lua require 'telescope.builtin'.git_commits()", + { desc = 'git commit log' }) -- helptags -map('n', '',":lua require 'telescope.builtin'.help_tags()") +map('n', '', ":lua require 'telescope.builtin'.help_tags()", + { desc = 'help tags' }) -- manpages -map('n', '',":lua require 'telescope.builtin'.man_pages()") +map('n', '', ":lua require 'telescope.builtin'.man_pages()", + { desc = 'man pages' }) -- colorschemes -map('n', '',":lua require 'telescope.builtin'.colorscheme(require 'telescope.themes'.get_ivy())") +map('n', '', + ":lua require 'telescope.builtin'.colorscheme(require 'telescope.themes'.get_ivy())", + { desc = 'colorschemes' }) -- spell suggestions -map('n', 'z=',":lua require 'telescope.builtin'.spell_suggest(require 'telescope.themes'.get_ivy())") - +map('n', 'z=', + ":lua require 'telescope.builtin'.spell_suggest(require 'telescope.themes'.get_ivy())") -- Format current Paragraph (esp useful in prose writing) -map('n', 'q', 'gqap', {silent=true}) -map('x', 'q', 'gq', {silent=true}) -map('n', 'Q', 'vapJgqap', {silent=true}) +map('n', 'q', 'gqap', + { silent = true, desc = 'Format current paragraph' }) +map('x', 'q', 'gq', { silent = true, desc = 'Format {motion}' }) +map('n', 'Q', 'vapJgqap', + { silent = true, desc = 'Unformat then format paragraph' }) -map('n', 'mp', 'MarkdownPreviewToggle') +map('n', 'mp', 'MarkdownPreviewToggle', + { desc = 'Toggle md preview' }) -- FORMAT code with -- PLUGIN: formatter.nvim @@ -158,17 +177,20 @@ map('n', 'f', ':FormatLock') map('n', 'F', ':FormatWriteLock') -- Enter distraction free prose mode with F11 -map('n', '', ':ZenMode', {silent=true}) +map('n', '', ':ZenMode', { silent = true }) -- SPELL CHECKING -- Move to the prev/next spelling error with [S ]S -- Move to the prev/next spelling error or suggestion with [s ]s -map('n', 'ZZ', ':setlocal spell! spelllang=en_us,de_de') -map('n', 'ZE', ':setlocal spell! spelllang=en_us') -map('n', 'ZG', ':setlocal spell! spelllang=de_de') +map('n', 'ZZ', ':setlocal spell! spelllang=en_us,de_de', + { desc = 'Toggle spellcheck' }) +map('n', 'ZE', ':setlocal spell! spelllang=en_us', + { desc = 'Toggle EN spellcheck' }) +map('n', 'ZG', ':setlocal spell! spelllang=de_de', + { desc = 'Toggle DE spellcheck' }) -- undo last spelling mistake from insert and normal mode map('i', '', 'u[s1z=`]au') -map('n', 's', 'ms[s1z=`s') +map('n', 's', 'ms[s1z=`s', { desc = 'Fix last spell error' }) -- PLUGIN: easy-align -- Start interactive EasyAlign in visual mode (e.g. vipga) @@ -178,22 +200,26 @@ map('n', 'ga', '(EasyAlign)') -- PLUGIN: vnsip -- jump around in snippets -map('i', '', [[vsnip#jumpable(1) ? '(vsnip-jump-next)' : '']], {expr=true}) -map('i', '', [[vsnip#jumpable(-1) ? '(vsnip-jump-next)' : '']], {expr=true}) +map('i', '', [[vsnip#jumpable(1) ? '(vsnip-jump-next)' : '']], + { expr = true }) +map('i', '', + [[vsnip#jumpable(-1) ? '(vsnip-jump-next)' : '']], + { expr = true }) -- PLUGIN: symbols-outline.nvim -map('n', 'o', 'SymbolsOutline', {silent=true}) +map('n', 'o', 'SymbolsOutline', { silent = true }) -- trim trailing whitespaces with mini.nvim trailspace -map("n", "w", function() require("mini.trailspace").trim() end, {noremap = true}) +map("n", "w", function() require("mini.trailspace").trim() end, + { noremap = true }) -- PLUGIN: dial-increment -map("n", "", require("dial.map").inc_normal(), {noremap = true}) -map("n", "", require("dial.map").dec_normal(), {noremap = true}) -map("v", "", require("dial.map").inc_visual(), {noremap = true}) -map("v", "", require("dial.map").dec_visual(), {noremap = true}) -map("v", "g",require("dial.map").inc_gvisual(), {noremap = true}) -map("v", "g",require("dial.map").dec_gvisual(), {noremap = true}) +map("n", "", require("dial.map").inc_normal(), { noremap = true }) +map("n", "", require("dial.map").dec_normal(), { noremap = true }) +map("v", "", require("dial.map").inc_visual(), { noremap = true }) +map("v", "", require("dial.map").dec_visual(), { noremap = true }) +map("v", "g", require("dial.map").inc_gvisual(), { noremap = true }) +map("v", "g", require("dial.map").dec_gvisual(), { noremap = true }) -- PLUGIN: zettelkasten.nvim map('n', '', [[:silent lua require 'zettelkasten'.link_follow()]]) @@ -206,22 +232,27 @@ map('n', 'G', ':Lazygit') -- PLUGIN: magma-nvim -- Operate jupyter notebooks from within vim -map('n', 'mm', ':MagmaEvaluateLine', {silent=true}) -map('n', 'M', '?^```{jV/```k:MagmaEvaluateVisual', {silent=true}) -map('x', 'm', ':MagmaEvaluateVisual', {silent=true}) -map('n', 'm', "nvim_exec('MagmaEvaluateOperator', v:true)", {expr=true, silent=true}) -map('n', 'mr', ':MagmaReevaluateCell', {silent=true}) -map('n', 'ma', ':MagmaShowOutput', {silent=true}) -map('n', 'mq', ':noautocmd :MagmaEnterOutput', {silent=true}) -map('n', 'md', ':MagmaDelete', {silent=true}) +map('n', 'mm', ':MagmaEvaluateLine', { silent = true }) +map('n', 'M', '?^```{jV/```k:MagmaEvaluateVisual', + { silent = true, desc = 'Evaluate current quarto cell' }) +map('x', 'm', ':MagmaEvaluateVisual', { silent = true }) +map('n', 'm', "nvim_exec('MagmaEvaluateOperator', v:true)", + { expr = true, silent = true }) +map('n', 'mr', ':MagmaReevaluateCell', { silent = true }) +map('n', 'ma', ':MagmaShowOutput', { silent = true }) +map('n', 'mq', ':noautocmd :MagmaEnterOutput', + { silent = true, desc = 'MagmaEnterOutput' }) +map('n', 'md', ':MagmaDelete', { silent = true }) map('n', 'ms', ':MagmaInterrupt') map('n', 'mI', ':MagmaInit ') map('n', 'mD', ':MagmaDeinit') map('n', 'mR', ':MagmaRestart') -- jump to beginning of previous/ next cell code -map('n', ']c', '/^```{}:nohl') -map('n', '[c', '?^```n}:nohl') +map('n', ']c', '/^```{}:nohl', { desc = 'Next quarto cell' }) +map('n', '[c', '?^```n}:nohl', { desc = 'Previous quarto cell' }) -- insert cell header above/below -map('n', 'mo', 'o```{python}```k') -map('n', 'mO', 'O```{python}```k') +map('n', 'mo', 'o```{python}```k', + { desc = 'Insert quarto cell below' }) +map('n', 'mO', 'O```{python}```k', + { desc = 'Insert quarto cell above' })