diff --git a/.config/nvim/lazy-lock.json b/.config/nvim/lazy-lock.json index bc91483..969aad1 100644 --- a/.config/nvim/lazy-lock.json +++ b/.config/nvim/lazy-lock.json @@ -1,47 +1,54 @@ { - "LuaSnip": { "branch": "master", "commit": "3732756842a2f7e0e76a7b0487e9692072857277" }, - "accelerated-jk": { "branch": "master", "commit": "156c5158b72059404f6b8aaf15b59f87dd0aaa88" }, - "aerial.nvim": { "branch": "master", "commit": "3c42785790d401731e7809a25f27f62dae2fec12" }, + "LuaSnip": { "branch": "master", "commit": "0abc8f390b278c3b4aabc4c004ac8a088b65cf24" }, + "R.nvim": { "branch": "main", "commit": "ef081566170e20d536bfaab168eb8841c0753b1c" }, + "accelerated-jk.nvim": { "branch": "main", "commit": "8fb5dad4ccc1811766cebf16b544038aeeb7806f" }, + "aerial.nvim": { "branch": "master", "commit": "28fe6e822ae344544c379d60fcb13c9519a1f08a" }, + "annotate.nvim": { "branch": "main", "commit": "c8fee95916c7e853609766c90b9bbd451ab1475f" }, "beacon.nvim": { "branch": "master", "commit": "5ab668c4123bc51269bf6f0a34828e68c142e764" }, - "blink-cmp-dictionary": { "branch": "master", "commit": "944b3b215b01303672d4213758db7c5c5a1e3c92" }, - "blink.cmp": { "branch": "main", "commit": "b19413d214068f316c78978b08264ed1c41830ec" }, - "browsher.nvim": { "branch": "main", "commit": "de87ffcdac45fc4fdd3f18882b81dbc002a2013d" }, + "blink-cmp-dictionary": { "branch": "master", "commit": "898a958cece34da20524d04ebc032a92a9565643" }, + "blink.cmp": { "branch": "main", "commit": "78336bc89ee5365633bcf754d93df01678b5c08f" }, + "browsher.nvim": { "branch": "main", "commit": "f09b445c2c9d08dcfe76a6b621161169df9bf9b5" }, "bufferline.nvim": { "branch": "main", "commit": "655133c3b4c3e5e05ec549b9f8cc2894ac6f51b3" }, - "conform.nvim": { "branch": "master", "commit": "afce105eb47b0869dfafdac90d82f02ef2419d61" }, + "conform.nvim": { "branch": "master", "commit": "016802de402556da54c36bd7359b441266b01cdd" }, "diffview.nvim": { "branch": "main", "commit": "4516612fe98ff56ae0415a259ff6361a89419b0a" }, - "flash.nvim": { "branch": "main", "commit": "fcea7ff883235d9024dc41e638f164a450c14ca2" }, - "friendly-snippets": { "branch": "main", "commit": "572f5660cf05f8cd8834e096d7b4c921ba18e175" }, - "gitsigns.nvim": { "branch": "main", "commit": "cdafc320f03f2572c40ab93a4eecb733d4016d07" }, - "gv.vim": { "branch": "master", "commit": "b6bb6664e2c95aa584059f195eb3a9f3cb133994" }, - "indent-blankline.nvim": { "branch": "master", "commit": "005b56001b2cb30bfa61b7986bc50657816ba4ba" }, - "indent-o-matic": { "branch": "master", "commit": "4d11e98f523d3c4500b1dc33f0d1a248a4f69719" }, - "lazy.nvim": { "branch": "main", "commit": "85c7ff3711b730b4030d03144f6db6375044ae82" }, - "lsp-progress.nvim": { "branch": "main", "commit": "ae52979ad412371ea6dc39ff70c8dfc681fb42b8" }, - "lualine.nvim": { "branch": "master", "commit": "3946f0122255bc377d14a59b27b609fb3ab25768" }, + "flash.nvim": { "branch": "main", "commit": "5f0f270fdc7c5b0c21d903ee85b9cb06f2ac636a" }, + "friendly-snippets": { "branch": "main", "commit": "6cd7280adead7f586db6fccbd15d2cac7e2188b9" }, + "gitsigns.nvim": { "branch": "main", "commit": "5be654f2232c10ddcad19c1607a67b6b4b78fc29" }, + "gv.vim": { "branch": "master", "commit": "ed7e9c6a118d92462c7d709c34a92682b60fa9f7" }, + "img-clip.nvim": { "branch": "main", "commit": "b6ddfb97b5600d99afe3452d707444afda658aca" }, + "indent-blankline.nvim": { "branch": "master", "commit": "d28a3f70721c79e3c5f6693057ae929f3d9c0a03" }, + "indent-o-matic": { "branch": "master", "commit": "81fa0e03bd2615a23b23312512371a2fc47fc0a4" }, + "lazy.nvim": { "branch": "main", "commit": "306a05526ada86a7b30af95c5cc81ffba93fef97" }, + "lsp-progress.nvim": { "branch": "main", "commit": "f6d5af10563b895ff846346f57cbd4451439f4c1" }, + "lualine.nvim": { "branch": "master", "commit": "221ce6b2d999187044529f49da6554a92f740a96" }, "lush.nvim": { "branch": "main", "commit": "9c60ec2279d62487d942ce095e49006af28eed6e" }, - "mason.nvim": { "branch": "main", "commit": "57e5a8addb8c71fb063ee4acda466c7cf6ad2800" }, + "mason.nvim": { "branch": "main", "commit": "2a6940af80375532e5e9e7c1f2fc6319a1b7a69d" }, "nvim-colorizer.lua": { "branch": "master", "commit": "a065833f35a3a7cc3ef137ac88b5381da2ba302e" }, "nvim-lspconfig": { "branch": "master", "commit": "5bfcc89fd155b4ffc02d18ab3b7d19c2d4e246a7" }, - "nvim-tree.lua": { "branch": "master", "commit": "3fb91e18a727ecc0385637895ec397dea90be42a" }, - "nvim-treesitter": { "branch": "master", "commit": "42fc28ba918343ebfd5565147a42a26580579482" }, - "nvim-web-devicons": { "branch": "master", "commit": "8dcb311b0c92d460fac00eac706abd43d94d68af" }, + "nvim-tree.lua": { "branch": "master", "commit": "b2aadda94b107480c48e548d6db51c6840b7b33c" }, + "nvim-treesitter": { "branch": "main", "commit": "857651fce37eba032ebe28f3a206283cdc65c45a" }, + "nvim-web-devicons": { "branch": "master", "commit": "2ae6958df7ced50baac5035cec0c15799eedfbf7" }, "obsidian.nvim": { "branch": "main", "commit": "ae1f76a75c7ce36866e1d9342a8f6f5b9c2caf9b" }, - "onedark.vim": { "branch": "main", "commit": "68dca198f23ef979dc6a123ad50c598902117232" }, - "plenary.nvim": { "branch": "master", "commit": "b9fd5226c2f76c951fc8ed5923d85e4de065e509" }, - "render-markdown.nvim": { "branch": "main", "commit": "6e0e8902dac70fecbdd8ce557d142062a621ec38" }, - "stickybuf.nvim": { "branch": "master", "commit": "0c1e5f1a3eb36eea2cea57083828269cc62c58e4" }, - "telescope.nvim": { "branch": "master", "commit": "83a3a713d6b2d2a408491a1b959e55a7fa8678e8" }, + "onedark.vim": { "branch": "main", "commit": "47bec7a6196a843dad195d2666c3ac84c6e80c78" }, + "pasteimg.nvim": { "branch": "main", "commit": "49afda85eee886187b458b58aaf74a0590138461" }, + "plenary.nvim": { "branch": "master", "commit": "74b06c6c75e4eeb3108ec01852001636d85a932b" }, + "punchlist.nvim": { "branch": "main", "commit": "33cbbc166a3447746284647390d0eb9282e9b2dd" }, + "render-markdown.nvim": { "branch": "main", "commit": "4663eb3ecd538bd5062628fb6d95bbe6bdca78f6" }, + "snacks.nvim": { "branch": "main", "commit": "882c996cf28183f4d63640de0b4c02ec886d01f2" }, + "snakemake": { "branch": "main", "commit": "35ab0421813248cea482de3fd796ad48e53d88d7" }, + "stickybuf.nvim": { "branch": "master", "commit": "9e00edfd94baef4a78b4248ae8309a2d4943f118" }, + "telescope.nvim": { "branch": "master", "commit": "40aedd8a68c78a656a10a8d62d80c54af59420fb" }, "toggleterm.nvim": { "branch": "main", "commit": "c80844fd52ba76f48fabf83e2b9f9b93273f418d" }, - "treesj": { "branch": "main", "commit": "4770492244ccecdc9b01e0e81fa8f2f6b4a23841" }, + "treesj": { "branch": "main", "commit": "79aedb401bbdc7e4202f7881eab5f6feb2105b0a" }, "trouble.nvim": { "branch": "main", "commit": "bd67efe408d4816e25e8491cc5ad4088e708a69a" }, "vim-commentary": { "branch": "master", "commit": "64a654ef4a20db1727938338310209b6a63f60c9" }, - "vim-diff-enhanced": { "branch": "master", "commit": "8d161f1e97a5f5e64ea4219e6663f98a109df7b1" }, - "vim-fugitive": { "branch": "master", "commit": "61b51c09b7c9ce04e821f6cf76ea4f6f903e3cf4" }, + "vim-diff-enhanced": { "branch": "master", "commit": "386820ebbcc3d55a43d81035f4352afc42cc49a1" }, + "vim-fugitive": { "branch": "master", "commit": "3b753cf8c6a4dcde6edee8827d464ba9b8c4a6f0" }, "vim-mergetool": { "branch": "master", "commit": "0275a85256ad173e3cde586d54f66566c01b607f" }, "vim-surround": { "branch": "master", "commit": "3d188ed2113431cf8dac77be61b842acb64433d9" }, - "vim-table-mode": { "branch": "master", "commit": "e156dbbedce0bbf61c0919db7678fa246fabd616" }, + "vim-table-mode": { "branch": "master", "commit": "bb025308a45c67c7c8f0763ba37bc2ee3f534df0" }, "vis": { "branch": "master", "commit": "6a87efbfbd97238716b602c2b53564aa6329b5de" }, "which-key.nvim": { "branch": "main", "commit": "0539da005b98b02cf730c1d9da82b8e8edb1c2d2" }, "zenburn.nvim": { "branch": "master", "commit": "0860da40c6f666dfff3381a8b0ee98e16e08ca66" }, - "zenfade": { "branch": "main", "commit": "75284b99d9941bfee16ff5372f4b8205dd16f456" } + "zenfade": { "branch": "main", "commit": "4b4202bcfef909268e9c9f7d77c620400b9b3ca2" } } diff --git a/.config/nvim/lua/config/autocmds.lua b/.config/nvim/lua/config/autocmds.lua index ccb42f8..a196045 100644 --- a/.config/nvim/lua/config/autocmds.lua +++ b/.config/nvim/lua/config/autocmds.lua @@ -113,7 +113,7 @@ vim.api.nvim_create_autocmd("FileType", { -- Briefly highlight yanked text vim.api.nvim_create_autocmd("TextYankPost", { callback = function() - vim.highlight.on_yank{higroup = "IncSearch", timeout=100} + vim.hl.on_yank({ higroup = "IncSearch", timeout = 100 }) end, pattern = "*", }) diff --git a/.config/nvim/lua/config/lazy.lua b/.config/nvim/lua/config/lazy.lua index 656898d..c72ea74 100644 --- a/.config/nvim/lua/config/lazy.lua +++ b/.config/nvim/lua/config/lazy.lua @@ -1,6 +1,6 @@ -- Bootstrap lazy.nvim local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" -if not (vim.uv or vim.loop).fs_stat(lazypath) then +if not vim.uv.fs_stat(lazypath) then local lazyrepo = "https://github.com/folke/lazy.nvim.git" local out = vim.fn.system({ "git", "clone", "--filter=blob:none", "--branch=stable", lazyrepo, lazypath }) if vim.v.shell_error ~= 0 then diff --git a/.config/nvim/lua/config/options.lua b/.config/nvim/lua/config/options.lua index 2e74d52..e98bd9f 100644 --- a/.config/nvim/lua/config/options.lua +++ b/.config/nvim/lua/config/options.lua @@ -45,6 +45,11 @@ vim.opt.signcolumn = "yes" -- always show the signcolumn to minimize distraction -- vim.cmd(":autocmd InsertLeave * set cul") -- Turn color back on when exiting insert mode -- vim.cmd("set guicursor=i:block") -- Always use block cursor. In some terminals and fonts (like iTerm), it can be hard to see the cursor when it changes to a line. +-- Visual mode uses block cursor; insert mode uses bar cursor (highlighted with +-- CursorIM highlight group); replace mode uses an underscore as the cursor, +-- also with CursorIM highlight +vim.opt.guicursor = "n-v-c:block,i:ver25-CursorIM,r-cr:hor20-CursorIM" + -- Forces the OSC 52 clipboard provider. Needs a terminal emulator that -- supports it (like iTerm, Alacritty). See :help clipboard-osc52 for details vim.g.clipboard = 'osc52' diff --git a/.config/nvim/lua/plugins/gitsigns.lua b/.config/nvim/lua/plugins/gitsigns.lua index 7c5b1c7..3f4956b 100644 --- a/.config/nvim/lua/plugins/gitsigns.lua +++ b/.config/nvim/lua/plugins/gitsigns.lua @@ -10,7 +10,7 @@ return { local gs = package.loaded.gitsigns local function map(mode, l, r, desc) - vim.keymap.set(mode, l, r, { buffer = buffer, desc = desc }) + vim.keymap.set(mode, l, r, { buf = buffer, desc = desc }) end map("n", "]h", gs.next_hunk, "Next hunk") diff --git a/.config/nvim/lua/plugins/nvim-lspconfig.lua b/.config/nvim/lua/plugins/nvim-lspconfig.lua index c5c082d..6815558 100644 --- a/.config/nvim/lua/plugins/nvim-lspconfig.lua +++ b/.config/nvim/lua/plugins/nvim-lspconfig.lua @@ -1,176 +1,93 @@ -- nvim-lspconfig allows convenient configuration of LSP clients +return { + "neovim/nvim-lspconfig", + config = function() --- nvim 0.11 changed the way lspconfig works, so we split the config based on --- version (hence the duplication) -local post_v011 = vim.version().minor >= 11 - -if post_v011 then - return { - "neovim/nvim-lspconfig", - version = "v2.5", - config = function() - -- Python language server - vim.lsp.config.pyright = { - cmd = { "pyright-langserver", "--stdio" }, - filetypes = { "python" }, - root_markers = { - "pyproject.toml", - "setup.py", - "setup.cfg", - "requirements.txt", - "Pipfile", - "pyrightconfig.json", - ".git", - }, - } - - -- ruff for Python as well - vim.lsp.config("ruff", { - init_options = { - settings = { - lint = { - preview = true, - }, - }, - }, - }) - - -- Bash language server - vim.lsp.config.bashls = { - cmd = { "bash-language-server", "start" }, - filetypes = { "sh", "bash" }, - root_markers = { ".git" }, - } - - -- R language server - vim.lsp.config.r_language_server = { - cmd = { "R", "--slave", "-e", "languageserver::run()" }, - filetypes = { "r", "rmd" }, - root_markers = { ".git", "DESCRIPTION" }, - } - - vim.lsp.config.ansible = { - cmd = { "ansible-language-server", "--stdio" }, - filetypes = { "yaml.ansible" }, - } + vim.lsp.config("pyright", { + cmd = { "pyright-langserver", "--stdio" }, + filetypes = { "python" }, + root_markers = { + "pyproject.toml", + "setup.py", + "setup.cfg", + "requirements.txt", + "Pipfile", + "pyrightconfig.json", + ".git", + }, + }) - -- Lua language server - vim.lsp.config.lua_ls = { - cmd = { "lua-language-server" }, - filetypes = { "lua" }, - root_markers = { ".luarc.json", ".luarc.jsonc", ".git" }, + vim.lsp.config("ruff", { + init_options = { settings = { - Lua = { - runtime = { version = "LuaJIT" }, - workspace = { - library = { vim.env.VIMRUNTIME }, - }, - }, + lint = { preview = true }, }, - } - - -- By default show the virtual text. - vim.diagnostic.config({ virtual_text = true }) - - -- LSP keymaps - vim.api.nvim_create_autocmd("LspAttach", { - group = vim.api.nvim_create_augroup("UserLspConfig", {}), - callback = function(ev) - vim.keymap.set("n", "cv", function() - local current_config = vim.diagnostic.config() - vim.diagnostic.config({ - virtual_text = not current_config.virtual_text, - }) - end, { buffer = ev.buf, desc = "Toggle diagnostic virtual text" }) - vim.keymap.set( - "n", - "ce", - vim.diagnostic.open_float, - { buffer = ev.buf, desc = "Open diagnostics/errors" } - ) - end, - }) - end, - keys = { - { - "cl", - function() - local clients = vim.lsp.get_clients({ bufnr = 0 }) - if #clients > 0 then - vim.cmd("LspStop") - else - vim.cmd("LspStart") - end - end, - desc = "Toggle LSP", }, - }, - } -else - return { - "neovim/nvim-lspconfig", - version = "v2.5", - init = function() - local lspconfig = require("lspconfig") + }) - -- Below, autostart = false means that you need to explicity call :LspStart (cl) - -- - -- ---------------------------------------------------------------------- - -- CONFIGURE ADDITIONAL LANGUAGE SERVERS HERE - -- - -- pyright is the language server for Python - lspconfig.pyright.setup({ autostart = false }) + vim.lsp.config("bashls", { + cmd = { "bash-language-server", "start" }, + filetypes = { "sh", "bash" }, + root_markers = { ".git" }, + }) - lspconfig.bashls.setup({ autostart = false }) + vim.lsp.config("r_language_server", { + cmd = { "R", "--slave", "-e", "languageserver::run()" }, + filetypes = { "r", "rmd" }, + root_markers = { ".git", "DESCRIPTION" }, + }) - -- language server for R - lspconfig.r_language_server.setup({ autostart = false }) + vim.lsp.config("ansible", { + cmd = { "ansible-language-server", "--stdio" }, + filetypes = { "yaml.ansible" }, + }) - -- Language server for Lua. These are the recommended options - -- when mainly using Lua for Neovim - lspconfig.lua_ls.setup({ - settings = { - Lua = { - runtime = { - version = "LuaJIT", - }, - workspace = { - library = { vim.env.VIMRUNTIME }, - }, + vim.lsp.config("lua_ls", { + cmd = { "lua-language-server" }, + filetypes = { "lua" }, + root_markers = { ".luarc.json", ".luarc.jsonc", ".git" }, + settings = { + Lua = { + runtime = { version = "LuaJIT" }, + workspace = { + library = { vim.env.VIMRUNTIME }, }, }, - }) - - -- Use LspAttach autocommand to only map the following keys after - -- the language server attaches to the current buffer - vim.api.nvim_create_autocmd("LspAttach", { - group = vim.api.nvim_create_augroup("UserLspConfig", {}), - callback = function(ev) - vim.keymap.set("n", "cgd", vim.lsp.buf.definition, { buffer = ev.buf, desc = "Goto Definition" }) - vim.keymap.set("n", "cK", vim.lsp.buf.hover, { buffer = ev.buf, desc = "Hover help" }) - vim.keymap.set("n", "crn", vim.lsp.buf.rename, { buffer = ev.buf, desc = "Rename" }) - vim.keymap.set("n", "cgr", vim.lsp.buf.references, { buffer = ev.buf, desc = "Goto References" }) - vim.keymap.set("n", "ca", vim.lsp.buf.code_action, { buffer = ev.buf, desc = "Code Action" }) - end, - }) - end, - keys = { - -- because autostart=false above, need to manually start the language server. - { - "cl", - function() - local clients = vim.lsp.get_clients({ bufnr = 0 }) - if #clients > 0 then - vim.cmd("LspStop") - else - vim.cmd("LspStart") - end - end, - desc = "Toggle LSP", }, - { "ce", vim.diagnostic.open_float, desc = "Open diagnostics/errors" }, - { "]d", vim.diagnostic.goto_next, desc = "Next diagnostic/error" }, - { "[d", vim.diagnostic.goto_prev, desc = "Prev diagnostic/error" }, + }) + + vim.diagnostic.config({ virtual_text = true }) + + vim.api.nvim_create_autocmd("LspAttach", { + group = vim.api.nvim_create_augroup("UserLspConfig", {}), + callback = function(ev) + vim.keymap.set("n", "cv", function() + local current_config = vim.diagnostic.config() + vim.diagnostic.config({ + virtual_text = not current_config.virtual_text, + }) + end, { buf = ev.buf, desc = "Toggle diagnostic virtual text" }) + vim.keymap.set( + "n", + "ce", + vim.diagnostic.open_float, + { buf = ev.buf, desc = "Open diagnostics/errors" } + ) + end, + }) + end, + keys = { + { + "cl", + function() + local clients = vim.lsp.get_clients({ bufnr = 0 }) + if #clients > 0 then + vim.cmd("LspStop") + else + vim.cmd("LspStart") + end + end, + desc = "Toggle LSP", }, - } -end + }, +} diff --git a/.config/nvim/lua/plugins/nvim-tree.lua b/.config/nvim/lua/plugins/nvim-tree.lua index 65959b9..0958540 100644 --- a/.config/nvim/lua/plugins/nvim-tree.lua +++ b/.config/nvim/lua/plugins/nvim-tree.lua @@ -27,8 +27,8 @@ return { api.tree.reload() end end - vim.keymap.set("n", "ga", git_add, { buffer = bufnr, desc = "Git Add" }) - vim.keymap.set("n", "gu", git_unstage, { buffer = bufnr, desc = "Git Unstage" }) + vim.keymap.set("n", "ga", git_add, { buf = bufnr, desc = "Git Add" }) + vim.keymap.set("n", "gu", git_unstage, { buf = bufnr, desc = "Git Unstage" }) end, }) end, diff --git a/.config/nvim/lua/plugins/obsidian.lua b/.config/nvim/lua/plugins/obsidian.lua index d2e7df2..a62a935 100644 --- a/.config/nvim/lua/plugins/obsidian.lua +++ b/.config/nvim/lua/plugins/obsidian.lua @@ -23,7 +23,7 @@ return { return "ObsidianFollowLink" end end, - opts = { buffer = true, expr = true }, + opts = { buf = true, expr = true }, }, }, diff --git a/.config/nvim/lua/plugins/punchlist.lua b/.config/nvim/lua/plugins/punchlist.lua new file mode 100644 index 0000000..7c77509 --- /dev/null +++ b/.config/nvim/lua/plugins/punchlist.lua @@ -0,0 +1,7 @@ +return { + "daler/punchlist.nvim", + dependencies = { "folke/snacks.nvim" }, + config = function() + require("punchlist").setup({}) + end, +} diff --git a/.config/nvim/lua/plugins/r-nvim.lua b/.config/nvim/lua/plugins/r-nvim.lua index 0ca0fe1..26dd7d2 100644 --- a/.config/nvim/lua/plugins/r-nvim.lua +++ b/.config/nvim/lua/plugins/r-nvim.lua @@ -44,7 +44,7 @@ return { local path = vim.api.nvim_buf_get_name(0) require("r.send").cmd('rmarkdown::render("' .. path .. '")') end, - { buffer = true, desc = "Render Rmarkdown" }) + { buf = true, desc = "Render Rmarkdown" }) -- In 0.99.4 which is used here for compatibility with older -- R versions, the RDSendLine command sends the entire treesitter block @@ -55,7 +55,7 @@ return { local line = vim.api.nvim_get_current_line() require("r.send").cmd(line) vim.cmd("normal! j") - end, { buffer = true }) + end, { buf = true }) end, }, }, diff --git a/.config/nvim/lua/plugins/treesitter.lua b/.config/nvim/lua/plugins/treesitter.lua index e503e0f..f225db1 100644 --- a/.config/nvim/lua/plugins/treesitter.lua +++ b/.config/nvim/lua/plugins/treesitter.lua @@ -1,59 +1,87 @@ -- treesitter provides sophisticated syntax highlighting and code inspection + + +-- List the parsers here that you want to have installed. +-- +-- Recent versions of treesitter do not install by default. These can be +-- installed with: +-- +-- :lua require("nvim-treesitter").install(require("plugins.treesitter")[1].opts.parsers) +-- + +local parsers = { + "bash", + "css", + "dockerfile", + "hcl", + "html", + "json", + "lua", + "markdown", + "markdown_inline", + "python", + "vim", + "vimdoc", + "yaml", + "r", + "rst", + "snakemake", +} + +local configured_parsers = {} +for _, parser in ipairs(parsers) do + configured_parsers[parser] = true +end + return { { "nvim-treesitter/nvim-treesitter", - version = false, + branch = "main", + lazy = false, build = ":TSUpdate", - event = { "BufReadPost", "BufNewFile" }, + dependencies = { "williamboman/mason.nvim" }, + opts = { parsers = parsers }, config = function() - require("nvim-treesitter.configs").setup({ - highlight = { - enable = true, - }, - indent = { - enable = true, - -- Let vim-python-pep8-indent handle the python and snakemake indentation; - -- disable markdown indentation because it prevents bulleted lists from wrapping correctly with `gq`. - disable = { "markdown" }, - }, - -- -------------------------------------------------------------------- - -- CONFIGURE ADDITIONAL PARSERS HERE - -- These will be attempted to be installed automatically, but you'll need a C compiler installed. - ensure_installed = { - "bash", - "css", - "dockerfile", - "hcl", - "html", - "json", - "lua", - "markdown", - "markdown_inline", - "python", - "vim", - "vimdoc", - "yaml", - "r", - "rst", - "snakemake", - }, - incremental_selection = { - enable = true, - keymaps = { - init_selection = "cs", - node_incremental = "", - scope_incremental = false, - node_decremental = "", - }, - }, - }) - vim.cmd("set foldmethod=expr") - vim.cmd("set foldexpr=nvim_treesitter#foldexpr()") - vim.cmd("set nofoldenable") + require("nvim-treesitter").setup() - -- RMarkdown doesn't have a good treesitter parser, but Markdown does + -- RMarkdown doesn't have a dedicated parser, but Markdown does. vim.treesitter.language.register("markdown", "rmd") vim.treesitter.language.register("markdown", "rmarkdown") + + -- The main branch no longer auto-enables highlighting or indentation, so + -- start Treesitter explicitly for filetypes whose parsers we manage here. + vim.api.nvim_create_autocmd("FileType", { + pattern = "*", + callback = function() + local language = vim.treesitter.language.get_lang(vim.bo.filetype) or vim.bo.filetype + if not configured_parsers[language] then + return + end + + vim.treesitter.start() + + -- Markdown indentation interferes with wrapping bulleted lists. + if language ~= "markdown" then + vim.bo.indentexpr = "v:lua.require'nvim-treesitter'.indentexpr()" + end + end, + }) + + vim.opt.foldmethod = "expr" + vim.opt.foldexpr = "v:lua.vim.treesitter.foldexpr()" + vim.opt.foldenable = false + + -- Preserve the previous incremental-selection mappings using Nvim 0.12's + -- built-in Treesitter selection API. + vim.keymap.set("n", "cs", function() + vim.treesitter.select("parent") + end, { desc = "Start Treesitter selection" }) + vim.keymap.set("x", "", function() + vim.treesitter.select("parent") + end, { desc = "Expand Treesitter selection" }) + vim.keymap.set("x", "", function() + vim.treesitter.select("child") + end, { desc = "Shrink Treesitter selection" }) end, }, } diff --git a/docs/changelog.rst b/docs/changelog.rst index 4424126..fb9173c 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -1,6 +1,46 @@ Changelog ========= +2026-08-29 +---------- + +**setup, nvim** + +nvim 0.12.5 is now installed by default. **nvim plugins now only support 0.12.5+**. + +.. note:: + + Use the ``nvim-0.11`` branch of this repo if you want to stick to an earlier + nvim version. + +The reason for this is that multiple plugins have been moving toward this +cutoff of 0.12, and maintaining backwards compatibility here was increasing +complexity. + +Now upon installation, ``tree-sitter-cli`` is installed with Mason and then all +configured treesitter parsers are installed. + +If you are migrating from an earlier nvim: + +1. Update your dotfiles with the changes in this commit. Make any backups you + want. +2. Run ``setup.sh --install-neovim``. It will tell you the dir you need to + delete before installing, and after doing so you can re-run the command to + install. + +If you already have nvim 0.12.5+ installed somewhere: + +1. Adjust your path, or update your alias, so that nvim 0.12.5 is used. +2. Run ``setup.sh --nvim-test-drive``. This will make a backup of your + nvim-related dotfiles, copy over the latest from this repo, and do the Mason + and treesitter installation. + +Other updates: + +- added the punchlist.nvim plugin +- updated tool versions in setup.sh +- make insert and replace cursors more obvious + 2026-07-27 ---------- diff --git a/docs/nvim-plugins.rst b/docs/nvim-plugins.rst index 46174b7..7e24146 100644 --- a/docs/nvim-plugins.rst +++ b/docs/nvim-plugins.rst @@ -352,9 +352,8 @@ default; start it with :kbd:`cl`. .. note:: - nvim 0.11 changed the way LSPs are handled, making them more natively - integrated. These dotfiles now support nvim 0.11+ and are backwards - compatible with 0.10. + These dotfiles use the native LSP configuration API and require nvim 0.12 + or newer. .. contents:: :local: @@ -750,6 +749,56 @@ mapped, which you can read about in the `README for aerial .. plugin-metadata:: :name: aerial +.. _punchlist_ref: + +``punchlist.nvim`` +~~~~~~~~~~~~~~~~~~ + +`punchlist `__ is a plugin to make +annotations on files, like using comments in Google Docs or Microsoft Word. The +annotations are stored in a hidden directory in the repo, but are visually +attached to text in a buffer. + +Annotations move with the text that you edit, and can be cut-and-paste if +editing is too disruptive to track position automatically. + +A summary can be shown that can be pasted into LLM agents to direct them right +to the files and lines of interest. + +The keymaps use the ````, by default :kbd:`\`. + +.. list-table:: + :header-rows: 1 + :align: left + + * - command + - description + + * - :kbd:`pd` + - Add a DISCUSS annotation + + * - :kbd:`pf` + - Add a FIX annotation + + * - :kbd:`ps` + - Show the list of all annotations, ready to copy + + * - :kbd:`px` + - Cut an annotation + + * - :kbd:`pv` + - Paste an annotation on current line/selection + + * - :kbd:`pr` + - Re-anchor an annotation + + * - :kbd:`pc` + - Clear all annotations in repo (asks for confirmation) + +.. plugin-metadata:: + :name: punchlist + + Visuals +++++++ @@ -1025,11 +1074,28 @@ to do something with that. For example, colorschemes can use that information, or you can select text based on its semantic meaning within the programming language (like easily select an entire function, or the body of a for-loop). -Treesitter is configured to ensure the parsers listed in the config are -installed. These will be attempted to be installed automatically, but they do -require a C compiler to be available. +Things have been changing recently in the treesitter-related world. This config +now uses the ``main`` branch, which requires nvim 0.12+, ``tree-sitter-cli`` +0.26.1+, and a C compiler. + +Both ``--install-neovim`` and ``--nvim-test-drive`` install the CLI and all +parsers listed in the config. The normal installation runs this setup +headlessly after restoring the configured plugins. This requires running +``--dotfiles`` first so that :file:`~/.config/nvim` exists. + +To set them up manually instead, first open nvim and install the CLI with Mason:: + + :MasonInstall tree-sitter-cli + +Then install all parsers listed in the config:: + + :lua require("nvim-treesitter").install(require("plugins.treesitter")[1].opts.parsers) + +Installation runs asynchronously. Parsers are stored in nvim-treesitter's +default :file:`~/.local/share/nvim/site/parser` directory. Use +``:checkhealth nvim-treesitter`` to check the installed parsers. -- On a Mac, this may need XCode Command Line Tools to be installed. +- On a Mac, the compiler may need XCode Command Line Tools to be installed. - A fresh Ubuntu installation will need ``sudo apt install build-essential`` - RHEL/Fedora will need ``sudo dnf install 'Development Tools'`` (and may need the `EPEL repo `__ enabled). @@ -1037,9 +1103,9 @@ require a C compiler to be available. packages via conda `_, -Alternatively, comment out the entire ``ensure_installed`` block in -:file:`~/.config/nvim/lua/plugins/treesitter.lua`; this means you will not have -treesitter-enabled syntax highlighting though. +Alternatively, remove parsers from the ``parsers`` table in +:file:`~/.config/nvim/lua/plugins/treesitter.lua`; removed languages will not +have treesitter-enabled syntax highlighting. .. list-table:: :header-rows: 1 diff --git a/docs/starthere.rst b/docs/starthere.rst index 6e14e48..80ce180 100644 --- a/docs/starthere.rst +++ b/docs/starthere.rst @@ -161,10 +161,11 @@ more help on deciding. .. details:: Details - This installs Neovim to :file:`~/opt/bin`, and then creates an ``alias - vim=nvim`` in the :file:`~/.aliases` file (which is sourced by - :file:`~/.bashrc`). This way, whenever you call ``vim``, the alias will - redirect it to ``nvim``. + This installs Neovim to :file:`~/opt/bin`, restores the configured plugins, + installs ``tree-sitter-cli``, and installs all configured Treesitter + parsers. It then creates an ``alias vim=nvim`` in the :file:`~/.aliases` + file (which is sourced by :file:`~/.bashrc`). This way, whenever you call + ``vim``, the alias will redirect it to ``nvim``. However it's important to close and reopen your terminal, because this alias is conditional on finding nvim, and the alias is only created upon @@ -183,34 +184,22 @@ more help on deciding. changed. Please see :ref:`nvim-lua` for more context, rationale, and details on migrating to this new config method. -After closing and reopening your terminal from step 2b, now open neovim to -trigger automatic plugin installation. Plugins are managed via the `lazy.nvim -`_ manager, which will bootstrap itself and -then download, install, and configure all plugins automatically. +The ``--install-neovim`` step restores plugins with `lazy.nvim +`_, installs ``tree-sitter-cli`` with Mason, +and installs all Treesitter parsers listed in the config. No separate plugin +setup step is needed. -.. code-block:: bash - - nvim - # Wait for plugins to download and install (you'll see progress messages) - # When everything is finished, quit with :q - -Or run this command to install plugins and quit automatically when done: - -.. code-block:: bash - - nvim +"lua require('lazy').restore({wait=true})" +q +This automatic setup requires the nvim config to already be at +:file:`~/.config/nvim`, which is why ``--dotfiles`` comes first in the +recommended order. It also requires a C compiler for the Treesitter parsers. +See :ref:`treesitter_ref` for platform-specific prerequisites. .. details:: Details - ``lazy.nvim`` will show progress downloading plugins. Treesitter will also - automatically install parsers, so you should watch the log on the bottom and - wait until everything settles down. Then you can quit as normal with - ``:q``. - - If running ``nvim`` didn't work, check that it's on your path. Close and then - reopen your terminal just to make sure. If you installed with ``./.setup.sh - --install-neovim``, it put it in ``~/opt/bin/nvim``. Make sure that directory - is on your PATH by checking: + If running ``nvim`` after installation does not work, check that it is on + your path. Close and then reopen your terminal just to make sure. The setup + command puts it in ``~/opt/bin/nvim``. Make sure that directory is on your + PATH by checking: .. code-block:: bash diff --git a/setup.sh b/setup.sh index e823701..60a00d3 100755 --- a/setup.sh +++ b/setup.sh @@ -22,17 +22,17 @@ set -eo pipefail # Change tool versions here VISIDATA_VERSION=3.3 HUB_VERSION=2.14.2 -NVIM_VERSION=0.11.5 -RG_VERSION=15.1.0 +NVIM_VERSION=0.12.5 +RG_VERSION=15.2.0 BAT_VERSION=0.26.1 -JQ_VERSION=1.8.1 +JQ_VERSION=1.8.2 ICDIFF_VERSION=2.0.4 -BFG_VERSION=1.14.0 -FD_VERSION=10.4.2 -BLACK_VERSION=22.6.0 -PYP_VERSION=1.1.0 -FZF_VERSION=0.72.0 -TMUX_VERSION=3.6a +BFG_VERSION=1.15.0 +FD_VERSION=10.5.0 +BLACK_VERSION=26.5.1 +PYP_VERSION=1.3.0 +FZF_VERSION=0.74.3 +TMUX_VERSION=3.7 function showHelp() { @@ -100,12 +100,11 @@ function showHelp() { echo " 3) ./setup.sh --install-conda" echo " 4) ./setup.sh --set-up-bioconda" echo " 5) CLOSE TERMINAL, OPEN A NEW ONE" - echo " 6) Open vim (which should now be aliased to nvim) and allow plugins to install, then quit" - echo " 7) ./setup.sh --install-fzf" - echo " 8) ./setup.sh --install-ripgrep" - echo " 9) ./setup.sh --install-vd" - echo " 10) ./setup.sh --install-pyp" - echo " 11) ./setup.sh --install-fd" + echo " 6) ./setup.sh --install-fzf" + echo " 7) ./setup.sh --install-ripgrep" + echo " 8) ./setup.sh --install-vd" + echo " 9) ./setup.sh --install-pyp" + echo " 10) ./setup.sh --install-fd" echo echo " On Mac:" echo " ./setup.sh --mac-stuff" @@ -135,7 +134,7 @@ function showHelp() { "packages. See apt-installs-minimal.txt for list, and edit if needed" cmd "--install-neovim" \ - "neovim is a drop-in replacement for vim, with additional features" \ + "Install neovim, configured plugins, tree-sitter-cli, and Treesitter parsers" \ "Homepage: https://neovim.io/" cmd "--compile-neovim" \ @@ -262,8 +261,8 @@ function showHelp() { "Installs gh, the github CLI" cmd "--nvim-test-drive" \ - "Move nvim binary, plugins, and config to backup directories so you can " \ - "try new updates from these dotfiles. Does not delete anything." + "Move nvim plugins, parsers, Mason packages, and config to backup " \ + "directories, then reinstall them for a clean test. Does not delete anything." cmd "--restore-nvim-plugins" \ "Copy over the nvim plugin lockfile from the repo to your " \ @@ -387,6 +386,50 @@ check_opt_bin_in_path () { fi } +# Install every Treesitter parser listed in the nvim config and wait for the +# asynchronous installs to finish. The caller is responsible for installing +# nvim-treesitter and tree-sitter-cli first. +install_treesitter_parsers () { + local nvim_bin=$1 + local ts_install_dir + local ts_install_lua + local ts_failed= + + printf "${YELLOW}Installing configured Treesitter parsers...${UNSET}\n" + ts_install_dir=$(mktemp -d) + ts_install_lua="$ts_install_dir/ts-install.lua" + cat > "$ts_install_lua" <<'EOF' +local ok, err = pcall(function() + local parsers = require("plugins.treesitter")[1].opts.parsers + assert(type(parsers) == "table" and #parsers > 0, "no parsers configured in plugins/treesitter.lua") + print(("Installing %d parsers: %s"):format(#parsers, table.concat(parsers, " "))) + + assert(vim.fn.executable("tree-sitter") == 1, "the tree-sitter CLI is not on Nvim's PATH") + require("nvim-treesitter").install(parsers, { force = true, summary = true }):wait(900000) + + local parser_dir = require("nvim-treesitter.config").get_install_dir("parser") + local missing = vim.tbl_filter(function(lang) + return vim.fn.filereadable(vim.fs.joinpath(parser_dir, lang .. ".so")) == 0 + end, parsers) + assert(#missing == 0, "parsers missing from " .. parser_dir .. ": " .. table.concat(missing, " ")) +end) + +if not ok then + vim.api.nvim_echo({ { "Treesitter parser installation failed: " .. tostring(err), "ErrorMsg" } }, true, {}) + vim.cmd("cquit") +end +print("All configured Treesitter parsers installed") +EOF + + "$nvim_bin" --headless "+luafile $ts_install_lua" +qa