From 3c7c0e1e870c40c360b49230c8b408b719fec46a Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Thu, 30 Jan 2025 22:25:53 +0100 Subject: [PATCH 01/27] nvim: Do not hide away html comments in md files Why would I want to completely hide comments I left for myself. --- nvim/.config/nvim/lua/plugins/prose.lua | 26 ++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/nvim/.config/nvim/lua/plugins/prose.lua b/nvim/.config/nvim/lua/plugins/prose.lua index 602954f..98c2b3b 100644 --- a/nvim/.config/nvim/lua/plugins/prose.lua +++ b/nvim/.config/nvim/lua/plugins/prose.lua @@ -81,6 +81,11 @@ local prose_plugs = { removed = { raw = "[_]", rendered = "󱋭 ", highlight = "RenderMarkdownTodo" }, }, }, + html = { + comment = { + conceal = false, + }, + }, }, name = "render-markdown", -- Only needed if you have another plugin named markdown.nvim dependencies = { @@ -146,7 +151,7 @@ local prose_plugs = { -- bring zettelkasten commands { - "mickael-menu/zk-nvim", + "zk-org/zk-nvim", config = function() if require("core.util").is_available("which-key") then require("which-key").add({ @@ -159,6 +164,24 @@ local prose_plugs = { opts = vim.tbl_extend("force", { orphan = true }, opts or {}) require("zk").edit(opts, { title = "Zk Orphans" }) end) + require("zk.commands").add("ZkGrep", function(opts) + local collection = {} + local list_opts = { select = { "title", "path", "absPath" } } + require("zk.api").list(vim.env.ZK_NOTEBOOK_DIR, list_opts, function(_, notes) + for _, note in ipairs(notes) do + collection[note.absPath] = note.title or note.path + end + end) + local options = vim.tbl_deep_extend("force", { + prompt_title = "Notes", + search_dirs = { vim.env.ZK_NOTEBOOK_DIR }, + disable_coordinates = true, + path_display = function(_, path) + return collection[path] + end, + }, opts or {}) + require("telescope.builtin").live_grep(options) + end) end require("zk").setup({ picker = "telescope", @@ -199,6 +222,7 @@ local prose_plugs = { desc = "note search", }, { "nf", "ZkMatch", desc = "find note from selection", mode = "v" }, + { "nw", "ZkGrep", desc = "grep notes" }, { "nt", "ZkTags", desc = "note tags" }, { "nc", "ZkCd", desc = "notedir cd" }, { "no", "ZkOrphans { sort = { 'modified' } }", desc = "orphans list" }, From 99c4f67fbcc1130bd51778fbfa97ffeddda61c1b Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Thu, 30 Jan 2025 22:26:22 +0100 Subject: [PATCH 02/27] nvim: Enable formatting through typst lsp --- nvim/.config/nvim/lua/plugins/lsp.lua | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/nvim/.config/nvim/lua/plugins/lsp.lua b/nvim/.config/nvim/lua/plugins/lsp.lua index 5b6e2ac..a73b1fd 100644 --- a/nvim/.config/nvim/lua/plugins/lsp.lua +++ b/nvim/.config/nvim/lua/plugins/lsp.lua @@ -35,7 +35,11 @@ local servers = { serve_d = {}, taplo = {}, texlab = {}, - tinymist = {}, + tinymist = { + settings = { + formatterMode = "typstyle", + }, + }, ts_ls = {}, yamlls = {}, } From 5e1a20adf09043609c42229667266a76b2c55d17 Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Thu, 30 Jan 2025 22:26:53 +0100 Subject: [PATCH 03/27] task: Rename today completed report to donetoday --- office/.config/task/taskrc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/office/.config/task/taskrc b/office/.config/task/taskrc index c9cf994..12270ae 100644 --- a/office/.config/task/taskrc +++ b/office/.config/task/taskrc @@ -44,10 +44,10 @@ report.today.sort=urgency- report.today.columns=id,project,priority,urgency,due,description,tags,scheduled,entry.age,recur report.today.labels=,Project,Pri,Urg,Due,Description,Tags,Sched,Age,Recur # report overview of tasks accomplished today -report.today.completed.description=Tasks completed today -report.today.completed.filter=status:completed end.after:tod -report.today.completed.columns=id,project,priority,urgency,due,description,tags,scheduled,entry.age,recur -report.today.completed.labels=,Project,Pri,Urg,Due,Description,Tags,Sched,Age,Recur +report.donetoday.description=Tasks completed today +report.donetoday.filter=status:completed end.after:tod +report.donetoday.columns=id,project,priority,urgency,due,description,tags,scheduled,entry.age,recur +report.donetoday.labels=,Project,Pri,Urg,Due,Description,Tags,Sched,Age,Recur # reorder priorities so that explicitly tagged 'Low' items are lower than normal uda.priority.values=H,M,,L From ce78b895979d116130aa0bfae6f44381d56b17b7 Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Thu, 30 Jan 2025 22:27:09 +0100 Subject: [PATCH 04/27] jrnl: Update config for new version --- writing/jrnl/config/jrnl/jrnl.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/writing/jrnl/config/jrnl/jrnl.yaml b/writing/jrnl/config/jrnl/jrnl.yaml index 5971cb8..14741d0 100644 --- a/writing/jrnl/config/jrnl/jrnl.yaml +++ b/writing/jrnl/config/jrnl/jrnl.yaml @@ -13,7 +13,7 @@ journals: default: journal: ~/documents/records/jrnl.md linewrap: 79 -tagsymbols: '+' +tagsymbols: + template: false timeformat: '%F %r' -version: v4.1 +version: v4.2 From 49c9dfcc9b338b9bf2a302bdeb32a7da10f814d8 Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Thu, 30 Jan 2025 22:29:57 +0100 Subject: [PATCH 05/27] nvim: Get beancount python env from dynamic home env While we are still hacking our way around a specific pipx venv (which has to change), we are at least not hardcoding my own home directory name anymore. --- nvim/.config/nvim/lua/plugins/completion.lua | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/nvim/.config/nvim/lua/plugins/completion.lua b/nvim/.config/nvim/lua/plugins/completion.lua index 6d38c40..4c75211 100644 --- a/nvim/.config/nvim/lua/plugins/completion.lua +++ b/nvim/.config/nvim/lua/plugins/completion.lua @@ -1,3 +1,5 @@ +local is_available = require("core.util").is_available + local completion_engine = { { "hrsh7th/nvim-cmp", @@ -178,11 +180,12 @@ local snippet_engine = { "benfowler/telescope-luasnip.nvim", dependencies = { { "nvim-telescope/telescope.nvim", optional = true } }, config = function() - if require("core.util").is_available("telescope") then + if is_available("telescope") then require("telescope").load_extension("luasnip") end end, }, + { "hrsh7th/nvim-cmp", optional = true }, }, event = { "InsertEnter" }, build = "make install_jsregexp", @@ -237,15 +240,10 @@ local beancount_cmp = { }, ft = "beancount", opts = function(_, opts) - vim.g.python3_host_prog = "/home/marty/.local/pipx/venvs/beancount/bin/python" + -- FIXME: Find a way to dynamically derive environment + vim.g.python3_host_prog = os.getenv("HOME") .. "/.local/pipx/venvs/beancount/bin/python" table.insert(opts.sources, { name = "beancount", - -- option = { - -- -- TODO: implement dynamically - -- -- I believe if we don't supply this it automatically takes - -- -- from the open file which would be good enough - -- account = "/home/marty/documents/records/budget/main.beancount", - -- }, }) end, } From 2618eb55b8966219933cfcb59bf93956b779289f Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Thu, 30 Jan 2025 22:30:24 +0100 Subject: [PATCH 06/27] nvim: Add cmp completion for render-markdown items --- nvim/.config/nvim/lua/plugins/completion.lua | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/nvim/.config/nvim/lua/plugins/completion.lua b/nvim/.config/nvim/lua/plugins/completion.lua index 4c75211..ba17644 100644 --- a/nvim/.config/nvim/lua/plugins/completion.lua +++ b/nvim/.config/nvim/lua/plugins/completion.lua @@ -260,9 +260,28 @@ local latex_cmp = { end, } +local markdown_cmp = {} +-- FIXME: Currently always set to true but should ideally +-- recognize if we have render-markdown available or not +if is_available("render-markdown") or true then + markdown_cmp = { + "nvim-cmp", + dependencies = { + { "MeanderingProgrammer/render-markdown.nvim", main = "render-markdown", optional = true }, + }, + ft = "markdown", + opts = function(_, opts) + table.insert(opts.sources, { + name = "render-markdown", + }) + end, + } +end + return { completion_engine, snippet_engine, beancount_cmp, latex_cmp, + markdown_cmp, } From 3a10d7a849dc9775a0efd289a944da22bede8425 Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Fri, 31 Jan 2025 09:46:45 +0100 Subject: [PATCH 07/27] nvim: Switch nvim-cmp for blink.cmp completion Switched completion engines. Blink is supposedly faster and so on but what I really love is the batteries-included style. I don't have to set up the basic lsp, path, buffer and cmdline completions, nor styling for basic kind displays and more. Hundreds of lines of config shrink down to 60, very nice. --- nvim/.config/nvim/lua/plugins/completion.lua | 346 ++++--------------- nvim/.config/nvim/lua/plugins/languages.lua | 23 +- 2 files changed, 73 insertions(+), 296 deletions(-) diff --git a/nvim/.config/nvim/lua/plugins/completion.lua b/nvim/.config/nvim/lua/plugins/completion.lua index ba17644..60295f7 100644 --- a/nvim/.config/nvim/lua/plugins/completion.lua +++ b/nvim/.config/nvim/lua/plugins/completion.lua @@ -1,287 +1,63 @@ -local is_available = require("core.util").is_available - -local completion_engine = { - { - "hrsh7th/nvim-cmp", - branch = "main", - version = false, -- new releases (>2022) are sadly not versioned - dependencies = { - -- TODO: Move to lsp - "hrsh7th/cmp-nvim-lsp", - "hrsh7th/cmp-nvim-lsp-signature-help", - "hrsh7th/cmp-path", - "hrsh7th/cmp-buffer", - "hrsh7th/cmp-calc", - "hrsh7th/cmp-cmdline", - -- TODO: Move me into a separate load? - "cbarrete/completion-vcard", - "f3fora/cmp-spell", - "jc-doyle/cmp-pandoc-references", - -- TODO: Decide: get rid or just enable in very specific circumstances - "lukas-reineke/cmp-rg", - -- TODO: Move to treesitter - { "ray-x/cmp-treesitter", dependencies = { "nvim-treesitter/nvim-treesitter" } }, - }, - opts = function() - local cmp = require("cmp") - -- style 'ghosttext' which appears behind cursor, showing current completion - vim.api.nvim_set_hl(0, "CmpGhostText", { link = "Comment", default = true }) - - local has_words_before = function() - ---@diagnostic disable-next-line:deprecated - local line, col = unpack(vim.api.nvim_win_get_cursor(0)) - return col ~= 0 - and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil - end - - local kind_icons = { - Text = "", - Method = "", - Function = "󰊕", - Constructor = "", - Field = "", - Variable = "", - Class = "", - Interface = "", - Module = "", - Property = "", - Unit = "", - Value = "V", - Enum = "", - Keyword = "", - Snippet = "", - Color = "", - File = "", - Reference = "", - Folder = "", - EnumMember = "", - Constant = "", - Struct = "", - Event = "", - Operator = "", - TypeParameter = "", - } - - -- `/` cmdline setup. - cmp.setup.cmdline("/", { - completion = { completeopt = "menu,menuone,noinsert,noselect" }, - preselect = cmp.PreselectMode.None, - mapping = cmp.mapping.preset.cmdline(), - sources = { { name = "buffer" } }, - }) - -- `:` cmdline setup. - cmp.setup.cmdline(":", { - completion = { completeopt = "menu,menuone,noinsert,noselect" }, - preselect = cmp.PreselectMode.None, - mapping = cmp.mapping.preset.cmdline(), - sources = cmp.config.sources({ { name = "path" } }, { - { name = "cmdline", option = { ignore_cmds = { "Man", "!" } } }, - }), - }) - return { - window = { documentation = cmp.config.window.bordered() }, - -- add noselect to not automatically select first item - completion = { completeopt = "menu,menuone,noinsert" }, - preselect = cmp.PreselectMode.Item, -- not sure what this changes diff than above? - experimental = { - ghost_text = { - hl_group = "CmpGhostText", - }, - }, - sources = { - { name = "nvim_lsp" }, - { name = "nvim_lsp_signature_help" }, - { name = "pandoc_references" }, - { name = "calc" }, - { name = "path" }, - { name = "buffer", keyword_length = 3 }, - { name = "spell", keyword_length = 3 }, - -- { name = 'rg', keyword_length = 5 }, - { name = "vCard" }, - }, - mapping = cmp.mapping.preset.insert({ - [""] = cmp.mapping.scroll_docs(-4), - [""] = cmp.mapping.scroll_docs(4), - [""] = cmp.mapping({ - i = function(fallback) - if cmp.visible() and cmp.get_active_entry() then - cmp.confirm({ - behavior = cmp.ConfirmBehavior.Replace, - select = false, - }) - else - fallback() - end - end, - s = cmp.mapping.confirm({ select = true }), - c = cmp.mapping.confirm({ - behavior = cmp.ConfirmBehavior.Replace, - select = false, - }), -- disable selection in cmd mode - }), - [""] = cmp.mapping(function(fallback) - -- expand_or_jumpable() will always jump - -- expand_or_locally_jumpable() only jumps when still inside snippet region - if cmp.visible() then - cmp.select_next_item() - elseif has_words_before() then - cmp.complete() - else - fallback() - end - end, { "i", "s" }), - [""] = cmp.mapping(function(fallback) - if cmp.visible() then - cmp.select_prev_item() - else - fallback() - end - end, { "i", "s" }), - }), - formatting = { - expandable_indicator = true, - fields = { "kind", "abbr", "menu" }, - format = function(entry, vim_item) - -- Kind icons, removing kind text leaving only icon - -- vim_item.kind = string.format('%s %s', kind_icons[vim_item.kind], vim_item.kind) - vim_item.kind = string.format("%s", kind_icons[vim_item.kind]) - - -- Source - vim_item.menu = ({ - buffer = "", - calc = "󰃬", - digraphs = "∬", - latex_symbols = "𝓧", - luasnip = "", - nvim_lsp = "ℒ", - nvim_lua = "󰢱", - pandoc_references = "", - spell = "󰓆", - vCard = "󰛋", - })[entry.source.name] - return vim_item - end, - }, - } - end, - event = { "InsertEnter", "CmdlineEnter" }, - }, -} --- --- TODO: Enable more lazy loaded startup? And integrate into --- cmp as insert source instead of in its setup config below. -local snippet_engine = { - "nvim-cmp", - dependencies = { - "L3MON4D3/LuaSnip", - "rafamadriz/friendly-snippets", - "saadparwaiz1/cmp_luasnip", - { - "benfowler/telescope-luasnip.nvim", - dependencies = { { "nvim-telescope/telescope.nvim", optional = true } }, - config = function() - if is_available("telescope") then - require("telescope").load_extension("luasnip") - end - end, - }, - { "hrsh7th/nvim-cmp", optional = true }, - }, - event = { "InsertEnter" }, - build = "make install_jsregexp", - opts = function(_, opts) - local cmp = require("cmp") - local luasnip = require("luasnip") - - require("luasnip.loaders.from_vscode").lazy_load({ exclude = { "markdown", "quarto" } }) - require("luasnip.loaders.from_snipmate").lazy_load() - - opts.snippet = { - expand = function(item) - require("luasnip").lsp_expand(item.body) - end, - } - local has_words_before = function() - ---@diagnostic disable-next-line:deprecated - local line, col = unpack(vim.api.nvim_win_get_cursor(0)) - return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil - end - - table.insert(opts.sources, { name = "luasnip", keyword_length = 1 }) - - opts.mapping[""] = cmp.mapping(function(fallback) -- expand_or_jumpable() will always jump - -- expand_or_locally_jumpable() only jumps when still inside snippet region - if luasnip.expand_or_locally_jumpable() then - luasnip.expand_or_jump() - elseif cmp.visible() then - cmp.select_next_item() - elseif has_words_before() then - cmp.complete() - else - fallback() - end - end, { "i", "s" }) - opts.mapping[""] = cmp.mapping(function(fallback) - if luasnip.locally_jumpable(-1) then - luasnip.jump(-1) - elseif cmp.visible() then - cmp.select_prev_item() - else - fallback() - end - end, { "i", "s" }) - end, -} - -local beancount_cmp = { - "nvim-cmp", - dependencies = { - "crispgm/cmp-beancount", - }, - ft = "beancount", - opts = function(_, opts) - -- FIXME: Find a way to dynamically derive environment - vim.g.python3_host_prog = os.getenv("HOME") .. "/.local/pipx/venvs/beancount/bin/python" - table.insert(opts.sources, { - name = "beancount", - }) - end, -} - -local latex_cmp = { - "nvim-cmp", - dependencies = { - -- TODO: Needs better lazy loading - "kdheepak/cmp-latex-symbols", - }, - event = "CursorHold", - opts = function(_, opts) - table.insert(opts.sources, { name = "latex_symbols" }) - end, -} - -local markdown_cmp = {} --- FIXME: Currently always set to true but should ideally --- recognize if we have render-markdown available or not -if is_available("render-markdown") or true then - markdown_cmp = { - "nvim-cmp", - dependencies = { - { "MeanderingProgrammer/render-markdown.nvim", main = "render-markdown", optional = true }, - }, - ft = "markdown", - opts = function(_, opts) - table.insert(opts.sources, { - name = "render-markdown", - }) - end, - } -end - return { - completion_engine, - snippet_engine, - beancount_cmp, - latex_cmp, - markdown_cmp, + -- full documentation here: https://cmp.saghen.dev/ + "saghen/blink.cmp", + dependencies = { + "saghen/blink.compat", + "rafamadriz/friendly-snippets", + "hrsh7th/cmp-calc", + "f3fora/cmp-spell", + { "aspeddro/cmp-pandoc.nvim", opts = { + filetypes = { "pandoc", "markdown", "quarto", "rmd" }, + } }, + }, + lazy = false, + opts = { + keymap = { preset = "default" }, + + appearance = { + -- Sets the fallback highlight groups to nvim-cmp's highlight groups + -- Useful for when your theme doesn't support blink.cmp + -- Will be removed in a future release + use_nvim_cmp_as_default = true, + -- Set to 'mono' for 'Nerd Font Mono' or 'normal' for 'Nerd Font' + -- Adjusts spacing to ensure icons are aligned + nerd_font_variant = "mono", + }, + completion = { + documentation = { auto_show = true, auto_show_delay_ms = 500 }, + -- ghost_text = { enabled = true }, + }, + signature = { + enabled = true, + }, + + -- Default list of enabled providers defined so that you can extend it + -- elsewhere in your config, without redefining it, due to `opts_extend` + sources = { + default = { + "pandoc", + "calc", + "lsp", + "path", + "snippets", + "buffer", + "spell", + }, + providers = { + calc = { + name = "calc", + module = "blink.compat.source", + }, + spell = { + name = "spell", + module = "blink.compat.source", + }, + pandoc = { + name = "cmp_pandoc", + module = "blink.compat.source", + }, + }, + }, + }, + opts_extend = { "sources.default" }, } diff --git a/nvim/.config/nvim/lua/plugins/languages.lua b/nvim/.config/nvim/lua/plugins/languages.lua index c24cc38..26d42f8 100644 --- a/nvim/.config/nvim/lua/plugins/languages.lua +++ b/nvim/.config/nvim/lua/plugins/languages.lua @@ -12,17 +12,18 @@ return { }, dependencies = { { "Bilal2453/luvit-meta" }, -- optional `vim.uv` typings - { -- optional completion source for require statements and module annotations - "hrsh7th/nvim-cmp", - opts = function(_, opts) - opts.sources = opts.sources or {} - table.insert(opts.sources, { - name = "lazydev", - group_index = 0, -- set group index to 0 to skip loading LuaLS completions - }) - end, - optional = true, - }, + -- FIXME: Set up to work with blink.cmp + -- { -- optional completion source for require statements and module annotations + -- "hrsh7th/nvim-cmp", + -- opts = function(_, opts) + -- opts.sources = opts.sources or {} + -- table.insert(opts.sources, { + -- name = "lazydev", + -- group_index = 0, -- set group index to 0 to skip loading LuaLS completions + -- }) + -- end, + -- optional = true, + -- }, }, }, } From f4da232b792f8281f83548f382b3a8f3efc768e7 Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Fri, 31 Jan 2025 12:35:27 +0100 Subject: [PATCH 08/27] nvim: Add pandoc completion to blink --- nvim/.config/nvim/lua/plugins/completion.lua | 12 +++++++++--- nvim/.config/nvim/lua/plugins/data_analysis.lua | 1 - 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/nvim/.config/nvim/lua/plugins/completion.lua b/nvim/.config/nvim/lua/plugins/completion.lua index 60295f7..ca41d47 100644 --- a/nvim/.config/nvim/lua/plugins/completion.lua +++ b/nvim/.config/nvim/lua/plugins/completion.lua @@ -6,9 +6,15 @@ return { "rafamadriz/friendly-snippets", "hrsh7th/cmp-calc", "f3fora/cmp-spell", - { "aspeddro/cmp-pandoc.nvim", opts = { - filetypes = { "pandoc", "markdown", "quarto", "rmd" }, - } }, + { + "aspeddro/cmp-pandoc.nvim", + dependencies = { + "nvim-lua/plenary.nvim", + }, + opts = { + filetypes = { "pandoc", "markdown", "quarto", "rmd" }, + }, + }, }, lazy = false, opts = { diff --git a/nvim/.config/nvim/lua/plugins/data_analysis.lua b/nvim/.config/nvim/lua/plugins/data_analysis.lua index 6719b50..ef5c393 100644 --- a/nvim/.config/nvim/lua/plugins/data_analysis.lua +++ b/nvim/.config/nvim/lua/plugins/data_analysis.lua @@ -15,7 +15,6 @@ return { dependencies = { "jmbuhr/otter.nvim", "neovim/nvim-lspconfig", - "hrsh7th/nvim-cmp", "nvim-treesitter/nvim-treesitter", { "benlubas/molten-nvim", optional = true }, }, From 8486f8f0f6d6a5bc0b8b395bdf0dace39f2be9ac Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Fri, 31 Jan 2025 12:36:09 +0100 Subject: [PATCH 09/27] nvim: Change select all mapping I only rarely use it these days, and it takes up a valuable 'menu' space. Simply capitalize for now so it is more out of the way. --- nvim/.config/nvim/lua/core/mappings.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nvim/.config/nvim/lua/core/mappings.lua b/nvim/.config/nvim/lua/core/mappings.lua index c0c5880..dab1ef0 100644 --- a/nvim/.config/nvim/lua/core/mappings.lua +++ b/nvim/.config/nvim/lua/core/mappings.lua @@ -120,7 +120,7 @@ map("n", "\\", ":vsp", { desc = "open vert split" }) map("n", "T", ":tabedit | Vifm", { desc = "open tab" }) -- select the whole buffer with -a -map("n", "a", "ggVG", { desc = "select all" }) +map("n", "A", "ggVG", { desc = "select all" }) -- Format current Paragraph (esp useful in prose writing) map("n", "q", "gqap", { silent = true, desc = "Format current paragraph" }) From 0f77a110d37069e2ded7ef92cc48124f55cbda38 Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Fri, 31 Jan 2025 12:37:04 +0100 Subject: [PATCH 10/27] nvim: Track master for plenary Ensure that we run the master branch version of plenary and do not adhere to any versioned release since the newest is now multiple years back. --- nvim/.config/nvim/lua/plugins/base.lua | 2 ++ 1 file changed, 2 insertions(+) diff --git a/nvim/.config/nvim/lua/plugins/base.lua b/nvim/.config/nvim/lua/plugins/base.lua index 35bac31..838f938 100644 --- a/nvim/.config/nvim/lua/plugins/base.lua +++ b/nvim/.config/nvim/lua/plugins/base.lua @@ -251,4 +251,6 @@ return { { "stevearc/stickybuf.nvim", config = true }, -- make it a little less painful to open really big (>2mb) files by disabling features -- { "LunarVim/bigfile.nvim", lazy = false }, + -- set plenary to follow master branch here, but let individual plugins actually load it + { "nvim-lua/plenary.nvim", version = false, optional = true }, } From 1848ec168b68f27283d955b474108e0a88ef4025 Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Fri, 31 Jan 2025 12:37:56 +0100 Subject: [PATCH 11/27] nvim: Add simple LLM assisted programming Added codecompanion as a test for LLM assistance during programming. Will see how much I end up using it. --- nvim/.config/nvim/lua/plugins/llm.lua | 49 +++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 nvim/.config/nvim/lua/plugins/llm.lua diff --git a/nvim/.config/nvim/lua/plugins/llm.lua b/nvim/.config/nvim/lua/plugins/llm.lua new file mode 100644 index 0000000..7a339e4 --- /dev/null +++ b/nvim/.config/nvim/lua/plugins/llm.lua @@ -0,0 +1,49 @@ +return { + -- TODO: Add completion w blink, see https://codecompanion.olimorris.dev/installation.html + { + "olimorris/codecompanion.nvim", + dependencies = { + "nvim-lua/plenary.nvim", + "nvim-treesitter/nvim-treesitter", + "github/copilot.vim", + }, + opts = { + strategies = { + chat = { adapter = "groq" }, + inline = { adapter = "groq" }, + }, + adapters = { + groq = function() + return require("codecompanion.adapters").extend("openai", { + env = { + api_key = "GROQ_API_KEY", + }, + name = "Groq", + url = "https://api.groq.com/openai/v1/chat/completions", + schema = { + model = { + default = "llama-3.1-8b-instant", + choices = { + "llama-3.3-70b-versatile", + "mixtral-8x7b-32768", + }, + }, + }, + max_tokens = { + default = 4096, + }, + temperature = { + default = 1, + }, + }) + end, + }, + }, + keys = { + { "aa", "CodeCompanionActions", desc = "Actions", silent = true, mode = { "n", "v" } }, + { "ac", "CodeCompanionChat Toggle", desc = "Toggle chat", silent = true }, + { "ac", "CodeCompanionChat Add", desc = "Add to chat", silent = true, mode = "v" }, + }, + cmd = { "CodeCompanionActions", "CodeCompanionChat", "CodeCompanion", "CodeCompanionCmd" }, + }, +} From d7d5c5f908eee5fe8765464fc94fe13e50b9227f Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Fri, 31 Jan 2025 12:38:06 +0100 Subject: [PATCH 12/27] nvim: Update plugins --- nvim/.config/nvim/lazy-lock.json | 90 ++++++++++++++------------------ 1 file changed, 38 insertions(+), 52 deletions(-) diff --git a/nvim/.config/nvim/lazy-lock.json b/nvim/.config/nvim/lazy-lock.json index 01b8a10..049641a 100644 --- a/nvim/.config/nvim/lazy-lock.json +++ b/nvim/.config/nvim/lazy-lock.json @@ -1,47 +1,37 @@ { "Arduino.nvim": { "branch": "main", "commit": "5988e7b08d8d6dc0a2d37e805cbed57dc13d869a" }, "FixCursorHold.nvim": { "branch": "master", "commit": "1900f89dc17c603eec29960f57c00bd9ae696495" }, - "LuaSnip": { "branch": "master", "commit": "03c8e67eb7293c404845b3982db895d59c0d1538" }, "Navigator.nvim": { "branch": "master", "commit": "91d86506ac2a039504d5205d32a1d4bc7aa57072" }, - "aerial.nvim": { "branch": "master", "commit": "9c29a1a66eb31384888e413e510ba72496e06770" }, "bats.vim": { "branch": "master", "commit": "6a5d2ef22b0ede503d867770afd02ebb1f97b709" }, - "cmp-beancount": { "branch": "main", "commit": "29e23297c06b9d69771e4b14e0fb3b9d583a150e" }, - "cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" }, + "blink.cmp": { "branch": "main", "commit": "b6f11a0aa33e601c469a126e3ed6e35208fe3ea3" }, + "blink.compat": { "branch": "main", "commit": "1176525a78319a208300a1910b6fd9e0cfabff25" }, "cmp-calc": { "branch": "main", "commit": "5947b412da67306c5b68698a02a846760059be2e" }, - "cmp-cmdline": { "branch": "main", "commit": "d250c63aa13ead745e3a40f61fdd3470efde3923" }, - "cmp-latex-symbols": { "branch": "main", "commit": "165fb66afdbd016eaa1570e41672c4c557b57124" }, - "cmp-nvim-lsp": { "branch": "main", "commit": "39e2eda76828d88b773cc27a3f61d2ad782c922d" }, - "cmp-nvim-lsp-signature-help": { "branch": "main", "commit": "031e6ba70b0ad5eee49fd2120ff7a2e325b17fa7" }, - "cmp-pandoc-references": { "branch": "master", "commit": "2c808dff631a783ddd2c554c4c6033907589baf6" }, - "cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" }, - "cmp-rg": { "branch": "master", "commit": "70a43543f61b6083ba9c3b7deb9ccee671410ac6" }, + "cmp-pandoc.nvim": { "branch": "main", "commit": "30faa4456a7643c4cb02d8fa18438fd484ed7602" }, "cmp-spell": { "branch": "master", "commit": "694a4e50809d6d645c1ea29015dad0c293f019d6" }, - "cmp-treesitter": { "branch": "master", "commit": "958fcfa0d8ce46d215e19cc3992c542f576c4123" }, - "cmp_luasnip": { "branch": "master", "commit": "98d9cb5c2c38532bd9bdb481067b20fea8f32e90" }, - "completion-vcard": { "branch": "master", "commit": "2220fd517a985ececed1adcf0e5be8f2815564c7" }, - "conform.nvim": { "branch": "master", "commit": "6239d9986f51ca93ded99ecdb1af0e287eabb651" }, - "dial.nvim": { "branch": "master", "commit": "46b4375e84e8eb771129bff6b2b1e47746601ef9" }, - "dressing.nvim": { "branch": "master", "commit": "43b8f74e0b1e3f41e51f640f8efa3bcd401cea0d" }, - "fidget.nvim": { "branch": "main", "commit": "ef99df04a1c53a453602421bc0f756997edc8289" }, + "codecompanion.nvim": { "branch": "main", "commit": "7cc8c94b373a60f86ef40bfc4ecc7c83a9771231" }, + "conform.nvim": { "branch": "master", "commit": "80b57f662b5e13ae8c2c7c38639966084625fa5e" }, + "copilot.vim": { "branch": "release", "commit": "87038123804796ca7af20d1b71c3428d858a9124" }, + "dial.nvim": { "branch": "master", "commit": "34bbd9c387c358190e61ce71017faad3dffa7a74" }, + "dressing.nvim": { "branch": "master", "commit": "3a45525bb182730fe462325c99395529308f431e" }, + "fidget.nvim": { "branch": "main", "commit": "9238947645ce17d96f30842e61ba81147185b657" }, "flash.nvim": { "branch": "main", "commit": "ec0bf2842189f65f60fd40bf3557cac1029cc932" }, - "friendly-snippets": { "branch": "main", "commit": "de8fce94985873666bd9712ea3e49ee17aadb1ed" }, + "friendly-snippets": { "branch": "main", "commit": "efff286dd74c22f731cdec26a70b46e5b203c619" }, "fwatch.nvim": { "branch": "main", "commit": "a691f7349dc66285cd75a1a698dd28bca45f2bf8" }, "git-conflict.nvim": { "branch": "main", "commit": "4bbfdd92d547d2862a75b4e80afaf30e73f7bbb4" }, "gitsigns.nvim": { "branch": "main", "commit": "0b04035bb7b3c83e999b9676e2fb46fd0aa9f910" }, - "glance.nvim": { "branch": "master", "commit": "17ee84e29ac33e7e5d91609f675cee8477586bda" }, - "grug-far.nvim": { "branch": "main", "commit": "9a2f78219390b47d67795ab09390d7f092e23976" }, + "glance.nvim": { "branch": "master", "commit": "1a08824835d7582457b67acbe23ca33487912a5e" }, + "grug-far.nvim": { "branch": "main", "commit": "635e69adf3a714621bd0a289314bc23c5848babb" }, "helpview.nvim": { "branch": "main", "commit": "34be34afd0811dee17e6b0c46176d9140659fe8e" }, - "hunk.nvim": { "branch": "master", "commit": "eb89245a66bdfce10436d15923bf4deb43d23c96" }, "image.nvim": { "branch": "master", "commit": "da64ce69598875c9af028afe129f916b02ccc42e" }, "img-clip.nvim": { "branch": "main", "commit": "28a32d811d69042f4fa5c3d5fa35571df2bc1623" }, "jupytext.nvim": { "branch": "main", "commit": "c8baf3ad344c59b3abd461ecc17fc16ec44d0f7b" }, - "lazy.nvim": { "branch": "main", "commit": "7967abe55752aa90532e6bb4bd4663fe27a264cb" }, + "lazy.nvim": { "branch": "main", "commit": "7e6c863bc7563efbdd757a310d17ebc95166cef3" }, "lazydev.nvim": { "branch": "main", "commit": "f59bd14a852ca43db38e3662395354cb2a9b13e0" }, "lsp-setup.nvim": { "branch": "main", "commit": "6e4e977512ce426d8b52c27f3b6e6aefc73e1452" }, - "ltex_extra.nvim": { "branch": "dev", "commit": "57192d7ae5ba8cef3c10e90f2cd62d4a7cdaab69" }, + "ltex_extra.nvim": { "branch": "dev", "commit": "09dc879b1873001f855bca5ad1f024ca15b9bbaf" }, "lualine.nvim": { "branch": "master", "commit": "2a5bae925481f999263d6f5ed8361baef8df4f83" }, "luarocks.nvim": { "branch": "main", "commit": "1db9093915eb16ba2473cfb8d343ace5ee04130a" }, - "luvit-meta": { "branch": "main", "commit": "57d464c4acb5c2e66bd4145060f5dc9e96a7bbb7" }, + "luvit-meta": { "branch": "main", "commit": "1df30b60b1b4aecfebc785aa98943db6c6989716" }, "markmap.nvim": { "branch": "main", "commit": "5fb6755cf5434511cc23a4936c9eb76b9142fba5" }, "mason-conform.nvim": { "branch": "main", "commit": "abce2be529f3b4b336c56d0ba6336a9144e0fee6" }, "mason-lspconfig.nvim": { "branch": "main", "commit": "25c11854aa25558ee6c03432edfa0df0217324be" }, @@ -49,43 +39,39 @@ "mason.nvim": { "branch": "main", "commit": "c43eeb5614a09dc17c03a7fb49de2e05de203924" }, "mdeval.nvim": { "branch": "master", "commit": "0e1b248db174a9659a9ab16eb8c90ff3aec55264" }, "mini.nvim": { "branch": "main", "commit": "64e95aa77587d04f97a5579b2106a82a08a7d968" }, - "molten-nvim": { "branch": "main", "commit": "66ee5c0a0fbe3e014b867d04db44592f2d3eb30f" }, - "neo-tree.nvim": { "branch": "main", "commit": "a77af2e764c5ed4038d27d1c463fa49cd4794e07" }, - "neogen": { "branch": "main", "commit": "dc50715c009f89b8111197fd2f282f6042daa7ea" }, - "neotest": { "branch": "master", "commit": "6d3d22cdad49999ef774ebe1bc250a4994038964" }, + "molten-nvim": { "branch": "main", "commit": "c621baf53459a6c45dfd98dcc11cbba7a7ae9470" }, + "neo-tree.nvim": { "branch": "main", "commit": "5d172e8315444dbc32867d1c7b04d8e7e68ec4e1" }, + "neogen": { "branch": "main", "commit": "b2e78708876f4da507839726816010a68e33fec8" }, + "neotest": { "branch": "master", "commit": "d66cf4e05a116957f0d3a7755a24291c7d1e1f72" }, "neotest-python": { "branch": "master", "commit": "a2861ab3c9a0bf75a56b11835c2bfc8270f5be7e" }, "nui.nvim": { "branch": "main", "commit": "a0fd35fcbb4cb479366f1dc5f20145fd718a3733" }, "nvim-FeMaco.lua": { "branch": "main", "commit": "96bbf843595dbe865838b3f2484b73557f34700c" }, - "nvim-cmp": { "branch": "main", "commit": "ca4d3330d386e76967e53b85953c170658255ecb" }, - "nvim-colorizer.lua": { "branch": "master", "commit": "4acf88d31b3a7a1a7f31e9c30bf2b23c6313abdb" }, - "nvim-coverage": { "branch": "main", "commit": "aa4b4400588e2259e87e372b1e4e90ae13cf5a39" }, - "nvim-lint": { "branch": "master", "commit": "6b46370d02cd001509a765591a3ffc481b538794" }, - "nvim-lspconfig": { "branch": "master", "commit": "7b0a2f6b14485bb5a237fc1328a487ff3e4a08c5" }, - "nvim-nio": { "branch": "master", "commit": "a428f309119086dc78dd4b19306d2d67be884eee" }, - "nvim-surround": { "branch": "main", "commit": "9f0cb495f25bff32c936062d85046fbda0c43517" }, - "nvim-toggleterm.lua": { "branch": "main", "commit": "022ff5594acccc8d90d2e46dc43994f7722ebdf7" }, + "nvim-colorizer.lua": { "branch": "master", "commit": "39142aa1390d6ccdca57cb6dc5b2c7bfed460ffe" }, + "nvim-coverage": { "branch": "main", "commit": "a939e425e363319d952a6c35fb3f38b34041ded2" }, + "nvim-lint": { "branch": "master", "commit": "789b7ada1b4f00e08d026dffde410dcfa6a0ba87" }, + "nvim-lspconfig": { "branch": "master", "commit": "e5bf88e5ea1c4cea5ea96b1e970cb264f7a401a1" }, + "nvim-nio": { "branch": "master", "commit": "21f5324bfac14e22ba26553caf69ec76ae8a7662" }, + "nvim-surround": { "branch": "main", "commit": "ae298105122c87bbe0a36b1ad20b06d417c0433e" }, + "nvim-toggleterm.lua": { "branch": "main", "commit": "50ea089fc548917cc3cc16b46a8211833b9e3c7c" }, "nvim-treesitter": { "branch": "master", "commit": "cfc6f2c117aaaa82f19bcce44deec2c194d900ab" }, - "nvim-treesitter-context": { "branch": "master", "commit": "920999bf53daa63ddf12efdeb5137a7cea1cc201" }, + "nvim-treesitter-context": { "branch": "master", "commit": "bece284c5322ddf6946fa4bdc383a2bc033269d7" }, "nvim-treesitter-endwise": { "branch": "master", "commit": "8b34305ffc28bd75a22f5a0a9928ee726a85c9a6" }, "nvim-treesitter-textsubjects": { "branch": "master", "commit": "a8d2844bba925d9450ef7ab215f3b054028288ca" }, - "nvim-ts-autotag": { "branch": "main", "commit": "f2d24aca1bcbbd2c0306fd93d52e3697027b77ff" }, - "nvim-ts-context-commentstring": { "branch": "main", "commit": "9c74db656c3d0b1c4392fc89a016b1910539e7c0" }, + "nvim-ts-autotag": { "branch": "main", "commit": "1cca23c9da708047922d3895a71032bc0449c52d" }, + "nvim-ts-context-commentstring": { "branch": "main", "commit": "1b212c2eee76d787bbea6aa5e92a2b534e7b4f8f" }, "nvim-web-devicons": { "branch": "master", "commit": "5b9067899ee6a2538891573500e8fd6ff008440f" }, - "otter.nvim": { "branch": "main", "commit": "ca9ce67d0399380b659923381b58d174344c9ee7" }, - "parrot.nvim": { "branch": "main", "commit": "413679a79cf220c261a4700cee5a01cadd99db53" }, + "otter.nvim": { "branch": "main", "commit": "7b42ce1f9deabc596214fc3b80e5ab4fd5b32726" }, "peek.nvim": { "branch": "master", "commit": "5820d937d5414baea5f586dc2a3d912a74636e5b" }, - "plenary.nvim": { "branch": "master", "commit": "50012918b2fc8357b87cff2a7f7f0446e47da174" }, + "plenary.nvim": { "branch": "master", "commit": "3707cdb1e43f5cea73afb6037e6494e7ce847a66" }, "popup.nvim": { "branch": "master", "commit": "b7404d35d5d3548a82149238289fa71f7f6de4ac" }, - "quarto-nvim": { "branch": "main", "commit": "23083a0152799ca7263ac9ae53d768d4dd93d24e" }, - "rainbow-delimiters.nvim": { "branch": "master", "commit": "e0f9b3efe150724af2d2ed59997d5ece373840e3" }, - "render-markdown": { "branch": "main", "commit": "6096cf3608b576a38fd1396227dbc0473091714d" }, + "quarto-nvim": { "branch": "main", "commit": "1cb2d24d7793241bd43f38e3a6f99a6d11f84458" }, + "rainbow-delimiters.nvim": { "branch": "master", "commit": "dc788723f717bdd3041838b8db34cce53c9aa920" }, + "render-markdown": { "branch": "main", "commit": "16369540a005ad0cf267498162aedca6dfca1b9c" }, "smartcolumn.nvim": { "branch": "main", "commit": "d01b99355c7fab13233f48d0f28dc097e68a03f7" }, "stickybuf.nvim": { "branch": "master", "commit": "2160fcd536d81f5fa43f7167dba6634e814e3154" }, - "telescope-fzf-native.nvim": { "branch": "main", "commit": "cf48d4dfce44e0b9a2e19a008d6ec6ea6f01a83b" }, - "telescope-jj.nvim": { "branch": "main", "commit": "9527e39f30eded7950ca127698422ec412d633c4" }, - "telescope-luasnip.nvim": { "branch": "master", "commit": "11668478677de360dea45cf2b090d34f21b8ae07" }, + "telescope-fzf-native.nvim": { "branch": "main", "commit": "dae2eac9d91464448b584c7949a31df8faefec56" }, "telescope.nvim": { "branch": "master", "commit": "a0bbec21143c7bc5f8bb02e0005fa0b982edc026" }, - "texpresso.vim": { "branch": "main", "commit": "1cc949fde8ed3220968039b6b1b6ccdd9f475087" }, + "texpresso.vim": { "branch": "main", "commit": "907838c08bbf99ad6bed3c908f1d0551a92ab4e0" }, "todo-comments.nvim": { "branch": "main", "commit": "ae0a2afb47cf7395dc400e5dc4e05274bf4fb9e0" }, "trouble.nvim": { "branch": "main", "commit": "40c5317a6e90fe3393f07b0fee580d9e93a216b4" }, "twilight.nvim": { "branch": "main", "commit": "8bb7fa7b918baab1ca81b977102ddb54afa63512" }, @@ -95,8 +81,8 @@ "vim-numbertoggle": { "branch": "main", "commit": "df9b1fe616507340718716204ba7f434125bdf7a" }, "vim-spellsync": { "branch": "master", "commit": "3d6dd50de9c4d953cc16638112a6ae196df41463" }, "wezterm.nvim": { "branch": "main", "commit": "f73bba23ab4becd146fa2d0a3a16a84b987eeaca" }, - "which-key.nvim": { "branch": "main", "commit": "9b365a6428a9633e3eeb34dbef1b791511c54f70" }, + "which-key.nvim": { "branch": "main", "commit": "8ab96b38a2530eacba5be717f52e04601eb59326" }, "wrapping.nvim": { "branch": "master", "commit": "3a823200c297885b70515fa8d974e1763c578e26" }, "zen-mode.nvim": { "branch": "main", "commit": "04b52674b8c800f8b7d4609e8bd8d0212e3ffa79" }, - "zk-nvim": { "branch": "main", "commit": "469e7562b8dbf1bcbfe1be245ca5d1724917f5c6" } + "zk-nvim": { "branch": "main", "commit": "50d92038d22ad9a537dcfd463c38527591430df6" } } From ddaaa697951a3d45a86170ab9ced6f21439ef656 Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Sat, 1 Feb 2025 10:44:34 +0100 Subject: [PATCH 13/27] nvim: Check if code evaluation maps set before overriding If we already have cc/cx mappings set before we come to set them for markdown filetypes we will not override them. --- nvim/.config/nvim/after/ftplugin/markdown.lua | 8 ++++++-- nvim/.config/nvim/lua/plugins/data_analysis.lua | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/nvim/.config/nvim/after/ftplugin/markdown.lua b/nvim/.config/nvim/after/ftplugin/markdown.lua index d7f2888..9da841e 100644 --- a/nvim/.config/nvim/after/ftplugin/markdown.lua +++ b/nvim/.config/nvim/after/ftplugin/markdown.lua @@ -14,8 +14,12 @@ end -- edit code cells with full lsp access map("n", "ce", "FeMaco", { silent = true, desc = "edit code block" }) -- execute code cells -map("n", "cc", "MdEval", { silent = true, desc = "evaluate code block" }) -map("n", "cx", "MdEvalClean", { silent = true, desc = "clear code results" }) +if not vim.fn.mapcheck("cc") then + map("n", "cc", "MdEval", { silent = true, desc = "evaluate code block" }) +end +if not vim.fn.mapcheck("cx") then + map("n", "cx", "MdEvalClean", { silent = true, desc = "clear code results" }) +end -- jump to beginning of previous/ next cell code map("n", "]c", "/^```}:nohl", { desc = "next code cell" }) diff --git a/nvim/.config/nvim/lua/plugins/data_analysis.lua b/nvim/.config/nvim/lua/plugins/data_analysis.lua index ef5c393..76c83bf 100644 --- a/nvim/.config/nvim/lua/plugins/data_analysis.lua +++ b/nvim/.config/nvim/lua/plugins/data_analysis.lua @@ -144,7 +144,7 @@ return { ":noautocmd :MoltenEnterOutput", { silent = true, desc = "show output" } ) - map("n", "cP", function() + map("n", "cx", function() vim.cmd("MoltenHideOutput") vim.cmd("MoltenDelete") end, { silent = true, desc = "hide output" }) From a5d28351cd2309301cae127036783c4aeb7244ef Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Sat, 1 Feb 2025 10:45:52 +0100 Subject: [PATCH 14/27] nvim: Ensure FeMaCo newline in codefence injections When formatting femaco buffers it would sometimes remove the newline necessary at the end of code fences to have the (```) remain on its own line. This attempts to fix it. --- nvim/.config/nvim/lua/plugins/data_analysis.lua | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/nvim/.config/nvim/lua/plugins/data_analysis.lua b/nvim/.config/nvim/lua/plugins/data_analysis.lua index 76c83bf..2b40065 100644 --- a/nvim/.config/nvim/lua/plugins/data_analysis.lua +++ b/nvim/.config/nvim/lua/plugins/data_analysis.lua @@ -227,8 +227,15 @@ return { cmd = { "FeMaco", }, - ft = { "markdown", "quarto" }, - opts = {}, + ft = { "markdown", "rmd", "quarto" }, + opts = { + ensure_newline = function(base_ft) + if base_ft == "quarto" or base_ft == "markdown" then + return true + end + return false + end, + }, dependencies = { "nvim-treesitter/nvim-treesitter", }, From 8b5e4dc0979ccb2904857a8339a8d8f902dd9fb8 Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Sat, 1 Feb 2025 10:46:22 +0100 Subject: [PATCH 15/27] nvim: Do not always run ruff_fix Ruff fix removes unused imports etc. which is sometimes more annoying than helpful. --- nvim/.config/nvim/lua/plugins/formatting.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nvim/.config/nvim/lua/plugins/formatting.lua b/nvim/.config/nvim/lua/plugins/formatting.lua index 2ff40a2..c382f80 100644 --- a/nvim/.config/nvim/lua/plugins/formatting.lua +++ b/nvim/.config/nvim/lua/plugins/formatting.lua @@ -14,7 +14,7 @@ local formatters = { lua = { "stylua" }, markdown = { "prettier", "injected" }, nim = { "nimpretty" }, - python = { "ruff_fix", "ruff_format", "ruff_organize_imports" }, + python = { "ruff_format", "ruff_organize_imports" }, quarto = { "prettier", "injected" }, sh = { "shfmt" }, sql = { "sleek" }, From 90161be418c1c8da3aa359cb185a40685ba118ed Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Mon, 3 Feb 2025 16:37:55 +0100 Subject: [PATCH 16/27] nvim: Add check for local .venv python dir --- nvim/.config/nvim/lua/core/util.lua | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/nvim/.config/nvim/lua/core/util.lua b/nvim/.config/nvim/lua/core/util.lua index 043136a..5fb9e4a 100644 --- a/nvim/.config/nvim/lua/core/util.lua +++ b/nvim/.config/nvim/lua/core/util.lua @@ -64,6 +64,11 @@ function T.get_python_venv_basefolder(workspace) return venv_path_cached end local match + match = vim.fn.finddir(".venv", "**1") + if match ~= "" then + venv_path_cached = match + return venv_path_cached + end -- Look downwards for file, can be nested. Limit to 1 depth for speed rn -- TODO: Maybe not hardcode 1-depth but allow choice. match = vim.fn.findfile("pyvenv.cfg", "**1") @@ -79,8 +84,8 @@ function T.get_python_venv_basefolder(workspace) if obj.code ~= 0 then return end - local venv_base_folder = obj.stdout:match("^%s*(.-)%s*$") - venv_path_cached = venv_base_folder + match = obj.stdout:match("^%s*(.-)%s*$") + venv_path_cached = match return venv_path_cached end end From 6edd3143cb156c25542f89af01fce51ea328653a Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Mon, 3 Feb 2025 16:38:38 +0100 Subject: [PATCH 17/27] nvim: Show markdown code blocks in full width --- nvim/.config/nvim/lua/plugins/prose.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/nvim/.config/nvim/lua/plugins/prose.lua b/nvim/.config/nvim/lua/plugins/prose.lua index 98c2b3b..dbd4f3a 100644 --- a/nvim/.config/nvim/lua/plugins/prose.lua +++ b/nvim/.config/nvim/lua/plugins/prose.lua @@ -72,7 +72,8 @@ local prose_plugs = { render_modes = { "n", "c", "i" }, code = { sign = false, - width = "block", + width = "full", + position = "right", right_pad = 1, }, checkbox = { From 4d98c9ab467ff02a66160f9babca9b80e6e416d6 Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Mon, 3 Feb 2025 16:43:42 +0100 Subject: [PATCH 18/27] nvim: Fix quarto jupyter kernel setup Creates a hidden kernel file with the current filename and '.kernel.json' suffix by default (in the file directory). But 'JupyterStart' command can also be given an argument to use as the filename / file path for the kernel file. That way we can also attach to already running kernels for longer running projects. --- nvim/.config/nvim/after/ftplugin/quarto.lua | 63 +++++++++++++++------ 1 file changed, 46 insertions(+), 17 deletions(-) diff --git a/nvim/.config/nvim/after/ftplugin/quarto.lua b/nvim/.config/nvim/after/ftplugin/quarto.lua index 170805a..213108e 100644 --- a/nvim/.config/nvim/after/ftplugin/quarto.lua +++ b/nvim/.config/nvim/after/ftplugin/quarto.lua @@ -9,9 +9,22 @@ local default_buffer_session = function() return temp_path end +-- TODO: Puths kernel into local file dir currently, +-- could take an argument to put it into temporary dir instead. +local kernel_filename = function() + local buf = vim.api.nvim_buf_get_name(0) + if not buf or buf:match("^$") then + vim.fn.tempname() + end + local path, name = buf:match("(.-)([^\\/]-%.?([^%.\\/]*))$") + + return path .. "." .. name .. ".kernel.json" +end + -- Start quarto session -local startsession = function(file, args) - file = file or default_buffer_session() +local startsession = function(opts) + local args = opts.fargs + local kernel_filen = args[1] or kernel_filename() local path = require("core.util").get_python_venv_bin() if not path then @@ -19,39 +32,55 @@ local startsession = function(file, args) end vim.g["python3_host_prog"] = path - if vim.fn.executable("jupyter-console") ~= 1 then + -- simply attach to existing if exists + if vim.fn.filereadable(kernel_filen) == 1 then + print(kernel_filen) + vim.cmd("MoltenInit " .. kernel_filen) return end - if args then - file = args[0] + -- look for session maker + local exec_name = "jupyter-kernel" + local exec_path = (require("core.util").get_python_venv_basefolder() or "") .. "/bin/" .. exec_name + if vim.fn.filereadable(exec_path) ~= 1 then + exec_path = exec_name + if vim.fn.executable(exec_path) ~= 1 then + return + end end + + -- make our own session local once = false - vim.fn.jobstart({ "jupyter", "console", "-f", file }, { - on_stdout = function(_) + vim.fn.jobstart({ exec_path, "--KernelManager.connection_file", kernel_filen }, { + on_stderr = function(_, data) if not once then - vim.cmd("MoltenInit " .. file) + for _, v in pairs(data) do + if v:find("connect a client") then + vim.cmd("MoltenInit " .. kernel_filen) + once = true + end + end end - once = true end, on_exit = function(_) - vim.notify(string.format("jupyter kernel stopped: %s", file), vim.log.levels.INFO) + vim.notify(string.format("jupyter kernel stopped: %s", kernel_filen), vim.log.levels.INFO) end, stdin = nil, }) end -vim.api.nvim_create_user_command("JupyterStart", function() - startsession(vim.b["sessionfile"] or default_buffer_session()) -end, {}) + +vim.api.nvim_create_user_command("JupyterStart", function(opts) + startsession(opts) +end, { nargs = "?" }) if vim.g.quarto_auto_init_molten_session then - vim.api.nvim_create_autocmd({ "InsertEnter", "BufEnter" }, { + vim.api.nvim_create_autocmd({ "BufEnter" }, { callback = function() if vim.b["sessionfile"] == nil then - local path = default_buffer_session() + local path = kernel_filename() vim.b["sessionfile"] = path - vim.schedule_wrap(function() - startsession(path) + vim.schedule(function() + startsession({ fargs = { path } }) end) end end, From ba6a8c16ce09b7cbea4c262cc021ce5d84f3f728 Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Wed, 5 Feb 2025 18:28:17 +0100 Subject: [PATCH 19/27] nvim: Simplify statusline python check --- nvim/.config/nvim/lua/plugins/statusline.lua | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/nvim/.config/nvim/lua/plugins/statusline.lua b/nvim/.config/nvim/lua/plugins/statusline.lua index 468067b..3543201 100644 --- a/nvim/.config/nvim/lua/plugins/statusline.lua +++ b/nvim/.config/nvim/lua/plugins/statusline.lua @@ -22,14 +22,11 @@ return { return "" -- we don't know if we have python yet, start a check else - vim.system({ "poetry", "env", "info", "-p" }, { text = true }, function(obj) - if obj.code == 0 then - has_pynvim = 1 - else - has_pynvim = 0 - end - end) - has_pynvim = 0 + if vim.fn.has("python3") == 1 then + has_pynvim = 1 + else + has_pynvim = 0 + end end end From ad3c8a61399cf4b04041ae86d30467aeaf2bf41c Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Wed, 5 Feb 2025 18:28:51 +0100 Subject: [PATCH 20/27] nvim: Lazy load completion on insert mode only --- nvim/.config/nvim/lua/plugins/completion.lua | 4 ++-- nvim/.config/nvim/lua/plugins/pickers.lua | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/nvim/.config/nvim/lua/plugins/completion.lua b/nvim/.config/nvim/lua/plugins/completion.lua index ca41d47..7b39561 100644 --- a/nvim/.config/nvim/lua/plugins/completion.lua +++ b/nvim/.config/nvim/lua/plugins/completion.lua @@ -9,14 +9,14 @@ return { { "aspeddro/cmp-pandoc.nvim", dependencies = { - "nvim-lua/plenary.nvim", + "nvim-lua/plenary.nvim", }, opts = { filetypes = { "pandoc", "markdown", "quarto", "rmd" }, }, }, }, - lazy = false, + event = { "InsertEnter" }, opts = { keymap = { preset = "default" }, diff --git a/nvim/.config/nvim/lua/plugins/pickers.lua b/nvim/.config/nvim/lua/plugins/pickers.lua index c8d1053..0ab8c6b 100644 --- a/nvim/.config/nvim/lua/plugins/pickers.lua +++ b/nvim/.config/nvim/lua/plugins/pickers.lua @@ -28,7 +28,7 @@ return { keys = { { "se", "Neotree toggle left", desc = "filetree", silent = true }, }, - lazy = false + lazy = false, }, { "MagicDuck/grug-far.nvim", lazy = false, opts = {} }, -- fuzzy matching picker From 9421ef807dd91feee8fea85fa84b32550f3e1c34 Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Wed, 5 Feb 2025 18:30:32 +0100 Subject: [PATCH 21/27] nvim: Remove lsp-setup.nvim plugin Removed the plugin since all its functionality can be replicated with an equal amount of lines without it nowadays. Should be even simpler in the future when we can just have individual lsp server config files in the config dir. --- nvim/.config/nvim/lazy-lock.json | 3 +- nvim/.config/nvim/lua/plugins/lsp.lua | 316 +++++++++++--------------- 2 files changed, 136 insertions(+), 183 deletions(-) diff --git a/nvim/.config/nvim/lazy-lock.json b/nvim/.config/nvim/lazy-lock.json index 049641a..9cdd146 100644 --- a/nvim/.config/nvim/lazy-lock.json +++ b/nvim/.config/nvim/lazy-lock.json @@ -27,7 +27,6 @@ "jupytext.nvim": { "branch": "main", "commit": "c8baf3ad344c59b3abd461ecc17fc16ec44d0f7b" }, "lazy.nvim": { "branch": "main", "commit": "7e6c863bc7563efbdd757a310d17ebc95166cef3" }, "lazydev.nvim": { "branch": "main", "commit": "f59bd14a852ca43db38e3662395354cb2a9b13e0" }, - "lsp-setup.nvim": { "branch": "main", "commit": "6e4e977512ce426d8b52c27f3b6e6aefc73e1452" }, "ltex_extra.nvim": { "branch": "dev", "commit": "09dc879b1873001f855bca5ad1f024ca15b9bbaf" }, "lualine.nvim": { "branch": "master", "commit": "2a5bae925481f999263d6f5ed8361baef8df4f83" }, "luarocks.nvim": { "branch": "main", "commit": "1db9093915eb16ba2473cfb8d343ace5ee04130a" }, @@ -49,7 +48,7 @@ "nvim-colorizer.lua": { "branch": "master", "commit": "39142aa1390d6ccdca57cb6dc5b2c7bfed460ffe" }, "nvim-coverage": { "branch": "main", "commit": "a939e425e363319d952a6c35fb3f38b34041ded2" }, "nvim-lint": { "branch": "master", "commit": "789b7ada1b4f00e08d026dffde410dcfa6a0ba87" }, - "nvim-lspconfig": { "branch": "master", "commit": "e5bf88e5ea1c4cea5ea96b1e970cb264f7a401a1" }, + "nvim-lspconfig": { "branch": "master", "commit": "bf81bef7d75a0f4a0cf61462b318ea00b3c97cc8" }, "nvim-nio": { "branch": "master", "commit": "21f5324bfac14e22ba26553caf69ec76ae8a7662" }, "nvim-surround": { "branch": "main", "commit": "ae298105122c87bbe0a36b1ad20b06d417c0433e" }, "nvim-toggleterm.lua": { "branch": "main", "commit": "50ea089fc548917cc3cc16b46a8211833b9e3c7c" }, diff --git a/nvim/.config/nvim/lua/plugins/lsp.lua b/nvim/.config/nvim/lua/plugins/lsp.lua index a73b1fd..0618215 100644 --- a/nvim/.config/nvim/lua/plugins/lsp.lua +++ b/nvim/.config/nvim/lua/plugins/lsp.lua @@ -44,178 +44,46 @@ local servers = { yamlls = {}, } -return { - -- lsp setup +local lsp = { + { -- pretty lsp 'peek' menus + "DNLHC/glance.nvim", + opts = { border = { enable = true }, theme = { enable = true, mode = "auto" } }, + cmd = { "Glance" }, + }, { - "junnplus/lsp-setup.nvim", + "neovim/nvim-lspconfig", dependencies = { - { - "neovim/nvim-lspconfig", - -- will sometimes not keep up with lsp changes if set to stable - version = false, - }, - { - "williamboman/mason.nvim", - cmd = { - "Mason", - "MasonInstall", - "MasonUninstall", - "MasonUninstallAll", - "MasonLog", - "MasonUpdate", - }, - build = ":MasonUpdate", - keys = { - { "vm", ":Mason", desc = "Mason" }, - }, - }, { "williamboman/mason-lspconfig.nvim", + opts = { automatic_installation = true }, + dependencies = { + "williamboman/mason.nvim", + cmd = { + "Mason", + "MasonInstall", + "MasonUninstall", + "MasonUninstallAll", + "MasonLog", + "MasonUpdate", + }, + opts = {}, + build = ":MasonUpdate", + keys = { + { "vm", ":Mason", desc = "Mason" }, + }, + }, cmd = { "LspInstall", "LspUninstall" }, }, + { "saghen/blink.cmp", optional = true }, }, event = { "BufReadPost", "BufNewFile", "BufWritePre" }, - config = function() - vim.diagnostic.config({ virtual_text = true }) - vim.fn.sign_define("DiagnosticSignError", { text = "✘", texthl = "DiagnosticSignError" }) - vim.fn.sign_define("DiagnosticSignWarn", { text = "", texthl = "DiagnosticSignWarn" }) - vim.fn.sign_define("DiagnosticSignInfo", { text = "", texthl = "DiagnosticSignInfo" }) - vim.fn.sign_define("DiagnosticSignHint", { text = "", texthl = "DiagnosticSignHint" }) - - local lsp = require("lsp-setup") - - local function on_attach(_, bufnr) - local map = vim.keymap.set - map( - "n", - "[d", - "lua vim.diagnostic.goto_prev()", - { buffer = bufnr, desc = "Previous diagnostic" } - ) - map("n", "]d", "lua vim.diagnostic.goto_next()", { buffer = bufnr, desc = "Next diagnostic" }) - map( - "n", - "[D", - "lua vim.diagnostic.goto_prev({severity = vim.diagnostic.severity.ERROR})", - { buffer = bufnr, desc = "Previous error" } - ) - map( - "n", - "]D", - "lua vim.diagnostic.goto_next({severity = vim.diagnostic.severity.ERROR})", - { buffer = bufnr, desc = "Next error" } - ) - - if require("core.util").is_available("which-key") then - require("which-key").add({ "l", group = "language" }) - end - map( - "n", - "ld", - "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 - map("n", "lr", "Glance references", { buffer = bufnr, desc = "References" }) - map("n", "lf", "Glance definitions", { buffer = bufnr, desc = "Definition" }) - map( - "n", - "lt", - "Glance type_definitions", - { buffer = bufnr, desc = "Type definition" } - ) - map( - "n", - "lm", - "Glance implementations", - { buffer = bufnr, desc = "Implementation" } - ) - elseif vim.fn.exists(":Telescope") then - map( - "n", - "lr", - "Telescope lsp_references", - { buffer = bufnr, desc = "References" } - ) - map( - "n", - "lf", - "Telescope lsp_definitions", - { buffer = bufnr, desc = "Definition" } - ) - map( - "n", - "lt", - "Telescope lsp_type_definitions", - { buffer = bufnr, desc = "Type definition" } - ) - map( - "n", - "lm", - "Telescope lsp_implementations", - { buffer = bufnr, desc = "Implementation" } - ) - else - map( - "n", - "lr", - "lua vim.lsp.buf.references()", - { buffer = bufnr, desc = "References" } - ) - map( - "n", - "lf", - "lua vim.lsp.buf.definition()", - { buffer = bufnr, desc = "Definition" } - ) - map( - "n", - "lt", - "lua vim.lsp.buf.type_definition()", - { buffer = bufnr, desc = "Type definition" } - ) - map( - "n", - "lm", - "lua vim.lsp.buf.implementation()", - { buffer = bufnr, desc = "Implementation" } - ) - end - map("n", "K", "lua vim.lsp.buf.hover()", { buffer = bufnr, desc = "Hover definition" }) - map( - "n", - "lc", - "lua vim.lsp.buf.declaration()", - { buffer = bufnr, desc = "Declaration" } - ) - map( - "n", - "ls", - "lua vim.lsp.buf.signature_help()", - { buffer = bufnr, desc = "Signature help" } - ) - map("n", "lo", function() - vim.diagnostic.enable(not vim.diagnostic.is_enabled()) - end, { buffer = bufnr, desc = "Toggle Diagnostics" }) - end + opts = { servers = servers }, + config = function(_, lspconfig_opts) + local lspconfig = require("lspconfig") -- Display diagnostics as virtual text only if not in insert mode -- /r/neovim/comments/12inp4c/disable_diagnostics_virtual_text_when_in_insert/jqqifwk/ + vim.diagnostic.config({ virtual_text = true }) vim.api.nvim_create_autocmd("InsertEnter", { callback = function() vim.diagnostic.config({ virtual_text = false }) @@ -227,16 +95,19 @@ return { end, }) - lsp.setup({ - default_mappings = false, - servers = servers, - on_attach = on_attach, - inlay_hints = { - enabled = vim.fn.has("nvim-0.10") == true and true or false, - }, - }) + vim.fn.sign_define("DiagnosticSignError", { text = "✘", texthl = "DiagnosticSignError" }) + vim.fn.sign_define("DiagnosticSignWarn", { text = "", texthl = "DiagnosticSignWarn" }) + vim.fn.sign_define("DiagnosticSignInfo", { text = "", texthl = "DiagnosticSignInfo" }) + vim.fn.sign_define("DiagnosticSignHint", { text = "", texthl = "DiagnosticSignHint" }) + + for server, config in pairs(lspconfig_opts.servers) do + -- TODO: Check if it actually can be ignored in Nvim 0.11+, see https://cmp.saghen.dev/installation.html#lazy-nvim + if vim.fn.has("nvim-0.11") == false then + config.capabilities = require("blink.cmp").get_lsp_capabilities(config.capabilities) + end + lspconfig[server].setup(config) + end - local lspconfig = require("lspconfig") lspconfig.nushell.setup({}) lspconfig.marksman.setup({ @@ -279,7 +150,6 @@ return { end, } end - on_attach(client, bufnr) end, on_new_config = function(conf, new_root) if require("lspconfig.util").root_pattern(".zk")(new_root) then @@ -295,12 +165,10 @@ return { -- we primarily use pyright for cmp lsp completion & hover info lspconfig.basedpyright.setup({ on_attach = function(client, bufnr) - on_attach(client, bufnr) require("core.util").set_python_env() if python_path == nil then python_path, _ = vim.fn.expand(require("core.util").get_python_venv_bin(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 end, @@ -319,7 +187,6 @@ return { }) lspconfig.ruff.setup({ on_attach = function(client, bufnr) - on_attach(client, bufnr) require("core.util").set_python_env() client.server_capabilities.hoverProvider = false -- we use pyright for hover info if python_path == nil then @@ -343,7 +210,6 @@ return { callback = function() lspconfig.ltex.setup({ on_attach = function(client, bufnr) - on_attach(client, bufnr) if require("core.util").is_available("ltex_extra") then require("ltex_extra").setup() end @@ -360,10 +226,98 @@ return { end, keys = { { "vs", ":LspInfo", desc = "LspInfo" } }, }, - -- pretty lsp 'peek' menus - { - "DNLHC/glance.nvim", - opts = { border = { enable = true }, theme = { enable = true, mode = "auto" } }, - cmd = { "Glance" }, - }, } + +vim.api.nvim_create_autocmd("LspAttach", { + desc = "LSP actions", + callback = function(event) + local o = function(add_opts) + return vim.tbl_extend("force", { buffer = event.buf }, add_opts) + end + + local map = vim.keymap.set + map("n", "K", "lua vim.lsp.buf.hover()", o({ desc = "Hover definition" })) + map("n", "[d", "lua vim.diagnostic.goto_prev()", o({ desc = "Previous diagnostic" })) + map("n", "]d", "lua vim.diagnostic.goto_next()", o({ desc = "Next diagnostic" })) + map( + "n", + "[D", + "lua vim.diagnostic.goto_prev({severity = vim.diagnostic.severity.ERROR})", + o({ desc = "Previous error" }) + ) + map( + "n", + "]D", + "lua vim.diagnostic.goto_next({severity = vim.diagnostic.severity.ERROR})", + o({ desc = "Next error" }) + ) + + if require("core.util").is_available("which-key") then + require("which-key").add({ "l", group = "language" }) + end + map("n", "ld", "lua vim.diagnostic.open_float()", o({ desc = "Show line diagnostics" })) + map("n", "lI", function() + vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled()) + end, o({ desc = "Toggle inlay hints" })) + map("n", "la", "lua vim.lsp.buf.code_action()", o({ desc = "Codeactions" })) + map("n", "ln", "lua vim.lsp.buf.rename()", o({ desc = "Rename element" })) + map("n", "lc", "lua vim.lsp.buf.declaration()", o({ desc = "Declaration" })) + map("n", "ls", "lua vim.lsp.buf.signature_help()", o({ desc = "Signature help" })) + map("n", "lo", function() + vim.diagnostic.enable(not vim.diagnostic.is_enabled()) + end, o({ desc = "Toggle Diagnostics" })) + + local pref = function(glances, telescope, fallback) + if glances and vim.fn.exists(":Glance") > 0 then + return glances + elseif telescope and vim.fn.exists(":Telescope") > 0 then + return telescope + else + return fallback + end + end + + map( + "n", + "lr", + pref( + "Glance references", + "Telescope lsp_references", + "lua vim.lsp.buf.references()" + ), + o({ desc = "References" }) + ) + map( + "n", + "lf", + pref( + "Glance definitions", + "Telescope lsp_definitions", + "lua vim.lsp.buf.definition()" + ), + o({ desc = "Definition" }) + ) + map( + "n", + "lt", + pref( + "Glance type_definitions", + "Telescope lsp_type_definitions", + "lua vim.lsp.buf.type_definition()" + ), + o({ desc = "Type definition" }) + ) + map( + "n", + "lm", + pref( + "Glance implementations", + "Telescope lsp_implementations", + "lua vim.lsp.buf.implementation()" + ), + o({ desc = "Implementation" }) + ) + end, +}) + +return lsp From 50d78cbb2f7db05591c68b5d74d1548a87eec28a Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Wed, 5 Feb 2025 19:05:50 +0100 Subject: [PATCH 22/27] nvim: Overhaul prose preview keys --- nvim/.config/nvim/after/ftplugin/markdown.lua | 12 ++-- nvim/.config/nvim/after/ftplugin/quarto.lua | 5 +- nvim/.config/nvim/after/ftplugin/typst.lua | 3 + nvim/.config/nvim/lazy-lock.json | 1 + nvim/.config/nvim/lua/plugins/prose.lua | 67 ++++++++++++------- 5 files changed, 56 insertions(+), 32 deletions(-) create mode 100644 nvim/.config/nvim/after/ftplugin/typst.lua diff --git a/nvim/.config/nvim/after/ftplugin/markdown.lua b/nvim/.config/nvim/after/ftplugin/markdown.lua index 9da841e..303dc82 100644 --- a/nvim/.config/nvim/after/ftplugin/markdown.lua +++ b/nvim/.config/nvim/after/ftplugin/markdown.lua @@ -32,18 +32,18 @@ if require("core.util").is_available("which-key") then require("which-key").add({ "p", group = "prose" }) end -- show nice md preview in browser (auto-syncs scrolling) +local peek_key = "po" if require("core.util").is_available("peek") then - local peek = require("peek") - local function togglePeek() + map("n", peek_key, function() + local peek = require("peek") if peek.is_open() then peek.close() else peek.open() end - end - map("n", "po", togglePeek, { desc = "show md preview" }) -else - map("n", "po", "MarkdownPreviewToggle", { desc = "show md preview" }) + end, { desc = "show md preview" }) +elseif vim.fn.exists(":MarkdownPreviewToggle") > 0 then + map("n", peek_key, "MarkdownPreviewToggle", { desc = "show md preview" }) end -- create mindmaps directly from markdown! requires external executable diff --git a/nvim/.config/nvim/after/ftplugin/quarto.lua b/nvim/.config/nvim/after/ftplugin/quarto.lua index 213108e..3251bbc 100644 --- a/nvim/.config/nvim/after/ftplugin/quarto.lua +++ b/nvim/.config/nvim/after/ftplugin/quarto.lua @@ -1,3 +1,7 @@ +if require("core.util").is_available("quarto") then + vim.keymap.set("n", "po", require("quarto").quartoPreview, { desc = "show quarto preview" }) +end + local default_buffer_session = function() local buffer_path = vim.api.nvim_buf_get_name(0) or vim.fn.tempname() local temp_path = vim.fn.stdpath("run") .. "/molten-sessions" .. buffer_path .. ".json" @@ -34,7 +38,6 @@ local startsession = function(opts) -- simply attach to existing if exists if vim.fn.filereadable(kernel_filen) == 1 then - print(kernel_filen) vim.cmd("MoltenInit " .. kernel_filen) return end diff --git a/nvim/.config/nvim/after/ftplugin/typst.lua b/nvim/.config/nvim/after/ftplugin/typst.lua new file mode 100644 index 0000000..e3d8d14 --- /dev/null +++ b/nvim/.config/nvim/after/ftplugin/typst.lua @@ -0,0 +1,3 @@ +if vim.fn.exists(":TypstPreviewToggle") > 0 then + vim.keymap.set("n", "po", "TypstPreviewToggle", { desc = "show typst preview" }) +end diff --git a/nvim/.config/nvim/lazy-lock.json b/nvim/.config/nvim/lazy-lock.json index 9cdd146..838c019 100644 --- a/nvim/.config/nvim/lazy-lock.json +++ b/nvim/.config/nvim/lazy-lock.json @@ -74,6 +74,7 @@ "todo-comments.nvim": { "branch": "main", "commit": "ae0a2afb47cf7395dc400e5dc4e05274bf4fb9e0" }, "trouble.nvim": { "branch": "main", "commit": "40c5317a6e90fe3393f07b0fee580d9e93a216b4" }, "twilight.nvim": { "branch": "main", "commit": "8bb7fa7b918baab1ca81b977102ddb54afa63512" }, + "typst-preview.nvim": { "branch": "master", "commit": "c1100e8788baabe8ca8f8cd7fd63d3d479e49e36" }, "undotree": { "branch": "main", "commit": "eab459ab87dd249617b5f7187bb69e614a083047" }, "vifm.vim": { "branch": "master", "commit": "a8130c37d144b51d84bee19f0532abcd3583383f" }, "vim-criticmarkup": { "branch": "master", "commit": "d15dc134eb177a170c79f6377f81eb02a9d20b02" }, diff --git a/nvim/.config/nvim/lua/plugins/prose.lua b/nvim/.config/nvim/lua/plugins/prose.lua index dbd4f3a..76b531b 100644 --- a/nvim/.config/nvim/lua/plugins/prose.lua +++ b/nvim/.config/nvim/lua/plugins/prose.lua @@ -97,7 +97,7 @@ local prose_plugs = { cmd = "RenderMarkdown", keys = { { - "pp", + "pm", function() require("render-markdown").toggle() end, @@ -106,29 +106,43 @@ local prose_plugs = { }, }, }, + --- PREVIEW SECTION -- generate an auto-updating html preview for md files -- uses the very nice peek if deno is available, otherwise falls back to markdown-preview { "toppair/peek.nvim", - event = { "VeryLazy" }, cond = vim.fn.executable("deno") == 1, build = "deno task --quiet build:fast", ft = md_like, - config = function() - require("peek").setup() - vim.api.nvim_create_user_command("PeekOpen", require("peek").open, {}) - vim.api.nvim_create_user_command("PeekClose", require("peek").close, {}) - end, + opts = {}, }, { "iamcco/markdown-preview.nvim", - event = { "VeryLazy" }, cond = vim.fn.executable("deno") == 0, build = function() vim.fn["mkdp#util#install"]() end, + version = false, ft = md_like, + cmd = { "MarkdownPreviewToggle", "MarkdownPreview", "MarkdownPreviewStop" }, }, + { + "chomosuke/typst-preview.nvim", + ft = { "typst" }, + opts = { -- to use mason-managed binary + dependencies_bin = { ["tinymist"] = "tinymist" }, + }, + cmd = { + "TypstPreview", + "TypstPreviewUpdate", + "TypstPreviewStop", + "TypstPreviewToggle", + "TypstPreviewFollowCursor", + "TypstPreviewNoFollowCursor", + "TypstPreviewFollowCursorToggle", + }, + }, + --- END PREVIEW SECTION -- easy copy paste of images into markup files { @@ -145,7 +159,7 @@ local prose_plugs = { }, cmd = { "PasteImage" }, keys = { - { "pi", "PasteImage", desc = "Paste image from system clipboard" }, + { "pi", "PasteImage", desc = "Paste image from system clipboard" }, }, ft = prose_ft, }, @@ -244,22 +258,25 @@ local prose_plugs = { -- cite as you write from papis databases -- ADDITIONAL DEPENDENCIES: papis and yq in shell env - -- { - -- "jghauser/papis.nvim", - -- dependencies = { - -- "kkharji/sqlite.lua", - -- "MunifTanjim/nui.nvim", - -- "pysan3/pathlib.nvim", - -- "nvim-neotest/nvim-nio", - -- "nvim-treesitter/nvim-treesitter", - -- }, - -- cond = vim.fn.executable("papis") == 1 and vim.fn.executable("yq") == 1, - -- ft = writing_ft, - -- lazy = false, - -- config = function() - -- require("papis").setup({}) - -- end, - -- }, + -- still same issues: slow, buggy, does not work for me + { + "jghauser/papis.nvim", + dependencies = { + "kkharji/sqlite.lua", + "MunifTanjim/nui.nvim", + "pysan3/pathlib.nvim", + "nvim-neotest/nvim-nio", + -- if not already installed, you may also want: + { "nvim-telescope/telescope.nvim", optional = true }, + -- "hrsh7th/nvim-cmp", + }, + config = function() + require("papis").setup({ + init_filetypes = prose_ft, + }) + end, + lazy = false, + }, { "barreiroleo/ltex_extra.nvim", branch = "dev", From 7d616c1cb58c83707be66c4c9cd38c275b4d0262 Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Thu, 6 Feb 2025 11:45:29 +0100 Subject: [PATCH 23/27] nvim: Improve indentscope disables Improved conditional disabling of indentscope lines, e.g. in lazy and mason floats, terminals and helpfiles. --- nvim/.config/nvim/lua/plugins/base.lua | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/nvim/.config/nvim/lua/plugins/base.lua b/nvim/.config/nvim/lua/plugins/base.lua index 838f938..be88221 100644 --- a/nvim/.config/nvim/lua/plugins/base.lua +++ b/nvim/.config/nvim/lua/plugins/base.lua @@ -203,6 +203,32 @@ return { draw = { animation = require("mini.indentscope").gen_animation.none() }, options = { indent_at_cursor = false }, }) + -- disable indentlines for terminals + vim.api.nvim_create_autocmd("TermOpen", { + pattern = "*", + callback = function() + vim.b.miniindentscope_disable = true + end, + }) + vim.api.nvim_create_autocmd("FileType", { + pattern = { + "lazy", + "mason", + "help", + "lspinfo", + "packer", + "checkhealth", + "man", + "gitcommit", + "TelescopePrompt", + "TelescopeResults", + "trouble", + }, + callback = function() + vim.b.miniindentscope_disable = true + end, + }) + require("mini.map").setup() require("mini.move").setup() require("mini.operators").setup() From 9d15bc79f499b156584b0f970370dafa38191dbc Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Thu, 6 Feb 2025 12:49:10 +0100 Subject: [PATCH 24/27] nvim: Clean up markdown/quarto key maps --- nvim/.config/nvim/after/ftplugin/markdown.lua | 14 +++++----- nvim/.config/nvim/after/ftplugin/quarto.lua | 17 +++--------- .../nvim/lua/plugins/data_analysis.lua | 26 +++++++++---------- 3 files changed, 21 insertions(+), 36 deletions(-) diff --git a/nvim/.config/nvim/after/ftplugin/markdown.lua b/nvim/.config/nvim/after/ftplugin/markdown.lua index 303dc82..50d5511 100644 --- a/nvim/.config/nvim/after/ftplugin/markdown.lua +++ b/nvim/.config/nvim/after/ftplugin/markdown.lua @@ -11,22 +11,20 @@ if require("core.util").is_available("zk") and require("zk.util").notebook_root( map("n", "", "lua vim.lsp.buf.definition()", { silent = true }) end --- edit code cells with full lsp access -map("n", "ce", "FeMaco", { silent = true, desc = "edit code block" }) -- execute code cells -if not vim.fn.mapcheck("cc") then - map("n", "cc", "MdEval", { silent = true, desc = "evaluate code block" }) +if vim.fn.mapcheck("cc") == "" then + map("n", "cc", require("mdeval").eval_code_block, { silent = true, desc = "evaluate code block" }) end -if not vim.fn.mapcheck("cx") then - map("n", "cx", "MdEvalClean", { silent = true, desc = "clear code results" }) +if vim.fn.mapcheck("cx") == "" then + map("n", "cx", require("mdeval").eval_clean_results, { silent = true, desc = "clear code results" }) end -- jump to beginning of previous/ next cell code map("n", "]c", "/^```}:nohl", { desc = "next code cell" }) map("n", "[c", "?^```n}:nohl", { desc = "previous code cell" }) -- insert cell header above/below -map("n", "co", "o```python```k", { desc = "Insert quarto cell below" }) -map("n", "cO", "O```python```k", { desc = "Insert quarto cell above" }) +map("n", "co", "o```python```k", { desc = "Insert code cell below" }) +map("n", "cO", "O```python```k", { desc = "Insert code cell above" }) if require("core.util").is_available("which-key") then require("which-key").add({ "p", group = "prose" }) diff --git a/nvim/.config/nvim/after/ftplugin/quarto.lua b/nvim/.config/nvim/after/ftplugin/quarto.lua index 3251bbc..a38d353 100644 --- a/nvim/.config/nvim/after/ftplugin/quarto.lua +++ b/nvim/.config/nvim/after/ftplugin/quarto.lua @@ -2,17 +2,6 @@ if require("core.util").is_available("quarto") then vim.keymap.set("n", "po", require("quarto").quartoPreview, { desc = "show quarto preview" }) end -local default_buffer_session = function() - local buffer_path = vim.api.nvim_buf_get_name(0) or vim.fn.tempname() - local temp_path = vim.fn.stdpath("run") .. "/molten-sessions" .. buffer_path .. ".json" - - local dir = vim.fn.fnamemodify(temp_path, ":p:h") - if vim.fn.getftype(dir) ~= "dir" then - vim.fn.mkdir(dir, "p") - end - return temp_path -end - -- TODO: Puths kernel into local file dir currently, -- could take an argument to put it into temporary dir instead. local kernel_filename = function() @@ -29,6 +18,7 @@ end local startsession = function(opts) local args = opts.fargs local kernel_filen = args[1] or kernel_filename() + vim.b["sessionfile"] = kernel_filen local path = require("core.util").get_python_venv_bin() if not path then @@ -75,15 +65,14 @@ end vim.api.nvim_create_user_command("JupyterStart", function(opts) startsession(opts) end, { nargs = "?" }) +vim.keymap.set("n", "cS", ":JupyterStart", { desc = "start code session", silent = true }) if vim.g.quarto_auto_init_molten_session then vim.api.nvim_create_autocmd({ "BufEnter" }, { callback = function() if vim.b["sessionfile"] == nil then - local path = kernel_filename() - vim.b["sessionfile"] = path vim.schedule(function() - startsession({ fargs = { path } }) + startsession() end) end end, diff --git a/nvim/.config/nvim/lua/plugins/data_analysis.lua b/nvim/.config/nvim/lua/plugins/data_analysis.lua index 2b40065..0b125b5 100644 --- a/nvim/.config/nvim/lua/plugins/data_analysis.lua +++ b/nvim/.config/nvim/lua/plugins/data_analysis.lua @@ -40,10 +40,11 @@ return { map("n", "ca", require("quarto.runner").run_above, { desc = "run cells above" }) map("n", "cb", require("quarto.runner").run_below, { desc = "run cells below" }) map("n", "cA", require("quarto.runner").run_all, { desc = "run all similar cells" }) + -- TODO: overwritten by other moves, i.e. comment? map("n", "]c", "/^```{}:nohl", { desc = "Codecell forward" }) map("n", "[c", "?^```n}:nohl", { desc = "Codecell last" }) - map("n", "co", "o```{python}```k", { desc = "Insert quarto cell below" }) - map("n", "cO", "O```{python}```k", { desc = "Insert quarto cell above" }) + map("n", "co", "o```{python}```k", { desc = "Insert code cell below" }) + map("n", "cO", "O```{python}```k", { desc = "Insert code cell above" }) if require("core.util").is_available("which-key") then require("which-key").add({ "c", group = "codecells" }) @@ -191,9 +192,9 @@ return { ft = { "norg", "quarto", "python" }, keys = { { "vn", ":MoltenInfo" }, - { "cJ", ":JupyterStart", desc = "start jupyter", silent = true }, }, cmd = { + "JupyterStart", "MoltenInfo", "MoltenInit", "MoltenDeinit", @@ -224,9 +225,7 @@ return { -- Edit code blocks in md/quarto using whatever language is { "AckslD/nvim-FeMaco.lua", - cmd = { - "FeMaco", - }, + cmd = { "FeMaco" }, ft = { "markdown", "rmd", "quarto" }, opts = { ensure_newline = function(base_ft) @@ -236,20 +235,19 @@ return { return false end, }, + config = function(_, opts) + vim.keymap.set("n", "ce", ":FeMaco", { desc = "edit codecell" }) + require("femaco").setup(opts) + end, dependencies = { "nvim-treesitter/nvim-treesitter", }, - keys = { - { "ce", ":FeMaco", desc = "edit codecell" }, - }, }, -- MARKDOWN ONLY -- Evaluate markdown code blocks - { + { -- TODO: Have results appear as virtual text instead of real text? "jubnzv/mdeval.nvim", - cmd = { - "MdEval", - }, + cmd = { "MdEval" }, ft = { "markdown" }, opts = { require_confirmation = false, @@ -277,7 +275,7 @@ return { }, }, }, - cond = vim.fn.executable("jupytext") == 1, -- only runs if imagemagick installed + cond = vim.fn.executable("jupytext") == 1, -- only runs if jupytext installed lazy = false, -- does not work in lazy mode }, } From 101937a8c2f370d29e0fdaf2d7980be2a57bc831 Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Thu, 6 Feb 2025 13:13:41 +0100 Subject: [PATCH 25/27] nvim: Fix image.nvim functionality Track master since no new version has been tagged. Change some settings around and make installation more robust using the new lazy rocks system. --- nvim/.config/nvim/lazy-lock.json | 2 +- .../nvim/lua/plugins/data_analysis.lua | 66 +++++++++---------- 2 files changed, 32 insertions(+), 36 deletions(-) diff --git a/nvim/.config/nvim/lazy-lock.json b/nvim/.config/nvim/lazy-lock.json index 838c019..52fa1bc 100644 --- a/nvim/.config/nvim/lazy-lock.json +++ b/nvim/.config/nvim/lazy-lock.json @@ -22,7 +22,7 @@ "glance.nvim": { "branch": "master", "commit": "1a08824835d7582457b67acbe23ca33487912a5e" }, "grug-far.nvim": { "branch": "main", "commit": "635e69adf3a714621bd0a289314bc23c5848babb" }, "helpview.nvim": { "branch": "main", "commit": "34be34afd0811dee17e6b0c46176d9140659fe8e" }, - "image.nvim": { "branch": "master", "commit": "da64ce69598875c9af028afe129f916b02ccc42e" }, + "image.nvim": { "branch": "master", "commit": "6ffafab2e98b5bda46bf227055aa84b90add8cdc" }, "img-clip.nvim": { "branch": "main", "commit": "28a32d811d69042f4fa5c3d5fa35571df2bc1623" }, "jupytext.nvim": { "branch": "main", "commit": "c8baf3ad344c59b3abd461ecc17fc16ec44d0f7b" }, "lazy.nvim": { "branch": "main", "commit": "7e6c863bc7563efbdd757a310d17ebc95166cef3" }, diff --git a/nvim/.config/nvim/lua/plugins/data_analysis.lua b/nvim/.config/nvim/lua/plugins/data_analysis.lua index 0b125b5..e05887b 100644 --- a/nvim/.config/nvim/lua/plugins/data_analysis.lua +++ b/nvim/.config/nvim/lua/plugins/data_analysis.lua @@ -53,48 +53,44 @@ return { ft = { "quarto" }, }, - { - "vhyrro/luarocks.nvim", - priority = 1001, -- this plugin needs to run before anything else - opts = { - rocks = { "magick" }, - }, - }, -- image display { "3rd/image.nvim", - dependencies = { "luarocks.nvim", { "nvim-treesitter/nvim-treesitter", optional = true } }, - cond = vim.fn.executable("magick") == 1, -- only runs if imagemagick installed - config = function() - local integrations = {} - if vim.treesitter.language.get_lang("markdown") then - integrations["markdown"] = { - enabled = true, - clear_in_insert_mode = true, - download_remote_images = true, + version = false, + dependencies = { + { + "vhyrro/luarocks.nvim", + priority = 1001, -- this plugin needs to run before anything else + opts = { + rocks = { "magick" }, + }, + }, + { "nvim-treesitter/nvim-treesitter", optional = true }, + }, + opts = { + backend = "kitty", + editor_only_render_when_focused = true, + -- TODO: Check that this works without TS md parser, norg or typst installed + -- If errors go back to commit before 87691932 when this check was still here + integrations = { + markdown = { only_render_image_at_cursor = true, filetypes = { "markdown", "vimwiki", "quarto" }, - } - end - if vim.treesitter.language.get_lang("norg") then - integrations["neorg"] = { - enabled = true, - clear_in_insert_mode = true, - download_remote_images = true, + }, + neorg = { only_render_image_at_cursor = true, - filetypes = { "norg" }, - } - end - if next(integrations) ~= nil then -- only set up if we have at least 1 TS parser - require("image").setup({ - backend = "kitty", - integrations = integrations, - }) - vim.g.molten_image_provider = "image.nvim" - pcall(vim.fn.MoltenUpdateOption, "molten_image_provider", "image.nvim") - end + }, + typst = { + only_render_image_at_cursor = true, + }, + }, + }, + config = function(_, opts) + require("image").setup(opts) + vim.g.molten_image_provider = "image.nvim" + pcall(vim.fn.MoltenUpdateOption, "molten_image_provider", "image.nvim") end, - ft = { "markdown", "vimwiki", "quarto", "norg", "python" }, + ft = { "markdown", "vimwiki", "quarto", "norg", "typst", "python" }, priority = 60, }, -- REPL work From 99eada00b8ca79070b265dcc3e9751e14a1d1326 Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Thu, 6 Feb 2025 13:19:18 +0100 Subject: [PATCH 26/27] nvim: Improve custom toggle terms Added euporia term to split it from other python variations. Fixed python command selection. Improved mapping and which key display. Removed indentline settings since that is responsibility of indentline. --- nvim/.config/nvim/lua/plugins/terminal.lua | 119 +++++++++------------ 1 file changed, 50 insertions(+), 69 deletions(-) diff --git a/nvim/.config/nvim/lua/plugins/terminal.lua b/nvim/.config/nvim/lua/plugins/terminal.lua index ac97546..54f5726 100644 --- a/nvim/.config/nvim/lua/plugins/terminal.lua +++ b/nvim/.config/nvim/lua/plugins/terminal.lua @@ -1,68 +1,54 @@ -return { - -- simpler, programmable and multiple terminal toggling for nvim +return { -- simple programmable terminal toggling for nvim { "akinsho/nvim-toggleterm.lua", + init = function(_) + if require("core.util").is_available("which-key") then + require("which-key").add({ "t", group = "terminal" }) + end + end, config = function() require("toggleterm").setup({ - open_mapping = [[=]], + open_mapping = [[tt]], insert_mappings = false, -- don't map the key in insert mode terminal_mappings = false, }) local Terminal = require("toggleterm.terminal").Terminal - -- need to disable indentlines since they obscure first line of terminal - if require("core.util").is_available("mini.nvim") then - vim.api.nvim_create_autocmd({ "TermOpen" }, { - pattern = "*", - callback = function() - vim.b.miniindentscope_disable = true - end, - }) - end - local function custom_term_set_toggle_key(term) vim.keymap.set("t", "", function() term:toggle() - end, { silent = true, buffer = true }) + end, { silent = true, buffer = true, desc = "terminal" }) end - -- create python window - local function get_python_cmd() - if vim.fn.executable("py") then - return "py" - end - if vim.fn.executable("ptipython") then - return "ptipython" - end - if vim.fn.executable("ipython") then - return "ipython" - end - if vim.fn.executable("ptpython") then - return "ptpython" - end - if vim.fn.executable("python") then - return "python" - end + local custom_term_default_style = function(cmd) + return { + cmd = cmd, + hidden = true, + direction = "float", + float_opts = { border = "curved" }, + on_open = custom_term_set_toggle_key, + } end local terms = { - lazygit = Terminal:new({ - cmd = "lazygit", - hidden = true, - direction = "float", - float_opts = { border = "curved" }, - on_open = custom_term_set_toggle_key, - }), - python = Terminal:new({ - cmd = get_python_cmd(), - hidden = true, - direction = "float", - float_opts = { border = "curved" }, - on_open = custom_term_set_toggle_key, - }), + lazygit = Terminal:new(custom_term_default_style("lazygit")), + python = Terminal:new(custom_term_default_style(function() + for _, exec in pairs({ "py", "ptipython", "ipython", "ptpython", "python" }) do + if vim.fn.executable(exec) > 0 then + return exec + end + end + end)), + euporie = Terminal:new(custom_term_default_style(function() + local kernel = vim.b.sessionfile + if kernel then + return "euporie-console --connection-file '" .. kernel .. "'" + end + return "euporie-console" + end)), } - -- create a lazygit window with the lazygit command - local function toggle_custom_term(term, bang, vertsize) + -- have user decide between floating or split + local function toggle_split_or_float(term, bang, vertsize) vertsize = vertsize or vim.o.columns * 0.4 if not bang then term.direction = "float" @@ -74,30 +60,25 @@ return { end end - local function _Pythonterm_toggle(opts) - toggle_custom_term(terms.python, opts.bang) - end - local function _Lazygit_toggle(opts) - toggle_custom_term(terms.lazygit, opts.bang, vim.o.columns * 0.6) - end - - vim.api.nvim_create_user_command( - "Lazygit", - _Lazygit_toggle, - { desc = "Toggle floating Lazygit terminal", bang = true } - ) - vim.api.nvim_create_user_command( - "Pythonterm", - _Pythonterm_toggle, - { desc = "Toggle floating Python terminal", bang = true } - ) + vim.api.nvim_create_user_command("Lazygit", function(opts) + toggle_split_or_float(terms.lazygit, opts.bang, vim.o.columns * 0.6) + end, { desc = "Toggle floating Lazygit terminal", bang = true }) + vim.api.nvim_create_user_command("Pythonterm", function(opts) + toggle_split_or_float(terms.python, opts.bang) + end, { desc = "Toggle floating Python terminal", bang = true }) + vim.api.nvim_create_user_command("Euporieterm", function(opts) + toggle_split_or_float(terms.euporie, opts.bang) + end, { desc = "Toggle floating Euporie terminal", bang = true }) end, - cmd = { "ToggleTerm", "TermExec", "Lazygit", "Pythonterm" }, + cmd = { "ToggleTerm", "TermExec", "Lazygit", "Pythonterm", "Euporieterm" }, keys = { - { "sg", ":Lazygit", desc = "git floating" }, - { "sG", ":Lazygit!", desc = "git buffer" }, - { "sp", ":Pythonterm", desc = "python floating" }, - { "sP", ":Pythonterm!", desc = "python buffer" }, + { "tt", ":ToggleTerm", desc = "terminal" }, + { "tg", ":Lazygit", desc = "git floating" }, + { "tG", ":Lazygit!", desc = "git buffer" }, + { "tp", ":Pythonterm", desc = "python floating" }, + { "tP", ":Pythonterm!", desc = "python buffer" }, + { "te", ":Euporieterm", desc = "euporie floating" }, + { "tE", ":Euporieterm!", desc = "euporie buffer" }, }, }, } From fd01c8aac2855b18558e8af8618f737e27156881 Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Thu, 6 Feb 2025 14:09:34 +0100 Subject: [PATCH 27/27] nvim: Add whichkey group for codecompanion --- nvim/.config/nvim/lua/plugins/llm.lua | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/nvim/.config/nvim/lua/plugins/llm.lua b/nvim/.config/nvim/lua/plugins/llm.lua index 7a339e4..0307ceb 100644 --- a/nvim/.config/nvim/lua/plugins/llm.lua +++ b/nvim/.config/nvim/lua/plugins/llm.lua @@ -7,6 +7,11 @@ return { "nvim-treesitter/nvim-treesitter", "github/copilot.vim", }, + init = function(_) + if require("core.util").is_available("which-key") then + require("which-key").add({ "a", group = "codecompanion" }) + end + end, opts = { strategies = { chat = { adapter = "groq" },