From 0a6059c3373dbf8dee445fc863f136feacaba4ce Mon Sep 17 00:00:00 2001 From: Andrew Patterson Date: Fri, 19 Sep 2025 10:51:31 +0100 Subject: [PATCH 01/13] initial commit of NvChad update to v2.5 --- init.lua | 1 + lazy-lock.json | 44 +++ lua/README.md | 3 + lua/chadrc.lua | 25 +- lua/configs/cmp.lua | 52 +++ lua/configs/dapui.lua | 38 +++ lua/configs/neotest.lua | 16 + lua/configs/overrides.lua | 59 ++++ lua/configs/python.lua | 31 ++ lua/highlights.lua | 19 ++ lua/lua_snippets/all.lua | 13 + lua/lua_snippets/converted/markdown.json | 316 ++++++++++++++++++ lua/lua_snippets/converted/package.json | 20 ++ lua/lua_snippets/plaintex.lua | 16 + .../plaintex/plaintex-snippets.json | 7 + lua/lua_snippets/snippets/markdown.snippets | 215 ++++++++++++ lua/lua_snippets/tex.lua | 100 ++++++ lua/lua_snippets/text.lua | 16 + lua/lua_snippets/ultisnips/markdown.snippets | 284 ++++++++++++++++ lua/mappings.lua | 65 +++- lua/myinit.lua | 12 + lua/overrides.lua | 68 ++++ lua/plugins/myplugins.lua | 309 +++++++++++++++++ lua/stim-treesitter-config.lua | 49 +++ lua/stim-treesitter.lua | 136 ++++++++ 25 files changed, 1891 insertions(+), 23 deletions(-) create mode 100644 lazy-lock.json create mode 100644 lua/README.md create mode 100644 lua/configs/cmp.lua create mode 100644 lua/configs/dapui.lua create mode 100644 lua/configs/neotest.lua create mode 100644 lua/configs/overrides.lua create mode 100644 lua/configs/python.lua create mode 100644 lua/highlights.lua create mode 100644 lua/lua_snippets/all.lua create mode 100644 lua/lua_snippets/converted/markdown.json create mode 100644 lua/lua_snippets/converted/package.json create mode 100644 lua/lua_snippets/plaintex.lua create mode 100644 lua/lua_snippets/plaintex/plaintex-snippets.json create mode 100644 lua/lua_snippets/snippets/markdown.snippets create mode 100644 lua/lua_snippets/tex.lua create mode 100644 lua/lua_snippets/text.lua create mode 100644 lua/lua_snippets/ultisnips/markdown.snippets create mode 100644 lua/myinit.lua create mode 100644 lua/overrides.lua create mode 100644 lua/plugins/myplugins.lua create mode 100644 lua/stim-treesitter-config.lua create mode 100644 lua/stim-treesitter.lua diff --git a/init.lua b/init.lua index e861b68ca..4b46a671c 100644 --- a/init.lua +++ b/init.lua @@ -35,3 +35,4 @@ require "autocmds" vim.schedule(function() require "mappings" end) +require 'myinit' diff --git a/lazy-lock.json b/lazy-lock.json new file mode 100644 index 000000000..b1d9cc72a --- /dev/null +++ b/lazy-lock.json @@ -0,0 +1,44 @@ +{ + "CopilotChat.nvim": { "branch": "main", "commit": "181a523f5bf6b8f277e6a994907c23f9e84d2445" }, + "FixCursorHold.nvim": { "branch": "master", "commit": "1900f89dc17c603eec29960f57c00bd9ae696495" }, + "LuaSnip": { "branch": "master", "commit": "b3104910bb5ebf40492aadffae18f2528fa757d9" }, + "NvChad": { "branch": "v2.5", "commit": "b5b38ebee53bcc8b71a917916ce61504ffffd509" }, + "base46": { "branch": "v3.0", "commit": "390bbb6cf149dc9da1a91548598c809f62fbc3c6" }, + "better-escape.nvim": { "branch": "master", "commit": "19a38aab94961016430905ebec30d272a01e9742" }, + "cmp-async-path": { "branch": "main", "commit": "0ed1492f59e730c366d261a5ad822fa37e44c325" }, + "cmp-buffer": { "branch": "main", "commit": "b74fab3656eea9de20a9b8116afa3cfc4ec09657" }, + "cmp-nvim-lsp": { "branch": "main", "commit": "bd5a7d6db125d4654b50eeae9f5217f24bb22fd3" }, + "cmp-nvim-lua": { "branch": "main", "commit": "f12408bdb54c39c23e67cab726264c10db33ada8" }, + "cmp_luasnip": { "branch": "master", "commit": "98d9cb5c2c38532bd9bdb481067b20fea8f32e90" }, + "conform.nvim": { "branch": "master", "commit": "b4aab989db276993ea5dcb78872be494ce546521" }, + "copilot.vim": { "branch": "release", "commit": "dfe0a3a1c256167d181488a73ec6ccab8d8931a9" }, + "friendly-snippets": { "branch": "main", "commit": "572f5660cf05f8cd8834e096d7b4c921ba18e175" }, + "gitsigns.nvim": { "branch": "main", "commit": "f780609807eca1f783a36a8a31c30a48fbe150c5" }, + "indent-blankline.nvim": { "branch": "master", "commit": "005b56001b2cb30bfa61b7986bc50657816ba4ba" }, + "lazy.nvim": { "branch": "main", "commit": "6c3bda4aca61a13a9c63f1c1d1b16b9d3be90d7a" }, + "mason.nvim": { "branch": "main", "commit": "7dc4facca9702f95353d5a1f87daf23d78e31c2a" }, + "menu": { "branch": "main", "commit": "7a0a4a2896b715c066cfbe320bdc048091874cc6" }, + "minty": { "branch": "main", "commit": "aafc9e8e0afe6bf57580858a2849578d8d8db9e0" }, + "neogen": { "branch": "main", "commit": "d7f9461727751fb07f82011051338a9aba07581d" }, + "neotest": { "branch": "master", "commit": "2cf3544fb55cdd428a9a1b7154aea9c9823426e8" }, + "neotest-python": { "branch": "master", "commit": "ed9b4d794b89044cc32e5476e637936331473c6e" }, + "nvim-autopairs": { "branch": "master", "commit": "23320e75953ac82e559c610bec5a90d9c6dfa743" }, + "nvim-cmp": { "branch": "main", "commit": "b5311ab3ed9c846b585c0c15b7559be131ec4be9" }, + "nvim-dap": { "branch": "master", "commit": "7523676a4be17644587aa47e4d42f6f7646d4727" }, + "nvim-dap-python": { "branch": "master", "commit": "bfe572e4458e0ac876b9539a1e9f301c72db8ea0" }, + "nvim-dap-ui": { "branch": "master", "commit": "cf91d5e2d07c72903d052f5207511bf7ecdb7122" }, + "nvim-lint": { "branch": "master", "commit": "0864f81c681e15d9bdc1156fe3a17bd07db5a3ed" }, + "nvim-lspconfig": { "branch": "master", "commit": "1f7fbc34e6420476142b5cc85e9bee52717540fb" }, + "nvim-nio": { "branch": "master", "commit": "21f5324bfac14e22ba26553caf69ec76ae8a7662" }, + "nvim-tree.lua": { "branch": "master", "commit": "e179ad2f83b5955ab0af653069a493a1828c2697" }, + "nvim-treesitter": { "branch": "master", "commit": "42fc28ba918343ebfd5565147a42a26580579482" }, + "nvim-web-devicons": { "branch": "master", "commit": "6e51ca170563330e063720449c21f43e27ca0bc1" }, + "plenary.nvim": { "branch": "master", "commit": "b9fd5226c2f76c951fc8ed5923d85e4de065e509" }, + "snippet-converter.nvim": { "branch": "main", "commit": "d7e783618f02541641980ebd823e439bdef64a4f" }, + "telescope.nvim": { "branch": "master", "commit": "b4da76be54691e854d3e0e02c36b0245f945c2c7" }, + "ui": { "branch": "v3.0", "commit": "4852e04faefbba3a18cb197b76ac00f4bc2e615f" }, + "vim-markdown": { "branch": "master", "commit": "8f6cb3a6ca4e3b6bcda0730145a0b700f3481b51" }, + "vimtex": { "branch": "master", "commit": "77f31bd02cec678823c8614e6400db97390b5ce7" }, + "volt": { "branch": "main", "commit": "620de1321f275ec9d80028c68d1b88b409c0c8b1" }, + "which-key.nvim": { "branch": "main", "commit": "370ec46f710e058c9c1646273e6b225acf47cbed" } +} diff --git a/lua/README.md b/lua/README.md new file mode 100644 index 000000000..0cc616c21 --- /dev/null +++ b/lua/README.md @@ -0,0 +1,3 @@ +# Example_config + +This can be used as an example custom config for NvChad. Do check the https://github.com/NvChad/nvcommunity diff --git a/lua/chadrc.lua b/lua/chadrc.lua index 9eca87cde..b34d66cf0 100644 --- a/lua/chadrc.lua +++ b/lua/chadrc.lua @@ -1,24 +1,13 @@ --- This file needs to have same structure as nvconfig.lua --- https://github.com/NvChad/ui/blob/v3.0/lua/nvconfig.lua --- Please read that file to know all available options :( - ---@type ChadrcConfig local M = {} -M.base46 = { - theme = "onedark", +-- Path to overriding theme and highlights files +local highlights = require "highlights" - -- hl_override = { - -- Comment = { italic = true }, - -- ["@comment"] = { italic = true }, - -- }, +M.base46 = { + theme = "catppuccin", + transparency = true, + hl_override = highlights.override, + hl_add = highlights.add } - --- M.nvdash = { load_on_startup = true } --- M.ui = { --- tabufline = { --- lazyload = false --- } --- } - return M diff --git a/lua/configs/cmp.lua b/lua/configs/cmp.lua new file mode 100644 index 000000000..bc5d8c60f --- /dev/null +++ b/lua/configs/cmp.lua @@ -0,0 +1,52 @@ +local has_words_before = function() + unpack = unpack or table.unpack + 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 cmp = require "cmp" +local options = { + + mapping = { + [""] = cmp.mapping.select_prev_item(), + [""] = cmp.mapping.select_next_item(), + [""] = cmp.mapping.scroll_docs(-4), + [""] = cmp.mapping.scroll_docs(4), + [""] = cmp.mapping.complete(), + [""] = cmp.mapping.close(), + -- [""] = cmp.mapping.confirm { + -- behavior = cmp.ConfirmBehavior.Insert, + -- select = true, + -- }, + [""] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.mapping.confirm { + behavior = cmp.ConfirmBehavior.Insert, + select = true, + } + elseif require("luasnip").expand_or_jumpable() then + vim.fn.feedkeys(vim.api.nvim_replace_termcodes("luasnip-expand-or-jump", true, true, true), "") + elseif has_words_before() then + cmp.complete() + else + fallback() + end + end, { + "i", + "s", + }), + [""] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_prev_item() + elseif require("luasnip").jumpable(-1) then + vim.fn.feedkeys(vim.api.nvim_replace_termcodes("luasnip-jump-prev", true, true, true), "") + else + fallback() + end + end, { + "i", + "s", + }), + }, +} + +return options diff --git a/lua/configs/dapui.lua b/lua/configs/dapui.lua new file mode 100644 index 000000000..2b501e99a --- /dev/null +++ b/lua/configs/dapui.lua @@ -0,0 +1,38 @@ +local dap = require "dap" +local dapui = require "dapui" + +-- First, set up dap-ui +dapui.setup { + -- Optional: configure layouts + layouts = { + { + elements = { + -- Elements can be strings or table with id and size keys. + {id = "scopes", size = 1.0}, + }, + size = 40, -- 40 columns + position = "left", + }, + { + elements = { + -- { id = "scopes", size = 0.3 }, + {id = "repl", size = 1.0}, + }, + size = 0.25, -- 25% of total lines + position = "bottom", + }, + }, +} + +-- Automatically open UI when debugging starts +dap.listeners.after.event_initialized["dapui_config"] = function() + dapui.open() +end +dap.listeners.before.event_terminated["dapui_config"] = function() + dapui.close() +end +dap.listeners.before.event_exited["dapui_config"] = function() + dapui.close() +end + +-- Add some keymaps for debug terminal diff --git a/lua/configs/neotest.lua b/lua/configs/neotest.lua new file mode 100644 index 000000000..ef875c900 --- /dev/null +++ b/lua/configs/neotest.lua @@ -0,0 +1,16 @@ +local neotest = require "neotest" + +neotest.setup { + adapters = { + require "neotest-python" { + python = vim.fn.exepath "python", + root = vim.fn.getcwd(), + dap = { justMyCode = false }, + args = { "--verbose", "-xvs" }, + runner = "pytest", + discovery = { enabled = true }, + }, + }, +} + +return neotest diff --git a/lua/configs/overrides.lua b/lua/configs/overrides.lua new file mode 100644 index 000000000..c4cd2c7ac --- /dev/null +++ b/lua/configs/overrides.lua @@ -0,0 +1,59 @@ +local M = {} + +M.treesitter = { + ensure_installed = { + "vim", + "lua", + "html", + "css", + "javascript", + "typescript", + "tsx", + "c", + "markdown", + "markdown_inline", + }, + indent = { + enable = true, + -- disable = { + -- "python" + -- }, + }, +} + +M.mason = { + ensure_installed = { + -- lua stuff + "lua-language-server", + "stylua", + + -- web dev stuff + "css-lsp", + "html-lsp", + "typescript-language-server", + "deno", + "prettier", + + -- c/cpp stuff + "clangd", + "clang-format", + }, +} + +-- git support in nvimtree +M.nvimtree = { + git = { + enable = true, + }, + + renderer = { + highlight_git = true, + icons = { + show = { + git = true, + }, + }, + }, +} + +return M diff --git a/lua/configs/python.lua b/lua/configs/python.lua new file mode 100644 index 000000000..6fbbd6d25 --- /dev/null +++ b/lua/configs/python.lua @@ -0,0 +1,31 @@ +local M = {} + +M.setup = function() + local lspconfig = require("lspconfig") + + -- Pyright setup + lspconfig.pyright.setup{} + + -- Null-ls setup for Black, Ruff, MyPy + local null_ls = require("null-ls") + null_ls.setup({ + sources = { + null_ls.builtins.formatting.black, -- Black + null_ls.builtins.diagnostics.ruff, -- Ruff + null_ls.builtins.diagnostics.mypy, -- MyPy + }, + }) +end + + -- Format on save using Black + vim.api.nvim_create_autocmd("BufWritePre", { + pattern = "*.py", + callback = function() + vim.lsp.buf.format({async = false}) + end, + }) + +local dap = require('dap') + +-- Set key mappings for debugging +return M diff --git a/lua/highlights.lua b/lua/highlights.lua new file mode 100644 index 000000000..ebf2dfb24 --- /dev/null +++ b/lua/highlights.lua @@ -0,0 +1,19 @@ +-- To find any highlight groups: " Telescope highlights" +-- Each highlight group can take a table with variables fg, bg, bold, italic, etc +-- base30 variable names can also be used as colors + +local M = {} + +---@type Base46HLGroupsList +M.override = { + Comment = { + italic = true, + }, +} + +---@type HLTable +M.add = { + NvimTreeOpenedFolderName = { fg = "green", bold = true }, +} + +return M diff --git a/lua/lua_snippets/all.lua b/lua/lua_snippets/all.lua new file mode 100644 index 000000000..0767c7bee --- /dev/null +++ b/lua/lua_snippets/all.lua @@ -0,0 +1,13 @@ +local ls = require "luasnip" +local s = ls.snippet +local sn = ls.snippet_node +local isn = ls.indent_snippet_node +local t = ls.text_node +local i = ls.insert_node +local f = ls.function_node +local c = ls.choice_node +local d = ls.dynamic_node +local r = ls.restore_node +local events = require("luasnip.util.events") +local ai = require("luasnip.nodes.absolute_indexer") + diff --git a/lua/lua_snippets/converted/markdown.json b/lua/lua_snippets/converted/markdown.json new file mode 100644 index 000000000..4b9ac67ee --- /dev/null +++ b/lua/lua_snippets/converted/markdown.json @@ -0,0 +1,316 @@ +{ + "[": { + "prefix": "[", + "body": "[${1:text}](https://${2:address})" + }, + "[\"": { + "prefix": "[\"", + "body": "[${1:text}](https://${2:address} \"${3:title}\")" + }, + "[:": { + "prefix": "[:", + "body": [ + "[${1:id}]: https://${2:url}", + "" + ] + }, + "[:\"": { + "prefix": "[:\"", + "body": [ + "[${1:id}]: https://${2:url} \"${3:title}\"", + "" + ] + }, + "![": { + "prefix": "![", + "body": "![${1:alttext}](${2:/images/image.jpg})" + }, + "![\"": { + "prefix": "![\"", + "body": "![${1:alttext}](${2:/images/image.jpg} \"${3:title}\")" + }, + "![:": { + "prefix": "![:", + "body": [ + "![${1:id}]: ${2:url}", + "" + ] + }, + "![:\"": { + "prefix": "![:\"", + "body": [ + "![${1:id}]: ${2:url} \"${3:title}\"", + "" + ] + }, + "<": { + "prefix": "<", + "body": "" + }, + "**": { + "prefix": "**", + "body": "**${1:bold}**" + }, + "__": { + "prefix": "__", + "body": "__${1:bold}__" + }, + "-": { + "prefix": "-", + "body": "- $0" + }, + "blockquote": { + "prefix": "blockquote", + "body": [ + "{% blockquote %\\}", + "${0:quote}", + "{% endblockquote %\\}", + "" + ] + }, + "blockquote-author": { + "prefix": "blockquote-author", + "body": [ + "{% blockquote ${1:author}, ${2:title} %\\}", + "${0:quote}", + "{% endblockquote %\\}", + "" + ] + }, + "blockquote-link": { + "prefix": "blockquote-link", + "body": [ + "{% blockquote ${1:author} ${2:URL} ${3:link_text} %\\}", + "${0:quote}", + "{% endblockquote %\\}", + "" + ] + }, + "```": { + "prefix": "```", + "body": [ + "```$1", + "${0:$TM_SELECTED_TEXT}", + "```", + "" + ] + }, + "```l": { + "prefix": "```l", + "body": [ + "```${1:language}", + "${2:code}", + "```", + "" + ] + }, + "codeblock-short": { + "prefix": "codeblock-short", + "body": [ + "{% codeblock %\\}", + "${0:code_snippet}", + "{% endcodeblock %\\}", + "" + ] + }, + "codeblock-full": { + "prefix": "codeblock-full", + "body": [ + "{% codeblock ${1:title} lang:${2:language} ${3:URL} ${4:link_text} %\\}", + "${0:code_snippet}", + "{% endcodeblock %\\}", + "" + ] + }, + "gist-full": { + "prefix": "gist-full", + "body": [ + "{% gist ${1:gist_id} ${0:filename} %\\}", + "" + ] + }, + "gist-short": { + "prefix": "gist-short", + "body": [ + "{% gist ${0:gist_id} %\\}", + "" + ] + }, + "img": { + "prefix": "img", + "body": [ + "{% img ${1:class} ${2:URL} ${3:width} ${4:height} ${5:title_text} ${0:alt_text} %\\}", + "" + ] + }, + "youtube": { + "prefix": "youtube", + "body": [ + "{% youtube ${0:video_id} %\\}", + "" + ] + }, + "tb": { + "prefix": "tb", + "body": [ + "| ${0:factors} | ${1:a} | ${2:b} \t|", + "| ------------- |------------- | ------- |", + "| ${3:f1} | Y | N |", + "| ${4:f2} | Y | N |", + "", + "" + ] + }, + "pullquote": { + "prefix": "pullquote", + "body": [ + "{% pullquote %\\}", + "${1:text} {\" ${2:quote} \"\\} ${0:text}", + "{% endpullquote %\\}", + "" + ] + }, + "mbf": { + "prefix": "mbf", + "description": "bold face math text", + "body": "\\mathbf{${1:$TM_SELECTED_TEXT}\\}$0" + }, + "cal": { + "prefix": "cal", + "description": "math curly text", + "body": "\\mathcal{${1:$TM_SELECTED_TEXT}\\}$0" + }, + "sc": { + "prefix": "sc", + "description": "small caps text", + "body": "\\textsc{${1:$TM_SELECTED_TEXT}\\}$0" + }, + "rm": { + "prefix": "rm", + "description": "roman font text", + "body": "\\textrm{${1:$TM_SELECTED_TEXT}\\}$0" + }, + "tt": { + "prefix": "tt", + "description": "typewriter (monospace) text", + "body": "\\texttt{${1:$TM_SELECTED_TEXT}\\}$0" + }, + "frac": { + "prefix": "frac", + "description": "\\frac{}{}", + "body": "\\frac{${1:num}\\}{${2:denom}\\} $0" + }, + "sum": { + "prefix": "sum", + "description": "\\sum^{}_{}", + "body": "\\sum^{${1:n}\\}_{${2:i=1}\\} $0" + }, + "ddt": { + "prefix": "ddt", + "description": "time derivative", + "body": [ + "\\frac{d\\}{dt\\} {$1\\} {$0\\}", + "" + ] + }, + "lim": { + "prefix": "lim", + "description": "limit", + "body": [ + "\\lim_{{$1\\}\\} {{$2\\}\\} {$0\\}", + "" + ] + }, + "pdv": { + "prefix": "pdv", + "description": "partial derivation", + "body": [ + "\\frac{\\partial {$1\\}\\}{partial {$2\\}\\} {$0\\}", + "" + ] + }, + "ppdv": { + "prefix": "ppdv", + "description": "second partial derivation", + "body": [ + "\\frac{partial^2 {$1\\}\\}{partial {$2\\} partial {$3\\}\\} {$0\\}", + "" + ] + }, + "dv": { + "prefix": "dv", + "description": "derivative", + "body": [ + "\\frac{d {$1\\}\\}{d {$2\\}\\} {$0\\}", + "" + ] + }, + "sum": { + "prefix": "sum", + "description": "summation", + "body": [ + "\\sum_{{$1\\}\\} {$0\\}", + "" + ] + }, + "dot": { + "prefix": "dot", + "description": "dot", + "body": [ + "\\dot{{$1\\}\\} {$0\\}", + "" + ] + }, + "ddot": { + "prefix": "ddot", + "description": "ddot", + "body": [ + "\\ddot{{$1\\}\\} {$0\\}", + "" + ] + }, + "vec": { + "prefix": "vec", + "description": "vector", + "body": [ + "\\vec{{$1\\}\\} {$0\\}", + "" + ] + }, + "\\x": { + "prefix": "\\x", + "description": "cross product", + "body": [ + "\\times {$0\\}", + "" + ] + }, + ".": { + "prefix": ".", + "description": "dot product", + "body": [ + "\\cdot {$0\\}", + "" + ] + }, + "int": { + "prefix": "int", + "description": "integral", + "body": "\\int_{{$1\\}\\}^{{$2\\}\\} {$3\\} : d{$4\\} {$5\\}" + }, + "tra": { + "prefix": "tra", + "description": "trace", + "body": "\\textrm{Tr\\}\\left[ $1 \\right]${0:$TM_SELECTED_TEXT}" + }, + "ra": { + "prefix": "ra", + "description": "rightarrow", + "body": "\\rightarrow {$0\\}" + }, + "theta": { + "prefix": "`w", + "dectription": "theta", + "body": "\\theta" + } +} diff --git a/lua/lua_snippets/converted/package.json b/lua/lua_snippets/converted/package.json new file mode 100644 index 000000000..37eca66fc --- /dev/null +++ b/lua/lua_snippets/converted/package.json @@ -0,0 +1,20 @@ +{ + "name": "1", + "description": "Generated by snippet-converter.nvim (https://github.com/smjonas/snippet-converter.nvim)", + "contributes": { + "snippets": [ + { + "language": [ + "markdown" + ], + "path": "./markdown.json" + }, + { + "language": [ + "markdown" + ], + "path": "./markdown.json" + } + ] + } +} diff --git a/lua/lua_snippets/plaintex.lua b/lua/lua_snippets/plaintex.lua new file mode 100644 index 000000000..277b7b90e --- /dev/null +++ b/lua/lua_snippets/plaintex.lua @@ -0,0 +1,16 @@ +local ls = require "luasnip" +local s = ls.snippet +local sn = ls.snippet_node +local isn = ls.indent_snippet_node +local t = ls.text_node +local i = ls.insert_node +local f = ls.function_node +local c = ls.choice_node +local d = ls.dynamic_node +local r = ls.restore_node +local events = require("luasnip.util.events") +local ai = require("luasnip.nodes.absolute_indexer") + +return { + s("tex", t("bruh")) +} diff --git a/lua/lua_snippets/plaintex/plaintex-snippets.json b/lua/lua_snippets/plaintex/plaintex-snippets.json new file mode 100644 index 000000000..806197234 --- /dev/null +++ b/lua/lua_snippets/plaintex/plaintex-snippets.json @@ -0,0 +1,7 @@ +{ + "test": { + "prefix": "metest", + "body": ["bruh"], + "description": "test" + } +} diff --git a/lua/lua_snippets/snippets/markdown.snippets b/lua/lua_snippets/snippets/markdown.snippets new file mode 100644 index 000000000..9b27ad480 --- /dev/null +++ b/lua/lua_snippets/snippets/markdown.snippets @@ -0,0 +1,215 @@ +# Markdown + +# Includes octopress (http://octopress.org/) snippets + +# The suffix `c` stands for "Clipboard". + +snippet [ + [${1:text}](https://${2:address}) +snippet [* + [${1:link}](${2:`@*`}) +snippet [c + [${1:link}](${2:`@+`}) +snippet [" + [${1:text}](https://${2:address} "${3:title}") +snippet ["* + [${1:link}](${2:`@*`} "${3:title}") +snippet ["c + [${1:link}](${2:`@+`} "${3:title}") +snippet [: + [${1:id}]: https://${2:url} + +snippet [:* + [${1:id}]: ${2:`@*`} + +snippet [:c + [${1:id}]: ${2:`@+`} + +snippet [:" + [${1:id}]: https://${2:url} "${3:title}" + +snippet [:"* + [${1:id}]: ${2:`@*`} "${3:title}" + +snippet [:"c + [${1:id}]: ${2:`@+`} "${3:title}" + +snippet ![ + ![${1:alttext}](${2:/images/image.jpg}) +snippet ![* + ![${1:alt}](${2:`@*`}) +snippet ![c + ![${1:alt}](${2:`@+`}) +snippet ![" + ![${1:alttext}](${2:/images/image.jpg} "${3:title}") +snippet !["* + ![${1:alt}](${2:`@*`} "${3:title}") +snippet !["c + ![${1:alt}](${2:`@+`} "${3:title}") +snippet ![: + ![${1:id}]: ${2:url} + +snippet ![:* + ![${1:id}]: ${2:`@*`} + +snippet ![:" + ![${1:id}]: ${2:url} "${3:title}" + +snippet ![:"* + ![${1:id}]: ${2:`@*`} "${3:title}" + +snippet ![:"c + ![${1:id}]: ${2:`@+`} "${3:title}" + +snippet < + +snippet <* + <`@*`> +snippet +snippet ** + **${1:bold}** +snippet __ + __${1:bold}__ +snippet === + `repeat('=', strlen(getline(line('.') - 3)))` + + ${0} +snippet - + - ${0} +snippet --- + `repeat('-', strlen(getline(line('.') - 3)))` + + ${0} +snippet blockquote + {% blockquote %} + ${0:quote} + {% endblockquote %} + +snippet blockquote-author + {% blockquote ${1:author}, ${2:title} %} + ${0:quote} + {% endblockquote %} + +snippet blockquote-link + {% blockquote ${1:author} ${2:URL} ${3:link_text} %} + ${0:quote} + {% endblockquote %} + +snippet ``` + \`\`\`${1} + ${0:${VISUAL}} + \`\`\` + +# Language. +snippet ```l + \`\`\`${1:language} + ${2:code} + \`\`\` + +snippet codeblock-short + {% codeblock %} + ${0:code_snippet} + {% endcodeblock %} + +snippet codeblock-full + {% codeblock ${1:title} lang:${2:language} ${3:URL} ${4:link_text} %} + ${0:code_snippet} + {% endcodeblock %} + +snippet gist-full + {% gist ${1:gist_id} ${0:filename} %} + +snippet gist-short + {% gist ${0:gist_id} %} + +snippet img + {% img ${1:class} ${2:URL} ${3:width} ${4:height} ${5:title_text} ${0:alt_text} %} + +snippet youtube + {% youtube ${0:video_id} %} + +snippet tb + | ${0:factors} | ${1:a} | ${2:b} | + | ------------- |------------- | ------- | + | ${3:f1} | Y | N | + | ${4:f2} | Y | N | + +# The quote should appear only once in the text. It is inherently part of it. +# See http://octopress.org/docs/plugins/pullquote/ for more info. + +snippet pullquote + {% pullquote %} + ${1:text} {" ${2:quote} "} ${0:text} + {% endpullquote %} + +# All taken from tex defaults +snippet mbf bold face math text + \\mathbf{${1:${VISUAL:text}}}${0} +snippet cal math curly text + \\mathcal{${1:${VISUAL:text}}}${0} +snippet sc small caps text + \\textsc{${1:${VISUAL:text}}}${0} +snippet rm roman font text + \\textrm{${1:${VISUAL:text}}}${0} +snippet tt typewriter (monospace) text + \\texttt{${1:${VISUAL:text}}}${0} +snippet frac \frac{}{} + \\frac{${1:num}}{${2:denom}} ${0} +snippet sum \sum^{}_{} + \\sum^{${1:n}}_{${2:i=1}} ${0} +snippet lim \lim_{} + \\lim_{${1:n \\to \\infty}} ${0} +# Time derivative +snippet ddt time derivative + \\frac{d}{dt} {$1} {$0} + +# Limit +snippet lim limit + \\lim_{{$1}} {{$2}} {$0} + +# Partial derivative +snippet pdv partial derivation + \\frac{\\partial {$1}}{\partial {$2}} {$0} + +# Second order partial derivative +snippet ppdv second partial derivation + \\frac{\partial^2 {$1}}{\partial {$2} \partial {$3}} {$0} + +# Ordinary derivative +snippet dv derivative + \\frac{d {$1}}{d {$2}} {$0} + +# Summation +snippet summ summation + \\sum_{{$1}} {$0} + +# Shorthand for time derivative +snippet dot dot + \\dot{{$1}} {$0} + +# Shorthand for second order time derivative +snippet ddot ddot + \\ddot{{$1}} {$0} + +# Vector +snippet vec vector + \\vec{{$1}} {$0} + +# Cross product +snippet \x cross product + \\times {$0} + +# Dot product +snippet . dot product + \\cdot {$0} + +# Integral +snippet int integral + \\int_{{$1}}^{{$2}} {$3} \: d{$4} {$5} +# Trace operator +snippet tra trace + \\textrm{Tr}\\left[ ${1} \\right]${0:${VISUAL}} +# Right arrow +snippet ra rightarrow + \\rightarrow {$0} diff --git a/lua/lua_snippets/tex.lua b/lua/lua_snippets/tex.lua new file mode 100644 index 000000000..ac279d726 --- /dev/null +++ b/lua/lua_snippets/tex.lua @@ -0,0 +1,100 @@ +local ls = require "luasnip" +local s = ls.snippet +local sn = ls.snippet_node +local isn = ls.indent_snippet_node +local t = ls.text_node +local i = ls.insert_node +local f = ls.function_node +local c = ls.choice_node +local d = ls.dynamic_node +local r = ls.restore_node +local events = require("luasnip.util.events") +local ai = require("luasnip.nodes.absolute_indexer") + +local tex = {} +tex.in_mathzone = function() + return vim .fn['vimtex#syntax#in_mathzone']() == 1 +end + +return { + s("ket", { + t({"\\ket{"}), + i(1), + t({"}"}), + i(0) + }, + {condition = tex.in_mathzone } + ), + s("lrb", { + t({"\\left( "}), + i(1), + t(" \\right) "), + i(0) + }), + s("lra", { + t({"\\langle "}), + i(1), + t(" \\rangle "), + i(0) + }), + s("lrs", { + t({"\\left\\[ "}), + i(1), + t(" \\right\\] "), + i(0) + }), + s("lrc", { + t({"\\left\\{ "}), + i(1), + t(" \\right\\} "), + i(0) + }), + s("~", { + t("\\tilde{"), + i(1), + t("} "), + i(0) + } + ), + s("^", { + t("\\hat{"), + i(1), + t("} "), + i(0) + } + ), + s("trm", { + t("\\textrm{"), + i(1), + t("} "), + i(0) + } + ), + s("figcirc", { + t({"\\begin{figure}[h]", + "\t\\begin{center}", + "\t\t\\begin{tikzpicture}", + "\t\t\t\\begin{yquant}", + "\t\t\t\tqubit {$\\ket{"}), + i(3), + t("}$} "), + t("q["), + i(5), + t({"];", + "\t\t\t\t"}), + i(6), + t({"", + "\t\t\t\\end{yquant}", + "\t\t\\end{tikzpicture}", + "\t\\end{center}", + "\t\\caption{"}), + i(1), + t("}\\label{fig:"), + i(2), + t({"}", + "\\end{figure}"}), + i(0) + } + ), + +} diff --git a/lua/lua_snippets/text.lua b/lua/lua_snippets/text.lua new file mode 100644 index 000000000..a28f551ee --- /dev/null +++ b/lua/lua_snippets/text.lua @@ -0,0 +1,16 @@ +local ls = require "luasnip" +local s = ls.snippet +local sn = ls.snippet_node +local isn = ls.indent_snippet_node +local t = ls.text_node +local i = ls.insert_node +local f = ls.function_node +local c = ls.choice_node +local d = ls.dynamic_node +local r = ls.restore_node +local events = require("luasnip.util.events") +local ai = require("luasnip.nodes.absolute_indexer") + +return { + s("test", t("bruh")) +} diff --git a/lua/lua_snippets/ultisnips/markdown.snippets b/lua/lua_snippets/ultisnips/markdown.snippets new file mode 100644 index 000000000..5a2fd467a --- /dev/null +++ b/lua/lua_snippets/ultisnips/markdown.snippets @@ -0,0 +1,284 @@ +priority -50 + +global !p +def math(): + return vim.eval('vimtex#syntax#in_mathzone()') == '1' +endglobal + +global !p +# A overkill(dirty) table with automatic alignment feature +def create_table(snip): + # retrieving single line from current string and treat it like tabstops count + placeholders_string = snip.buffer[snip.line].strip() + rows_amount = int(placeholders_string[0]) + columns_amount = int(placeholders_string[1]) + + prefix_str = "from vimsnippets import display_width;" + + # erase current line + snip.buffer[snip.line] = "" + + # create anonymous snippet with expected content and number of tabstops + anon_snippet_title = "| " + anon_snippet_delimiter = "|" + for col in range(1, columns_amount+1): + sync_rows = [x*columns_amount+col for x in range(rows_amount+1)] + sync_str = ",".join(["t[{0}]".format(x) for x in sync_rows]) + max_width_str = "max(list(map(display_width, [" + sync_str + "])))" + cur_width_str = "display_width(t[" + str(col) + "])" + rv_val = "(" + max_width_str + "-" + cur_width_str + ")*' '" + anon_snippet_title += "${" + str(col) + ":head" + str(col)\ + + "}`!p " + prefix_str + "snip.rv=" + rv_val + "` | " + anon_snippet_delimiter += ":`!p " + prefix_str + "snip.rv = "\ + + max_width_str + "*'-'" + "`-|" + + anon_snippet_title += "\n" + + anon_snippet_delimiter += "\n" + anon_snippet_body = "" + for row in range(1, rows_amount+1): + body_row = "| " + for col in range(1, columns_amount+1): + sync_rows = [x*columns_amount+col for x in range(rows_amount+1)] + sync_str = ",".join(["t[{0}]".format(x) for x in sync_rows]) + max_width_str = "max(list(map(display_width, [" + sync_str + "])))" + cur_width_str = "display_width(t[" + str(row*columns_amount+col) + "])" + rv_val = "(" + max_width_str + "-" + cur_width_str + ")*' '" + placeholder = "R{0}C{1}".format(row, col) + body_row += "${" + str(row*columns_amount+col) + ":" + placeholder\ + + "}`!p " + prefix_str + "snip.rv=" + rv_val + "` | " + + body_row += "\n" + anon_snippet_body += body_row + + anon_snippet_table = anon_snippet_title + anon_snippet_delimiter + anon_snippet_body + + # expand anonymous snippet + snip.expand_anon(anon_snippet_table) +endglobal + +########################### +# Sections and Paragraphs # +########################### +snippet sec "Section" b +# ${1:Section Name} # +$0 +endsnippet + +snippet ssec "Sub Section" b +## ${1:Section Name} ## +$0 +endsnippet + +snippet sssec "SubSub Section" b +### ${1:Section Name} ### +$0 +endsnippet + +snippet par "Paragraph" b +#### ${1:Paragraph Name} #### +$0 +endsnippet + +snippet spar "Paragraph" b +##### ${1:Paragraph Name} ##### +$0 +endsnippet + +################### +# Text formatting # +################### + +snippet * "italics" +*${1:${VISUAL}}*$0 +endsnippet + +snippet ** "bold" +**${1:${VISUAL}}**$0 +endsnippet + +snippet *** "bold italics" +***${1:${VISUAL}}***$0 +endsnippet + +snippet /* "Comment" +$0 +endsnippet + +snippet $ "Mathmode" A +\$${1:${VISUAL}}\$$0 +endsnippet + +snippet $$ "Inline Math" +\$\$ +${1:${VISUAL}} +\$\$ +$0 +endsnippet + +################ +# Common stuff # +################ +snippet link "Link to something" +[${1:${VISUAL:Text}}](${3:https://${2:www.url.com}})$0 +endsnippet + +snippet img "Image" +![${1:pic alt}](${2:path}${3/.+/ "/}${3:opt title}${3/.+/"/})$0 +endsnippet + +snippet ilc "Inline Code" i +\`${1:${VISUAL}}\`$0 +endsnippet + +snippet cbl "Codeblock" b +\`\`\`$1 +${2:${VISUAL}} +\`\`\` +$0 +endsnippet + +snippet refl "Reference Link" +[${1:${VISUAL:Text}}][${2:id}]$0 + +[$2]:${4:https://${3:www.url.com}} "${5:$4}" +endsnippet + +snippet fnt "Footnote" +[^${1:${VISUAL:Footnote}}]$0 + +[^$1]:${2:Text} +endsnippet + +snippet detail "Disclosure" + + ${1:${2}}$0 + +endsnippet + +post_jump "create_table(snip)" +snippet "tb([1-9][1-9])" "Fancy table" br +`!p snip.rv = match.group(1)` +endsnippet + +#snippet `a iA +#\\alpha +#endsnippet +#snippet `b iA +#\\beta +#endsnippet +#snippet `c iA +#\\chi +#endsnippet +#snippet `d iA +#\\delta +#endsnippet +#snippet `e iA +#\\epsilon +#endsnippet +#snippet `f iA +#\\phi +#endsnippet +#snippet `g iA +#\\gamma +#endsnippet +#snippet `h iA +#\\eta +#endsnippet +#snippet `k iA +#\\kappa +#endsnippet +#snippet `l iA +#\\lambda +#endsnippet +#snippet `m iA +#\\mu +#endsnippet +#snippet `n iA +#\\nu +#endsnippet +#snippet `o iA +#\\omega +#endsnippet +#snippet `p iA +#\\pi +#endsnippet +#snippet `q iA +#\\theta +#endsnippet +#snippet `r iA +#\\rho +#endsnippet +#snippet `s iA +#\\sigma +#endsnippet +#snippet `t iA +#\\tau +#endsnippet +#snippet `u iA +#\\upsilon +#endsnippet +#snippet `z iA +#\\zeta +#endsnippet +#snippet `D iA +#\\Delta +#endsnippet +#snippet `F iA +#\\Phi +#endsnippet +#snippet `G iA +#\\Gamma +#endsnippet +#snippet `L iA +#\\Lambda +#endsnippet +#snippet `N iA +#\\nabla +#endsnippet +#snippet `O iA +#\\Omega +#endsnippet +#snippet `Q iA +#\\Theta +#endsnippet +#snippet `R iA +#\\varrho +#endsnippet +#snippet `U iA +#\\Upsilon +#endsnippet +#snippet `X iA +#\\Xi +#endsnippet +#snippet `Y iA +#\\Psi +#endsnippet +#snippet `i iA +#\\int_{$1}^{$2} +#endsnippet +#snippet `S iA +#\\sum_{$1}^{$2} +#endsnippet +#snippet `8 iA +#\\infty +#endsnippet +#snippet `= iA +#\\equiv +#endsnippet +#snippet `. iA +#\\cdot +#endsnippet +#snippet `~ iA +#\\tilde{$1} +#endsnippet +#snippet `^ iA +#\\hat{$1} +#endsnippet +#snippet `; iA +#\\dot{$1} +#endsnippet +#snippet \`_ iA +#\\bar{$1} +#endsnippet +# vim:ft=snippets: diff --git a/lua/mappings.lua b/lua/mappings.lua index 783b78f9c..d8ad42818 100644 --- a/lua/mappings.lua +++ b/lua/mappings.lua @@ -1,10 +1,65 @@ require "nvchad.mappings" +local map = vim.keymap.set --- add yours here +-- Normal Mode +map("n", ";", ":", {desc = "enter command mode", nowait = true}) +map("n", "j", "j", {desc = "Disable wrapping" }) +map("n", "k", "k", {desc = "Disable wrapping" }) -local map = vim.keymap.set +map("n", "", ':lua require"dap".continue()', {desc= "Debug continue", noremap = true, silent = true } ) +map("n", "", ':lua require"dap".terminate()', {desc= "Debug Terminate", noremap = true, silent = true } ) +map("n", "", ':lua require"dap".restart()', {desc= "Debug Restart", noremap = true, silent = true } ) +map("n", "", ':lua require"dap".step_over()', {desc= "Step Over", noremap = true, silent = true } ) +map("n", "", ':lua require"dap".step_into()', {desc= "Step Into", noremap = true, silent = true } ) +map("n", "", ':lua require"dap".step_out()', {desc= "Step Out", noremap = true, silent = true } ) +map("n", "", ':lua require"dap".toggle_breakpoint()', {desc = "Toggle Breakpoint", noremap = true, silent = true }) +map("n", "dc", ":lua require'dapui'.toggle()", {desc = "Debug: Toggle UI" }) +map("n", "ds", ":lua require'neogen'.generate()", {desc = "Debug: Test Method" }) + +map("n", "tt", ":lua require'neotest'.run.run()", {desc = "Neotest: Run test" }) +map("n", "dtm", ":lua require'neotest'.run.run({strategy = 'dap'})", {desc = "Neotest: Debug test" }) +map("n", "ts", ":lua require'neotest'.summary.toggle()", {desc = "Neotest: Toggle test summary" }) +map("n", "tp", ":lua require'neotest'.output_panel.toggle()", {desc = "Neotest: Toggle output panel" }) + +map("n", "ac", ":CopilotChat ", {desc = "CopilotChat - Prompt" }) +map("n", "ae", ":CopilotChatExplain", {desc = "CopilotChat - Explain code" }) +map("n", "at", ":CopilotChatTests", {desc = "CopilotChat - Generate tests" }) +map("n", "af", ":CopilotChatFix", {desc = "CopilotChat - Fix code" }) +map("n", "ar", ":CopilotChatReview", {desc = "CopilotChat - Review code" }) +map("n", "aw", ":CopilotChatToggle", {desc = "CopilotChat - Toggle Window" }) +map("n", "aq", + function() + local input = vim.fn.input "Quick Chat: " + if input ~= "" then + require("CopilotChat").ask(input, { + selection = require("CopilotChat.select").buffer, + }) + end + end, + {desc = "CopilotChat - Quick chat"}) + +-- Visual mode + +-- map("v", ">", ">gv", {desc = "indent" }) +-- map("v", "ac", ":CopilotChat ", {desc = "CopilotChat - Prompt" }) +-- map("v", "ae", ":CopilotChatExplain", {desc = "CopilotChat - Explain code" }) +-- map("v", "at", ":CopilotChatTests", {desc = "CopilotChat - Generate tests" }) +-- map("v", "af", ":CopilotChatFix", {desc = "CopilotChat - Fix code" }) +-- map("v", "ar", ":CopilotChatReview", {desc = "CopilotChat - Review code" }) + + +-- Insert Mode +map("i", ";;", "", {desc = "Enter normal mode", nowait = true } ) -map("n", ";", ":", { desc = "CMD enter command mode" }) -map("i", "jk", "") +map({"i", "n"}, "", + function() + require("nvchad.term").toggle {pos = "sp", id="htoggleterm"} + end, + {desc = "Toggle horizontal term",} +) --- map({ "n", "i", "v" }, "", " w ") +map("i", "", "u[s1z=`]au", {desc = "Autocorrect spelling" }) +map("i", "", + 'copilot#Accept("")', + {desc ="Accept Copilot suggestion", silent = true, expr = true, noremap = false, replace_keycodes = false } +) diff --git a/lua/myinit.lua b/lua/myinit.lua new file mode 100644 index 000000000..c8732269c --- /dev/null +++ b/lua/myinit.lua @@ -0,0 +1,12 @@ +local autocmd = vim.api.nvim_create_autocmd + +-- Auto resize panes when resizing nvim window +-- autocmd("VimResized", { +-- pattern = "*", +-- command = "tabdo wincmd =", +-- }) +vim.opt.spelllang = "en_gb" +vim.opt.spell = true +-- local python_config = require("configs.python") +-- python_config.setup() +-- require("../custom/stim-treesitter-config").setup() diff --git a/lua/overrides.lua b/lua/overrides.lua new file mode 100644 index 000000000..72c629b03 --- /dev/null +++ b/lua/overrides.lua @@ -0,0 +1,68 @@ +local M = {} + +local has_words_before = function() + unpack = unpack or table.unpack + 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 cmp = require("cmp") + +M.nvimtree = { + git = { + enable = true, + }, + renderer = { + highlight_git = true, + icons = { + show = { + git = true, + }, + }, + }, +} +M.cmp = { + + mapping = { + [""] = cmp.mapping.select_prev_item(), + [""] = cmp.mapping.select_next_item(), + [""] = cmp.mapping.scroll_docs(-4), + [""] = cmp.mapping.scroll_docs(4), + [""] = cmp.mapping.complete(), + [""] = cmp.mapping.close(), + -- [""] = cmp.mapping.confirm { + -- behavior = cmp.ConfirmBehavior.Insert, + -- select = true, + -- }, + [""] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.mapping.confirm { + behavior = cmp.ConfirmBehavior.Insert, + select = true, + } + elseif require("luasnip").expand_or_jumpable() then + vim.fn.feedkeys(vim.api.nvim_replace_termcodes("luasnip-expand-or-jump", true, true, true), "") + elseif has_words_before() then + cmp.complete() + else + fallback() + end + end, { + "i", + "s", + }), + [""] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_prev_item() + elseif require("luasnip").jumpable(-1) then + vim.fn.feedkeys(vim.api.nvim_replace_termcodes("luasnip-jump-prev", true, true, true), "") + else + fallback() + end + end, { + "i", + "s", + }), + }, +} + +return M diff --git a/lua/plugins/myplugins.lua b/lua/plugins/myplugins.lua new file mode 100644 index 000000000..5c025c218 --- /dev/null +++ b/lua/plugins/myplugins.lua @@ -0,0 +1,309 @@ +local overrides = require "configs.overrides" +local has_words_before = function() + unpack = unpack or table.unpack + 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 cmp = require "cmp" + +---@type NvPluginSpec[] +local plugins = { + + -- Override plugin definition options + { + "neovim/nvim-lspconfig", + dependencies = { + -- format & linting + { + "mfussenegger/nvim-lint", + }, + }, + config = function() + require "nvchad.configs.lspconfig" + require "configs.lspconfig" + end, -- Override to setup mason-lspconfig + }, + + -- override plugin configs + { + "williamboman/mason.nvim", + opts = overrides.mason, + }, + + { + "nvim-treesitter/nvim-treesitter", + opts = overrides.treesitter, + }, + + { + "nvim-tree/nvim-tree.lua", + opts = overrides.nvimtree, + }, + { + "hrsh7th/nvim-cmp", + opts = function() + local conf = require "nvchad.configs.cmp" + conf.mapping[""] = 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 = true }, + } + conf.mapping[""] = cmp.mapping(function(fallback) + if cmp.visible() then + local entry = cmp.get_selected_entry() + if not entry then + cmp.select_next_item { behavior = cmp.SelectBehavior.Select } + else + cmp.confirm() + end + elseif require("luasnip").expand_or_jumpable() then + vim.fn.feedkeys(vim.api.nvim_replace_termcodes("luasnip-expand-or-jump", true, true, true), "") + elseif has_words_before() then + cmp.complete() + else + fallback() + end + end, { + "i", + "s", + -- "c", + }) + conf.mapping[""] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_prev_item() + elseif require("luasnip").jumpable(-1) then + vim.fn.feedkeys(vim.api.nvim_replace_termcodes("luasnip-jump-prev", true, true, true), "") + else + fallback() + end + end, { + "i", + "s", + }) + return conf + end, + }, + { + "L3MON4D3/LuaSnip", + opts = overrides.luasnip, + config = function() + require("luasnip.loaders.from_lua").lazy_load { paths = { vim.fn.stdpath "config" .. "/lua/custom/lua_snippets" } } + require("luasnip.loaders.from_vscode").lazy_load { + paths = { vim.fn.stdpath "config" .. "/lua/custom/lua_snippets/converted" }, + } + require("luasnip.loaders.from_vscode").lazy_load() + end, + }, + + -- Install a plugin + { + "max397574/better-escape.nvim", + event = "InsertEnter", + config = function() + require("better_escape").setup() + end, + }, + + { + "lervag/vimtex", + lazy = false, + config = function() + vim.api.nvim_create_autocmd({ "FileType" }, { + group = vim.api.nvim_create_augroup("lazyvim_vimtex_conceal", { clear = true }), + pattern = { "bib", "tex" }, + callback = function() + vim.wo.conceallevel = 2 + end, + }) + vim.g.vimtex_mappings_disable = { ["n"] = { "K" } } + vim.g.vimtex_quickfix_method = vim.fn.executable "pplatex" == 1 and "pplatex" or "latexlog" + vim.g.tex_flavor = "luatex" + vim.g.vimtex_quickfix_mode = 0 + vim.g.Tex_MultipleCompileFormats = "pdf,bib,pdf" + vim.g.vimtex_view_general_viewer = "zathura" + vim.g.vimtex_viewer_zathura = 1 + vim.g.vimtex_compiler_latexmk = { out_dir = "build" } + end, + }, + + { + "smjonas/snippet-converter.nvim", + config = function() + local template = { + sources = { + ultisnips = { + vim.fn.stdpath "config" .. "/lua/custom/lua_snippets/ultisnips", + }, + snipmate = { + vim.fn.stdpath "config" .. "/lua/custom/lua_snippets/snippets", + }, + }, + output = { + vscode_luasnip = { + vim.fn.stdpath "config" .. "/lua/custom/lua_snippets/converted", + }, + }, + } + + require("snippet_converter").setup { + templates = { template }, + } + end, + }, + { + "preservim/vim-markdown", + config = function() + vim.g.vim_markdown_math = 1 + end, + }, + { + "mfussenegger/nvim-dap", + dependencies = { + "mfussenegger/nvim-dap-python", + config = function() + require("dap-python").setup "~/.virtualenvs/debugpy/bin/python" + require("dap-python").test_runner = "pytest" + end, + }, + config = function() + local dap = require "dap" + dap.adapters.python = { + type = "executable", + command = "python", + args = { "-m", "debugpy.adapter" }, + } + dap.configurations.python = { + { + type = "python", + request = "launch", + name = "Launch file", + program = "${file}", -- This will launch the current file + pythonPath = function() + return "python" + end, + }, + } + require "configs.python" + end, + }, + { + "rcarriga/nvim-dap-ui", + dependencies = { + "mfussenegger/nvim-dap", + "nvim-neotest/nvim-nio", + }, + config = function() + require "configs.dapui" + end, + }, + { + "nvim-neotest/neotest", + dependencies = { + "nvim-neotest/neotest-python", + "nvim-neotest/nvim-nio", + "nvim-lua/plenary.nvim", + "antoinemadec/FixCursorHold.nvim", + "nvim-treesitter/nvim-treesitter", + }, + ft = "python", + config = function() + require "configs.neotest" + end, + -- config = function() + -- require("neotest").setup { + -- adapters = { + -- require "neotest-python" { + -- python = vim.fn.expand "python", + -- root = function() + -- return vim.fn.getcwd() + -- end, + -- dap = { justMyCode = false }, + -- args = { "--log-level", "DEBUG", "--verbose", "-xvs" }, + -- runner = "pytest", + -- discovery = { + -- enabled = true, + -- }, + -- is_test_file = function(filename) + -- return filename:match "^tests?%.?py$" or filename:match "^test_.+%.py$" or filename:match "%.test_.+%.py$" + -- end, + -- pytest_discover_instances = true, + -- }, + -- }, + -- } + -- end, + }, + { + "danymat/neogen", + dependencies = "nvim-treesitter/nvim-treesitter", + config = true, + ft = { "python", "javascript", "typescript", "lua" }, -- Add filetypes you need + opts = { + enabled = true, + languages = { + python = { + template = { + annotation_convention = "reST", -- or "google_docstrings" or "reST" + }, + }, + }, + }, + }, + { + "github/copilot.vim", + lazy = false, + config = function() + vim.g.copilot_no_tab_map = true + vim.g.copilot_assume_mapped = true + end, + }, + { + "CopilotC-Nvim/CopilotChat.nvim", + lazy = false, + -- branch = "canary", + dependencies = { + { "nvim-lua/plenary.nvim" }, + }, + build = "make tiktoken", + opts = { + question_header = "## User ", + answer_header = "## Copilot ", + error_header = "## Error ", + { + -- model = 3gpt-4.1', -- AI model to use + temperature = 0.1, -- Lower = focused, higher = creative + window = { + layout = "vertical", -- 'vertical', 'horizontal', 'float' + width = 0.3, -- 50% of screen width + }, + auto_insert_mode = true, -- Enter insert mode when opening + }, + }, + }, + + { + "nvim-telescope/telescope.nvim", + opts = overrides.telescope, + }, + + -- To make a plugin not be loaded + -- { + -- "NvChad/nvim-colorizer.lua", + -- enabled = false + -- }, + + -- All NvChad plugins are lazy-loaded by default + -- For a plugin to be loaded, you will need to set either `ft`, `cmd`, `keys`, `event`, or set `lazy = false` + -- If you want a plugin to load on startup, add `lazy = false` to a plugin spec, for example + -- { + -- "mg979/vim-visual-multi", + -- lazy = false, + -- } +} + +return plugins diff --git a/lua/stim-treesitter-config.lua b/lua/stim-treesitter-config.lua new file mode 100644 index 000000000..e5fe3e036 --- /dev/null +++ b/lua/stim-treesitter-config.lua @@ -0,0 +1,49 @@ +-- Stim Tree-sitter configuration (auto-generated) +local M = {} + +function M.setup(opts) + opts = opts or {} + local defaults = { + grammar_path = vim.fn.expand("~/tree-sitter-stim"), + auto_install = true, + highlight_measurements = true, + keymaps = { show_info = "si" } + } + opts = vim.tbl_deep_extend("force", defaults, opts) + + local ok, parsers = pcall(require, "nvim-treesitter.parsers") + if not ok then + vim.notify("nvim-treesitter not found", vim.log.levels.ERROR) + return + end + + local parser_config = parsers.get_parser_configs() + parser_config.stim = { + install_info = { + url = opts.grammar_path, + files = {"src/parser.c"}, + branch = "main", + generate_requires_npm = false, + requires_generate_from_grammar = false, + }, + filetype = "stim", + } + + vim.filetype.add({ extension = { stim = "stim" } }) + + if opts.auto_install then + vim.defer_fn(function() + pcall(vim.cmd, "TSInstallSync stim") + end, 100) + end + + if opts.highlight_measurements then + require('stim-treesitter').setup() + if opts.keymaps.show_info then + vim.keymap.set('n', opts.keymaps.show_info, ':StimInfoTS', + { desc = 'Show Stim measurement info' }) + end + end +end + +return M diff --git a/lua/stim-treesitter.lua b/lua/stim-treesitter.lua new file mode 100644 index 000000000..57605cd47 --- /dev/null +++ b/lua/stim-treesitter.lua @@ -0,0 +1,136 @@ +-- Stim Tree-sitter plugin (auto-generated) +local M = {} +local ts_utils = require('nvim-treesitter.ts_utils') +local ns_id = vim.api.nvim_create_namespace('stim_treesitter_highlights') + +local function parse_measurements_ts(bufnr) + local parser = vim.treesitter.get_parser(bufnr, 'stim') + if not parser then return {} end + local tree = parser:parse()[1] + local root = tree:root() + local measurements = {} + local measurement_count = 0 + local query = vim.treesitter.query.parse('stim', [[(measurement_instruction) @measurement]]) + for id, node in query:captures(root, bufnr) do + local start_row, start_col, end_row, end_col = node:range() + local text = vim.api.nvim_buf_get_text(bufnr, start_row, start_col, end_row, end_col, {})[1] + local target_count = 0 + for child in node:iter_children() do + if child:type() == 'target' then target_count = target_count + 1 end + end + for i = 1, target_count do + measurements[measurement_count] = { + line = start_row + 1, + node = node, + text = text, + index = measurement_count + } + measurement_count = measurement_count + 1 + end + end + return measurements +end + +local function get_record_ref_at_cursor(bufnr) + local cursor = vim.api.nvim_win_get_cursor(0) + local row = cursor[1] - 1 + local col = cursor[2] + local parser = vim.treesitter.get_parser(bufnr, 'stim') + if not parser then return nil end + local tree = parser:parse()[1] + local root = tree:root() + local query = vim.treesitter.query.parse('stim', [[(record_ref) @ref (invalid_record_ref) @invalid_ref]]) + for id, node, metadata in query:iter_captures(root, bufnr) do + local start_row, start_col, end_row, end_col = node:range() + if row >= start_row and row <= end_row then + if row > start_row or col >= start_col then + if row < end_row or col < end_col then + local text = vim.api.nvim_buf_get_text(bufnr, start_row, start_col, end_row, end_col, {})[1] + local index = tonumber(text:match("rec%[([%-]?%d+)%]")) + local capture_name = query.captures[id] + local is_valid = capture_name == "ref" + return {node = node, index = index, row = start_row, start_col = start_col, end_col = end_col, is_valid = is_valid} + end + end + end + end + return nil +end + +local function resolve_measurement_index(rec_index, measurements_up_to_line) + if rec_index >= 0 then return nil end + return measurements_up_to_line + rec_index +end + +function M.highlight_measurement() + local bufnr = vim.api.nvim_get_current_buf() + vim.api.nvim_buf_clear_namespace(bufnr, ns_id, 0, -1) + local record_ref = get_record_ref_at_cursor(bufnr) + if not record_ref then return end + if not record_ref.is_valid then + vim.api.nvim_buf_add_highlight(bufnr, ns_id, 'Error', record_ref.row, record_ref.start_col, record_ref.end_col) + return + end + local measurements = parse_measurements_ts(bufnr) + local cursor_line = vim.api.nvim_win_get_cursor(0)[1] + local measurements_before = 0 + for idx, measurement in pairs(measurements) do + if measurement.line <= cursor_line then measurements_before = measurements_before + 1 end + end + local target_index = resolve_measurement_index(record_ref.index, measurements_before) + if target_index and target_index >= 0 then + for idx, measurement in pairs(measurements) do + if idx == target_index then + local start_row, _, end_row, _ = measurement.node:range() + vim.api.nvim_buf_add_highlight(bufnr, ns_id, 'StimMeasurementHighlight', start_row, 0, -1) + break + end + end + end + vim.api.nvim_buf_add_highlight(bufnr, ns_id, 'StimRecordHighlight', record_ref.row, record_ref.start_col, record_ref.end_col) +end + +function M.show_info() + local bufnr = vim.api.nvim_get_current_buf() + local record_ref = get_record_ref_at_cursor(bufnr) + if not record_ref then return end + if not record_ref.is_valid then + vim.notify(string.format("Invalid record reference rec[%d]: positive indices are not valid in Stim", record_ref.index), vim.log.levels.ERROR) + return + end + local measurements = parse_measurements_ts(bufnr) + local cursor_line = vim.api.nvim_win_get_cursor(0)[1] + local measurements_before = 0 + for idx, measurement in pairs(measurements) do + if measurement.line <= cursor_line then measurements_before = measurements_before + 1 end + end + local target_index = resolve_measurement_index(record_ref.index, measurements_before) + if target_index and target_index >= 0 then + for idx, measurement in pairs(measurements) do + if idx == target_index then + vim.notify(string.format("rec[%d] → Measurement #%d at line %d: %s", record_ref.index, idx, measurement.line, measurement.text), vim.log.levels.INFO) + return + end + end + end + vim.notify(string.format("rec[%d] points to a measurement that doesn't exist", record_ref.index), vim.log.levels.WARN) +end + +function M.setup() + vim.cmd([[ + highlight default StimMeasurementHighlight guibg=#3a5f3a ctermbg=22 + highlight default StimRecordHighlight guibg=#5f3a3a ctermbg=52 + ]]) + vim.api.nvim_create_augroup('StimTreesitter', { clear = true }) + vim.api.nvim_create_autocmd({ 'CursorMoved', 'CursorMovedI' }, { + group = 'StimTreesitter', + pattern = '*.stim', + callback = function() + local ok = pcall(vim.treesitter.get_parser, 0, 'stim') + if ok then M.highlight_measurement() end + end + }) + vim.api.nvim_create_user_command('StimInfoTS', M.show_info, {}) +end + +return M From c371af1dfe0cabb80439e043702968990c65facb Mon Sep 17 00:00:00 2001 From: Andrew Patterson Date: Fri, 19 Sep 2025 22:28:21 +0100 Subject: [PATCH 02/13] update pluginf to work with nvchad2.5 --- lua/configs/lint.lua | 93 ++++++++++++++ lua/configs/lspconfig.lua | 246 +++++++++++++++++++++++++++++++++++++- lua/configs/mason.lua | 22 ++++ lua/configs/none-ls.lua | 37 ++++++ lua/plugins/myplugins.lua | 26 +++- 5 files changed, 415 insertions(+), 9 deletions(-) create mode 100644 lua/configs/lint.lua create mode 100644 lua/configs/mason.lua create mode 100644 lua/configs/none-ls.lua diff --git a/lua/configs/lint.lua b/lua/configs/lint.lua new file mode 100644 index 000000000..b185862d6 --- /dev/null +++ b/lua/configs/lint.lua @@ -0,0 +1,93 @@ +local M = {} + +M.setup = function() + local lint = require "lint" + + -- local root = vim.fn.getcwd() + -- local pyproject_path = root .. "/pyproject.toml" + -- + -- if vim.fn.filereadable(pyproject_path) == 1 then + -- lint.linters.mypy.args = vim.list_extend( + -- lint.linters.mypy.args or {}, + -- { "--config-file", pyproject_path } + -- ) + -- else + -- lint.linters.mypy.args = vim.list_extend( + -- lint.linters.mypy.args or {}, + -- { "--config-file", "pyproject.toml" } + -- ) + -- end + + lint.linters.mypy = vim.tbl_deep_extend("force", lint.linters.mypy, { + cmd = "python", + args = vim.list_extend({ "-m", "mypy" }, lint.linters.mypy.args) + }) + + lint.linters.pylint = vim.tbl_deep_extend("force", lint.linters.pylint, { + cmd = "python", + args = vim.list_extend({ "-m", "pylint" }, lint.linters.pylint.args) + }) + + + lint.linters_by_ft = { + python = { "ruff", "mypy", "pylint" }, + cpp = { "cpplint", "cppcheck" }, + } + + local signs = { + Error = " ", + Warn = " ", + Hint = " ", + Info = " ", + } + + vim.diagnostic.config({ + virtual_text = false, + signs = true, + underline = true, + update_in_insert = false, + float = { + source = true, + border = "rounded", + header = "", + prefix = "", + format = function(diagnostic) + return string.format("%s: %s", diagnostic.source or "LSP", diagnostic.message) + end, + }, + signs = { + text = signs, + linehl = {}, + numhl = {}, + }, + severity_sort = true, + }) + + local lint_augroup = vim.api.nvim_create_augroup("lint", { clear = true }) + + vim.api.nvim_create_autocmd({ "BufEnter", "BufWritePost", "InsertLeave" }, { + group = lint_augroup, + callback = function() + lint.try_lint() + end, + }) + + -- Highlight configurations + vim.api.nvim_command "highlight DiagnosticUnderlineError gui=underline guisp=#FF0000" + vim.api.nvim_command "highlight DiagnosticUnderlineWarn gui=underline guisp=#FF9900" + vim.api.nvim_command "highlight DiagnosticUnderlineInfo gui=underline guisp=#0000FF" + vim.api.nvim_command "highlight DiagnosticUnderlineHint gui=underline guisp=#00FF00" + + vim.api.nvim_create_autocmd("CursorHold", { + group = lint_augroup, + callback = function() + vim.diagnostic.open_float(nil, { + focusable = false, + scope = "line", + border = "single", + }) + end, + }) +end + +return M diff --git a/lua/configs/lspconfig.lua b/lua/configs/lspconfig.lua index 20a0cce02..48cedfb6d 100644 --- a/lua/configs/lspconfig.lua +++ b/lua/configs/lspconfig.lua @@ -1,6 +1,246 @@ require("nvchad.configs.lspconfig").defaults() -local servers = { "html", "cssls" } -vim.lsp.enable(servers) - -- read :h vim.lsp.config for changing options of lsp servers +local nv_on_attach = require("nvchad.configs.lspconfig").on_attach +local on_init = require("nvchad.configs.lspconfig").on_init +local capabilities = require("nvchad.configs.lspconfig").capabilities + +-- Diagnostic signs - using new API instead of deprecated sign_define +-- local signs = { +-- Error = " ", +-- Warn = " ", +-- Hint = " ", +-- Info = " ", +-- } + -- Diagnostics configuration + +-- Enhanced diagnostic configuration with signs +-- vim.diagnostic.config({ +-- virtual_text = false, -- Keep virtual text enabled +-- signs = true, -- Keep signs for errors +-- underline = true, -- Enable underlining +-- update_in_insert = true, +-- virtual_text = { +-- prefix = "●", +-- source = "if_many", +-- spacing = 4, +-- severity = { +-- min = vim.diagnostic.severity.HINT, +-- }, + -- format = function(diagnostic) + -- if diagnostic.source == "harper_ls" then + -- return string.format("[grammar] %s", diagnostic.message) + -- end + -- return diagnostic.message + -- end, +-- }, +-- float = { +-- source = true, +-- border = "rounded", +-- header = "", +-- prefix = "", +-- format = function(diagnostic) +-- return string.format("%s: %s", diagnostic.source or "LSP", diagnostic.message) +-- end, +-- }, +-- signs = { +-- text = signs, +-- linehl = {}, +-- numhl = {}, +-- }, +-- underline = true, +-- update_in_insert = false, +-- severity_sort = true, +-- }) + +-- Signs are now configured via vim.diagnostic.config above + +-- Show all diagnostics on cursor hold +-- vim.api.nvim_create_autocmd("CursorHold", { +-- callback = function() +-- local opts = { +-- focusable = false, +-- close_events = { "BufLeave", "CursorMoved", "InsertEnter", "FocusLost" }, +-- border = "rounded", +-- source = "always", +-- prefix = " ", +-- scope = "cursor", +-- } +-- vim.diagnostic.open_float(nil, opts) +-- end, +-- }) +-- +-- wrap NVChad’s on_attach to remove that default ra binding +local on_attach = function(client, bufnr) + nv_on_attach(client, bufnr) + -- vim.keymap.del("n", "ra", { buffer = bufnr }) + + -- Enable inlay hints if supported + if client.supports_method("textDocument/inlayHint") then + vim.lsp.inlay_hint.enable(true, { bufnr = bufnr }) + end + + -- Enable semantic tokens if supported + if client.supports_method("textDocument/semanticTokens") then + vim.highlight.priorities.semantic_tokens = 95 + end +end + +local marksman_caps = vim.deepcopy(capabilities) +marksman_caps.workspace = vim.tbl_extend("force", marksman_caps.workspace, { + workspaceFolders = false, +}) + + +-- Define all servers and only specify the bits that differ from the default +local servers = { + -- simple defaults + cssls = {}, + eslint = {}, + -- harper_ls = {}, + html = {}, + jsonls = {}, + + -- -- Lua + -- lua_ls = { + -- settings = { + -- Lua = { + -- diagnostics = { enable = false }, + -- workspace = { + -- library = { + -- vim.fn.expand "$VIMRUNTIME/lua", + -- vim.fn.expand "$VIMRUNTIME/lua/vim/lsp", + -- vim.fn.stdpath "data" .. "/lazy/ui/nvchad_types", + -- vim.fn.stdpath "data" .. "/lazy/lazy.nvim/lua/lazy", + -- }, + -- maxPreload = 100000, + -- preloadFileSize = 10000, + -- }, + -- }, + -- }, + -- }, + -- + -- -- Go (Simplified) + -- gopls = { + -- on_attach = function(client, bufnr) + -- client.server_capabilities.documentFormattingProvider = false + -- client.server_capabilities.documentRangeFormattingProvider = false + -- on_attach(client, bufnr) + -- end, + -- settings = { + -- gopls = { + -- analyses = { + -- unusedparams = true, + -- }, + -- staticcheck = true, + -- gofumpt = true, -- A common and recommended setting + -- }, + -- }, + -- }, + -- + -- -- Ruby LSP (with Rails & RSpec add-ons) + -- ruby_lsp = { + -- on_attach = function(client, bufnr) + -- client.server_capabilities.documentFormattingProvider = false + -- client.server_capabilities.documentRangeFormattingProvider = false + -- require "configs.functions.ruby_deps"(client, bufnr) + -- on_attach(client, bufnr) + -- end, + -- init_options = { + -- formatter = "standard", + -- linters = { "standard" }, + -- addonSettings = { + -- ["Ruby LSP Rails"] = { + -- enablePendingMigrationsPrompt = false, + -- }, + -- ["Ruby LSP RSpec"] = { + -- rspecCommand = "rspec -f d", + -- }, + -- }, + -- }, + -- cmd = { "mise", "exec", "--", "ruby-lsp" }, + -- settings = { + -- ruby = { + -- diagnostics = true, + -- formatting = true, + -- lint = true, + -- completion = true, + -- ignored_diagnostics = { "Layout/TrailingEmptyLines" }, + -- }, + -- }, + -- }, + -- + -- -- TypeScript / JavaScript (Corrected Name) + -- ts_ls = { + -- on_attach = function(client, bufnr) + -- client.server_capabilities.documentFormattingProvider = false + -- client.server_capabilities.documentRangeFormattingProvider = false + -- on_attach(client, bufnr) + -- end, + -- }, + -- + -- -- Biome (alternative JS/TS linter & formatter) + -- biome = { + -- on_attach = function(client, bufnr) + -- client.server_capabilities.documentFormattingProvider = false + -- client.server_capabilities.documentRangeFormattingProvider = false + -- on_attach(client, bufnr) + -- end, + -- }, + -- + -- -- Hypr configuration language + -- hyprls = { + -- -- lspconfig defaults are sufficient here + -- }, + + -- Rust (handled by rustaceanvim) + + -- Markdown + marksman = { + capabilities = marksman_caps, + filetypes = { "markdown" }, + single_file_support = true, + }, + + -- ruff = { + -- cmd = {"ruff", "server"}, + -- filetypes = {"python"}, + -- root_markers = {".git", "pyproject.toml"}, + -- settings = {}, + -- }, + + pyright = { + on_attach = function(client, bufnr) + client.server_capabilities.publishDiagnosticsProvider = false + on_attach(client, bufnr) + end, + settings = { + python = { + analysis = { + typeCheckingMode = "basic", -- options: off, basic, strict + autoSearchPaths = true, + useLibraryCodeForTypes = true, + }, + } + } + }, + -- Disabled to avoid conflicts with marksman and improve performance + -- markdown_oxide = { + -- on_attach = function(client, bufnr) + -- client.server_capabilities.documentFormattingProvider = false + -- client.server_capabilities.documentRangeFormattingProvider = false + -- on_attach(client, bufnr) + -- end, + -- }, +} + +for name, opts in pairs(servers) do + local server_opts = vim.tbl_deep_extend("force", { + on_attach = on_attach, + on_init = on_init, + capabilities = capabilities, + }, opts) + + vim.lsp.config(name, server_opts) +end +vim.lsp.enable(vim.tbl_keys(servers)) diff --git a/lua/configs/mason.lua b/lua/configs/mason.lua new file mode 100644 index 000000000..ad65cf2b0 --- /dev/null +++ b/lua/configs/mason.lua @@ -0,0 +1,22 @@ +-- lua/configs/mason.lua +require("mason").setup({ + ui = { + icons = { + package_installed = "✓", + package_pending = "➜", + package_uninstalled = "✗" + } + } +}) + +require("mason-lspconfig").setup({ + ensure_installed = { + "pyright", + "ruff", + "html", + "cssls", + "jsonls", + "marksman", + }, + automatic_installation = true, +}) diff --git a/lua/configs/none-ls.lua b/lua/configs/none-ls.lua new file mode 100644 index 000000000..e7b010828 --- /dev/null +++ b/lua/configs/none-ls.lua @@ -0,0 +1,37 @@ +local none_ls = require("none-ls") + +return { + sources = { + -- Mypy with pyproject.toml support + none_ls.builtins.diagnostics.mypy.with({ + extra_args = function(params) + local root = params.root + if root then + local pyproject_path = root .. "/pyproject.toml" + if vim.fn.filereadable(pyproject_path) == 1 then + return {"--config-file", pyproject_path} + end + end + return {} + end, + }), + + -- Ruff for linting and formatting + -- none_ls.builtins.diagnostics.ruff, + -- none_ls.builtins.formatting.ruff, + + -- Pylint if you want it + -- none_ls.builtins.diagnostics.pylint.with({ + -- extra_args = function(params) + -- local root = params.root + -- if root then + -- local pyproject_path = root .. "/pyproject.toml" + -- if vim.fn.filereadable(pyproject_path) == 1 then + -- return {"--rcfile", pyproject_path} + -- end + -- end + -- return {} + -- end, + -- }), + }, +} diff --git a/lua/plugins/myplugins.lua b/lua/plugins/myplugins.lua index 5c025c218..50550e30e 100644 --- a/lua/plugins/myplugins.lua +++ b/lua/plugins/myplugins.lua @@ -10,19 +10,33 @@ local cmp = require "cmp" local plugins = { -- Override plugin definition options + { + "mfussenegger/nvim-lint", + event = { + "BufReadPre", + "BufNewFile", + }, + config = function() + require("configs.lint").setup() + end, + }, { "neovim/nvim-lspconfig", - dependencies = { - -- format & linting - { - "mfussenegger/nvim-lint", - }, - }, + event = { "BufReadPre", "BufNewFile" }, config = function() require "nvchad.configs.lspconfig" require "configs.lspconfig" end, -- Override to setup mason-lspconfig }, + { + "nvimtools/none-ls.nvim", + -- event = "VeryLazy", + dependencies = { "nvim-lua/plenary.nvim" }, + config = function() + local none_ls = require("none-ls") + none_ls.setup(require("configs.none-ls")) + end, + }, -- override plugin configs { From 2d0426381894bfa92d636c66b42d6c494098c270 Mon Sep 17 00:00:00 2001 From: Andrew Patterson Date: Fri, 19 Sep 2025 22:29:09 +0100 Subject: [PATCH 03/13] modify stim treeesitter lamost working --- init.lua | 1 + lazy-lock.json | 1 + lua/stim-treesitter-config.lua | 10 +- lua/stim-treesitter.lua | 231 ++++++++++++++++++++++++++++----- 4 files changed, 206 insertions(+), 37 deletions(-) diff --git a/init.lua b/init.lua index 4b46a671c..a082231e1 100644 --- a/init.lua +++ b/init.lua @@ -36,3 +36,4 @@ vim.schedule(function() require "mappings" end) require 'myinit' +require("stim-treesitter-config").setup() diff --git a/lazy-lock.json b/lazy-lock.json index b1d9cc72a..116862cad 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -22,6 +22,7 @@ "neogen": { "branch": "main", "commit": "d7f9461727751fb07f82011051338a9aba07581d" }, "neotest": { "branch": "master", "commit": "2cf3544fb55cdd428a9a1b7154aea9c9823426e8" }, "neotest-python": { "branch": "master", "commit": "ed9b4d794b89044cc32e5476e637936331473c6e" }, + "none-ls.nvim": { "branch": "main", "commit": "78111a97cebed3dfda8157af8141bf1915cfc327" }, "nvim-autopairs": { "branch": "master", "commit": "23320e75953ac82e559c610bec5a90d9c6dfa743" }, "nvim-cmp": { "branch": "main", "commit": "b5311ab3ed9c846b585c0c15b7559be131ec4be9" }, "nvim-dap": { "branch": "master", "commit": "7523676a4be17644587aa47e4d42f6f7646d4727" }, diff --git a/lua/stim-treesitter-config.lua b/lua/stim-treesitter-config.lua index e5fe3e036..a61caa509 100644 --- a/lua/stim-treesitter-config.lua +++ b/lua/stim-treesitter-config.lua @@ -31,11 +31,11 @@ function M.setup(opts) vim.filetype.add({ extension = { stim = "stim" } }) - if opts.auto_install then - vim.defer_fn(function() - pcall(vim.cmd, "TSInstallSync stim") - end, 100) - end + -- if opts.auto_install then + -- vim.defer_fn(function() + -- pcall(vim.cmd, "TSInstallSync stim") + -- end, 100) + -- end if opts.highlight_measurements then require('stim-treesitter').setup() diff --git a/lua/stim-treesitter.lua b/lua/stim-treesitter.lua index 57605cd47..6ef44ce07 100644 --- a/lua/stim-treesitter.lua +++ b/lua/stim-treesitter.lua @@ -1,26 +1,59 @@ --- Stim Tree-sitter plugin (auto-generated) +-- ~/.config/nvim/lua/stim-treesitter.lua +-- Tree-sitter based Stim Circuit Reader Plugin for Neovim +-- This version uses the correct Tree-sitter API + local M = {} -local ts_utils = require('nvim-treesitter.ts_utils') local ns_id = vim.api.nvim_create_namespace('stim_treesitter_highlights') +-- Parse measurements using Tree-sitter local function parse_measurements_ts(bufnr) local parser = vim.treesitter.get_parser(bufnr, 'stim') - if not parser then return {} end + if not parser then + return {} + end + local tree = parser:parse()[1] + if not tree then + return {} + end + local root = tree:root() + local measurements = {} local measurement_count = 0 - local query = vim.treesitter.query.parse('stim', [[(measurement_instruction) @measurement]]) - for id, node in query:captures(root, bufnr) do + + -- Query for measurement instructions + local query_string = [[ + (measurement_instruction) @measurement + ]] + + local ok, query = pcall(vim.treesitter.query.parse, 'stim', query_string) + if not ok then + return {} + end + + for id, node in query:iter_captures(root, bufnr, 0, -1) do local start_row, start_col, end_row, end_col = node:range() - local text = vim.api.nvim_buf_get_text(bufnr, start_row, start_col, end_row, end_col, {})[1] + local text = vim.api.nvim_buf_get_text(bufnr, start_row, start_col, end_row, end_col, {}) + text = text[1] or "" + + -- Count targets in this measurement local target_count = 0 for child in node:iter_children() do - if child:type() == 'target' then target_count = target_count + 1 end + if child:type() == 'target' then + target_count = target_count + 1 + end + end + + -- If no explicit targets found, assume at least one measurement + if target_count == 0 then + target_count = 1 end + + -- Store each measurement target for i = 1, target_count do measurements[measurement_count] = { - line = start_row + 1, + line = start_row + 1, -- Convert to 1-indexed node = node, text = text, index = measurement_count @@ -28,109 +61,243 @@ local function parse_measurements_ts(bufnr) measurement_count = measurement_count + 1 end end + return measurements end +-- Find record reference at cursor position local function get_record_ref_at_cursor(bufnr) local cursor = vim.api.nvim_win_get_cursor(0) - local row = cursor[1] - 1 + local row = cursor[1] - 1 -- Convert to 0-indexed local col = cursor[2] + local parser = vim.treesitter.get_parser(bufnr, 'stim') - if not parser then return nil end + if not parser then + return nil + end + local tree = parser:parse()[1] + if not tree then + return nil + end + local root = tree:root() - local query = vim.treesitter.query.parse('stim', [[(record_ref) @ref (invalid_record_ref) @invalid_ref]]) - for id, node, metadata in query:iter_captures(root, bufnr) do + + -- Query for record references + local query_string = [[ + (record_ref) @ref + ]] + + local ok, query = pcall(vim.treesitter.query.parse, 'stim', query_string) + if not ok then + return nil + end + + for id, node in query:iter_captures(root, bufnr, 0, -1) do local start_row, start_col, end_row, end_col = node:range() + + -- Check if cursor is within this node if row >= start_row and row <= end_row then if row > start_row or col >= start_col then if row < end_row or col < end_col then - local text = vim.api.nvim_buf_get_text(bufnr, start_row, start_col, end_row, end_col, {})[1] + -- Extract the index value + local text = vim.api.nvim_buf_get_text(bufnr, start_row, start_col, end_row, end_col, {}) + text = text[1] or "" local index = tonumber(text:match("rec%[([%-]?%d+)%]")) - local capture_name = query.captures[id] - local is_valid = capture_name == "ref" - return {node = node, index = index, row = start_row, start_col = start_col, end_col = end_col, is_valid = is_valid} + + -- Check if it's valid (only negative indices are valid in Stim) + local is_valid = index and index < 0 + + return { + node = node, + index = index, + row = start_row, + start_col = start_col, + end_col = end_col, + is_valid = is_valid + } end end end end + return nil end +-- Calculate which measurement a record reference points to local function resolve_measurement_index(rec_index, measurements_up_to_line) - if rec_index >= 0 then return nil end + -- In Stim, only negative indices are valid + if not rec_index or rec_index >= 0 then + return nil + end + + -- rec[-1] is the most recent measurement return measurements_up_to_line + rec_index end +-- Highlight measurement from record reference function M.highlight_measurement() local bufnr = vim.api.nvim_get_current_buf() + + -- Clear previous highlights vim.api.nvim_buf_clear_namespace(bufnr, ns_id, 0, -1) + local record_ref = get_record_ref_at_cursor(bufnr) - if not record_ref then return end + if not record_ref then + return + end + if not record_ref.is_valid then - vim.api.nvim_buf_add_highlight(bufnr, ns_id, 'Error', record_ref.row, record_ref.start_col, record_ref.end_col) + -- Highlight invalid positive index as error + vim.api.nvim_buf_add_highlight(bufnr, ns_id, 'Error', + record_ref.row, record_ref.start_col, record_ref.end_col) return end + + -- Parse all measurements local measurements = parse_measurements_ts(bufnr) + + -- Count measurements up to the line with the record reference local cursor_line = vim.api.nvim_win_get_cursor(0)[1] local measurements_before = 0 for idx, measurement in pairs(measurements) do - if measurement.line <= cursor_line then measurements_before = measurements_before + 1 end + if measurement.line <= cursor_line then + measurements_before = measurements_before + 1 + end end + + -- Resolve the measurement index local target_index = resolve_measurement_index(record_ref.index, measurements_before) + if target_index and target_index >= 0 then + -- Find and highlight the corresponding measurement for idx, measurement in pairs(measurements) do if idx == target_index then local start_row, _, end_row, _ = measurement.node:range() - vim.api.nvim_buf_add_highlight(bufnr, ns_id, 'StimMeasurementHighlight', start_row, 0, -1) + vim.api.nvim_buf_add_highlight(bufnr, ns_id, 'StimMeasurementHighlight', + start_row, 0, -1) break end end end - vim.api.nvim_buf_add_highlight(bufnr, ns_id, 'StimRecordHighlight', record_ref.row, record_ref.start_col, record_ref.end_col) + + -- Highlight the record reference itself + vim.api.nvim_buf_add_highlight(bufnr, ns_id, 'StimRecordHighlight', + record_ref.row, record_ref.start_col, record_ref.end_col) end +-- Show information about measurement at cursor function M.show_info() local bufnr = vim.api.nvim_get_current_buf() local record_ref = get_record_ref_at_cursor(bufnr) - if not record_ref then return end + + if not record_ref then + vim.notify("No record reference under cursor", vim.log.levels.INFO) + return + end + if not record_ref.is_valid then - vim.notify(string.format("Invalid record reference rec[%d]: positive indices are not valid in Stim", record_ref.index), vim.log.levels.ERROR) + vim.notify(string.format( + "Invalid record reference rec[%d]: positive indices are not valid in Stim", + record_ref.index or 0 + ), vim.log.levels.ERROR) return end + local measurements = parse_measurements_ts(bufnr) local cursor_line = vim.api.nvim_win_get_cursor(0)[1] local measurements_before = 0 + for idx, measurement in pairs(measurements) do - if measurement.line <= cursor_line then measurements_before = measurements_before + 1 end + if measurement.line <= cursor_line then + measurements_before = measurements_before + 1 + end end + local target_index = resolve_measurement_index(record_ref.index, measurements_before) + if target_index and target_index >= 0 then for idx, measurement in pairs(measurements) do if idx == target_index then - vim.notify(string.format("rec[%d] → Measurement #%d at line %d: %s", record_ref.index, idx, measurement.line, measurement.text), vim.log.levels.INFO) + vim.notify(string.format( + "rec[%d] → Measurement #%d at line %d: %s", + record_ref.index, idx, measurement.line, measurement.text + ), vim.log.levels.INFO) return end end end - vim.notify(string.format("rec[%d] points to a measurement that doesn't exist", record_ref.index), vim.log.levels.WARN) + + vim.notify(string.format( + "rec[%d] points to a measurement that doesn't exist (would be index %d)", + record_ref.index, target_index or -1 + ), vim.log.levels.WARN) end +-- Setup function function M.setup() + -- Define highlight groups vim.cmd([[ highlight default StimMeasurementHighlight guibg=#3a5f3a ctermbg=22 highlight default StimRecordHighlight guibg=#5f3a3a ctermbg=52 ]]) - vim.api.nvim_create_augroup('StimTreesitter', { clear = true }) + + -- Setup autocmds for cursor movement + local group = vim.api.nvim_create_augroup('StimTreesitter', { clear = true }) + vim.api.nvim_create_autocmd({ 'CursorMoved', 'CursorMovedI' }, { - group = 'StimTreesitter', + group = group, pattern = '*.stim', callback = function() - local ok = pcall(vim.treesitter.get_parser, 0, 'stim') - if ok then M.highlight_measurement() end + -- Check if buffer is valid + local bufnr = vim.api.nvim_get_current_buf() + if not vim.api.nvim_buf_is_valid(bufnr) then + return + end + + -- Only run if we have the stim parser + local ok, parser = pcall(vim.treesitter.get_parser, bufnr, 'stim') + if ok and parser then + -- Wrap in pcall to prevent errors from breaking cursor movement + pcall(M.highlight_measurement) + end end }) - vim.api.nvim_create_user_command('StimInfoTS', M.show_info, {}) + + -- Create commands + vim.api.nvim_create_user_command('StimInfoTS', M.show_info, { + desc = 'Show information about the Stim measurement record under cursor' + }) + + vim.api.nvim_create_user_command('StimCheckParser', function() + M.check_parser() + end, { + desc = 'Check if Stim Tree-sitter parser is installed' + }) end +-- Function to check if Tree-sitter parser is available +function M.check_parser() + local bufnr = vim.api.nvim_get_current_buf() + local ok, parser = pcall(vim.treesitter.get_parser, bufnr, 'stim') + + if not ok then + vim.notify([[ +Tree-sitter parser for Stim not found! +Please install it first: +1. Build the grammar (see setup instructions) +2. Register it with nvim-treesitter +3. Run :TSInstall stim + ]], vim.log.levels.WARN) + return false + end + + vim.notify("Stim Tree-sitter parser is installed and working!", vim.log.levels.INFO) + return true +end + +-- Export the get_record_ref_at_cursor function for external use +M.get_record_ref_at_cursor = get_record_ref_at_cursor + return M + From 85aaf51b492faeb00d65d37447432b7576691352 Mon Sep 17 00:00:00 2001 From: Andrew Patterson Date: Mon, 6 Oct 2025 10:43:21 +0100 Subject: [PATCH 04/13] fixes for stim viewer and luatex instead of latexpdf --- init.lua | 1 - lua/README.md | 3 - lua/myinit.lua | 85 +++++++-- lua/overrides.lua | 17 +- lua/plugins/myplugins.lua | 18 +- lua/stim-treesitter-config.lua | 49 ------ lua/stim-treesitter.lua | 303 --------------------------------- 7 files changed, 93 insertions(+), 383 deletions(-) delete mode 100644 lua/README.md delete mode 100644 lua/stim-treesitter-config.lua delete mode 100644 lua/stim-treesitter.lua diff --git a/init.lua b/init.lua index a082231e1..4b46a671c 100644 --- a/init.lua +++ b/init.lua @@ -36,4 +36,3 @@ vim.schedule(function() require "mappings" end) require 'myinit' -require("stim-treesitter-config").setup() diff --git a/lua/README.md b/lua/README.md deleted file mode 100644 index 0cc616c21..000000000 --- a/lua/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# Example_config - -This can be used as an example custom config for NvChad. Do check the https://github.com/NvChad/nvcommunity diff --git a/lua/myinit.lua b/lua/myinit.lua index c8732269c..3be143618 100644 --- a/lua/myinit.lua +++ b/lua/myinit.lua @@ -1,12 +1,77 @@ -local autocmd = vim.api.nvim_create_autocmd - --- Auto resize panes when resizing nvim window --- autocmd("VimResized", { --- pattern = "*", --- command = "tabdo wincmd =", --- }) vim.opt.spelllang = "en_gb" vim.opt.spell = true --- local python_config = require("configs.python") --- python_config.setup() --- require("../custom/stim-treesitter-config").setup() + +local parser_config = require('nvim-treesitter.parsers').get_parser_configs() + +parser_config.stim = { + install_info = { + url = "/Users/andrewpatterson/stim-tresitter/", -- Local path to this repository + files = {"src/parser.c"}, + branch = "main", + generate_requires_npm = false, + requires_generate_from_grammar = true, + }, + filetype = "stim", +} + +require('nvim-treesitter.configs').setup({ + ensure_installed = { + -- your other parsers... + }, + + highlight = { + enable = true, + additional_vim_regex_highlighting = false, + }, + auto_install = false, -- Prevent conflicts + + -- Explicitly configure stim + parser_install_dir = vim.fn.stdpath("data") .. "/tree-sitter-parsers", + }) + + -- Force reload stim filetype +vim.treesitter.language.register("stim", "stim") +vim.filetype.add({ + extension = { + stim = 'stim', + }, + filename = { + ['*.stim'] = 'stim', + }, +}) +package.path = package.path .. ';/Users/andrewpatterson/stim-treesitter/?.lua' +-- local ok, result = pcall(function() +-- return loadfile('/Users/andrewpatterson/stim-tresitter/stim-treesitter.lua') +-- end) +-- +-- if ok and result then +-- print("File found and loadable") +-- local module = result() +-- print("Module type:", type(module)) +-- +-- if module then +-- print("Module contents:") +-- for k, v in pairs(module) do +-- print(" " .. k .. ": " .. type(v)) +-- end +-- +-- if module.setup then +-- print("Setup function found, calling it...") +-- module.setup() +-- print("Setup completed successfully") +-- else +-- print("No setup function found in module") +-- end +-- else +-- print("Module is nil") +-- end +-- else +-- print("File not found or not loadable: " .. tostring(result)) +-- end +-- Load and setup the plugin +-- require('stim-treesitter').setup() +local stim_treesitter_module = loadfile('/Users/andrewpatterson/stim-tresitter/stim-treesitter.lua')() + stim_treesitter_module.setup() + +-- Optional: Set up keybindings +vim.keymap.set('n', 'si', ':StimInfoTS', { desc = 'Stim: Show measurement info' }) diff --git a/lua/overrides.lua b/lua/overrides.lua index 72c629b03..398ee957b 100644 --- a/lua/overrides.lua +++ b/lua/overrides.lua @@ -7,19 +7,6 @@ local has_words_before = function() end local cmp = require("cmp") -M.nvimtree = { - git = { - enable = true, - }, - renderer = { - highlight_git = true, - icons = { - show = { - git = true, - }, - }, - }, -} M.cmp = { mapping = { @@ -35,10 +22,10 @@ M.cmp = { -- }, [""] = cmp.mapping(function(fallback) if cmp.visible() then - cmp.mapping.confirm { + cmp.confirm { behavior = cmp.ConfirmBehavior.Insert, select = true, - } + } elseif require("luasnip").expand_or_jumpable() then vim.fn.feedkeys(vim.api.nvim_replace_termcodes("luasnip-expand-or-jump", true, true, true), "") elseif has_words_before() then diff --git a/lua/plugins/myplugins.lua b/lua/plugins/myplugins.lua index 50550e30e..17db8bc52 100644 --- a/lua/plugins/myplugins.lua +++ b/lua/plugins/myplugins.lua @@ -139,10 +139,24 @@ local plugins = { vim.g.vimtex_quickfix_method = vim.fn.executable "pplatex" == 1 and "pplatex" or "latexlog" vim.g.tex_flavor = "luatex" vim.g.vimtex_quickfix_mode = 0 - vim.g.Tex_MultipleCompileFormats = "pdf,bib,pdf" + vim.g.vimtex_compiler_latexmk = { out_dir = "build" } vim.g.vimtex_view_general_viewer = "zathura" vim.g.vimtex_viewer_zathura = 1 - vim.g.vimtex_compiler_latexmk = { out_dir = "build" } + vim.g.vimtex_compiler_method = "latexmk" + vim.g.vimtex_compiler_latexmk_engines = { + _ = '-lualatex' + } + vim.g.vimtex_compiler_latexmk = { + build_dir = "build", + aux_dir = "build", + out_dir = "build", + options = { + "-verbose", + "-file-line-error", + "-synctex=1", + "-interaction=nonstopmode", + }, + } end, }, diff --git a/lua/stim-treesitter-config.lua b/lua/stim-treesitter-config.lua deleted file mode 100644 index a61caa509..000000000 --- a/lua/stim-treesitter-config.lua +++ /dev/null @@ -1,49 +0,0 @@ --- Stim Tree-sitter configuration (auto-generated) -local M = {} - -function M.setup(opts) - opts = opts or {} - local defaults = { - grammar_path = vim.fn.expand("~/tree-sitter-stim"), - auto_install = true, - highlight_measurements = true, - keymaps = { show_info = "si" } - } - opts = vim.tbl_deep_extend("force", defaults, opts) - - local ok, parsers = pcall(require, "nvim-treesitter.parsers") - if not ok then - vim.notify("nvim-treesitter not found", vim.log.levels.ERROR) - return - end - - local parser_config = parsers.get_parser_configs() - parser_config.stim = { - install_info = { - url = opts.grammar_path, - files = {"src/parser.c"}, - branch = "main", - generate_requires_npm = false, - requires_generate_from_grammar = false, - }, - filetype = "stim", - } - - vim.filetype.add({ extension = { stim = "stim" } }) - - -- if opts.auto_install then - -- vim.defer_fn(function() - -- pcall(vim.cmd, "TSInstallSync stim") - -- end, 100) - -- end - - if opts.highlight_measurements then - require('stim-treesitter').setup() - if opts.keymaps.show_info then - vim.keymap.set('n', opts.keymaps.show_info, ':StimInfoTS', - { desc = 'Show Stim measurement info' }) - end - end -end - -return M diff --git a/lua/stim-treesitter.lua b/lua/stim-treesitter.lua deleted file mode 100644 index 6ef44ce07..000000000 --- a/lua/stim-treesitter.lua +++ /dev/null @@ -1,303 +0,0 @@ --- ~/.config/nvim/lua/stim-treesitter.lua --- Tree-sitter based Stim Circuit Reader Plugin for Neovim --- This version uses the correct Tree-sitter API - -local M = {} -local ns_id = vim.api.nvim_create_namespace('stim_treesitter_highlights') - --- Parse measurements using Tree-sitter -local function parse_measurements_ts(bufnr) - local parser = vim.treesitter.get_parser(bufnr, 'stim') - if not parser then - return {} - end - - local tree = parser:parse()[1] - if not tree then - return {} - end - - local root = tree:root() - - local measurements = {} - local measurement_count = 0 - - -- Query for measurement instructions - local query_string = [[ - (measurement_instruction) @measurement - ]] - - local ok, query = pcall(vim.treesitter.query.parse, 'stim', query_string) - if not ok then - return {} - end - - for id, node in query:iter_captures(root, bufnr, 0, -1) do - local start_row, start_col, end_row, end_col = node:range() - local text = vim.api.nvim_buf_get_text(bufnr, start_row, start_col, end_row, end_col, {}) - text = text[1] or "" - - -- Count targets in this measurement - local target_count = 0 - for child in node:iter_children() do - if child:type() == 'target' then - target_count = target_count + 1 - end - end - - -- If no explicit targets found, assume at least one measurement - if target_count == 0 then - target_count = 1 - end - - -- Store each measurement target - for i = 1, target_count do - measurements[measurement_count] = { - line = start_row + 1, -- Convert to 1-indexed - node = node, - text = text, - index = measurement_count - } - measurement_count = measurement_count + 1 - end - end - - return measurements -end - --- Find record reference at cursor position -local function get_record_ref_at_cursor(bufnr) - local cursor = vim.api.nvim_win_get_cursor(0) - local row = cursor[1] - 1 -- Convert to 0-indexed - local col = cursor[2] - - local parser = vim.treesitter.get_parser(bufnr, 'stim') - if not parser then - return nil - end - - local tree = parser:parse()[1] - if not tree then - return nil - end - - local root = tree:root() - - -- Query for record references - local query_string = [[ - (record_ref) @ref - ]] - - local ok, query = pcall(vim.treesitter.query.parse, 'stim', query_string) - if not ok then - return nil - end - - for id, node in query:iter_captures(root, bufnr, 0, -1) do - local start_row, start_col, end_row, end_col = node:range() - - -- Check if cursor is within this node - if row >= start_row and row <= end_row then - if row > start_row or col >= start_col then - if row < end_row or col < end_col then - -- Extract the index value - local text = vim.api.nvim_buf_get_text(bufnr, start_row, start_col, end_row, end_col, {}) - text = text[1] or "" - local index = tonumber(text:match("rec%[([%-]?%d+)%]")) - - -- Check if it's valid (only negative indices are valid in Stim) - local is_valid = index and index < 0 - - return { - node = node, - index = index, - row = start_row, - start_col = start_col, - end_col = end_col, - is_valid = is_valid - } - end - end - end - end - - return nil -end - --- Calculate which measurement a record reference points to -local function resolve_measurement_index(rec_index, measurements_up_to_line) - -- In Stim, only negative indices are valid - if not rec_index or rec_index >= 0 then - return nil - end - - -- rec[-1] is the most recent measurement - return measurements_up_to_line + rec_index -end - --- Highlight measurement from record reference -function M.highlight_measurement() - local bufnr = vim.api.nvim_get_current_buf() - - -- Clear previous highlights - vim.api.nvim_buf_clear_namespace(bufnr, ns_id, 0, -1) - - local record_ref = get_record_ref_at_cursor(bufnr) - if not record_ref then - return - end - - if not record_ref.is_valid then - -- Highlight invalid positive index as error - vim.api.nvim_buf_add_highlight(bufnr, ns_id, 'Error', - record_ref.row, record_ref.start_col, record_ref.end_col) - return - end - - -- Parse all measurements - local measurements = parse_measurements_ts(bufnr) - - -- Count measurements up to the line with the record reference - local cursor_line = vim.api.nvim_win_get_cursor(0)[1] - local measurements_before = 0 - for idx, measurement in pairs(measurements) do - if measurement.line <= cursor_line then - measurements_before = measurements_before + 1 - end - end - - -- Resolve the measurement index - local target_index = resolve_measurement_index(record_ref.index, measurements_before) - - if target_index and target_index >= 0 then - -- Find and highlight the corresponding measurement - for idx, measurement in pairs(measurements) do - if idx == target_index then - local start_row, _, end_row, _ = measurement.node:range() - vim.api.nvim_buf_add_highlight(bufnr, ns_id, 'StimMeasurementHighlight', - start_row, 0, -1) - break - end - end - end - - -- Highlight the record reference itself - vim.api.nvim_buf_add_highlight(bufnr, ns_id, 'StimRecordHighlight', - record_ref.row, record_ref.start_col, record_ref.end_col) -end - --- Show information about measurement at cursor -function M.show_info() - local bufnr = vim.api.nvim_get_current_buf() - local record_ref = get_record_ref_at_cursor(bufnr) - - if not record_ref then - vim.notify("No record reference under cursor", vim.log.levels.INFO) - return - end - - if not record_ref.is_valid then - vim.notify(string.format( - "Invalid record reference rec[%d]: positive indices are not valid in Stim", - record_ref.index or 0 - ), vim.log.levels.ERROR) - return - end - - local measurements = parse_measurements_ts(bufnr) - local cursor_line = vim.api.nvim_win_get_cursor(0)[1] - local measurements_before = 0 - - for idx, measurement in pairs(measurements) do - if measurement.line <= cursor_line then - measurements_before = measurements_before + 1 - end - end - - local target_index = resolve_measurement_index(record_ref.index, measurements_before) - - if target_index and target_index >= 0 then - for idx, measurement in pairs(measurements) do - if idx == target_index then - vim.notify(string.format( - "rec[%d] → Measurement #%d at line %d: %s", - record_ref.index, idx, measurement.line, measurement.text - ), vim.log.levels.INFO) - return - end - end - end - - vim.notify(string.format( - "rec[%d] points to a measurement that doesn't exist (would be index %d)", - record_ref.index, target_index or -1 - ), vim.log.levels.WARN) -end - --- Setup function -function M.setup() - -- Define highlight groups - vim.cmd([[ - highlight default StimMeasurementHighlight guibg=#3a5f3a ctermbg=22 - highlight default StimRecordHighlight guibg=#5f3a3a ctermbg=52 - ]]) - - -- Setup autocmds for cursor movement - local group = vim.api.nvim_create_augroup('StimTreesitter', { clear = true }) - - vim.api.nvim_create_autocmd({ 'CursorMoved', 'CursorMovedI' }, { - group = group, - pattern = '*.stim', - callback = function() - -- Check if buffer is valid - local bufnr = vim.api.nvim_get_current_buf() - if not vim.api.nvim_buf_is_valid(bufnr) then - return - end - - -- Only run if we have the stim parser - local ok, parser = pcall(vim.treesitter.get_parser, bufnr, 'stim') - if ok and parser then - -- Wrap in pcall to prevent errors from breaking cursor movement - pcall(M.highlight_measurement) - end - end - }) - - -- Create commands - vim.api.nvim_create_user_command('StimInfoTS', M.show_info, { - desc = 'Show information about the Stim measurement record under cursor' - }) - - vim.api.nvim_create_user_command('StimCheckParser', function() - M.check_parser() - end, { - desc = 'Check if Stim Tree-sitter parser is installed' - }) -end - --- Function to check if Tree-sitter parser is available -function M.check_parser() - local bufnr = vim.api.nvim_get_current_buf() - local ok, parser = pcall(vim.treesitter.get_parser, bufnr, 'stim') - - if not ok then - vim.notify([[ -Tree-sitter parser for Stim not found! -Please install it first: -1. Build the grammar (see setup instructions) -2. Register it with nvim-treesitter -3. Run :TSInstall stim - ]], vim.log.levels.WARN) - return false - end - - vim.notify("Stim Tree-sitter parser is installed and working!", vim.log.levels.INFO) - return true -end - --- Export the get_record_ref_at_cursor function for external use -M.get_record_ref_at_cursor = get_record_ref_at_cursor - -return M - From f1b00257fcdef8ba07e323c58a467ca25871111b Mon Sep 17 00:00:00 2001 From: Andrew Patterson Date: Tue, 25 Nov 2025 22:37:24 +0000 Subject: [PATCH 05/13] attempt to get juppyter notebooks into nvim - not working currently --- ftplugin/markdown.lua | 2 ++ ftplugin/python.lua | 0 init.lua | 4 +++ lazy-lock.json | 46 ++++++++++++++----------- lua/configs/cmp.lua | 2 +- lua/configs/notebook.lua | 60 +++++++++++++++++++++++++++++++++ lua/mappings.lua | 45 ++++++++++++++++++++++++- lua/myinit.lua | 9 +++++ lua/plugins/myplugins.lua | 70 +++++++++++++++++++++++++++++++++++++++ 9 files changed, 216 insertions(+), 22 deletions(-) create mode 100644 ftplugin/markdown.lua create mode 100644 ftplugin/python.lua create mode 100644 lua/configs/notebook.lua diff --git a/ftplugin/markdown.lua b/ftplugin/markdown.lua new file mode 100644 index 000000000..c829417b9 --- /dev/null +++ b/ftplugin/markdown.lua @@ -0,0 +1,2 @@ +-- Activate quarto for markdown files to enable code cell execution +require("quarto").activate() diff --git a/ftplugin/python.lua b/ftplugin/python.lua new file mode 100644 index 000000000..e69de29bb diff --git a/init.lua b/init.lua index 4b46a671c..5f89c7eda 100644 --- a/init.lua +++ b/init.lua @@ -32,6 +32,10 @@ dofile(vim.g.base46_cache .. "statusline") require "options" require "autocmds" +-- Re-enable Python provider after NvChad options (NvChad disables it, but we need it for Molten) +vim.g.loaded_python3_provider = nil +vim.g.python3_host_prog = vim.fn.exepath('python3') or vim.fn.exepath('python') + vim.schedule(function() require "mappings" end) diff --git a/lazy-lock.json b/lazy-lock.json index 116862cad..54712331e 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -1,45 +1,51 @@ { - "CopilotChat.nvim": { "branch": "main", "commit": "181a523f5bf6b8f277e6a994907c23f9e84d2445" }, + "CopilotChat.nvim": { "branch": "main", "commit": "92f269971c33a6e2f405da8b14f01cd109b9a3a3" }, "FixCursorHold.nvim": { "branch": "master", "commit": "1900f89dc17c603eec29960f57c00bd9ae696495" }, - "LuaSnip": { "branch": "master", "commit": "b3104910bb5ebf40492aadffae18f2528fa757d9" }, - "NvChad": { "branch": "v2.5", "commit": "b5b38ebee53bcc8b71a917916ce61504ffffd509" }, - "base46": { "branch": "v3.0", "commit": "390bbb6cf149dc9da1a91548598c809f62fbc3c6" }, + "LuaSnip": { "branch": "master", "commit": "73813308abc2eaeff2bc0d3f2f79270c491be9d7" }, + "NvChad": { "branch": "v2.5", "commit": "f107fabe11ac8013dc3435ecd5382bee872b1584" }, + "base46": { "branch": "v3.0", "commit": "db58475d3fd2a16f9b1467d6895e3c4c195ed7dd" }, "better-escape.nvim": { "branch": "master", "commit": "19a38aab94961016430905ebec30d272a01e9742" }, "cmp-async-path": { "branch": "main", "commit": "0ed1492f59e730c366d261a5ad822fa37e44c325" }, "cmp-buffer": { "branch": "main", "commit": "b74fab3656eea9de20a9b8116afa3cfc4ec09657" }, "cmp-nvim-lsp": { "branch": "main", "commit": "bd5a7d6db125d4654b50eeae9f5217f24bb22fd3" }, "cmp-nvim-lua": { "branch": "main", "commit": "f12408bdb54c39c23e67cab726264c10db33ada8" }, "cmp_luasnip": { "branch": "master", "commit": "98d9cb5c2c38532bd9bdb481067b20fea8f32e90" }, - "conform.nvim": { "branch": "master", "commit": "b4aab989db276993ea5dcb78872be494ce546521" }, - "copilot.vim": { "branch": "release", "commit": "dfe0a3a1c256167d181488a73ec6ccab8d8931a9" }, + "conform.nvim": { "branch": "master", "commit": "9d859cbfbde7a1bd1770e7c97aef30ec5a237a71" }, + "copilot.vim": { "branch": "release", "commit": "da369d90cfd6c396b1d0ec259836a1c7222fb2ea" }, "friendly-snippets": { "branch": "main", "commit": "572f5660cf05f8cd8834e096d7b4c921ba18e175" }, - "gitsigns.nvim": { "branch": "main", "commit": "f780609807eca1f783a36a8a31c30a48fbe150c5" }, + "gitsigns.nvim": { "branch": "main", "commit": "1ee5c1fd068c81f9dd06483e639c2aa4587dc197" }, + "hererocks": { "branch": "master", "commit": "160228946bed9998f5e3b168bd0b66ba2690f8f3" }, + "image.nvim": { "branch": "master", "commit": "446a8a5cc7a3eae3185ee0c697732c32a5547a0b" }, "indent-blankline.nvim": { "branch": "master", "commit": "005b56001b2cb30bfa61b7986bc50657816ba4ba" }, - "lazy.nvim": { "branch": "main", "commit": "6c3bda4aca61a13a9c63f1c1d1b16b9d3be90d7a" }, - "mason.nvim": { "branch": "main", "commit": "7dc4facca9702f95353d5a1f87daf23d78e31c2a" }, + "jupytext.nvim": { "branch": "main", "commit": "c8baf3ad344c59b3abd461ecc17fc16ec44d0f7b" }, + "lazy.nvim": { "branch": "main", "commit": "59334064f8604ca073791c25dcc5c9698865406e" }, + "mason.nvim": { "branch": "main", "commit": "ad7146aa61dcaeb54fa900144d768f040090bff0" }, "menu": { "branch": "main", "commit": "7a0a4a2896b715c066cfbe320bdc048091874cc6" }, "minty": { "branch": "main", "commit": "aafc9e8e0afe6bf57580858a2849578d8d8db9e0" }, + "molten-nvim": { "branch": "main", "commit": "a286aa914d9a154bc359131aab788b5a077a5a99" }, "neogen": { "branch": "main", "commit": "d7f9461727751fb07f82011051338a9aba07581d" }, "neotest": { "branch": "master", "commit": "2cf3544fb55cdd428a9a1b7154aea9c9823426e8" }, - "neotest-python": { "branch": "master", "commit": "ed9b4d794b89044cc32e5476e637936331473c6e" }, - "none-ls.nvim": { "branch": "main", "commit": "78111a97cebed3dfda8157af8141bf1915cfc327" }, + "neotest-python": { "branch": "master", "commit": "7cab6e2ecc260bf61b97ca147574a470bd880cbd" }, + "none-ls.nvim": { "branch": "main", "commit": "5cf63841461b49989972d35bf886e076a1ab3649" }, "nvim-autopairs": { "branch": "master", "commit": "23320e75953ac82e559c610bec5a90d9c6dfa743" }, "nvim-cmp": { "branch": "main", "commit": "b5311ab3ed9c846b585c0c15b7559be131ec4be9" }, - "nvim-dap": { "branch": "master", "commit": "7523676a4be17644587aa47e4d42f6f7646d4727" }, - "nvim-dap-python": { "branch": "master", "commit": "bfe572e4458e0ac876b9539a1e9f301c72db8ea0" }, + "nvim-dap": { "branch": "master", "commit": "48570d8372f63c9e9ba399a16606f9553034a9b2" }, + "nvim-dap-python": { "branch": "master", "commit": "64652d1ae1db80870d9aac7132d76e37acd86a26" }, "nvim-dap-ui": { "branch": "master", "commit": "cf91d5e2d07c72903d052f5207511bf7ecdb7122" }, - "nvim-lint": { "branch": "master", "commit": "0864f81c681e15d9bdc1156fe3a17bd07db5a3ed" }, - "nvim-lspconfig": { "branch": "master", "commit": "1f7fbc34e6420476142b5cc85e9bee52717540fb" }, + "nvim-lint": { "branch": "master", "commit": "335a6044be16d7701001059cba9baa36fbeef422" }, + "nvim-lspconfig": { "branch": "master", "commit": "e688b486fe9291f151eae7e5c0b5a5c4ef980847" }, "nvim-nio": { "branch": "master", "commit": "21f5324bfac14e22ba26553caf69ec76ae8a7662" }, - "nvim-tree.lua": { "branch": "master", "commit": "e179ad2f83b5955ab0af653069a493a1828c2697" }, + "nvim-tree.lua": { "branch": "master", "commit": "87d096a39cb2d5d43e6771563575ff042a79f48b" }, "nvim-treesitter": { "branch": "master", "commit": "42fc28ba918343ebfd5565147a42a26580579482" }, - "nvim-web-devicons": { "branch": "master", "commit": "6e51ca170563330e063720449c21f43e27ca0bc1" }, + "nvim-web-devicons": { "branch": "master", "commit": "b8221e42cf7287c4dcde81f232f58d7b947c210d" }, + "otter.nvim": { "branch": "main", "commit": "c44d645f03ae96e2e3cdc37f92ecfa93a534b736" }, "plenary.nvim": { "branch": "master", "commit": "b9fd5226c2f76c951fc8ed5923d85e4de065e509" }, + "quarto-nvim": { "branch": "main", "commit": "0e9491509b38efbd83d3f41dbfacc7fc4bd40191" }, "snippet-converter.nvim": { "branch": "main", "commit": "d7e783618f02541641980ebd823e439bdef64a4f" }, "telescope.nvim": { "branch": "master", "commit": "b4da76be54691e854d3e0e02c36b0245f945c2c7" }, - "ui": { "branch": "v3.0", "commit": "4852e04faefbba3a18cb197b76ac00f4bc2e615f" }, + "ui": { "branch": "v3.0", "commit": "03b9718140375e7f3f5e4f3e04bc2b6c907440ec" }, "vim-markdown": { "branch": "master", "commit": "8f6cb3a6ca4e3b6bcda0730145a0b700f3481b51" }, - "vimtex": { "branch": "master", "commit": "77f31bd02cec678823c8614e6400db97390b5ce7" }, + "vimtex": { "branch": "master", "commit": "2e1bbabeb2c34bb17d7bc8cfdf8f95b16dd0db0c" }, "volt": { "branch": "main", "commit": "620de1321f275ec9d80028c68d1b88b409c0c8b1" }, - "which-key.nvim": { "branch": "main", "commit": "370ec46f710e058c9c1646273e6b225acf47cbed" } + "which-key.nvim": { "branch": "main", "commit": "904308e6885bbb7b60714c80ab3daf0c071c1492" } } diff --git a/lua/configs/cmp.lua b/lua/configs/cmp.lua index bc5d8c60f..2b36d383a 100644 --- a/lua/configs/cmp.lua +++ b/lua/configs/cmp.lua @@ -19,7 +19,7 @@ local options = { -- }, [""] = cmp.mapping(function(fallback) if cmp.visible() then - cmp.mapping.confirm { + cmp.confirm { behavior = cmp.ConfirmBehavior.Insert, select = true, } diff --git a/lua/configs/notebook.lua b/lua/configs/notebook.lua new file mode 100644 index 000000000..f4fe5136c --- /dev/null +++ b/lua/configs/notebook.lua @@ -0,0 +1,60 @@ +-- Notebook utilities +local M = {} + +-- Create a new notebook from a template +function M.new_notebook(filename) + -- Default filename if not provided + if not filename or filename == "" then + filename = vim.fn.input("Notebook name: ", "", "file") + if filename == "" then + print("Cancelled") + return + end + end + + -- Add .md extension if not present + if not filename:match("%.md$") then + filename = filename .. ".md" + end + + -- Create the file with a basic template + local template = [[--- +title: "]] .. filename:gsub("%.md$", "") .. [[" +jupyter: + kernelspec: + display_name: Python 3 + language: python + name: python3 +--- + +# ]] .. filename:gsub("%.md$", "") .. [[ + + +## Setup + +```{python} +import numpy as np +import pandas as pd +import matplotlib.pyplot as plt +``` + +## Analysis + +```{python} + +``` +]] + + -- Write the template to the file + vim.fn.writefile(vim.split(template, "\n"), filename) + + -- Open the file + vim.cmd("edit " .. filename) + + -- Initialize Molten for this buffer + vim.cmd("MoltenInit python3") + + print("Created notebook: " .. filename) +end + +return M diff --git a/lua/mappings.lua b/lua/mappings.lua index d8ad42818..b668a2694 100644 --- a/lua/mappings.lua +++ b/lua/mappings.lua @@ -27,7 +27,7 @@ map("n", "at", ":CopilotChatTests", {desc = "CopilotChat - Generate map("n", "af", ":CopilotChatFix", {desc = "CopilotChat - Fix code" }) map("n", "ar", ":CopilotChatReview", {desc = "CopilotChat - Review code" }) map("n", "aw", ":CopilotChatToggle", {desc = "CopilotChat - Toggle Window" }) -map("n", "aq", +map("n", "aq", function() local input = vim.fn.input "Quick Chat: " if input ~= "" then @@ -38,6 +38,49 @@ map("n", "aq", end, {desc = "CopilotChat - Quick chat"}) +-- Molten/Quarto (Jupyter) - context-aware keybindings +vim.api.nvim_create_autocmd("FileType", { + pattern = { "python", "markdown" }, + callback = function() + local buf = vim.api.nvim_get_current_buf() + + -- Use Ctrl-Enter for running cells (works in both Python and Markdown notebooks) + vim.keymap.set("n", "", function() + -- Use QuartoSend if available (for markdown), otherwise MoltenEvaluateLine + local has_quarto = pcall(require, "quarto") + if has_quarto and vim.bo.filetype == "markdown" then + require("quarto.runner").run_cell() + else + vim.cmd("MoltenEvaluateLine") + end + end, {desc = "Run cell", buffer = buf, silent = true}) + + vim.keymap.set("v", "", function() + local has_quarto = pcall(require, "quarto") + if has_quarto and vim.bo.filetype == "markdown" then + require("quarto.runner").run_range() + else + vim.cmd("MoltenEvaluateVisual") + end + end, {desc = "Run selection", buffer = buf, silent = true}) + + -- Molten-specific keybindings (use localleader to avoid conflicts) + vim.keymap.set("n", "mi", ":MoltenInit", {desc = "Initialize kernel", buffer = buf, silent = true}) + vim.keymap.set("n", "e", ":MoltenEvaluateOperator", {desc = "Evaluate operator", buffer = buf, silent = true}) + vim.keymap.set("n", "rr", ":MoltenReevaluateCell", {desc = "Re-evaluate cell", buffer = buf, silent = true}) + vim.keymap.set("n", "rd", ":MoltenDelete", {desc = "Delete cell", buffer = buf, silent = true}) + vim.keymap.set("n", "oh", ":MoltenHideOutput", {desc = "Hide output", buffer = buf, silent = true}) + vim.keymap.set("n", "os", ":noautocmd MoltenEnterOutput", {desc = "Open output window", buffer = buf, silent = true}) + vim.keymap.set("v", "r", ":MoltenEvaluateVisualgv", {desc = "Execute visual selection", buffer = buf, silent = true}) + + -- Quarto navigation (only in markdown) + if vim.bo.filetype == "markdown" then + vim.keymap.set("n", "]c", function() require("quarto.runner").run_cell() end, {desc = "Run cell and move next", buffer = buf, silent = true}) + vim.keymap.set("n", "[c", function() require("quarto.runner").run_above() end, {desc = "Run cell above", buffer = buf, silent = true}) + end + end, +}) + -- Visual mode -- map("v", ">", ">gv", {desc = "indent" }) diff --git a/lua/myinit.lua b/lua/myinit.lua index 3be143618..ce49a3311 100644 --- a/lua/myinit.lua +++ b/lua/myinit.lua @@ -75,3 +75,12 @@ local stim_treesitter_module = loadfile('/Users/andrewpatterson/stim-tresitter/s -- Optional: Set up keybindings vim.keymap.set('n', 'si', ':StimInfoTS', { desc = 'Stim: Show measurement info' }) + +-- Notebook utilities +vim.api.nvim_create_user_command("NewNotebook", function(opts) + require("configs.notebook").new_notebook(opts.args) +end, { + nargs = "?", + complete = "file", + desc = "Create a new Jupyter notebook (markdown format)", +}) diff --git a/lua/plugins/myplugins.lua b/lua/plugins/myplugins.lua index 17db8bc52..598a1743e 100644 --- a/lua/plugins/myplugins.lua +++ b/lua/plugins/myplugins.lua @@ -319,6 +319,76 @@ local plugins = { opts = overrides.telescope, }, + -- Jupyter notebook support + { + "benlubas/molten-nvim", + version = "^1.0.0", + build = ":UpdateRemotePlugins", + ft = { "python", "markdown" }, + cmd = { "MoltenInit", "MoltenInfo" }, + init = function() + vim.g.molten_image_provider = "image.nvim" + vim.g.molten_output_win_max_height = 20 + vim.g.molten_auto_open_output = false + vim.g.molten_wrap_output = true + vim.g.molten_virt_text_output = true + vim.g.molten_virt_lines_off_by_1 = true + end, + }, + { + "3rd/image.nvim", + opts = { + backend = "kitty", + integrations = { + markdown = { + enabled = true, + clear_in_insert_mode = false, + download_remote_images = true, + only_render_image_at_cursor = false, + filetypes = { "markdown", "vimwiki" }, + }, + }, + max_width = nil, + max_height = nil, + max_width_window_percentage = nil, + max_height_window_percentage = 50, + window_overlap_clear_enabled = false, + window_overlap_clear_ft_ignore = { "cmp_menu", "cmp_docs", "" }, + editor_only_render_when_focused = false, + tmux_show_only_in_active_window = false, + hijack_file_patterns = { "*.png", "*.jpg", "*.jpeg", "*.gif", "*.webp" }, + }, + }, + { + "quarto-dev/quarto-nvim", + ft = { "quarto", "markdown" }, + dependencies = { + "jmbuhr/otter.nvim", + "nvim-treesitter/nvim-treesitter", + }, + config = function() + require("quarto").setup { + lspFeatures = { + enabled = false, -- Disable to use your existing LSP setup + languages = { "r", "python", "julia", "bash", "lua", "html" }, + }, + codeRunner = { + enabled = true, + default_method = "molten", + }, + } + end, + }, + { + "GCBallesteros/jupytext.nvim", + ft = { "markdown" }, + opts = { + style = "markdown", + output_extension = "md", + force_ft = "markdown", + }, + }, + -- To make a plugin not be loaded -- { -- "NvChad/nvim-colorizer.lua", From c4da6c698f3aff65eb7d9f208e22e236d1717e45 Mon Sep 17 00:00:00 2001 From: Andrew Patterson Date: Thu, 15 Jan 2026 11:52:18 +0000 Subject: [PATCH 06/13] Avante.nvim (#1) * add avante and mcphub * add claude settingd * add avante.nvim to vim config --- .claude/settings.local.json | 12 +++++++ ftplugin/stim.lua | 2 ++ lazy-lock.json | 63 +++++++++++++++++++------------------ lua/myinit.lua | 59 ++++++++++++++++++++++++++++++++++ lua/plugins/myplugins.lua | 60 +++++++++++++++++++++++++++++++++++ 5 files changed, 166 insertions(+), 30 deletions(-) create mode 100644 .claude/settings.local.json create mode 100644 ftplugin/stim.lua diff --git a/.claude/settings.local.json b/.claude/settings.local.json new file mode 100644 index 000000000..de4937db5 --- /dev/null +++ b/.claude/settings.local.json @@ -0,0 +1,12 @@ +{ + "permissions": { + "allow": [ + "Bash(poetry env info:*)", + "Bash(poetry env list:*)", + "Bash(uvx --help:*)", + "WebFetch(domain:github.com)" + ], + "deny": [], + "ask": [] + } +} diff --git a/ftplugin/stim.lua b/ftplugin/stim.lua new file mode 100644 index 000000000..0e858d6b2 --- /dev/null +++ b/ftplugin/stim.lua @@ -0,0 +1,2 @@ +-- Comment configuration for .stim files +vim.bo.commentstring = "# %s" diff --git a/lazy-lock.json b/lazy-lock.json index 54712331e..1802678b5 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -1,51 +1,54 @@ { - "CopilotChat.nvim": { "branch": "main", "commit": "92f269971c33a6e2f405da8b14f01cd109b9a3a3" }, + "CopilotChat.nvim": { "branch": "main", "commit": "9db5d3eaafe9fc3c91ce9ecfc416de2798982487" }, "FixCursorHold.nvim": { "branch": "master", "commit": "1900f89dc17c603eec29960f57c00bd9ae696495" }, - "LuaSnip": { "branch": "master", "commit": "73813308abc2eaeff2bc0d3f2f79270c491be9d7" }, - "NvChad": { "branch": "v2.5", "commit": "f107fabe11ac8013dc3435ecd5382bee872b1584" }, - "base46": { "branch": "v3.0", "commit": "db58475d3fd2a16f9b1467d6895e3c4c195ed7dd" }, + "LuaSnip": { "branch": "master", "commit": "3732756842a2f7e0e76a7b0487e9692072857277" }, + "NvChad": { "branch": "v2.5", "commit": "30e75dbbdf33f393430d6e7612dd32ef84e2a710" }, + "avante.nvim": { "branch": "main", "commit": "a27b821cc1f9fec70d7b7dc4a42c6dbd76266997" }, + "base46": { "branch": "v3.0", "commit": "45b336ec52615dd1a3aa47848d894616dd6293a5" }, "better-escape.nvim": { "branch": "master", "commit": "19a38aab94961016430905ebec30d272a01e9742" }, - "cmp-async-path": { "branch": "main", "commit": "0ed1492f59e730c366d261a5ad822fa37e44c325" }, + "cmp-async-path": { "branch": "main", "commit": "a14d3a9c7f303551a0b8c64a0e4e6527ce39a8a2" }, "cmp-buffer": { "branch": "main", "commit": "b74fab3656eea9de20a9b8116afa3cfc4ec09657" }, - "cmp-nvim-lsp": { "branch": "main", "commit": "bd5a7d6db125d4654b50eeae9f5217f24bb22fd3" }, - "cmp-nvim-lua": { "branch": "main", "commit": "f12408bdb54c39c23e67cab726264c10db33ada8" }, + "cmp-nvim-lsp": { "branch": "main", "commit": "cbc7b02bb99fae35cb42f514762b89b5126651ef" }, + "cmp-nvim-lua": { "branch": "main", "commit": "e3a22cb071eb9d6508a156306b102c45cd2d573d" }, "cmp_luasnip": { "branch": "master", "commit": "98d9cb5c2c38532bd9bdb481067b20fea8f32e90" }, - "conform.nvim": { "branch": "master", "commit": "9d859cbfbde7a1bd1770e7c97aef30ec5a237a71" }, - "copilot.vim": { "branch": "release", "commit": "da369d90cfd6c396b1d0ec259836a1c7222fb2ea" }, + "conform.nvim": { "branch": "master", "commit": "8314f4c9e205e7f30b62147069729f9a1227d8bf" }, + "copilot.vim": { "branch": "release", "commit": "206011a8bc5078a02560d5c44177e9849e8f8d6c" }, "friendly-snippets": { "branch": "main", "commit": "572f5660cf05f8cd8834e096d7b4c921ba18e175" }, - "gitsigns.nvim": { "branch": "main", "commit": "1ee5c1fd068c81f9dd06483e639c2aa4587dc197" }, - "hererocks": { "branch": "master", "commit": "160228946bed9998f5e3b168bd0b66ba2690f8f3" }, + "gitsigns.nvim": { "branch": "main", "commit": "72acb69020c92d99cf388bfeb390481ccec50c04" }, + "hererocks": { "branch": "master", "commit": "3368b981eed0d8cfdc00822f1be73bd8bfb5a968" }, "image.nvim": { "branch": "master", "commit": "446a8a5cc7a3eae3185ee0c697732c32a5547a0b" }, "indent-blankline.nvim": { "branch": "master", "commit": "005b56001b2cb30bfa61b7986bc50657816ba4ba" }, "jupytext.nvim": { "branch": "main", "commit": "c8baf3ad344c59b3abd461ecc17fc16ec44d0f7b" }, - "lazy.nvim": { "branch": "main", "commit": "59334064f8604ca073791c25dcc5c9698865406e" }, - "mason.nvim": { "branch": "main", "commit": "ad7146aa61dcaeb54fa900144d768f040090bff0" }, + "lazy.nvim": { "branch": "main", "commit": "306a05526ada86a7b30af95c5cc81ffba93fef97" }, + "mason.nvim": { "branch": "main", "commit": "44d1e90e1f66e077268191e3ee9d2ac97cc18e65" }, + "mcphub.nvim": { "branch": "main", "commit": "5193329d510a68f1f5bf189960642c925c177a3a" }, "menu": { "branch": "main", "commit": "7a0a4a2896b715c066cfbe320bdc048091874cc6" }, "minty": { "branch": "main", "commit": "aafc9e8e0afe6bf57580858a2849578d8d8db9e0" }, "molten-nvim": { "branch": "main", "commit": "a286aa914d9a154bc359131aab788b5a077a5a99" }, "neogen": { "branch": "main", "commit": "d7f9461727751fb07f82011051338a9aba07581d" }, - "neotest": { "branch": "master", "commit": "2cf3544fb55cdd428a9a1b7154aea9c9823426e8" }, - "neotest-python": { "branch": "master", "commit": "7cab6e2ecc260bf61b97ca147574a470bd880cbd" }, - "none-ls.nvim": { "branch": "main", "commit": "5cf63841461b49989972d35bf886e076a1ab3649" }, - "nvim-autopairs": { "branch": "master", "commit": "23320e75953ac82e559c610bec5a90d9c6dfa743" }, - "nvim-cmp": { "branch": "main", "commit": "b5311ab3ed9c846b585c0c15b7559be131ec4be9" }, - "nvim-dap": { "branch": "master", "commit": "48570d8372f63c9e9ba399a16606f9553034a9b2" }, - "nvim-dap-python": { "branch": "master", "commit": "64652d1ae1db80870d9aac7132d76e37acd86a26" }, + "neotest": { "branch": "master", "commit": "deadfb1af5ce458742671ad3a013acb9a6b41178" }, + "neotest-python": { "branch": "master", "commit": "b0d3a861bd85689d8ed73f0590c47963a7eb1bf9" }, + "none-ls.nvim": { "branch": "main", "commit": "1fcf9cbf9acf893455c6cee792537aa709de62cb" }, + "nui.nvim": { "branch": "main", "commit": "de740991c12411b663994b2860f1a4fd0937c130" }, + "nvim-autopairs": { "branch": "master", "commit": "c2a0dd0d931d0fb07665e1fedb1ea688da3b80b4" }, + "nvim-cmp": { "branch": "main", "commit": "85bbfad83f804f11688d1ab9486b459e699292d6" }, + "nvim-dap": { "branch": "master", "commit": "cdfd55a133f63228c55f91378f12908cb2a78ded" }, + "nvim-dap-python": { "branch": "master", "commit": "1808458eba2b18f178f990e01376941a42c7f93b" }, "nvim-dap-ui": { "branch": "master", "commit": "cf91d5e2d07c72903d052f5207511bf7ecdb7122" }, - "nvim-lint": { "branch": "master", "commit": "335a6044be16d7701001059cba9baa36fbeef422" }, - "nvim-lspconfig": { "branch": "master", "commit": "e688b486fe9291f151eae7e5c0b5a5c4ef980847" }, + "nvim-lint": { "branch": "master", "commit": "ca6ea12daf0a4d92dc24c5c9ae22a1f0418ade37" }, + "nvim-lspconfig": { "branch": "master", "commit": "5a82e10b2df0ed31bec642c1c0344baee7c458b6" }, "nvim-nio": { "branch": "master", "commit": "21f5324bfac14e22ba26553caf69ec76ae8a7662" }, - "nvim-tree.lua": { "branch": "master", "commit": "87d096a39cb2d5d43e6771563575ff042a79f48b" }, + "nvim-tree.lua": { "branch": "master", "commit": "b8b44b6a2494d086a9177251a119f9daec6cace8" }, "nvim-treesitter": { "branch": "master", "commit": "42fc28ba918343ebfd5565147a42a26580579482" }, - "nvim-web-devicons": { "branch": "master", "commit": "b8221e42cf7287c4dcde81f232f58d7b947c210d" }, - "otter.nvim": { "branch": "main", "commit": "c44d645f03ae96e2e3cdc37f92ecfa93a534b736" }, + "nvim-web-devicons": { "branch": "master", "commit": "6788013bb9cb784e606ada44206b0e755e4323d7" }, + "otter.nvim": { "branch": "main", "commit": "b36e1a40617e35779d2097fc9b9fd701acd4f5e8" }, "plenary.nvim": { "branch": "master", "commit": "b9fd5226c2f76c951fc8ed5923d85e4de065e509" }, "quarto-nvim": { "branch": "main", "commit": "0e9491509b38efbd83d3f41dbfacc7fc4bd40191" }, "snippet-converter.nvim": { "branch": "main", "commit": "d7e783618f02541641980ebd823e439bdef64a4f" }, - "telescope.nvim": { "branch": "master", "commit": "b4da76be54691e854d3e0e02c36b0245f945c2c7" }, - "ui": { "branch": "v3.0", "commit": "03b9718140375e7f3f5e4f3e04bc2b6c907440ec" }, - "vim-markdown": { "branch": "master", "commit": "8f6cb3a6ca4e3b6bcda0730145a0b700f3481b51" }, - "vimtex": { "branch": "master", "commit": "2e1bbabeb2c34bb17d7bc8cfdf8f95b16dd0db0c" }, + "telescope.nvim": { "branch": "master", "commit": "3333a52ff548ba0a68af6d8da1e54f9cd96e9179" }, + "ui": { "branch": "v3.0", "commit": "ebf58649bc5c759ee6c730c87d8d2d4dd4124c0d" }, + "vim-markdown": { "branch": "master", "commit": "1bc9d0cd8e1cc3e901b0a49c2b50a843f1c89397" }, + "vimtex": { "branch": "master", "commit": "a50f40783c1cade2e8e2994a9f4a8e038a0a57bc" }, "volt": { "branch": "main", "commit": "620de1321f275ec9d80028c68d1b88b409c0c8b1" }, - "which-key.nvim": { "branch": "main", "commit": "904308e6885bbb7b60714c80ab3daf0c071c1492" } + "which-key.nvim": { "branch": "main", "commit": "3aab2147e74890957785941f0c1ad87d0a44c15a" } } diff --git a/lua/myinit.lua b/lua/myinit.lua index ce49a3311..430cff5b8 100644 --- a/lua/myinit.lua +++ b/lua/myinit.lua @@ -1,6 +1,65 @@ vim.opt.spelllang = "en_gb" vim.opt.spell = true +-- Suppress network connectivity errors from Copilot/GitHub API +-- This filters out DNS resolution failures and connection timeouts +-- while still showing other important errors +local original_notify = vim.notify +vim.notify = function(msg, level, opts) + -- Patterns to ignore (network-related errors) + local ignore_patterns = { + "Could not resolve host", + "curl error exit_code=6", + "curl error exit_code=7", -- Failed to connect + "curl error exit_code=28", -- Timeout + "api%.github%.com", + "api%.githubcopilot%.com", + "cannot resume dead coroutine", -- Consequence of network errors + } + + -- Check if message matches any ignore pattern + for _, pattern in ipairs(ignore_patterns) do + if msg and type(msg) == "string" and msg:match(pattern) then + -- Silently ignore this error + return + end + end + + -- For all other messages, use original notify + original_notify(msg, level, opts) +end + +-- Also suppress error display for network-related callback failures +vim.api.nvim_create_autocmd("FileType", { + pattern = "*", + callback = function() + -- Override error display to filter network errors + local original_errmsg = vim.api.nvim_err_writeln + vim.api.nvim_err_writeln = function(msg) + -- Check if this is a network-related error + if msg and type(msg) == "string" then + local network_error_patterns = { + "Could not resolve host", + "curl error exit_code=[678]", + "curl error exit_code=28", + "api%.github", + "cannot resume dead coroutine", + } + + for _, pattern in ipairs(network_error_patterns) do + if msg:match(pattern) then + return -- Silently ignore + end + end + end + + -- Show all other errors + original_errmsg(msg) + end + end, + once = true, +}) + local parser_config = require('nvim-treesitter.parsers').get_parser_configs() parser_config.stim = { diff --git a/lua/plugins/myplugins.lua b/lua/plugins/myplugins.lua index 598a1743e..08808762f 100644 --- a/lua/plugins/myplugins.lua +++ b/lua/plugins/myplugins.lua @@ -288,8 +288,49 @@ local plugins = { config = function() vim.g.copilot_no_tab_map = true vim.g.copilot_assume_mapped = true + vim.api.nvim_set_keymap("i", "", 'copilot#Accept("")', { silent = true, expr = true }) end, }, + { + "yetone/avante.nvim", + event = "VeryLazy", + version = false, + build = "make", + dependencies = { + "nvim-lua/plenary.nvim", + "MunifTanjim/nui.nvim", + "nvim-tree/nvim-web-devicons", + "nvim-tree/nvim-tree.lua", + "github/copilot.vim", + }, + opts = { + provider = "copilot", + providers = { + copilot = { + endpoint = "https://api.githubcopilot.com", + model = "gpt-4.1-2025-04-14", + timeout = 30000, + temperature = 0, + extra_request_body = { + max_tokens = 4096, + }, + }, + }, + behaviour = { + support_paste_from_clipboard = true, + }, + windows = { + sidebar_header = { + enabled = true, + }, + }, + mappings = { + files = { + enabled = true, + }, + }, + }, + }, { "CopilotC-Nvim/CopilotChat.nvim", lazy = false, @@ -313,6 +354,25 @@ local plugins = { }, }, }, + { + "ravitemer/mcphub.nvim", + lazy = false, + dependencies = { + "CopilotC-Nvim/CopilotChat.nvim", + }, + config = function() + require("mcphub").setup({ + extensions = { + copilotchat = { + enabled = true, + convert_tools_to_functions = true, + convert_resources_to_functions = true, + add_mcp_prefix = false, + }, + }, + }) + end, + }, { "nvim-telescope/telescope.nvim", From c91a37a27f6e64705ff3aa3c2707ab0ea1a25450 Mon Sep 17 00:00:00 2001 From: Andrew Patterson Date: Mon, 8 Jun 2026 09:48:58 +0100 Subject: [PATCH 07/13] update to use hosted version of stim-treesitter --- ftplugin/stim.lua | 6 ++++ lazy-lock.json | 71 ++++++++++++++++++++------------------- lua/configs/overrides.lua | 6 ++-- lua/myinit.lua | 68 ++++++++++++++++++------------------- lua/plugins/myplugins.lua | 12 +++++++ 5 files changed, 91 insertions(+), 72 deletions(-) diff --git a/ftplugin/stim.lua b/ftplugin/stim.lua index 0e858d6b2..54660c36f 100644 --- a/ftplugin/stim.lua +++ b/ftplugin/stim.lua @@ -1,2 +1,8 @@ -- Comment configuration for .stim files vim.bo.commentstring = "# %s" + +-- Enable treesitter syntax highlighting. +-- vim.treesitter.start() bypasses nvim-treesitter's highlight module (which +-- only activates parsers it knew about at startup) and directly starts the +-- built-in highlighter for this buffer. +pcall(vim.treesitter.start) diff --git a/lazy-lock.json b/lazy-lock.json index 1802678b5..ade814c37 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -1,54 +1,55 @@ { - "CopilotChat.nvim": { "branch": "main", "commit": "9db5d3eaafe9fc3c91ce9ecfc416de2798982487" }, + "CopilotChat.nvim": { "branch": "main", "commit": "2025f92022bef434de0511c5157a19974a9377a4" }, "FixCursorHold.nvim": { "branch": "master", "commit": "1900f89dc17c603eec29960f57c00bd9ae696495" }, - "LuaSnip": { "branch": "master", "commit": "3732756842a2f7e0e76a7b0487e9692072857277" }, - "NvChad": { "branch": "v2.5", "commit": "30e75dbbdf33f393430d6e7612dd32ef84e2a710" }, - "avante.nvim": { "branch": "main", "commit": "a27b821cc1f9fec70d7b7dc4a42c6dbd76266997" }, - "base46": { "branch": "v3.0", "commit": "45b336ec52615dd1a3aa47848d894616dd6293a5" }, - "better-escape.nvim": { "branch": "master", "commit": "19a38aab94961016430905ebec30d272a01e9742" }, - "cmp-async-path": { "branch": "main", "commit": "a14d3a9c7f303551a0b8c64a0e4e6527ce39a8a2" }, + "LuaSnip": { "branch": "master", "commit": "0abc8f390b278c3b4aabc4c004ac8a088b65cf24" }, + "NvChad": { "branch": "v2.5", "commit": "d042cc975247c2aa55fcb228e5d146dc1dc6c648" }, + "avante.nvim": { "branch": "main", "commit": "044f2ec3b23ecba3cbdd694ae15f05b4e06c429b" }, + "base46": { "branch": "v3.0", "commit": "884b990dcdbe07520a0892da6ba3e8d202b46337" }, + "better-escape.nvim": { "branch": "master", "commit": "3f4bc0b326606264ff75967f59091b5ddada0554" }, + "cmp-async-path": { "branch": "main", "commit": "f8af3f726e07f2e9d37672eaa9102581aefce149" }, "cmp-buffer": { "branch": "main", "commit": "b74fab3656eea9de20a9b8116afa3cfc4ec09657" }, "cmp-nvim-lsp": { "branch": "main", "commit": "cbc7b02bb99fae35cb42f514762b89b5126651ef" }, "cmp-nvim-lua": { "branch": "main", "commit": "e3a22cb071eb9d6508a156306b102c45cd2d573d" }, "cmp_luasnip": { "branch": "master", "commit": "98d9cb5c2c38532bd9bdb481067b20fea8f32e90" }, - "conform.nvim": { "branch": "master", "commit": "8314f4c9e205e7f30b62147069729f9a1227d8bf" }, - "copilot.vim": { "branch": "release", "commit": "206011a8bc5078a02560d5c44177e9849e8f8d6c" }, - "friendly-snippets": { "branch": "main", "commit": "572f5660cf05f8cd8834e096d7b4c921ba18e175" }, - "gitsigns.nvim": { "branch": "main", "commit": "72acb69020c92d99cf388bfeb390481ccec50c04" }, - "hererocks": { "branch": "master", "commit": "3368b981eed0d8cfdc00822f1be73bd8bfb5a968" }, - "image.nvim": { "branch": "master", "commit": "446a8a5cc7a3eae3185ee0c697732c32a5547a0b" }, - "indent-blankline.nvim": { "branch": "master", "commit": "005b56001b2cb30bfa61b7986bc50657816ba4ba" }, + "conform.nvim": { "branch": "master", "commit": "619363c30309d29ffa631e67c8183f2a72caa373" }, + "copilot.vim": { "branch": "release", "commit": "a12fd5672110c8aa7e3c8419e28c96943ca179be" }, + "friendly-snippets": { "branch": "main", "commit": "6cd7280adead7f586db6fccbd15d2cac7e2188b9" }, + "gitsigns.nvim": { "branch": "main", "commit": "25050e4ed39e628282831d4cbecb1850454ce915" }, + "hererocks": { "branch": "master", "commit": "3db37265c3839cbd4d27fc73f92fa7b58bc3a76f" }, + "image.nvim": { "branch": "master", "commit": "44e07129cd0ea0c60afa7a1991d35b5765b51a6b" }, + "indent-blankline.nvim": { "branch": "master", "commit": "d28a3f70721c79e3c5f6693057ae929f3d9c0a03" }, "jupytext.nvim": { "branch": "main", "commit": "c8baf3ad344c59b3abd461ecc17fc16ec44d0f7b" }, "lazy.nvim": { "branch": "main", "commit": "306a05526ada86a7b30af95c5cc81ffba93fef97" }, - "mason.nvim": { "branch": "main", "commit": "44d1e90e1f66e077268191e3ee9d2ac97cc18e65" }, - "mcphub.nvim": { "branch": "main", "commit": "5193329d510a68f1f5bf189960642c925c177a3a" }, + "mason.nvim": { "branch": "main", "commit": "16ba83bfc8a25f52bb545134f5bee082b195c460" }, + "mcphub.nvim": { "branch": "main", "commit": "7cd5db330f41b7bae02b2d6202218a061c3ebc1f" }, "menu": { "branch": "main", "commit": "7a0a4a2896b715c066cfbe320bdc048091874cc6" }, "minty": { "branch": "main", "commit": "aafc9e8e0afe6bf57580858a2849578d8d8db9e0" }, "molten-nvim": { "branch": "main", "commit": "a286aa914d9a154bc359131aab788b5a077a5a99" }, - "neogen": { "branch": "main", "commit": "d7f9461727751fb07f82011051338a9aba07581d" }, - "neotest": { "branch": "master", "commit": "deadfb1af5ce458742671ad3a013acb9a6b41178" }, - "neotest-python": { "branch": "master", "commit": "b0d3a861bd85689d8ed73f0590c47963a7eb1bf9" }, - "none-ls.nvim": { "branch": "main", "commit": "1fcf9cbf9acf893455c6cee792537aa709de62cb" }, + "neogen": { "branch": "main", "commit": "23e7e9f883d01289ebd90e98025acc860ea26366" }, + "neotest": { "branch": "master", "commit": "ad991822b7076b1d940b33a9d6d0d30416d5df81" }, + "neotest-python": { "branch": "master", "commit": "e6df4f1892f6137f58135917db24d1655937d831" }, + "none-ls.nvim": { "branch": "main", "commit": "01f8e62ea11603e59ad9ff7afcfa94fd183f76d6" }, "nui.nvim": { "branch": "main", "commit": "de740991c12411b663994b2860f1a4fd0937c130" }, - "nvim-autopairs": { "branch": "master", "commit": "c2a0dd0d931d0fb07665e1fedb1ea688da3b80b4" }, - "nvim-cmp": { "branch": "main", "commit": "85bbfad83f804f11688d1ab9486b459e699292d6" }, - "nvim-dap": { "branch": "master", "commit": "cdfd55a133f63228c55f91378f12908cb2a78ded" }, + "nvim-autopairs": { "branch": "master", "commit": "7b9923abad60b903ece7c52940e1321d39eccc79" }, + "nvim-cmp": { "branch": "main", "commit": "a1d504892f2bc56c2e79b65c6faded2fd21f3eca" }, + "nvim-dap": { "branch": "master", "commit": "531771530d4f82ad2d21e436e3cc052d68d7aebb" }, "nvim-dap-python": { "branch": "master", "commit": "1808458eba2b18f178f990e01376941a42c7f93b" }, - "nvim-dap-ui": { "branch": "master", "commit": "cf91d5e2d07c72903d052f5207511bf7ecdb7122" }, - "nvim-lint": { "branch": "master", "commit": "ca6ea12daf0a4d92dc24c5c9ae22a1f0418ade37" }, - "nvim-lspconfig": { "branch": "master", "commit": "5a82e10b2df0ed31bec642c1c0344baee7c458b6" }, + "nvim-dap-ui": { "branch": "master", "commit": "1a66cabaa4a4da0be107d5eda6d57242f0fe7e49" }, + "nvim-lint": { "branch": "master", "commit": "99cbc3ca8a76845fca50e496be7212bebf907dd3" }, + "nvim-lspconfig": { "branch": "master", "commit": "229b79051b380377664edc4cbd534930154921a1" }, "nvim-nio": { "branch": "master", "commit": "21f5324bfac14e22ba26553caf69ec76ae8a7662" }, - "nvim-tree.lua": { "branch": "master", "commit": "b8b44b6a2494d086a9177251a119f9daec6cace8" }, - "nvim-treesitter": { "branch": "master", "commit": "42fc28ba918343ebfd5565147a42a26580579482" }, - "nvim-web-devicons": { "branch": "master", "commit": "6788013bb9cb784e606ada44206b0e755e4323d7" }, - "otter.nvim": { "branch": "main", "commit": "b36e1a40617e35779d2097fc9b9fd701acd4f5e8" }, - "plenary.nvim": { "branch": "master", "commit": "b9fd5226c2f76c951fc8ed5923d85e4de065e509" }, - "quarto-nvim": { "branch": "main", "commit": "0e9491509b38efbd83d3f41dbfacc7fc4bd40191" }, + "nvim-tree.lua": { "branch": "master", "commit": "82f58063d67defc620e1ef8be606fc62a7b5dc1e" }, + "nvim-treesitter": { "branch": "master", "commit": "cf12346a3414fa1b06af75c79faebe7f76df080a" }, + "nvim-web-devicons": { "branch": "master", "commit": "dfbfaa967a6f7ec50789bead7ef87e336c1fa63c" }, + "otter.nvim": { "branch": "main", "commit": "d781eda3bc18dbc8677f9a24abdc705fb74e4428" }, + "plenary.nvim": { "branch": "master", "commit": "74b06c6c75e4eeb3108ec01852001636d85a932b" }, + "quarto-nvim": { "branch": "main", "commit": "17f1e5d664bc615478230dc0240666329efacf9b" }, "snippet-converter.nvim": { "branch": "main", "commit": "d7e783618f02541641980ebd823e439bdef64a4f" }, - "telescope.nvim": { "branch": "master", "commit": "3333a52ff548ba0a68af6d8da1e54f9cd96e9179" }, - "ui": { "branch": "v3.0", "commit": "ebf58649bc5c759ee6c730c87d8d2d4dd4124c0d" }, + "stim-treesitter-parser": { "branch": "main", "commit": "3c84d6ab09bc364ed712329cd4f9fb113e489aad" }, + "telescope.nvim": { "branch": "master", "commit": "7d324792b7943e4aa16ad007212e6acc6f9fe335" }, + "ui": { "branch": "v3.0", "commit": "3e67e9d5325fd47fdbc90ca00a147db2f3525754" }, "vim-markdown": { "branch": "master", "commit": "1bc9d0cd8e1cc3e901b0a49c2b50a843f1c89397" }, - "vimtex": { "branch": "master", "commit": "a50f40783c1cade2e8e2994a9f4a8e038a0a57bc" }, + "vimtex": { "branch": "master", "commit": "24e229914182ff301496a3e2c4214b28c4928d3f" }, "volt": { "branch": "main", "commit": "620de1321f275ec9d80028c68d1b88b409c0c8b1" }, "which-key.nvim": { "branch": "main", "commit": "3aab2147e74890957785941f0c1ad87d0a44c15a" } } diff --git a/lua/configs/overrides.lua b/lua/configs/overrides.lua index c4cd2c7ac..8c66ede3f 100644 --- a/lua/configs/overrides.lua +++ b/lua/configs/overrides.lua @@ -13,11 +13,11 @@ M.treesitter = { "markdown", "markdown_inline", }, + highlight = { + enable = true, + }, indent = { enable = true, - -- disable = { - -- "python" - -- }, }, } diff --git a/lua/myinit.lua b/lua/myinit.lua index 430cff5b8..c19984bdb 100644 --- a/lua/myinit.lua +++ b/lua/myinit.lua @@ -60,33 +60,33 @@ vim.api.nvim_create_autocmd("FileType", { once = true, }) -local parser_config = require('nvim-treesitter.parsers').get_parser_configs() - -parser_config.stim = { - install_info = { - url = "/Users/andrewpatterson/stim-tresitter/", -- Local path to this repository - files = {"src/parser.c"}, - branch = "main", - generate_requires_npm = false, - requires_generate_from_grammar = true, - }, - filetype = "stim", -} - -require('nvim-treesitter.configs').setup({ - ensure_installed = { - -- your other parsers... - }, - - highlight = { - enable = true, - additional_vim_regex_highlighting = false, - }, - auto_install = false, -- Prevent conflicts - - -- Explicitly configure stim - parser_install_dir = vim.fn.stdpath("data") .. "/tree-sitter-parsers", - }) +-- local parser_config = require('nvim-treesitter.parsers').get_parser_configs() +-- +-- parser_config.stim = { +-- install_info = { +-- url = "/Users/andrewpatterson/stim-tresitter/", -- Local path to this repository +-- files = {"src/parser.c"}, +-- branch = "main", +-- generate_requires_npm = false, +-- requires_generate_from_grammar = true, +-- }, +-- filetype = "stim", +-- } +-- +-- require('nvim-treesitter.configs').setup({ +-- ensure_installed = { +-- -- your other parsers... +-- }, +-- +-- highlight = { +-- enable = true, +-- additional_vim_regex_highlighting = false, +-- }, +-- auto_install = false, -- Prevent conflicts +-- +-- -- Explicitly configure stim +-- parser_install_dir = vim.fn.stdpath("data") .. "/tree-sitter-parsers", +-- }) -- Force reload stim filetype vim.treesitter.language.register("stim", "stim") @@ -98,9 +98,9 @@ vim.filetype.add({ ['*.stim'] = 'stim', }, }) -package.path = package.path .. ';/Users/andrewpatterson/stim-treesitter/?.lua' +-- package.path = package.path .. ';/Users/andrewpatterson/stim-treesitter/?.lua' -- local ok, result = pcall(function() --- return loadfile('/Users/andrewpatterson/stim-tresitter/stim-treesitter.lua') +-- return loadfile('/Users/andrewpatterson/stim-tresitter/lua/stim-treesitter.lua') -- end) -- -- if ok and result then @@ -129,11 +129,11 @@ package.path = package.path .. ';/Users/andrewpatterson/stim-treesitter/?.lua' -- end -- Load and setup the plugin -- require('stim-treesitter').setup() -local stim_treesitter_module = loadfile('/Users/andrewpatterson/stim-tresitter/stim-treesitter.lua')() - stim_treesitter_module.setup() - --- Optional: Set up keybindings -vim.keymap.set('n', 'si', ':StimInfoTS', { desc = 'Stim: Show measurement info' }) +-- local stim_treesitter_module = loadfile('/Users/andrewpatterson/stim-tresitter/lua/stim-treesitter.lua')() +-- stim_treesitter_module.setup() +-- +-- -- Optional: Set up keybindings +-- vim.keymap.set('n', 'si', ':StimInfoTS', { desc = 'Stim: Show measurement info' }) -- Notebook utilities vim.api.nvim_create_user_command("NewNotebook", function(opts) diff --git a/lua/plugins/myplugins.lua b/lua/plugins/myplugins.lua index 08808762f..d582daf2f 100644 --- a/lua/plugins/myplugins.lua +++ b/lua/plugins/myplugins.lua @@ -448,6 +448,18 @@ local plugins = { force_ft = "markdown", }, }, + { + "DuckTigger/stim-treesitter-parser", + event = "VeryLazy", -- ensure it loads at startup so :TSInstall stim works + dependencies = { "nvim-treesitter/nvim-treesitter" }, + config = function() + require("stim-treesitter-config").setup({ + -- defaults shown: + highlight_measurements = true, + keymaps = { show_info = "si" }, + }) + end, + }, -- To make a plugin not be loaded -- { From 504f100dd37aa151e043526b3ade0d12dd17e84e Mon Sep 17 00:00:00 2001 From: Andrew Patterson Date: Mon, 8 Jun 2026 09:55:41 +0100 Subject: [PATCH 08/13] don't use tresitter for highlighting --- lua/configs/overrides.lua | 3 --- 1 file changed, 3 deletions(-) diff --git a/lua/configs/overrides.lua b/lua/configs/overrides.lua index 8c66ede3f..0c6f62e81 100644 --- a/lua/configs/overrides.lua +++ b/lua/configs/overrides.lua @@ -13,9 +13,6 @@ M.treesitter = { "markdown", "markdown_inline", }, - highlight = { - enable = true, - }, indent = { enable = true, }, From 016b23976e87deb413a0ded88f3caa3da7ffea96 Mon Sep 17 00:00:00 2001 From: Andrew Patterson Date: Mon, 8 Jun 2026 11:06:50 +0100 Subject: [PATCH 09/13] fix Python treesitter decoration provider error Disables treesitter highlighting for Python files to prevent "attempt to call method 'range' (a nil value)" error that occurs during editing operations like c$. The error was caused by the conceal_line decoration provider trying to access treesitter objects that weren't properly initialized. Changes: - Add ftplugin/python.lua to disable treesitter highlighting - Add autocmd to stop treesitter on Python buffer enter - Configure treesitter to explicitly disable Python in all modules Co-Authored-By: Claude Sonnet 4.5 --- ftplugin/python.lua | 16 ++++++++++++++++ lua/autocmds.lua | 10 ++++++++++ lua/configs/overrides.lua | 10 ++++++++++ 3 files changed, 36 insertions(+) diff --git a/ftplugin/python.lua b/ftplugin/python.lua index e69de29bb..f979b7143 100644 --- a/ftplugin/python.lua +++ b/ftplugin/python.lua @@ -0,0 +1,16 @@ +-- Disable treesitter for Python files to avoid decoration provider errors +vim.b.ts_highlight = false + +-- Disable concealing +vim.opt_local.conceallevel = 0 +vim.opt_local.concealcursor = "" + +-- Force stop treesitter +local ok, ts_highlight = pcall(require, "vim.treesitter.highlighter") +if ok and ts_highlight then + pcall(function() + ts_highlight.active[vim.api.nvim_get_current_buf()] = nil + end) +end + +pcall(vim.treesitter.stop) diff --git a/lua/autocmds.lua b/lua/autocmds.lua index d2db0bbe1..b239f53e6 100644 --- a/lua/autocmds.lua +++ b/lua/autocmds.lua @@ -1 +1,11 @@ require "nvchad.autocmds" + +-- Disable treesitter for Python files to prevent decoration provider errors +vim.api.nvim_create_autocmd({"BufEnter", "BufWinEnter"}, { + pattern = "*.py", + callback = function(args) + vim.schedule(function() + pcall(vim.treesitter.stop, args.buf) + end) + end, +}) diff --git a/lua/configs/overrides.lua b/lua/configs/overrides.lua index 0c6f62e81..4666d244c 100644 --- a/lua/configs/overrides.lua +++ b/lua/configs/overrides.lua @@ -13,8 +13,18 @@ M.treesitter = { "markdown", "markdown_inline", }, + highlight = { + enable = true, + disable = function(lang, buf) + return lang == "python" + end, + }, indent = { enable = true, + disable = { "python" }, + }, + incremental_selection = { + disable = { "python" }, }, } From 9ccc41d8718517b7910ed3bef0bf156041de11c4 Mon Sep 17 00:00:00 2001 From: Andrew Patterson Date: Mon, 8 Jun 2026 11:13:15 +0100 Subject: [PATCH 10/13] add go to references in LSP (#2) --- lazy-lock.json | 70 +++++++++++++++++++-------------------- lua/configs/lspconfig.lua | 6 +++- 2 files changed, 40 insertions(+), 36 deletions(-) diff --git a/lazy-lock.json b/lazy-lock.json index 1802678b5..732138399 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -1,54 +1,54 @@ { - "CopilotChat.nvim": { "branch": "main", "commit": "9db5d3eaafe9fc3c91ce9ecfc416de2798982487" }, + "CopilotChat.nvim": { "branch": "main", "commit": "2025f92022bef434de0511c5157a19974a9377a4" }, "FixCursorHold.nvim": { "branch": "master", "commit": "1900f89dc17c603eec29960f57c00bd9ae696495" }, - "LuaSnip": { "branch": "master", "commit": "3732756842a2f7e0e76a7b0487e9692072857277" }, - "NvChad": { "branch": "v2.5", "commit": "30e75dbbdf33f393430d6e7612dd32ef84e2a710" }, - "avante.nvim": { "branch": "main", "commit": "a27b821cc1f9fec70d7b7dc4a42c6dbd76266997" }, - "base46": { "branch": "v3.0", "commit": "45b336ec52615dd1a3aa47848d894616dd6293a5" }, - "better-escape.nvim": { "branch": "master", "commit": "19a38aab94961016430905ebec30d272a01e9742" }, - "cmp-async-path": { "branch": "main", "commit": "a14d3a9c7f303551a0b8c64a0e4e6527ce39a8a2" }, + "LuaSnip": { "branch": "master", "commit": "0abc8f390b278c3b4aabc4c004ac8a088b65cf24" }, + "NvChad": { "branch": "v2.5", "commit": "d042cc975247c2aa55fcb228e5d146dc1dc6c648" }, + "avante.nvim": { "branch": "main", "commit": "adec75957134b8ab4a37da35151671c2849f8599" }, + "base46": { "branch": "v3.0", "commit": "884b990dcdbe07520a0892da6ba3e8d202b46337" }, + "better-escape.nvim": { "branch": "master", "commit": "3f4bc0b326606264ff75967f59091b5ddada0554" }, + "cmp-async-path": { "branch": "main", "commit": "f8af3f726e07f2e9d37672eaa9102581aefce149" }, "cmp-buffer": { "branch": "main", "commit": "b74fab3656eea9de20a9b8116afa3cfc4ec09657" }, "cmp-nvim-lsp": { "branch": "main", "commit": "cbc7b02bb99fae35cb42f514762b89b5126651ef" }, "cmp-nvim-lua": { "branch": "main", "commit": "e3a22cb071eb9d6508a156306b102c45cd2d573d" }, "cmp_luasnip": { "branch": "master", "commit": "98d9cb5c2c38532bd9bdb481067b20fea8f32e90" }, - "conform.nvim": { "branch": "master", "commit": "8314f4c9e205e7f30b62147069729f9a1227d8bf" }, - "copilot.vim": { "branch": "release", "commit": "206011a8bc5078a02560d5c44177e9849e8f8d6c" }, - "friendly-snippets": { "branch": "main", "commit": "572f5660cf05f8cd8834e096d7b4c921ba18e175" }, - "gitsigns.nvim": { "branch": "main", "commit": "72acb69020c92d99cf388bfeb390481ccec50c04" }, - "hererocks": { "branch": "master", "commit": "3368b981eed0d8cfdc00822f1be73bd8bfb5a968" }, - "image.nvim": { "branch": "master", "commit": "446a8a5cc7a3eae3185ee0c697732c32a5547a0b" }, - "indent-blankline.nvim": { "branch": "master", "commit": "005b56001b2cb30bfa61b7986bc50657816ba4ba" }, + "conform.nvim": { "branch": "master", "commit": "619363c30309d29ffa631e67c8183f2a72caa373" }, + "copilot.vim": { "branch": "release", "commit": "a12fd5672110c8aa7e3c8419e28c96943ca179be" }, + "friendly-snippets": { "branch": "main", "commit": "6cd7280adead7f586db6fccbd15d2cac7e2188b9" }, + "gitsigns.nvim": { "branch": "main", "commit": "25050e4ed39e628282831d4cbecb1850454ce915" }, + "hererocks": { "branch": "master", "commit": "3db37265c3839cbd4d27fc73f92fa7b58bc3a76f" }, + "image.nvim": { "branch": "master", "commit": "44e07129cd0ea0c60afa7a1991d35b5765b51a6b" }, + "indent-blankline.nvim": { "branch": "master", "commit": "d28a3f70721c79e3c5f6693057ae929f3d9c0a03" }, "jupytext.nvim": { "branch": "main", "commit": "c8baf3ad344c59b3abd461ecc17fc16ec44d0f7b" }, "lazy.nvim": { "branch": "main", "commit": "306a05526ada86a7b30af95c5cc81ffba93fef97" }, - "mason.nvim": { "branch": "main", "commit": "44d1e90e1f66e077268191e3ee9d2ac97cc18e65" }, - "mcphub.nvim": { "branch": "main", "commit": "5193329d510a68f1f5bf189960642c925c177a3a" }, + "mason.nvim": { "branch": "main", "commit": "16ba83bfc8a25f52bb545134f5bee082b195c460" }, + "mcphub.nvim": { "branch": "main", "commit": "7cd5db330f41b7bae02b2d6202218a061c3ebc1f" }, "menu": { "branch": "main", "commit": "7a0a4a2896b715c066cfbe320bdc048091874cc6" }, "minty": { "branch": "main", "commit": "aafc9e8e0afe6bf57580858a2849578d8d8db9e0" }, "molten-nvim": { "branch": "main", "commit": "a286aa914d9a154bc359131aab788b5a077a5a99" }, - "neogen": { "branch": "main", "commit": "d7f9461727751fb07f82011051338a9aba07581d" }, - "neotest": { "branch": "master", "commit": "deadfb1af5ce458742671ad3a013acb9a6b41178" }, - "neotest-python": { "branch": "master", "commit": "b0d3a861bd85689d8ed73f0590c47963a7eb1bf9" }, - "none-ls.nvim": { "branch": "main", "commit": "1fcf9cbf9acf893455c6cee792537aa709de62cb" }, + "neogen": { "branch": "main", "commit": "23e7e9f883d01289ebd90e98025acc860ea26366" }, + "neotest": { "branch": "master", "commit": "ad991822b7076b1d940b33a9d6d0d30416d5df81" }, + "neotest-python": { "branch": "master", "commit": "e6df4f1892f6137f58135917db24d1655937d831" }, + "none-ls.nvim": { "branch": "main", "commit": "01f8e62ea11603e59ad9ff7afcfa94fd183f76d6" }, "nui.nvim": { "branch": "main", "commit": "de740991c12411b663994b2860f1a4fd0937c130" }, - "nvim-autopairs": { "branch": "master", "commit": "c2a0dd0d931d0fb07665e1fedb1ea688da3b80b4" }, - "nvim-cmp": { "branch": "main", "commit": "85bbfad83f804f11688d1ab9486b459e699292d6" }, - "nvim-dap": { "branch": "master", "commit": "cdfd55a133f63228c55f91378f12908cb2a78ded" }, + "nvim-autopairs": { "branch": "master", "commit": "7b9923abad60b903ece7c52940e1321d39eccc79" }, + "nvim-cmp": { "branch": "main", "commit": "a1d504892f2bc56c2e79b65c6faded2fd21f3eca" }, + "nvim-dap": { "branch": "master", "commit": "531771530d4f82ad2d21e436e3cc052d68d7aebb" }, "nvim-dap-python": { "branch": "master", "commit": "1808458eba2b18f178f990e01376941a42c7f93b" }, - "nvim-dap-ui": { "branch": "master", "commit": "cf91d5e2d07c72903d052f5207511bf7ecdb7122" }, - "nvim-lint": { "branch": "master", "commit": "ca6ea12daf0a4d92dc24c5c9ae22a1f0418ade37" }, - "nvim-lspconfig": { "branch": "master", "commit": "5a82e10b2df0ed31bec642c1c0344baee7c458b6" }, + "nvim-dap-ui": { "branch": "master", "commit": "1a66cabaa4a4da0be107d5eda6d57242f0fe7e49" }, + "nvim-lint": { "branch": "master", "commit": "d48f3a76189d03b2239f6df1b2f7e3fa8353743b" }, + "nvim-lspconfig": { "branch": "master", "commit": "229b79051b380377664edc4cbd534930154921a1" }, "nvim-nio": { "branch": "master", "commit": "21f5324bfac14e22ba26553caf69ec76ae8a7662" }, - "nvim-tree.lua": { "branch": "master", "commit": "b8b44b6a2494d086a9177251a119f9daec6cace8" }, - "nvim-treesitter": { "branch": "master", "commit": "42fc28ba918343ebfd5565147a42a26580579482" }, - "nvim-web-devicons": { "branch": "master", "commit": "6788013bb9cb784e606ada44206b0e755e4323d7" }, - "otter.nvim": { "branch": "main", "commit": "b36e1a40617e35779d2097fc9b9fd701acd4f5e8" }, - "plenary.nvim": { "branch": "master", "commit": "b9fd5226c2f76c951fc8ed5923d85e4de065e509" }, - "quarto-nvim": { "branch": "main", "commit": "0e9491509b38efbd83d3f41dbfacc7fc4bd40191" }, + "nvim-tree.lua": { "branch": "master", "commit": "07f541fcaa4a5ae019598240362449ab7e9812b3" }, + "nvim-treesitter": { "branch": "master", "commit": "cf12346a3414fa1b06af75c79faebe7f76df080a" }, + "nvim-web-devicons": { "branch": "master", "commit": "dfbfaa967a6f7ec50789bead7ef87e336c1fa63c" }, + "otter.nvim": { "branch": "main", "commit": "d781eda3bc18dbc8677f9a24abdc705fb74e4428" }, + "plenary.nvim": { "branch": "master", "commit": "74b06c6c75e4eeb3108ec01852001636d85a932b" }, + "quarto-nvim": { "branch": "main", "commit": "17f1e5d664bc615478230dc0240666329efacf9b" }, "snippet-converter.nvim": { "branch": "main", "commit": "d7e783618f02541641980ebd823e439bdef64a4f" }, - "telescope.nvim": { "branch": "master", "commit": "3333a52ff548ba0a68af6d8da1e54f9cd96e9179" }, - "ui": { "branch": "v3.0", "commit": "ebf58649bc5c759ee6c730c87d8d2d4dd4124c0d" }, + "telescope.nvim": { "branch": "master", "commit": "7d324792b7943e4aa16ad007212e6acc6f9fe335" }, + "ui": { "branch": "v3.0", "commit": "3e67e9d5325fd47fdbc90ca00a147db2f3525754" }, "vim-markdown": { "branch": "master", "commit": "1bc9d0cd8e1cc3e901b0a49c2b50a843f1c89397" }, - "vimtex": { "branch": "master", "commit": "a50f40783c1cade2e8e2994a9f4a8e038a0a57bc" }, + "vimtex": { "branch": "master", "commit": "24e229914182ff301496a3e2c4214b28c4928d3f" }, "volt": { "branch": "main", "commit": "620de1321f275ec9d80028c68d1b88b409c0c8b1" }, "which-key.nvim": { "branch": "main", "commit": "3aab2147e74890957785941f0c1ad87d0a44c15a" } } diff --git a/lua/configs/lspconfig.lua b/lua/configs/lspconfig.lua index 48cedfb6d..aee860199 100644 --- a/lua/configs/lspconfig.lua +++ b/lua/configs/lspconfig.lua @@ -70,11 +70,15 @@ local capabilities = require("nvchad.configs.lspconfig").capabilities -- end, -- }) -- --- wrap NVChad’s on_attach to remove that default ra binding +-- wrap NVChad's on_attach to remove that default ra binding local on_attach = function(client, bufnr) nv_on_attach(client, bufnr) -- vim.keymap.del("n", "ra", { buffer = bufnr }) + -- Add missing LSP keybindings + vim.keymap.set("n", "gr", vim.lsp.buf.references, { buffer = bufnr, desc = "LSP Go to references" }) + vim.keymap.set("n", "gi", vim.lsp.buf.implementation, { buffer = bufnr, desc = "LSP Go to implementation" }) + -- Enable inlay hints if supported if client.supports_method("textDocument/inlayHint") then vim.lsp.inlay_hint.enable(true, { bufnr = bufnr }) From ec8c9f0f0f74cd0d7cd5f39a12323ffdc5adc9a7 Mon Sep 17 00:00:00 2001 From: Andrew Patterson Date: Mon, 8 Jun 2026 11:16:32 +0100 Subject: [PATCH 11/13] add more claude permissions --- .claude/settings.local.json | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.claude/settings.local.json b/.claude/settings.local.json index de4937db5..2a81f0403 100644 --- a/.claude/settings.local.json +++ b/.claude/settings.local.json @@ -4,7 +4,10 @@ "Bash(poetry env info:*)", "Bash(poetry env list:*)", "Bash(uvx --help:*)", - "WebFetch(domain:github.com)" + "WebFetch(domain:github.com)", + "Bash(nvim:*)", + "Bash(git add:*)", + "Bash(git push)" ], "deny": [], "ask": [] From c43e6fb09a75ccd8c80989f1595050562d68b829 Mon Sep 17 00:00:00 2001 From: Andrew Patterson Date: Mon, 8 Jun 2026 12:12:26 +0100 Subject: [PATCH 12/13] remove nvim0.12 workarounds --- .claude/settings.local.json | 9 ++++++++- ftplugin/python.lua | 16 ---------------- lua/autocmds.lua | 10 ---------- lua/configs/overrides.lua | 10 ---------- 4 files changed, 8 insertions(+), 37 deletions(-) diff --git a/.claude/settings.local.json b/.claude/settings.local.json index 2a81f0403..2ab439274 100644 --- a/.claude/settings.local.json +++ b/.claude/settings.local.json @@ -7,7 +7,14 @@ "WebFetch(domain:github.com)", "Bash(nvim:*)", "Bash(git add:*)", - "Bash(git push)" + "Bash(git push)", + "Read(//Users/andrewpatterson/.local/share/nvim/lazy/nvim-treesitter/**)", + "Bash(ls -la queries/python/)", + "Bash(grep -l \"conceal\" queries/python/*.scm)", + "Read(//opt/homebrew/Cellar/neovim/**)", + "Read(//opt/homebrew/Cellar/neovim/0.12.2/bin/**)", + "Bash(brew info *)", + "WebFetch(domain:api.github.com)" ], "deny": [], "ask": [] diff --git a/ftplugin/python.lua b/ftplugin/python.lua index f979b7143..e69de29bb 100644 --- a/ftplugin/python.lua +++ b/ftplugin/python.lua @@ -1,16 +0,0 @@ --- Disable treesitter for Python files to avoid decoration provider errors -vim.b.ts_highlight = false - --- Disable concealing -vim.opt_local.conceallevel = 0 -vim.opt_local.concealcursor = "" - --- Force stop treesitter -local ok, ts_highlight = pcall(require, "vim.treesitter.highlighter") -if ok and ts_highlight then - pcall(function() - ts_highlight.active[vim.api.nvim_get_current_buf()] = nil - end) -end - -pcall(vim.treesitter.stop) diff --git a/lua/autocmds.lua b/lua/autocmds.lua index b239f53e6..d2db0bbe1 100644 --- a/lua/autocmds.lua +++ b/lua/autocmds.lua @@ -1,11 +1 @@ require "nvchad.autocmds" - --- Disable treesitter for Python files to prevent decoration provider errors -vim.api.nvim_create_autocmd({"BufEnter", "BufWinEnter"}, { - pattern = "*.py", - callback = function(args) - vim.schedule(function() - pcall(vim.treesitter.stop, args.buf) - end) - end, -}) diff --git a/lua/configs/overrides.lua b/lua/configs/overrides.lua index 4666d244c..0c6f62e81 100644 --- a/lua/configs/overrides.lua +++ b/lua/configs/overrides.lua @@ -13,18 +13,8 @@ M.treesitter = { "markdown", "markdown_inline", }, - highlight = { - enable = true, - disable = function(lang, buf) - return lang == "python" - end, - }, indent = { enable = true, - disable = { "python" }, - }, - incremental_selection = { - disable = { "python" }, }, } From ffb3f5108a7da3f9b14b00e3e94cdd9254fcdfc3 Mon Sep 17 00:00:00 2001 From: Andrew Patterson Date: Mon, 29 Jun 2026 11:49:18 +0100 Subject: [PATCH 13/13] update lazy lock --- lazy-lock.json | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/lazy-lock.json b/lazy-lock.json index ade814c37..667139dd1 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -1,12 +1,12 @@ { - "CopilotChat.nvim": { "branch": "main", "commit": "2025f92022bef434de0511c5157a19974a9377a4" }, + "CopilotChat.nvim": { "branch": "main", "commit": "f0c2a23ab79dc295f5e0eef0d8b587a39020c852" }, "FixCursorHold.nvim": { "branch": "master", "commit": "1900f89dc17c603eec29960f57c00bd9ae696495" }, "LuaSnip": { "branch": "master", "commit": "0abc8f390b278c3b4aabc4c004ac8a088b65cf24" }, "NvChad": { "branch": "v2.5", "commit": "d042cc975247c2aa55fcb228e5d146dc1dc6c648" }, - "avante.nvim": { "branch": "main", "commit": "044f2ec3b23ecba3cbdd694ae15f05b4e06c429b" }, + "avante.nvim": { "branch": "main", "commit": "90a0e77c63251c367935caeaa0070670522c960b" }, "base46": { "branch": "v3.0", "commit": "884b990dcdbe07520a0892da6ba3e8d202b46337" }, "better-escape.nvim": { "branch": "master", "commit": "3f4bc0b326606264ff75967f59091b5ddada0554" }, - "cmp-async-path": { "branch": "main", "commit": "f8af3f726e07f2e9d37672eaa9102581aefce149" }, + "cmp-async-path": { "branch": "main", "commit": "98185a91d49ff5dd249aebf2f7456e18063fa2a0" }, "cmp-buffer": { "branch": "main", "commit": "b74fab3656eea9de20a9b8116afa3cfc4ec09657" }, "cmp-nvim-lsp": { "branch": "main", "commit": "cbc7b02bb99fae35cb42f514762b89b5126651ef" }, "cmp-nvim-lua": { "branch": "main", "commit": "e3a22cb071eb9d6508a156306b102c45cd2d573d" }, @@ -14,13 +14,13 @@ "conform.nvim": { "branch": "master", "commit": "619363c30309d29ffa631e67c8183f2a72caa373" }, "copilot.vim": { "branch": "release", "commit": "a12fd5672110c8aa7e3c8419e28c96943ca179be" }, "friendly-snippets": { "branch": "main", "commit": "6cd7280adead7f586db6fccbd15d2cac7e2188b9" }, - "gitsigns.nvim": { "branch": "main", "commit": "25050e4ed39e628282831d4cbecb1850454ce915" }, + "gitsigns.nvim": { "branch": "main", "commit": "2038c666bd9d8a0b7349a0b6ee00dc83104b9ecf" }, "hererocks": { "branch": "master", "commit": "3db37265c3839cbd4d27fc73f92fa7b58bc3a76f" }, - "image.nvim": { "branch": "master", "commit": "44e07129cd0ea0c60afa7a1991d35b5765b51a6b" }, + "image.nvim": { "branch": "master", "commit": "88351f1f7d9dbae286e671ce3690a49660dd8a5c" }, "indent-blankline.nvim": { "branch": "master", "commit": "d28a3f70721c79e3c5f6693057ae929f3d9c0a03" }, "jupytext.nvim": { "branch": "main", "commit": "c8baf3ad344c59b3abd461ecc17fc16ec44d0f7b" }, "lazy.nvim": { "branch": "main", "commit": "306a05526ada86a7b30af95c5cc81ffba93fef97" }, - "mason.nvim": { "branch": "main", "commit": "16ba83bfc8a25f52bb545134f5bee082b195c460" }, + "mason.nvim": { "branch": "main", "commit": "2a6940af80375532e5e9e7c1f2fc6319a1b7a69d" }, "mcphub.nvim": { "branch": "main", "commit": "7cd5db330f41b7bae02b2d6202218a061c3ebc1f" }, "menu": { "branch": "main", "commit": "7a0a4a2896b715c066cfbe320bdc048091874cc6" }, "minty": { "branch": "main", "commit": "aafc9e8e0afe6bf57580858a2849578d8d8db9e0" }, @@ -32,13 +32,13 @@ "nui.nvim": { "branch": "main", "commit": "de740991c12411b663994b2860f1a4fd0937c130" }, "nvim-autopairs": { "branch": "master", "commit": "7b9923abad60b903ece7c52940e1321d39eccc79" }, "nvim-cmp": { "branch": "main", "commit": "a1d504892f2bc56c2e79b65c6faded2fd21f3eca" }, - "nvim-dap": { "branch": "master", "commit": "531771530d4f82ad2d21e436e3cc052d68d7aebb" }, + "nvim-dap": { "branch": "master", "commit": "9e848e09a697ee95302a3ef2dd43fd6eb709e570" }, "nvim-dap-python": { "branch": "master", "commit": "1808458eba2b18f178f990e01376941a42c7f93b" }, "nvim-dap-ui": { "branch": "master", "commit": "1a66cabaa4a4da0be107d5eda6d57242f0fe7e49" }, - "nvim-lint": { "branch": "master", "commit": "99cbc3ca8a76845fca50e496be7212bebf907dd3" }, - "nvim-lspconfig": { "branch": "master", "commit": "229b79051b380377664edc4cbd534930154921a1" }, + "nvim-lint": { "branch": "master", "commit": "01c9842c089069ab497430159312b2c8868a4590" }, + "nvim-lspconfig": { "branch": "master", "commit": "bfcc0171a43f22afa61d927ffe9fcb6cb85dc99e" }, "nvim-nio": { "branch": "master", "commit": "21f5324bfac14e22ba26553caf69ec76ae8a7662" }, - "nvim-tree.lua": { "branch": "master", "commit": "82f58063d67defc620e1ef8be606fc62a7b5dc1e" }, + "nvim-tree.lua": { "branch": "master", "commit": "8e8be709c9a93e1ebefde7964884a8b564bfd3e0" }, "nvim-treesitter": { "branch": "master", "commit": "cf12346a3414fa1b06af75c79faebe7f76df080a" }, "nvim-web-devicons": { "branch": "master", "commit": "dfbfaa967a6f7ec50789bead7ef87e336c1fa63c" }, "otter.nvim": { "branch": "main", "commit": "d781eda3bc18dbc8677f9a24abdc705fb74e4428" }, @@ -46,10 +46,10 @@ "quarto-nvim": { "branch": "main", "commit": "17f1e5d664bc615478230dc0240666329efacf9b" }, "snippet-converter.nvim": { "branch": "main", "commit": "d7e783618f02541641980ebd823e439bdef64a4f" }, "stim-treesitter-parser": { "branch": "main", "commit": "3c84d6ab09bc364ed712329cd4f9fb113e489aad" }, - "telescope.nvim": { "branch": "master", "commit": "7d324792b7943e4aa16ad007212e6acc6f9fe335" }, + "telescope.nvim": { "branch": "master", "commit": "427b576c16792edad01a92b89721d923c19ad60f" }, "ui": { "branch": "v3.0", "commit": "3e67e9d5325fd47fdbc90ca00a147db2f3525754" }, "vim-markdown": { "branch": "master", "commit": "1bc9d0cd8e1cc3e901b0a49c2b50a843f1c89397" }, - "vimtex": { "branch": "master", "commit": "24e229914182ff301496a3e2c4214b28c4928d3f" }, + "vimtex": { "branch": "master", "commit": "63745fa542346e0f09a496d440645ef6ff75b62c" }, "volt": { "branch": "main", "commit": "620de1321f275ec9d80028c68d1b88b409c0c8b1" }, "which-key.nvim": { "branch": "main", "commit": "3aab2147e74890957785941f0c1ad87d0a44c15a" } }