From c03b88c6cc2ac88ab88c76b97fda08cff43db650 Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Thu, 6 Jun 2024 09:43:20 +0200 Subject: [PATCH 01/10] nvim: Formatting --- nvim/.config/nvim/lua/plugins/ide.lua | 5 +- nvim/.config/nvim/lua/plugins/prose.lua | 10 +++- nvim/.config/nvim/lua/plugins/ui.lua | 68 +++++++++++++++---------- 3 files changed, 53 insertions(+), 30 deletions(-) diff --git a/nvim/.config/nvim/lua/plugins/ide.lua b/nvim/.config/nvim/lua/plugins/ide.lua index 043030b..193d998 100644 --- a/nvim/.config/nvim/lua/plugins/ide.lua +++ b/nvim/.config/nvim/lua/plugins/ide.lua @@ -22,7 +22,9 @@ local formatters = { javascript = { { "prettierd", "prettier" } }, javascriptreact = { { "prettierd", "prettier" } }, json = { "jq" }, + liquid = { { "prettierd", "prettier" } }, lua = { "stylua" }, + markdown = { { "prettierd", "prettier" } }, python = { "ruff_fix", "ruff_format" }, sh = { "shfmt" }, svelte = { { "prettierd", "prettier" } }, @@ -123,7 +125,7 @@ return { end, }) end, - event = { "BufWritePost", "InsertLeave" }, + event = { "BufWritePre", "InsertEnter" }, }, -- formatting setup @@ -248,6 +250,7 @@ return { "nvim-neotest/neotest", dependencies = { "nvim-lua/plenary.nvim", + "nvim-neotest/nvim-nio", "nvim-treesitter/nvim-treesitter", "antoinemadec/FixCursorHold.nvim", diff --git a/nvim/.config/nvim/lua/plugins/prose.lua b/nvim/.config/nvim/lua/plugins/prose.lua index a5dcc7a..17d9646 100644 --- a/nvim/.config/nvim/lua/plugins/prose.lua +++ b/nvim/.config/nvim/lua/plugins/prose.lua @@ -71,7 +71,15 @@ local prose_plugs = { require("zk").edit(opts, { title = "Zk Orphans" }) end) end - require("zk").setup({ picker = "telescope" }) + require("zk").setup({ + picker = "telescope", + lsp = { + auto_attach = { + enabled = true, + filteypes = { "markdown", "quarto" }, + }, + }, + }) end, ft = writing_ft, cmd = { diff --git a/nvim/.config/nvim/lua/plugins/ui.lua b/nvim/.config/nvim/lua/plugins/ui.lua index 479e256..7e5690a 100644 --- a/nvim/.config/nvim/lua/plugins/ui.lua +++ b/nvim/.config/nvim/lua/plugins/ui.lua @@ -3,34 +3,46 @@ return { { "nvim-lualine/lualine.nvim", requires = { "nvim-tree/nvim-web-devicons", config = true }, - opts = { - options = { - icons_enabled = true, - theme = "auto", - component_separators = { left = "", right = "" }, - section_separators = { left = "", right = "" }, - disabled_filetypes = {}, - always_divide_middle = true, - }, - sections = { - lualine_a = { "mode" }, - lualine_b = { "branch", "diff", "diagnostics" }, - lualine_c = { "filename" }, - lualine_x = { "encoding", "fileformat", "filetype" }, - lualine_y = { "progress" }, - lualine_z = { "location" }, - }, - inactive_sections = { - lualine_a = {}, - lualine_b = { "branch", "diff" }, - lualine_c = { "filename" }, - lualine_x = {}, - lualine_y = { "location" }, - lualine_z = {}, - }, - tabline = {}, - extensions = { "quickfix", "toggleterm" }, - }, + config = function() + -- FIXME: Errors out on no pynvim installed + -- local function molten() + -- if + -- require("core.util").is_available("molten.status") + -- and require("molten.status").initialized() ~= "" + -- then + -- return "󱪄" + -- end + -- return "" + -- end + require("lualine").setup({ + options = { + icons_enabled = true, + theme = "auto", + component_separators = { left = "", right = "" }, + section_separators = { left = "", right = "" }, + disabled_filetypes = {}, + always_divide_middle = true, + }, + sections = { + lualine_a = { "mode" }, + lualine_b = { "branch", "diff", "diagnostics" }, + lualine_c = { "filename" }, + lualine_x = { "encoding", "fileformat", "filetype", "molten" }, + lualine_y = { "progress" }, + lualine_z = { "location" }, + }, + inactive_sections = { + lualine_a = {}, + lualine_b = { "branch", "diff" }, + lualine_c = { "filename" }, + lualine_x = {}, + lualine_y = { "location" }, + lualine_z = {}, + }, + tabline = {}, + extensions = { "quickfix", "toggleterm" }, + }) + end, event = { "BufNewFile", "BufAdd", "BufWinEnter" }, }, -- create pretty unobtrusive notifications From cb21789f3acb52007c319074005a9b99e81188a3 Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Thu, 6 Jun 2024 09:45:34 +0200 Subject: [PATCH 02/10] nvim: Add mapping for inlay hints `li` will show inlay hints if they are available for the active LSP server. --- nvim/.config/nvim/lua/plugins/config/lsp.lua | 3 +++ 1 file changed, 3 insertions(+) diff --git a/nvim/.config/nvim/lua/plugins/config/lsp.lua b/nvim/.config/nvim/lua/plugins/config/lsp.lua index c5b8b52..68eb1ca 100644 --- a/nvim/.config/nvim/lua/plugins/config/lsp.lua +++ b/nvim/.config/nvim/lua/plugins/config/lsp.lua @@ -77,6 +77,9 @@ local function on_attach(client, bufnr) "lua vim.diagnostic.open_float()", { buffer = bufnr, desc = "Line diagnostics" } ) + map("n", "li", function() + vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled()) + end, { buffer = bufnr, desc = "Inlay hints" }) 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(":Glance") then From 434974284aef08425db845c491e7358c3aa1a16c Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Thu, 6 Jun 2024 09:58:25 +0200 Subject: [PATCH 03/10] nvim: Fix flash for search and operator pending flash.nvim was activating on searches which, while perhaps useful for some people, was not for me. It stops the (incremental) search as soon as no valid target exists which drops you back into normal mode while still typing out the search and thus doing who-knows-what. The operator pending mode for the original jump mapping has been removed to allow the 'surround' mappings from mini plugin to always work correctly (`ysiw`, `csaw`, ...). --- nvim/.config/nvim/lua/plugins/core.lua | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/nvim/.config/nvim/lua/plugins/core.lua b/nvim/.config/nvim/lua/plugins/core.lua index baf7705..839a1c4 100644 --- a/nvim/.config/nvim/lua/plugins/core.lua +++ b/nvim/.config/nvim/lua/plugins/core.lua @@ -51,7 +51,7 @@ return { keys = { { "s", - mode = { "n", "x", "o" }, + mode = { "n", "x" }, function() require("flash").jump() end, @@ -73,22 +73,6 @@ return { end, desc = "Remote Flash", }, - { - "R", - mode = { "o", "x" }, - function() - require("flash").treesitter_search() - end, - desc = "Treesitter Search", - }, - { - "", - mode = { "c" }, - function() - require("flash").toggle() - end, - desc = "Toggle Flash Search", - }, }, }, From 7fd32f873a76fbe94842418bc0d485bcd81bd49c Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Thu, 6 Jun 2024 10:12:24 +0200 Subject: [PATCH 04/10] nvim: Change cmp results order and icons Made lsp and LaTeX icons a little less obnoxious, and fixed order to better load more pertinent results. --- nvim/.config/nvim/lua/plugins/config/cmp.lua | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/nvim/.config/nvim/lua/plugins/config/cmp.lua b/nvim/.config/nvim/lua/plugins/config/cmp.lua index 31db206..49840cc 100644 --- a/nvim/.config/nvim/lua/plugins/config/cmp.lua +++ b/nvim/.config/nvim/lua/plugins/config/cmp.lua @@ -42,11 +42,6 @@ cmp.setup({ end, }, sources = { - { name = "nvim_lsp" }, - { name = "nvim_lsp_signature_help" }, - { name = "otter" }, - { name = "luasnip", keyword_length = 2 }, - { name = "pandoc_references" }, { name = "nvim_lua" }, { name = "beancount", @@ -54,6 +49,11 @@ cmp.setup({ account = vim.env["HOME"] .. "/documents/records/budget/main.beancount", -- TODO implement dynamically }, }, + { name = "otter" }, + { name = "nvim_lsp" }, + { name = "nvim_lsp_signature_help" }, + { name = "luasnip", keyword_length = 2 }, + { name = "pandoc_references" }, { name = "calc" }, { name = "path" }, { name = "buffer", keyword_length = 3 }, @@ -61,7 +61,7 @@ cmp.setup({ { name = "spell", keyword_length = 3 }, { name = "tmux" }, -- { name = 'rg', keyword_length = 5 }, { name = "vCard" }, - { name = "digraphs" }, + { name = "digraphs", keyword_length = 2 }, }, mapping = cmp.mapping.preset.insert({ [""] = cmp.mapping.scroll_docs(-4), @@ -117,10 +117,10 @@ cmp.setup({ vim_item.menu = ({ buffer = "", calc = "󰃬", - digraphs = "", - latex_symbols = "󰊄", + digraphs = "∬", + latex_symbols = "𝓧", luasnip = "", - nvim_lsp = "", + nvim_lsp = "ℒ", nvim_lua = "󰢱", pandoc_references = "", spell = "󰓆", From e939305df398c1348c6412c08cc10962baa0c22f Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Thu, 6 Jun 2024 10:25:08 +0200 Subject: [PATCH 05/10] nvim: Update plugins --- nvim/.config/nvim/lazy-lock.json | 109 ++++++++++++++++--------------- 1 file changed, 56 insertions(+), 53 deletions(-) diff --git a/nvim/.config/nvim/lazy-lock.json b/nvim/.config/nvim/lazy-lock.json index 292b56d..24c8cdf 100644 --- a/nvim/.config/nvim/lazy-lock.json +++ b/nvim/.config/nvim/lazy-lock.json @@ -1,87 +1,90 @@ { - "Arduino.nvim": { "branch": "main", "commit": "fad71572bf7a79b88da38167a756259b03d0c3ef" }, + "Arduino.nvim": { "branch": "main", "commit": "7fd0f58c6f7a460ef180ef3bc9715baa37e9dd36" }, "BetterLua.vim": { "branch": "master", "commit": "d2d6c115575d09258a794a6f20ac60233eee59d5" }, "FixCursorHold.nvim": { "branch": "master", "commit": "1900f89dc17c603eec29960f57c00bd9ae696495" }, - "LuaSnip": { "branch": "master", "commit": "8ae1dedd988eb56441b7858bd1e8554dfadaa46d" }, + "LuaSnip": { "branch": "master", "commit": "03c8e67eb7293c404845b3982db895d59c0d1538" }, "Navigator.nvim": { "branch": "master", "commit": "91d86506ac2a039504d5205d32a1d4bc7aa57072" }, - "aerial.nvim": { "branch": "master", "commit": "3748e87a316a68754341cdffcef44fee61dee51c" }, + "aerial.nvim": { "branch": "master", "commit": "4d10acbcb760802ea74381ac3ed98cbb6e5f7805" }, "bats.vim": { "branch": "master", "commit": "6a5d2ef22b0ede503d867770afd02ebb1f97b709" }, - "cmp-beancount": { "branch": "main", "commit": "da154ea94d598e6649d6ad01efa0a8611eff460d" }, + "cmp-beancount": { "branch": "main", "commit": "c8a2533828b84546ae279d60137aec92bd52dc72" }, "cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" }, - "cmp-calc": { "branch": "main", "commit": "ce91d14d2e7a8b3f6ad86d85e34d41c1ae6268d9" }, - "cmp-cmdline": { "branch": "main", "commit": "8ee981b4a91f536f52add291594e89fb6645e451" }, + "cmp-calc": { "branch": "main", "commit": "5947b412da67306c5b68698a02a846760059be2e" }, + "cmp-cmdline": { "branch": "main", "commit": "d250c63aa13ead745e3a40f61fdd3470efde3923" }, "cmp-digraphs": { "branch": "master", "commit": "5efc1f0078d7c5f3ea1c8e3aad04da3fd6e081a9" }, - "cmp-nvim-lsp": { "branch": "main", "commit": "5af77f54de1b16c34b23cba810150689a3a90312" }, - "cmp-nvim-lsp-signature-help": { "branch": "main", "commit": "3d8912ebeb56e5ae08ef0906e3a54de1c66b92f1" }, + "cmp-latex-symbols": { "branch": "main", "commit": "165fb66afdbd016eaa1570e41672c4c557b57124" }, + "cmp-nvim-lsp": { "branch": "main", "commit": "39e2eda76828d88b773cc27a3f61d2ad782c922d" }, + "cmp-nvim-lsp-signature-help": { "branch": "main", "commit": "031e6ba70b0ad5eee49fd2120ff7a2e325b17fa7" }, "cmp-nvim-lua": { "branch": "main", "commit": "f12408bdb54c39c23e67cab726264c10db33ada8" }, "cmp-pandoc-references": { "branch": "master", "commit": "2c808dff631a783ddd2c554c4c6033907589baf6" }, "cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" }, "cmp-rg": { "branch": "master", "commit": "677a7874ee8f1afc648c2e7d63a97bc21a7663c5" }, - "cmp-spell": { "branch": "master", "commit": "32a0867efa59b43edbb2db67b0871cfad90c9b66" }, - "cmp-treesitter": { "branch": "master", "commit": "13e4ef8f4dd5639fca2eb9150e68f47639a9b37d" }, + "cmp-spell": { "branch": "master", "commit": "694a4e50809d6d645c1ea29015dad0c293f019d6" }, + "cmp-tmux": { "branch": "main", "commit": "95b1b921802e6f60627b3e76afb9380fddd87f9a" }, + "cmp-treesitter": { "branch": "master", "commit": "958fcfa0d8ce46d215e19cc3992c542f576c4123" }, "cmp_luasnip": { "branch": "master", "commit": "05a9ab28b53f71d1aece421ef32fee2cb857a843" }, "completion-vcard": { "branch": "master", "commit": "2220fd517a985ececed1adcf0e5be8f2815564c7" }, - "conform.nvim": { "branch": "master", "commit": "3d59cbd01a4b74124c5a6fb23b8cc63e5c2db3d5" }, + "conform.nvim": { "branch": "master", "commit": "9b26e81c4292106e68dda3e7b64473434fd5b3e0" }, "dial.nvim": { "branch": "master", "commit": "54b503f906bc9e5ab85288414840a1b86d40769f" }, - "dressing.nvim": { "branch": "master", "commit": "42d767b04c50a6966c9633e3968bc65c0c2f2bfc" }, - "fidget.nvim": { "branch": "main", "commit": "a3e1e79116ceb93d4c8c0ff432bf506b3213a24d" }, - "friendly-snippets": { "branch": "main", "commit": "b8fae73a479ae0a1c54f5c98fa687ae8a0addc53" }, + "dressing.nvim": { "branch": "master", "commit": "572314728cb1ce012e825fd66331f52c94acac12" }, + "fidget.nvim": { "branch": "main", "commit": "ef99df04a1c53a453602421bc0f756997edc8289" }, + "flash.nvim": { "branch": "main", "commit": "7bb4a9c75d1e20cd24185afedeaa11681829ba23" }, + "friendly-snippets": { "branch": "main", "commit": "e11b09bf10706bb74e16e4c3d11b2274d62e687f" }, "fwatch.nvim": { "branch": "main", "commit": "a691f7349dc66285cd75a1a698dd28bca45f2bf8" }, - "git-conflict.nvim": { "branch": "main", "commit": "4c8e252b87d54d944c1e56bfb477f78b6fdaf661" }, - "gitsigns.nvim": { "branch": "main", "commit": "6ef8c54fb526bf3a0bc4efb0b2fe8e6d9a7daed2" }, - "glance.nvim": { "branch": "master", "commit": "8ed5cf3b3b1231ea696d88c9efd977027429d869" }, - "headlines.nvim": { "branch": "master", "commit": "d39c4e6ed8963717bc9b2dc39fada8fe1039e9bf" }, - "image.nvim": { "branch": "master", "commit": "9b6248bd8b58b505559e31eb581b7c4638369ec3" }, - "lazy.nvim": { "branch": "main", "commit": "28126922c9b54e35a192ac415788f202c3944c9f" }, - "lightspeed.nvim": { "branch": "main", "commit": "fcc72d8a4d5f4ebba62d8a3a0660f88f1b5c3b05" }, - "lsp-setup.nvim": { "branch": "main", "commit": "22ba14fb5c4208fd93f616d7b99bb47656e6e144" }, - "lualine.nvim": { "branch": "master", "commit": "7d131a8d3ba5016229e8a1d08bf8782acea98852" }, + "git-conflict.nvim": { "branch": "main", "commit": "bfd9fe6fba9a161fc199771d85996236a0d0faad" }, + "gitsigns.nvim": { "branch": "main", "commit": "76927d14d3fbd4ba06ccb5246e79d93b5442c188" }, + "glance.nvim": { "branch": "master", "commit": "51059bcf21016387b6233c89eed220cf47fca752" }, + "headlines.nvim": { "branch": "master", "commit": "618ef1b2502c565c82254ef7d5b04402194d9ce3" }, + "image.nvim": { "branch": "master", "commit": "da64ce69598875c9af028afe129f916b02ccc42e" }, + "lazy.nvim": { "branch": "main", "commit": "b0ba3f9399bf48c86abaa4db1a40bd0b681d5018" }, + "lsp-setup.nvim": { "branch": "main", "commit": "6e4e977512ce426d8b52c27f3b6e6aefc73e1452" }, + "lualine.nvim": { "branch": "master", "commit": "0a5a66803c7407767b799067986b4dc3036e1983" }, "markdown-preview.nvim": { "branch": "master", "commit": "9becceee5740b7db6914da87358a183ad11b2049" }, - "markmap.nvim": { "branch": "main", "commit": "3befc2a54c2448a16c30c1c7762aab263f22946a" }, - "mason-lspconfig.nvim": { "branch": "main", "commit": "56e435e09f8729af2d41973e81a0db440f8fe9c9" }, - "mason-tool-installer.nvim": { "branch": "main", "commit": "bf0f4f8062d3acbe0afcc61db01a4d19d96310e4" }, + "markmap.nvim": { "branch": "main", "commit": "5fb6755cf5434511cc23a4936c9eb76b9142fba5" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "9ae570e206360e47d30b4c35a4550c165f4ea7b7" }, + "mason-tool-installer.nvim": { "branch": "main", "commit": "c5e07b8ff54187716334d585db34282e46fa2932" }, "mason.nvim": { "branch": "main", "commit": "c43eeb5614a09dc17c03a7fb49de2e05de203924" }, - "mini.nvim": { "branch": "main", "commit": "b5645ac6eefce8e7af9d7dd4e5e296a81cba8a10" }, - "molten-nvim": { "branch": "main", "commit": "21d766c2d60e5f6e03f507e7f3e382a2a927ad41" }, - "neogen": { "branch": "main", "commit": "cb1f384df804c1bf729332c4f728253fe17962d4" }, - "neotest": { "branch": "master", "commit": "b47c99265253f0a31a428b698c59ec0bc956e78d" }, + "mini.nvim": { "branch": "main", "commit": "f24747266a047617d06605a2316aa6c071662fa2" }, + "molten-nvim": { "branch": "main", "commit": "df5ccef3b6fda3582f7746e45327ee031f668826" }, + "neogen": { "branch": "main", "commit": "0daffcec249bf42275e322361fe55b89a05ff278" }, + "neotest": { "branch": "master", "commit": "6f35d797882c6ce0ab7c87dc86561512dc3d7aba" }, "neotest-python": { "branch": "master", "commit": "81d2265efac717bb567bc15cc652ae10801286b3" }, - "nvim-cmp": { "branch": "main", "commit": "04e0ca376d6abdbfc8b52180f8ea236cbfddf782" }, + "nvim-cmp": { "branch": "main", "commit": "5260e5e8ecadaf13e6b82cf867a909f54e15fd07" }, "nvim-colorizer.lua": { "branch": "master", "commit": "85855b38011114929f4058efc97af1059ab3e41d" }, - "nvim-coverage": { "branch": "main", "commit": "cf4b5c61dfac977026a51a2bcad9173c272986ce" }, - "nvim-lint": { "branch": "master", "commit": "966ab3dc37eee3e413692264b44a3011b05a6060" }, - "nvim-lspconfig": { "branch": "master", "commit": "41f40dc4b86f3e166cf08115f621001972565a20" }, - "nvim-surround": { "branch": "main", "commit": "703ec63aa798e5e07d309b35e42def34bebe0174" }, - "nvim-toggleterm.lua": { "branch": "main", "commit": "cbd041d91b90cd3c02df03fe6133208888f8e008" }, - "nvim-tree.lua": { "branch": "master", "commit": "f1b3e6a7eb92da492bd693257367d9256839ed3d" }, + "nvim-coverage": { "branch": "main", "commit": "aa4b4400588e2259e87e372b1e4e90ae13cf5a39" }, + "nvim-lint": { "branch": "master", "commit": "1a3a8d047bc01f1760ae4a0f5e80f111ea222e67" }, + "nvim-lspconfig": { "branch": "master", "commit": "d1ab6b6051976b04948e127b0f302a465b1394d6" }, + "nvim-nio": { "branch": "master", "commit": "8765cbc4d0c629c8158a5341e1b4305fd93c3a90" }, + "nvim-surround": { "branch": "main", "commit": "f1f0699a1d49f28e607ffa4361f1bbe757ac5ebc" }, + "nvim-toggleterm.lua": { "branch": "main", "commit": "066cccf48a43553a80a210eb3be89a15d789d6e6" }, + "nvim-tree.lua": { "branch": "master", "commit": "2bc725a3ebc23f0172fb0ab4d1134b81bcc13812" }, "nvim-treesitter": { "branch": "master", "commit": "f197a15b0d1e8d555263af20add51450e5aaa1f0" }, - "nvim-treesitter-context": { "branch": "master", "commit": "9c06b115abc57c99cf0aa81dc29490f5001f57a1" }, - "nvim-treesitter-endwise": { "branch": "master", "commit": "4c344ffc8d54d7e1ba2cefaaa2c10ea93aa1cc2d" }, - "nvim-treesitter-textsubjects": { "branch": "master", "commit": "55d11124c45e9bb506703f73e5775652ed5357e9" }, - "nvim-ts-autotag": { "branch": "main", "commit": "531f48334c422222aebc888fd36e7d109cb354cd" }, - "nvim-ts-context-commentstring": { "branch": "main", "commit": "7ab799a9792f7cf3883cf28c6a00ad431f3d382a" }, - "nvim-ts-rainbow2": { "branch": "master", "commit": "b3120cd5ae9ca524af9cb602f41e12e301fa985f" }, - "nvim-web-devicons": { "branch": "master", "commit": "a55b801b7ef5719ca25692c3a0a5447fdfb692ed" }, - "otter.nvim": { "branch": "main", "commit": "cf29fc255bce78fd03565b40722438c0ab3ce05d" }, + "nvim-treesitter-context": { "branch": "master", "commit": "5efba33af0f39942e426340da7bc15d7dec16474" }, + "nvim-treesitter-endwise": { "branch": "master", "commit": "8b34305ffc28bd75a22f5a0a9928ee726a85c9a6" }, + "nvim-treesitter-textsubjects": { "branch": "master", "commit": "1428108f18ce9d8cc4481dcedebeeb490eabf395" }, + "nvim-ts-autotag": { "branch": "main", "commit": "6eb4120a1aadef07ac312f1c4bc6456712220007" }, + "nvim-ts-context-commentstring": { "branch": "main", "commit": "cb064386e667def1d241317deed9fd1b38f0dc2e" }, + "nvim-web-devicons": { "branch": "master", "commit": "5b9067899ee6a2538891573500e8fd6ff008440f" }, + "otter.nvim": { "branch": "main", "commit": "5cd161f28835fada50d99c89dc05041565a27bdb" }, "plenary.nvim": { "branch": "master", "commit": "50012918b2fc8357b87cff2a7f7f0446e47da174" }, "popup.nvim": { "branch": "master", "commit": "b7404d35d5d3548a82149238289fa71f7f6de4ac" }, - "quarto-nvim": { "branch": "main", "commit": "0a35b3890e9d723b730506d7d8b3ba3d0d6aae2e" }, + "quarto-nvim": { "branch": "main", "commit": "67e09027b5d8bd948907734fc6fb15028ffdcd28" }, + "rainbow-delimiters.nvim": { "branch": "master", "commit": "12b1a1e095d968887a17ef791c2edb78d7595d46" }, "smartcolumn.nvim": { "branch": "main", "commit": "d01b99355c7fab13233f48d0f28dc097e68a03f7" }, "stickybuf.nvim": { "branch": "master", "commit": "2160fcd536d81f5fa43f7167dba6634e814e3154" }, - "telescope-fzf-native.nvim": { "branch": "main", "commit": "6c921ca12321edaa773e324ef64ea301a1d0da62" }, - "telescope.nvim": { "branch": "master", "commit": "d90956833d7c27e73c621a61f20b29fdb7122709" }, - "trouble.nvim": { "branch": "main", "commit": "f1168feada93c0154ede4d1fe9183bf69bac54ea" }, + "telescope-fzf-native.nvim": { "branch": "main", "commit": "9ef21b2e6bb6ebeaf349a0781745549bbb870d27" }, + "telescope.nvim": { "branch": "master", "commit": "a0bbec21143c7bc5f8bb02e0005fa0b982edc026" }, + "trouble.nvim": { "branch": "main", "commit": "46a19388d3507f4c4bebb9994bf821a79b3bc342" }, "twilight.nvim": { "branch": "main", "commit": "8bb7fa7b918baab1ca81b977102ddb54afa63512" }, "undotree": { "branch": "main", "commit": "eab459ab87dd249617b5f7187bb69e614a083047" }, "vifm.vim": { "branch": "master", "commit": "a8130c37d144b51d84bee19f0532abcd3583383f" }, "vim-criticmarkup": { "branch": "master", "commit": "d15dc134eb177a170c79f6377f81eb02a9d20b02" }, "vim-easy-align": { "branch": "master", "commit": "0db4ea6132110631ec678a99a82aa49a0686ae65" }, - "vim-exchange": { "branch": "master", "commit": "d6c1e9790bcb8df27c483a37167459bbebe0112e" }, "vim-numbertoggle": { "branch": "main", "commit": "df9b1fe616507340718716204ba7f434125bdf7a" }, "vim-pandoc-syntax": { "branch": "master", "commit": "16939cda184ff555938cc895cc62477c172997f9" }, + "vim-scimark": { "branch": "master", "commit": "9b66a88fa4bb87b8baab3c4aecc43b985b32e7fd" }, "vim-spellsync": { "branch": "master", "commit": "3d6dd50de9c4d953cc16638112a6ae196df41463" }, - "which-key.nvim": { "branch": "main", "commit": "ce741eb559c924d72e3a67d2189ad3771a231414" }, - "wrapping.nvim": { "branch": "master", "commit": "5e87f1424c86c50d3bc205830aa56ed1cad45467" }, + "which-key.nvim": { "branch": "main", "commit": "4b7167f8fb2dba3d01980735e3509e172c024c29" }, + "wrapping.nvim": { "branch": "master", "commit": "3a823200c297885b70515fa8d974e1763c578e26" }, "zen-mode.nvim": { "branch": "main", "commit": "cb73b8bd0ef9d765b942db09dc762c603a89ae44" }, - "zk-nvim": { "branch": "main", "commit": "fb0962b75a680561f94cae0588b8da92ea8d2fae" } + "zk-nvim": { "branch": "main", "commit": "66b9b490e930fb77f93a2a0c64e0da9a5144fd0a" } } \ No newline at end of file From 405af0f02036f809c4ef193268c35da16390f529 Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Thu, 6 Jun 2024 10:39:41 +0200 Subject: [PATCH 06/10] nvim: Move util to core.util module Moved all utility functions from their own directory into the core functionality direcotyr as a single file. --- nvim/.config/nvim/after/ftplugin/quarto.lua | 2 +- nvim/.config/nvim/lua/core/mappings.lua | 2 +- .../lua/{util/pyenv.lua => core/util.lua} | 30 ++++++++++++++----- nvim/.config/nvim/lua/plugins/config/lsp.lua | 6 ++-- nvim/.config/nvim/lua/plugins/core.lua | 2 +- nvim/.config/nvim/lua/plugins/ide.lua | 2 +- nvim/.config/nvim/lua/plugins/prose.lua | 2 +- nvim/.config/nvim/lua/plugins/telescope.lua | 2 +- nvim/.config/nvim/lua/plugins/ui.lua | 2 +- nvim/.config/nvim/lua/util/highlight.lua | 17 ----------- nvim/.config/nvim/lua/util/init.lua | 24 --------------- 11 files changed, 32 insertions(+), 59 deletions(-) rename nvim/.config/nvim/lua/{util/pyenv.lua => core/util.lua} (50%) delete mode 100644 nvim/.config/nvim/lua/util/highlight.lua delete mode 100644 nvim/.config/nvim/lua/util/init.lua diff --git a/nvim/.config/nvim/after/ftplugin/quarto.lua b/nvim/.config/nvim/after/ftplugin/quarto.lua index fff645a..18d1d03 100644 --- a/nvim/.config/nvim/after/ftplugin/quarto.lua +++ b/nvim/.config/nvim/after/ftplugin/quarto.lua @@ -13,7 +13,7 @@ end -- Start quarto session local startsession = function(file, args) file = file or default_buffer_session() - local path = require("util").get_python_venv() + local path = require("core.util").get_python_venv() vim.g["python3_host_prog"] = path if vim.fn.executable("jupyter-console") ~= 1 then diff --git a/nvim/.config/nvim/lua/core/mappings.lua b/nvim/.config/nvim/lua/core/mappings.lua index 2e8a6dc..a4d3028 100644 --- a/nvim/.config/nvim/lua/core/mappings.lua +++ b/nvim/.config/nvim/lua/core/mappings.lua @@ -1,5 +1,5 @@ local map = vim.keymap.set -local is_available = require("util").is_available +local is_available = require("core.util").is_available if is_available("which-key") then local prefix = require("which-key").register diff --git a/nvim/.config/nvim/lua/util/pyenv.lua b/nvim/.config/nvim/lua/core/util.lua similarity index 50% rename from nvim/.config/nvim/lua/util/pyenv.lua rename to nvim/.config/nvim/lua/core/util.lua index c3e89b6..d83d8f0 100644 --- a/nvim/.config/nvim/lua/util/pyenv.lua +++ b/nvim/.config/nvim/lua/core/util.lua @@ -1,22 +1,37 @@ local T = {} -local exepath = vim.fn.exepath -local function path_join(...) -return table.concat(vim.tbl_flatten { ... }, '/') +-- 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) + return T.get_plugin(plugin) and true or false +end + +-- Get the plugin file handle if it exists, return nil otherwise +function T.get_plugin(plugin) + local status, lib = pcall(require, plugin) + if status then + return lib + end + return nil end -- from https://github.com/ray-x/navigator.lua/issues/247#issue-1465308677 -T.get_path = function(workspace) +local function path_join(...) + return table.concat(vim.tbl_flatten({ ... }), "/") +end +-- return the current python environment path +function T.get_python_venv(workspace) -- Use activated virtualenv. if vim.env.VIRTUAL_ENV then return path_join(vim.env.VIRTUAL_ENV, "bin", "python") end - -- Find and use virtualenv in workspace directory. for _, pattern in ipairs({ "*", ".*" }) do local match = vim.fn.glob(path_join(workspace, pattern, "pyvenv.cfg")) if match ~= "" then - local py = path_join("bin", "python") + local py = path_join("bin", "python") match = string.gsub(match, "pyvenv.cfg", py) return match end @@ -26,9 +41,8 @@ T.get_path = function(workspace) return path_join(venv_base_folder, "bin", "python") end end - -- Fallback to system Python. - return exepath("python3") or exepath("python") or "python" + return vim.fn.exepath("python3") or vim.fn.exepath("python") or "python" end return T diff --git a/nvim/.config/nvim/lua/plugins/config/lsp.lua b/nvim/.config/nvim/lua/plugins/config/lsp.lua index 68eb1ca..d4e42a7 100644 --- a/nvim/.config/nvim/lua/plugins/config/lsp.lua +++ b/nvim/.config/nvim/lua/plugins/config/lsp.lua @@ -165,7 +165,7 @@ local python_path lspconfig.pyright.setup({ on_attach = function(client, bufnr) if python_path == nil then - python_path, _ = require("util").get_python_venv(client.config.root_dir) + python_path, _ = require("core.util").get_python_venv(client.config.root_dir) end -- print(string.format("[PYTHON VENV]: %s", vim.inspect(python_path))) client.config.settings.python.pythonPath = python_path @@ -176,14 +176,14 @@ lspconfig.ruff_lsp.setup({ on_attach = function(client, bufnr) on_attach(client, bufnr) if python_path == nil then - python_path, _ = require("util").get_python_venv(client.config.root_dir) + python_path, _ = require("core.util").get_python_venv(client.config.root_dir) end 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 +if require("core.util").is_available("arduino") then lspconfig.arduino_language_server.setup({ on_new_config = require("arduino").on_new_config, }) diff --git a/nvim/.config/nvim/lua/plugins/core.lua b/nvim/.config/nvim/lua/plugins/core.lua index 839a1c4..92414dc 100644 --- a/nvim/.config/nvim/lua/plugins/core.lua +++ b/nvim/.config/nvim/lua/plugins/core.lua @@ -111,7 +111,7 @@ return { hooks = { pre = function() -- use treesitter commentstring functionality if it's installed - if require("util").is_available("ts_context_commentstring") then + if require("core.util").is_available("ts_context_commentstring") then require("ts_context_commentstring.internal").update_commentstring() end end, diff --git a/nvim/.config/nvim/lua/plugins/ide.lua b/nvim/.config/nvim/lua/plugins/ide.lua index 193d998..c13ff31 100644 --- a/nvim/.config/nvim/lua/plugins/ide.lua +++ b/nvim/.config/nvim/lua/plugins/ide.lua @@ -265,7 +265,7 @@ return { }), }, }) - if require("util").is_available("which-key") then + if require("core.util").is_available("which-key") then require("which-key").register({ ["t"] = { name = "+test" } }) end end, diff --git a/nvim/.config/nvim/lua/plugins/prose.lua b/nvim/.config/nvim/lua/plugins/prose.lua index 17d9646..29b60c6 100644 --- a/nvim/.config/nvim/lua/plugins/prose.lua +++ b/nvim/.config/nvim/lua/plugins/prose.lua @@ -60,7 +60,7 @@ local prose_plugs = { { "mickael-menu/zk-nvim", config = function() - if require("util").is_available("which-key") then + if require("core.util").is_available("which-key") then local prefix = require("which-key").register prefix({ ["n"] = { name = "+notes" } }) prefix({ ["n"] = { name = "+note" } }) diff --git a/nvim/.config/nvim/lua/plugins/telescope.lua b/nvim/.config/nvim/lua/plugins/telescope.lua index 91e3e97..08fa63c 100644 --- a/nvim/.config/nvim/lua/plugins/telescope.lua +++ b/nvim/.config/nvim/lua/plugins/telescope.lua @@ -9,7 +9,7 @@ return { }, cmd = "Telescope", config = function() - if require("util").is_available("which-key") then + if require("core.util").is_available("which-key") then require("which-key").register({ ["f"] = { name = "+find" } }) end -- Setup up telescope fuzzy finding settings diff --git a/nvim/.config/nvim/lua/plugins/ui.lua b/nvim/.config/nvim/lua/plugins/ui.lua index 7e5690a..069051a 100644 --- a/nvim/.config/nvim/lua/plugins/ui.lua +++ b/nvim/.config/nvim/lua/plugins/ui.lua @@ -136,7 +136,7 @@ return { 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 + if require("core.util").is_available("mini.nvim") then vim.api.nvim_create_autocmd({ "TermOpen" }, { pattern = "*", callback = function() diff --git a/nvim/.config/nvim/lua/util/highlight.lua b/nvim/.config/nvim/lua/util/highlight.lua deleted file mode 100644 index d4c2e99..0000000 --- a/nvim/.config/nvim/lua/util/highlight.lua +++ /dev/null @@ -1,17 +0,0 @@ --- helper for easily defining highlight groups --- --- usage example - italicize comments: --- set_hl("Comment", { gui = "italic" }) -return function(group, options) - local bg = options.bg == nil and "" or "guibg=" .. options.bg - local fg = options.fg == nil and "" or "guifg=" .. options.fg - local gui = options.gui == nil and "" or "gui=" .. options.gui - local link = options.link or false - local target = options.target - - if not link then - vim.cmd(string.format("hi %s %s %s %s", group, bg, fg, gui)) - else - vim.cmd(string.format("hi! link", group, target)) - end -end diff --git a/nvim/.config/nvim/lua/util/init.lua b/nvim/.config/nvim/lua/util/init.lua deleted file mode 100644 index c200e2f..0000000 --- a/nvim/.config/nvim/lua/util/init.lua +++ /dev/null @@ -1,24 +0,0 @@ -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) - return T.get_plugin(plugin) and true or false -end - --- Get the plugin file handle if it exists, return nil otherwise -function T.get_plugin(plugin) - local status, lib = pcall(require, plugin) - if(status) then return lib end - return nil -end - --- get the current python environment --- return its path -function T.get_python_venv(workspace) - return require("util.pyenv").get_path(workspace) -end - -return T From 989081abfceae8385000cb39bcb2a6bad03cb726 Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Thu, 6 Jun 2024 15:40:01 +0200 Subject: [PATCH 07/10] nvim: Only register markdown which-keys if available Check for availability of which-key plugin before setting up layer key descriptions. --- nvim/.config/nvim/after/ftplugin/markdown.lua | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/nvim/.config/nvim/after/ftplugin/markdown.lua b/nvim/.config/nvim/after/ftplugin/markdown.lua index 739dcf6..19696ba 100644 --- a/nvim/.config/nvim/after/ftplugin/markdown.lua +++ b/nvim/.config/nvim/after/ftplugin/markdown.lua @@ -1,6 +1,9 @@ local map = vim.keymap.set -require("which-key").register({ ["c"] = { name = "+md-code" } }) -require("which-key").register({ ["e"] = { name = "+criticmarkup" } }) + +if require("core.util").is_available("which-key") then + require("which-key").register({ ["c"] = { name = "+codecells" } }) + require("which-key").register({ ["e"] = { name = "+criticmarkup" } }) +end if require("zk.util").notebook_root(vim.fn.expand("%:p")) ~= nil then map("n", "", "lua vim.lsp.buf.definition()", { silent = true }) From b37650ac0341dcc18c99af3498bfff79bc5095a0 Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Thu, 6 Jun 2024 15:42:12 +0200 Subject: [PATCH 08/10] nvim: Re-enable femaco plugin Since it in fact works wonderfully now, we re-enable FeMaco, allowing to edit codeblocks in markdown-like environments (but really anywhere) by simply invoking `ce` ('codeblock-edit'). The mapping is only active in markdown and quarto files for the time being, though more can probably be added. The command itself works anywhere (`:FeMaco`), so can be used in racket or norg or whereever. --- nvim/.config/nvim/lazy-lock.json | 2 ++ .../nvim/lua/plugins/data_analysis.lua | 20 +++++++++++-------- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/nvim/.config/nvim/lazy-lock.json b/nvim/.config/nvim/lazy-lock.json index 24c8cdf..3b080d2 100644 --- a/nvim/.config/nvim/lazy-lock.json +++ b/nvim/.config/nvim/lazy-lock.json @@ -43,11 +43,13 @@ "mason-lspconfig.nvim": { "branch": "main", "commit": "9ae570e206360e47d30b4c35a4550c165f4ea7b7" }, "mason-tool-installer.nvim": { "branch": "main", "commit": "c5e07b8ff54187716334d585db34282e46fa2932" }, "mason.nvim": { "branch": "main", "commit": "c43eeb5614a09dc17c03a7fb49de2e05de203924" }, + "mdeval.nvim": { "branch": "master", "commit": "2c32e2f3e7d8f222e7a4724989f218d036e1081d" }, "mini.nvim": { "branch": "main", "commit": "f24747266a047617d06605a2316aa6c071662fa2" }, "molten-nvim": { "branch": "main", "commit": "df5ccef3b6fda3582f7746e45327ee031f668826" }, "neogen": { "branch": "main", "commit": "0daffcec249bf42275e322361fe55b89a05ff278" }, "neotest": { "branch": "master", "commit": "6f35d797882c6ce0ab7c87dc86561512dc3d7aba" }, "neotest-python": { "branch": "master", "commit": "81d2265efac717bb567bc15cc652ae10801286b3" }, + "nvim-FeMaco.lua": { "branch": "main", "commit": "96bbf843595dbe865838b3f2484b73557f34700c" }, "nvim-cmp": { "branch": "main", "commit": "5260e5e8ecadaf13e6b82cf867a909f54e15fd07" }, "nvim-colorizer.lua": { "branch": "master", "commit": "85855b38011114929f4058efc97af1059ab3e41d" }, "nvim-coverage": { "branch": "main", "commit": "aa4b4400588e2259e87e372b1e4e90ae13cf5a39" }, diff --git a/nvim/.config/nvim/lua/plugins/data_analysis.lua b/nvim/.config/nvim/lua/plugins/data_analysis.lua index 8845b52..0443e6a 100644 --- a/nvim/.config/nvim/lua/plugins/data_analysis.lua +++ b/nvim/.config/nvim/lua/plugins/data_analysis.lua @@ -81,6 +81,18 @@ return { { "vn", ":MoltenInfo" }, }, }, + -- Edit code blocks in md/quarto using whatever language is + { + "AckslD/nvim-FeMaco.lua", + cmd = { + "FeMaco", + }, + ft = { "markdown", "quarto" }, + opts = {}, + dependencies = { + "nvim-treesitter/nvim-treesitter", + }, + }, -- MARKDOWN ONLY -- Evaluate markdown code blocks @@ -96,12 +108,4 @@ return { }, lazy = false, }, - { - "AckslD/nvim-FeMaco.lua", - cmd = { - "FeMaco", - }, - ft = { "markdown" }, - config = true, - }, } From 4697e09472d6d592def770a3863b3425fa4bf3dc Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Thu, 6 Jun 2024 16:10:41 +0200 Subject: [PATCH 09/10] nvim: Ensure pythonPath setting always finds entry LSP attachment would complain if it did not find an existing dict to access in the `settings.python` section of the python lsp dictionaries. This fixes that by creating an empty dict if nothing exists yet, essentially functioning as null-check. --- nvim/.config/nvim/lua/plugins/config/lsp.lua | 2 ++ 1 file changed, 2 insertions(+) diff --git a/nvim/.config/nvim/lua/plugins/config/lsp.lua b/nvim/.config/nvim/lua/plugins/config/lsp.lua index d4e42a7..3138473 100644 --- a/nvim/.config/nvim/lua/plugins/config/lsp.lua +++ b/nvim/.config/nvim/lua/plugins/config/lsp.lua @@ -168,6 +168,7 @@ lspconfig.pyright.setup({ python_path, _ = require("core.util").get_python_venv(client.config.root_dir) end -- print(string.format("[PYTHON VENV]: %s", vim.inspect(python_path))) + client.config.settings.python = {} or client.config.settings.python client.config.settings.python.pythonPath = python_path on_attach(client, bufnr) end, @@ -178,6 +179,7 @@ lspconfig.ruff_lsp.setup({ if python_path == nil then python_path, _ = require("core.util").get_python_venv(client.config.root_dir) end + client.config.settings.python = {} or client.config.settings.python client.config.settings.python.pythonPath = python_path end, }) From 8748b66344f9b71bc2423192e5d7451727e76196 Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Thu, 6 Jun 2024 16:14:09 +0200 Subject: [PATCH 10/10] nvim: Switch python lsp to basedpyright Switched pyright to basedpyright as it adds a couple noteworthy rules and some functions that are otherwise exlusive to pylance. Especially useful for me are semantic highlighting as well as inlay hints (now that nvim supports it from 0.10 onwards). --- nvim/.config/nvim/lua/plugins/config/lsp.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nvim/.config/nvim/lua/plugins/config/lsp.lua b/nvim/.config/nvim/lua/plugins/config/lsp.lua index 3138473..aa63460 100644 --- a/nvim/.config/nvim/lua/plugins/config/lsp.lua +++ b/nvim/.config/nvim/lua/plugins/config/lsp.lua @@ -33,7 +33,7 @@ local servers = { marksman = { filetypes = { "markdown", "quarto" }, }, - pyright = {}, + basedpyright = {}, ruff_lsp = {}, serve_d = {}, tailwindcss = {}, @@ -162,7 +162,7 @@ lspconfig.nushell.setup({}) local python_path -- ensure python virtualenv is determined automatically on lsp start -lspconfig.pyright.setup({ +lspconfig.basedpyright.setup({ on_attach = function(client, bufnr) if python_path == nil then python_path, _ = require("core.util").get_python_venv(client.config.root_dir)