From 25903242ee44fecf91eec962473f8816de978220 Mon Sep 17 00:00:00 2001 From: Tom Meagher Date: Tue, 5 Nov 2024 18:09:59 -0500 Subject: [PATCH] chore(nvim): up lazy code --- .config/nvim/lazy-lock.json | 28 ++++++++++++++-------------- .config/nvim/lua/config/autocmds.lua | 24 ++++++++++++++++++------ .config/nvim/lua/config/keymaps.lua | 8 ++++---- .config/nvim/lua/config/options.lua | 4 ++++ .config/nvim/lua/plugins.lua | 5 ----- .config/nvim/lua/util/lsp.lua | 9 +++++++++ .config/nvim/lua/util/root.lua | 6 +++++- .config/nvim/lua/util/ui.lua | 4 ++-- 8 files changed, 56 insertions(+), 32 deletions(-) diff --git a/.config/nvim/lazy-lock.json b/.config/nvim/lazy-lock.json index 70e742a..0a7c729 100644 --- a/.config/nvim/lazy-lock.json +++ b/.config/nvim/lazy-lock.json @@ -2,43 +2,43 @@ "cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" }, "cmp-nvim-lsp": { "branch": "main", "commit": "39e2eda76828d88b773cc27a3f61d2ad782c922d" }, "cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" }, - "conform.nvim": { "branch": "master", "commit": "6a28c90082a67f62a323ab90d988e000a718a8c7" }, + "conform.nvim": { "branch": "master", "commit": "d28ccf945374edd9f1c34a82f6c22261dbd8ab98" }, "copilot-cmp": { "branch": "master", "commit": "b6e5286b3d74b04256d0a7e3bd2908eabec34b44" }, "copilot.lua": { "branch": "master", "commit": "f8d8d872bb319f640d5177dad5fbf01f7a16d7d0" }, - "dressing.nvim": { "branch": "master", "commit": "1b7921eecc65af1baf8ac1dc06f0794934cbcfb2" }, + "dressing.nvim": { "branch": "master", "commit": "c334ac73e031f0dc93d6d91f3658ee75b8be1d3b" }, "edgy.nvim": { "branch": "main", "commit": "7e8dedc39abebe40c289b8012cc89b11c69aa7a0" }, "flash.nvim": { "branch": "main", "commit": "34c7be146a91fec3555c33fe89c7d643f6ef5cf1" }, "friendly-snippets": { "branch": "main", "commit": "de8fce94985873666bd9712ea3e49ee17aadb1ed" }, - "gitsigns.nvim": { "branch": "main", "commit": "ee7634ab4f0a6606438fe13e16cbf2065589a5ed" }, - "indent-blankline.nvim": { "branch": "master", "commit": "e7a4442e055ec953311e77791546238d1eaae507" }, - "lazy.nvim": { "branch": "main", "commit": "cf8ecc2c5e4332760431a33534240b0cbc6680ab" }, - "lualine.nvim": { "branch": "master", "commit": "b431d228b7bbcdaea818bdc3e25b8cdbe861f056" }, + "gitsigns.nvim": { "branch": "main", "commit": "4daf7022f1481edf1e8fb9947df13bb07c18e89a" }, + "indent-blankline.nvim": { "branch": "master", "commit": "04e44b09ee3ff189c69ab082edac1ef7ae2e256c" }, + "lazy.nvim": { "branch": "main", "commit": "b1134ab82ee4279e31f7ddf7e34b2a99eb9b7bc9" }, + "lualine.nvim": { "branch": "master", "commit": "640260d7c2d98779cab89b1e7088ab14ea354a02" }, "lush.nvim": { "branch": "main", "commit": "45a79ec4acb5af783a6a29673a999ce37f00497e" }, - "mason-lspconfig.nvim": { "branch": "main", "commit": "7446f47b3dfb7df801f31a6f6783c2ad119a6935" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "4d0e5b49363cac187326998b96aa6a2884e0e89b" }, "mason-nvim-dap.nvim": { "branch": "main", "commit": "8b9363d83b5d779813cdd2819b8308651cec2a09" }, "mason.nvim": { "branch": "main", "commit": "e2f7f9044ec30067bc11800a9e266664b88cda22" }, - "mini.nvim": { "branch": "main", "commit": "919b953f044d97a2243cc2d1f0b316a199434127" }, + "mini.nvim": { "branch": "main", "commit": "c8bc67a35e627908da644c5f8cd26b3f987f2627" }, "neo-tree.nvim": { "branch": "main", "commit": "a77af2e764c5ed4038d27d1c463fa49cd4794e07" }, "neotest": { "branch": "master", "commit": "6d3d22cdad49999ef774ebe1bc250a4994038964" }, "neotest-elixir": { "branch": "master", "commit": "c5067bcc3ec6a0bba7b5694fa15aeb17f16aeb3c" }, "neotest-vitest": { "branch": "main", "commit": "9e30dca989a2287cf3fde86b3e138ea7fa4de935" }, - "noice.nvim": { "branch": "main", "commit": "df448c649ef6bc5a6a633a44f2ad0ed8d4442499" }, + "noice.nvim": { "branch": "main", "commit": "5a78b42bec5e775f2db03bf93f6d1e0f3636306c" }, "nui.nvim": { "branch": "main", "commit": "b58e2bfda5cea347c9d58b7f11cf3012c7b3953f" }, - "nvim-cmp": { "branch": "main", "commit": "29fb4854573355792df9e156cb779f0d31308796" }, + "nvim-cmp": { "branch": "main", "commit": "f17d9b4394027ff4442b298398dfcaab97e40c4f" }, "nvim-dap": { "branch": "master", "commit": "7ff6936010b7222fea2caea0f67ed77f1b7c60dd" }, "nvim-dap-ui": { "branch": "master", "commit": "ffa89839f97bad360e78428d5c740fdad9a0ff02" }, - "nvim-dap-virtual-text": { "branch": "master", "commit": "52638640ae309cacdaff785fdbb854437bd1ee5c" }, + "nvim-dap-virtual-text": { "branch": "master", "commit": "76d80c3d171224315b61c006502a1e30c213a9ab" }, "nvim-lastplace": { "branch": "main", "commit": "0bb6103c506315044872e0f84b1f736c4172bb20" }, - "nvim-lspconfig": { "branch": "master", "commit": "28b205ebe73a18f401e040585106f9bafd8ff21f" }, + "nvim-lspconfig": { "branch": "master", "commit": "bc6ada4b0892b7f10852c0b8ca7209fd39a6d754" }, "nvim-nio": { "branch": "master", "commit": "a428f309119086dc78dd4b19306d2d67be884eee" }, "nvim-notify": { "branch": "master", "commit": "fbef5d32be8466dd76544a257d3f3dce20082a07" }, "nvim-scrollbar": { "branch": "main", "commit": "6994eb9f73d5fdc36ee2c8717940e8c853e51a49" }, "nvim-snippets": { "branch": "main", "commit": "56b4052f71220144689caaa2e5b66222ba5661eb" }, - "nvim-treesitter": { "branch": "master", "commit": "00d219068385a4aa80859d4606ad6e03af6faa83" }, + "nvim-treesitter": { "branch": "master", "commit": "dfd3207ed43a0c572c13acc02bf9d7dc270f4030" }, "nvim-ts-autotag": { "branch": "main", "commit": "e239a560f338be31337e7abc3ee42515daf23f5e" }, "plenary.nvim": { "branch": "master", "commit": "2d9b06177a975543726ce5c73fca176cedbffe9d" }, "telescope-fzf-native.nvim": { "branch": "main", "commit": "cf48d4dfce44e0b9a2e19a008d6ec6ea6f01a83b" }, - "telescope.nvim": { "branch": "master", "commit": "37dc9233a473dd6c3f54456ef9994d8f77c80211" }, + "telescope.nvim": { "branch": "master", "commit": "85922dde3767e01d42a08e750a773effbffaea3e" }, "trouble.nvim": { "branch": "main", "commit": "2f3b537f2207ce32f4459f9d56746ee013b5e01b" }, "ts-comments.nvim": { "branch": "main", "commit": "2002692ad1d3f6518d016550c20c2a890f0cbf0e" }, "twoslash-queries.nvim": { "branch": "main", "commit": "b92622c7b71eceefabd02eef24236041069904b1" }, diff --git a/.config/nvim/lua/config/autocmds.lua b/.config/nvim/lua/config/autocmds.lua index 8b175ab..ffb7420 100644 --- a/.config/nvim/lua/config/autocmds.lua +++ b/.config/nvim/lua/config/autocmds.lua @@ -16,7 +16,7 @@ vim.api.nvim_create_autocmd({ "FocusGained", "TermClose", "TermLeave" }, { vim.api.nvim_create_autocmd("TextYankPost", { group = augroup("highlight_yank"), callback = function() - vim.highlight.on_yank() + (vim.hl or vim.highlight).on_yank() end, }) @@ -89,11 +89,16 @@ vim.api.nvim_create_autocmd("FileType", { }, callback = function(event) vim.bo[event.buf].buflisted = false - vim.keymap.set("n", "q", "close", { - buffer = event.buf, - silent = true, - desc = "Quit buffer", - }) + vim.schedule(function() + vim.keymap.set("n", "q", function() + vim.cmd("close") + pcall(vim.api.nvim_buf_delete, event.buf, { force = true }) + end, { + buffer = event.buf, + silent = true, + desc = "Quit buffer", + }) + end) end, }) @@ -161,3 +166,10 @@ vim.api.nvim_create_autocmd({ "FileType" }, { end) end, }) + +-- allow C-l to clear terminal +vim.api.nvim_create_autocmd("TermOpen", { + callback = function(ev) + vim.keymap.set("t", "", "", { buffer = ev.buf, nowait = true }) + end, +}) diff --git a/.config/nvim/lua/config/keymaps.lua b/.config/nvim/lua/config/keymaps.lua index 844060f..1bb14ad 100644 --- a/.config/nvim/lua/config/keymaps.lua +++ b/.config/nvim/lua/config/keymaps.lua @@ -23,12 +23,12 @@ map("n", "", "vertical resize -2", { desc = "Decrease Window Wi map("n", "", "vertical resize +2", { desc = "Increase Window Width" }) -- Move Lines -map("n", "", "m .+1==", { desc = "Move Down" }) -map("n", "", "m .-2==", { desc = "Move Up" }) +map("n", "", "execute 'move .+' . v:count1==", { desc = "Move Down" }) +map("n", "", "execute 'move .-' . (v:count1 + 1)==", { desc = "Move Up" }) map("i", "", "m .+1==gi", { desc = "Move Down" }) map("i", "", "m .-2==gi", { desc = "Move Up" }) -map("v", "", ":m '>+1gv=gv", { desc = "Move Down" }) -map("v", "", ":m '<-2gv=gv", { desc = "Move Up" }) +map("v", "", ":execute \"'<,'>move '>+\" . v:count1gv=gv", { desc = "Move Down" }) +map("v", "", ":execute \"'<,'>move '<-\" . (v:count1 + 1)gv=gv", { desc = "Move Up" }) -- Visually select text that was last edited/pasted (Vimcast#26) map("n", "gV", "`[v`]", { noremap = true, silent = true }) diff --git a/.config/nvim/lua/config/options.lua b/.config/nvim/lua/config/options.lua index 209ac63..c6c8ac8 100644 --- a/.config/nvim/lua/config/options.lua +++ b/.config/nvim/lua/config/options.lua @@ -17,6 +17,10 @@ vim.g.tmm_statuscolumn = { folds_githl = false, -- highlight fold sign with git sign color } +-- Set LSP servers to be ignored when used with `util.root.detectors.lsp` +-- for detecting the LSP root +vim.g.root_lsp_ignore = { "copilot" } + -- Hide deprecation warnings vim.g.deprecation_warnings = false diff --git a/.config/nvim/lua/plugins.lua b/.config/nvim/lua/plugins.lua index 82d108b..dc42984 100644 --- a/.config/nvim/lua/plugins.lua +++ b/.config/nvim/lua/plugins.lua @@ -1177,11 +1177,6 @@ return { vscode.json_decode = function(str) return vim.json.decode(json.json_strip_comments(str)) end - - -- Extends dap.configurations with entries read from .vscode/launch.json - if vim.fn.filereadable(".vscode/launch.json") then - vscode.load_launchjs() - end end, }, diff --git a/.config/nvim/lua/util/lsp.lua b/.config/nvim/lua/util/lsp.lua index 577db00..996eb89 100644 --- a/.config/nvim/lua/util/lsp.lua +++ b/.config/nvim/lua/util/lsp.lua @@ -181,6 +181,15 @@ function M.get_config(server) return rawget(configs, server) end +---@return {default_config:lspconfig.Config} +function M.get_raw_config(server) + local ok, ret = pcall(require, "lspconfig.configs." .. server) + if ok then + return ret + end + return require("lspconfig.configs." .. server) +end + function M.is_enabled(server) local c = M.get_config(server) return c and c.enabled ~= false diff --git a/.config/nvim/lua/util/root.lua b/.config/nvim/lua/util/root.lua index 98251ac..bf10ca9 100644 --- a/.config/nvim/lua/util/root.lua +++ b/.config/nvim/lua/util/root.lua @@ -29,7 +29,11 @@ function M.detectors.lsp(buf) return {} end local roots = {} ---@type string[] - for _, client in pairs(require("util.lsp").get_clients({ bufnr = buf })) do + local clients = require("util.lsp").get_clients({ bufnr = buf }) + clients = vim.tbl_filter(function(client) + return not vim.tbl_contains(vim.g.root_lsp_ignore or {}, client.name) + end, clients) + for _, client in pairs(clients) do local workspace = client.config.workspace_folders for _, ws in pairs(workspace or {}) do roots[#roots + 1] = vim.uri_to_fname(ws.uri) diff --git a/.config/nvim/lua/util/ui.lua b/.config/nvim/lua/util/ui.lua index 13a208d..5c10804 100644 --- a/.config/nvim/lua/util/ui.lua +++ b/.config/nvim/lua/util/ui.lua @@ -151,8 +151,8 @@ function M.foldexpr() return "0" end - -- don't use treesitter folds for non-file buffers - if vim.bo[buf].buftype ~= "" then + -- don't use treesitter folds for terminal + if vim.bo[buf].buftype == "terminal" then return "0" end