From 1eda7c1d4df8cfc7aabd1d62a3eaf32566dbb3a6 Mon Sep 17 00:00:00 2001 From: asyncedd Date: Sun, 12 May 2024 09:51:23 +0900 Subject: [PATCH 01/56] feat: use builtin commenting --- lazy-lock.json | 3 +- lua/plugins/specs/editor.lua | 68 ------------------------------------ lua/settings/keymap.lua | 5 --- 3 files changed, 1 insertion(+), 75 deletions(-) diff --git a/lazy-lock.json b/lazy-lock.json index 9f64824b..94474cc7 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -1,5 +1,4 @@ { - "Comment.nvim": { "branch": "master", "commit": "0236521ea582747b58869cb72f70ccfa967d2e89" }, "LuaSnip": { "branch": "master", "commit": "b152822e1a4bafb6bdf11a16cc26525cbd95ee00" }, "actions-preview.nvim": { "branch": "master", "commit": "ceb6e06d1c8c30d8ddfe3afb03cd2c47b08b2798" }, "base46": { "branch": "v2.5", "commit": "bcc9ed2e88ef55b7e9d50b2f80f6a2d4b8080b1d" }, @@ -19,6 +18,7 @@ "lazy.nvim": { "branch": "main", "commit": "d3974346b6cef2116c8e7b08423256a834cb7cbc" }, "mini.ai": { "branch": "main", "commit": "55e9b7217f29e62f734e239bfeed5731a065d801" }, "mini.clue": { "branch": "main", "commit": "bde26d6f142eee03ea63015e73b6ac984d49a382" }, + "mini.comment": { "branch": "main", "commit": "f9f1a646fd3d9df7397aa1b9550a875fe8189eb0" }, "mini.diff": { "branch": "main", "commit": "10cc9d370737b8b8c8d996fc537394635da0a4b1" }, "mini.files": { "branch": "main", "commit": "17684f78d0499f11e54fc980838cfef3cf5c7c72" }, "mini.indentscope": { "branch": "main", "commit": "a8274b6ea2d868198d27bd91a31ed5ea3a6a5744" }, @@ -34,7 +34,6 @@ "nvim-spectre": { "branch": "master", "commit": "4651801ba37a9407b7257287aec45b6653ffc5e9" }, "nvim-treesitter": { "branch": "master", "commit": "4e21361e15b1d4147830c5fe571556eb1b14e6f9" }, "nvim-treesitter-textobjects": { "branch": "master", "commit": "23b820146956b3b681c19e10d3a8bc0cbd9a1d4c" }, - "nvim-ts-context-commentstring": { "branch": "main", "commit": "a6382f744f584bbf71d0a563af789af7190aabda" }, "nvim-web-devicons": { "branch": "master", "commit": "475fbcfcb6ee7c35aa33a6b6207ebd4032791d87" }, "plenary.nvim": { "branch": "master", "commit": "08e301982b9a057110ede7a735dd1b5285eb341f" }, "smart-open.nvim": { "branch": "main", "commit": "028bb71d20e8212da3514bf6dabfb17038d81ee4" }, diff --git a/lua/plugins/specs/editor.lua b/lua/plugins/specs/editor.lua index 3dd6ea0b..f884cf0a 100644 --- a/lua/plugins/specs/editor.lua +++ b/lua/plugins/specs/editor.lua @@ -54,46 +54,9 @@ return { "?", }, }, - { - "numToStr/Comment.nvim", - opts = function() - return { - pre_hook = require("ts_context_commentstring.integrations.comment_nvim").create_pre_hook(), - } - end, - keys = { - { "gc", mode = { "x", "n" } }, - { "gb", mode = { "x", "n" } }, - }, - dependencies = { - { - "JoosepAlviste/nvim-ts-context-commentstring", - opts = { - context_commentstring = { - enable = true, - }, - }, - dependencies = { - "nvim-treesitter/nvim-treesitter", - }, - }, - }, - }, { "echasnovski/mini.diff", event = "User FilePost", - -- opts = { - -- signs = dots.UI.icons.Gitsigns, - -- on_attach = function() - -- local gs = require("gitsigns") - -- - -- local map = vim.keymap.set - -- - -- -- stylua: ignore start - -- map("n", "]h", gs.next_hunk, { desc = "Next Hunk" }) - -- map("n", "[h", gs.prev_hunk, { desc= "Prev Hunk" }) - -- end, - -- }, opts = { view = { style = "sign", @@ -115,37 +78,6 @@ return { { "gS", "lua require('treesj').toggle()", desc = "TreeSJ - toggle" }, }, }, - -- { - -- "kylechui/nvim-surround", - -- opts = { - -- keymaps = { - -- insert = "m", - -- insert_line = "M", - -- normal = "ms", - -- normal_cur = "mss", - -- normal_line = "mS", - -- normal_cur_line = "mSS", - -- visual = "M", - -- visual_line = "gM", - -- delete = "md", - -- change = "mc", - -- change_line = "mS", - -- }, - -- }, - -- keys = { - -- { "m", mode = "i" }, - -- { "M", mode = "i" }, - -- "ms", - -- "mss", - -- "mS", - -- "mSS", - -- { "M", mode = "x" }, - -- { "gM", mode = "x" }, - -- "md", - -- "mc", - -- "mS", - -- }, - -- }, { "echasnovski/mini.surround", opts = { diff --git a/lua/settings/keymap.lua b/lua/settings/keymap.lua index cc0d507b..a180b06d 100644 --- a/lua/settings/keymap.lua +++ b/lua/settings/keymap.lua @@ -64,11 +64,6 @@ map("n", "x", function() require("nvchad.tabufline").close_buffer() end, { desc = "Buffer Close" }) --- Comment -map("n", "/", function() - require("Comment.api").toggle.linewise.current() -end, { desc = "Comment Toggle" }) - for i = 1, 9, 1 do vim.keymap.set("n", string.format("", i), function() vim.api.nvim_set_current_buf(vim.t.bufs[i]) From 1bf959a400f16ce69690e7b8431a42d0747da84c Mon Sep 17 00:00:00 2001 From: asyncedd Date: Sun, 12 May 2024 10:02:20 +0900 Subject: [PATCH 02/56] feat: use mini.splitjoin instead of treesj --- lazy-lock.json | 2 +- lua/plugins/specs/editor.lua | 11 +++-------- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/lazy-lock.json b/lazy-lock.json index 94474cc7..558fa115 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -23,6 +23,7 @@ "mini.files": { "branch": "main", "commit": "17684f78d0499f11e54fc980838cfef3cf5c7c72" }, "mini.indentscope": { "branch": "main", "commit": "a8274b6ea2d868198d27bd91a31ed5ea3a6a5744" }, "mini.operators": { "branch": "main", "commit": "2edc808e32fbf3e0d4759bdef26a7a143a19f509" }, + "mini.splitjoin": { "branch": "main", "commit": "a6b043b4afb075058a8c49325ff22e07f0e96170" }, "mini.surround": { "branch": "main", "commit": "0f528eb2e1bab420c0569d9e52615144c51db920" }, "noice.nvim": { "branch": "main", "commit": "f4decbc7a80229ccc9f86026b74bdcf0c39e38a7" }, "nui.nvim": { "branch": "main", "commit": "274fa89a9b4bed746647c2917091902f882509ec" }, @@ -40,7 +41,6 @@ "sqlite.lua": { "branch": "master", "commit": "d0ffd703b56d090d213b497ed4eb840495f14a11" }, "telescope-fzy-native.nvim": { "branch": "master", "commit": "282f069504515eec762ab6d6c89903377252bf5b" }, "telescope.nvim": { "branch": "master", "commit": "fac83a556e7b710dc31433dec727361ca062dbe9" }, - "treesj": { "branch": "main", "commit": "e1e82ab4237619d342c7102c9f13d4b9833bfd39" }, "ui": { "branch": "v2.5", "commit": "9c16efc915346c7bde5288ad94f0ea40a7267d31" }, "ultimate-autopair.nvim": { "branch": "v0.6", "commit": "6ecf7461d44513af89f8257f057fcc99e9297612" }, "vscode-svelte-snippets": { "branch": "master", "commit": "564ac3300bfeda01ff0bf6b89152cef43f85a4ce" }, diff --git a/lua/plugins/specs/editor.lua b/lua/plugins/specs/editor.lua index f884cf0a..3165fafc 100644 --- a/lua/plugins/specs/editor.lua +++ b/lua/plugins/specs/editor.lua @@ -69,14 +69,9 @@ return { end, }, { - "Wansmer/treesj", - opts = { - use_default_keymaps = false, - max_join_length = 1000, - }, - keys = { - { "gS", "lua require('treesj').toggle()", desc = "TreeSJ - toggle" }, - }, + "echasnovski/mini.splitjoin", + opts = true, + keys = { "gS" }, }, { "echasnovski/mini.surround", From 6410bdf9ca7a97c19fc3fbc559fb6a8536126d58 Mon Sep 17 00:00:00 2001 From: asyncedd Date: Sun, 12 May 2024 10:06:22 +0900 Subject: [PATCH 03/56] feat(telescope): add buffer searching --- lua/plugins/specs/tools.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/lua/plugins/specs/tools.lua b/lua/plugins/specs/tools.lua index edf8462e..91cf81c0 100644 --- a/lua/plugins/specs/tools.lua +++ b/lua/plugins/specs/tools.lua @@ -65,6 +65,7 @@ return { "lua require('telescope').extensions.smart_open.smart_open({ cwd_only = true, filename_first = false })", desc = "telescope: find_files", }, + { "fb", "Telescope buffers" }, { "fg", "Telescope live_grep", desc = "telescope: live_grep" }, { "f;", "Telescope resume", desc = "telescope: resume" }, { "fx", "Telescope diagnostics", desc = "telescope: diagnostics" }, From 68f41403c2e98aaad781b1dc34df7dbd5679518a Mon Sep 17 00:00:00 2001 From: asyncedd Date: Sun, 12 May 2024 10:12:22 +0900 Subject: [PATCH 04/56] replace mini.indentscope's textobj w/ mini.extra --- lazy-lock.json | 2 +- lua/plugins/specs/editor.lua | 14 ++++++++++---- lua/plugins/specs/ui.lua | 10 ---------- 3 files changed, 11 insertions(+), 15 deletions(-) diff --git a/lazy-lock.json b/lazy-lock.json index 558fa115..c181568d 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -20,8 +20,8 @@ "mini.clue": { "branch": "main", "commit": "bde26d6f142eee03ea63015e73b6ac984d49a382" }, "mini.comment": { "branch": "main", "commit": "f9f1a646fd3d9df7397aa1b9550a875fe8189eb0" }, "mini.diff": { "branch": "main", "commit": "10cc9d370737b8b8c8d996fc537394635da0a4b1" }, + "mini.extra": { "branch": "main", "commit": "3157df3aaf38f5b040a56fd02c8efb05a043e5ae" }, "mini.files": { "branch": "main", "commit": "17684f78d0499f11e54fc980838cfef3cf5c7c72" }, - "mini.indentscope": { "branch": "main", "commit": "a8274b6ea2d868198d27bd91a31ed5ea3a6a5744" }, "mini.operators": { "branch": "main", "commit": "2edc808e32fbf3e0d4759bdef26a7a143a19f509" }, "mini.splitjoin": { "branch": "main", "commit": "a6b043b4afb075058a8c49325ff22e07f0e96170" }, "mini.surround": { "branch": "main", "commit": "0f528eb2e1bab420c0569d9e52615144c51db920" }, diff --git a/lua/plugins/specs/editor.lua b/lua/plugins/specs/editor.lua index 3165fafc..0ca52eef 100644 --- a/lua/plugins/specs/editor.lua +++ b/lua/plugins/specs/editor.lua @@ -105,18 +105,24 @@ return { "echasnovski/mini.ai", opts = function() local ai = require("mini.ai") + + local gen_ai_spec = require("mini.extra").gen_ai_spec return { n_lines = 500, custom_textobjects = { f = ai.gen_spec.treesitter({ a = "@function.outer", i = "@function.inner" }, {}), + i = gen_ai_spec.indent(), }, } end, dependencies = { - "nvim-treesitter/nvim-treesitter-textobjects", - init = function() - require("lazy.core.loader").disable_rtp_plugin("nvim-treesitter-textobjects") - end, + { + "nvim-treesitter/nvim-treesitter-textobjects", + init = function() + require("lazy.core.loader").disable_rtp_plugin("nvim-treesitter-textobjects") + end, + }, + { "echasnovski/mini.extra", opts = true }, }, keys = { { "i", mode = { "x", "o" } }, diff --git a/lua/plugins/specs/ui.lua b/lua/plugins/specs/ui.lua index 815d8ff9..a8897548 100644 --- a/lua/plugins/specs/ui.lua +++ b/lua/plugins/specs/ui.lua @@ -32,16 +32,6 @@ return { dofile(vim.g.base46_cache .. "blankline") end, }, - { - "echasnovski/mini.indentscope", - opts = { - symbol = "", - }, - keys = { - { "ai", mode = { "x", "o" } }, - { "ii", mode = { "x", "o" } }, - }, - }, { "nvim-tree/nvim-web-devicons", opts = function() From 31524622a9e8d83b04276f9d10cff311fe94cfc7 Mon Sep 17 00:00:00 2001 From: asyncedd Date: Sun, 12 May 2024 10:15:40 +0900 Subject: [PATCH 05/56] rm cutlass.nvim idk y i added it in the first place --- lua/plugins/specs/editor.lua | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/lua/plugins/specs/editor.lua b/lua/plugins/specs/editor.lua index 0ca52eef..4c05ea23 100644 --- a/lua/plugins/specs/editor.lua +++ b/lua/plugins/specs/editor.lua @@ -170,18 +170,4 @@ return { { "=P", "(YankyPutBeforeFilter)", desc = "Put before applying a filter" }, }, }, - { - "gbprod/cutlass.nvim", - opts = { - exclude = { "ns", "nS", "or", "oR", "xR" }, - }, - keys = { - { "c", mode = { "n", "x", "o" } }, - { "C", mode = { "n", "x", "o" } }, - { "d", mode = { "n", "x", "o" } }, - { "D", mode = { "n", "x", "o" } }, - "x", - "X", - }, - }, } From dd61f76348182c5998287b39a7e20e190f2097b7 Mon Sep 17 00:00:00 2001 From: asyncedd Date: Sun, 12 May 2024 11:32:27 +0900 Subject: [PATCH 06/56] feat: add mini.move --- lazy-lock.json | 2 +- lua/plugins/specs/editor.lua | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/lazy-lock.json b/lazy-lock.json index c181568d..250d27a0 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -9,7 +9,6 @@ "cmp_luasnip": { "branch": "master", "commit": "05a9ab28b53f71d1aece421ef32fee2cb857a843" }, "conform.nvim": { "branch": "master", "commit": "12b3995537f52ba2810a9857e8ca256881febbda" }, "crates.nvim": { "branch": "main", "commit": "f00e11e8282b94f2a2e938d32712c99f0e0bdeb4" }, - "cutlass.nvim": { "branch": "main", "commit": "1ac7e4b53d79410be52a9e464d44c60556282b3e" }, "dressing.nvim": { "branch": "master", "commit": "5162edb1442a729a885c45455a07e9a89058be2f" }, "flash.nvim": { "branch": "main", "commit": "7bb4a9c75d1e20cd24185afedeaa11681829ba23" }, "friendly-snippets": { "branch": "main", "commit": "fa36367422da5a38560892e3db6d090a635d9d41" }, @@ -22,6 +21,7 @@ "mini.diff": { "branch": "main", "commit": "10cc9d370737b8b8c8d996fc537394635da0a4b1" }, "mini.extra": { "branch": "main", "commit": "3157df3aaf38f5b040a56fd02c8efb05a043e5ae" }, "mini.files": { "branch": "main", "commit": "17684f78d0499f11e54fc980838cfef3cf5c7c72" }, + "mini.move": { "branch": "main", "commit": "251d541a8ab745e81295a53c128829cb2bff18e3" }, "mini.operators": { "branch": "main", "commit": "2edc808e32fbf3e0d4759bdef26a7a143a19f509" }, "mini.splitjoin": { "branch": "main", "commit": "a6b043b4afb075058a8c49325ff22e07f0e96170" }, "mini.surround": { "branch": "main", "commit": "0f528eb2e1bab420c0569d9e52615144c51db920" }, diff --git a/lua/plugins/specs/editor.lua b/lua/plugins/specs/editor.lua index 4c05ea23..8dfc660f 100644 --- a/lua/plugins/specs/editor.lua +++ b/lua/plugins/specs/editor.lua @@ -170,4 +170,26 @@ return { { "=P", "(YankyPutBeforeFilter)", desc = "Put before applying a filter" }, }, }, + { + "echasnovski/mini.move", + opts = true, + keys = { + { + "", + mode = { "n", "x" }, + }, + { + "", + mode = { "n", "x" }, + }, + { + "", + mode = { "n", "x" }, + }, + { + "", + mode = { "n", "x" }, + }, + }, + }, } From 1e55d8b385127e33bc46c9d8898a9a308d9f82b9 Mon Sep 17 00:00:00 2001 From: asyncedd Date: Sun, 12 May 2024 11:52:11 +0900 Subject: [PATCH 07/56] feat: use mini.visit instead of grapple.nvim --- lazy-lock.json | 3 +-- lua/plugins/specs/tools.lua | 33 ++++++--------------------------- 2 files changed, 7 insertions(+), 29 deletions(-) diff --git a/lazy-lock.json b/lazy-lock.json index 250d27a0..d009d0e5 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -12,12 +12,10 @@ "dressing.nvim": { "branch": "master", "commit": "5162edb1442a729a885c45455a07e9a89058be2f" }, "flash.nvim": { "branch": "main", "commit": "7bb4a9c75d1e20cd24185afedeaa11681829ba23" }, "friendly-snippets": { "branch": "main", "commit": "fa36367422da5a38560892e3db6d090a635d9d41" }, - "grapple.nvim": { "branch": "main", "commit": "493f174a1ace3f2d55ba2191129e43b3875b9124" }, "indent-blankline.nvim": { "branch": "master", "commit": "3d08501caef2329aba5121b753e903904088f7e6" }, "lazy.nvim": { "branch": "main", "commit": "d3974346b6cef2116c8e7b08423256a834cb7cbc" }, "mini.ai": { "branch": "main", "commit": "55e9b7217f29e62f734e239bfeed5731a065d801" }, "mini.clue": { "branch": "main", "commit": "bde26d6f142eee03ea63015e73b6ac984d49a382" }, - "mini.comment": { "branch": "main", "commit": "f9f1a646fd3d9df7397aa1b9550a875fe8189eb0" }, "mini.diff": { "branch": "main", "commit": "10cc9d370737b8b8c8d996fc537394635da0a4b1" }, "mini.extra": { "branch": "main", "commit": "3157df3aaf38f5b040a56fd02c8efb05a043e5ae" }, "mini.files": { "branch": "main", "commit": "17684f78d0499f11e54fc980838cfef3cf5c7c72" }, @@ -25,6 +23,7 @@ "mini.operators": { "branch": "main", "commit": "2edc808e32fbf3e0d4759bdef26a7a143a19f509" }, "mini.splitjoin": { "branch": "main", "commit": "a6b043b4afb075058a8c49325ff22e07f0e96170" }, "mini.surround": { "branch": "main", "commit": "0f528eb2e1bab420c0569d9e52615144c51db920" }, + "mini.visits": { "branch": "main", "commit": "17bbec0e1669e4b91c1a50bbf56dc94d6f4873e8" }, "noice.nvim": { "branch": "main", "commit": "f4decbc7a80229ccc9f86026b74bdcf0c39e38a7" }, "nui.nvim": { "branch": "main", "commit": "274fa89a9b4bed746647c2917091902f882509ec" }, "nvim-cmp": { "branch": "main", "commit": "8f3c541407e691af6163e2447f3af1bd6e17f9a3" }, diff --git a/lua/plugins/specs/tools.lua b/lua/plugins/specs/tools.lua index 91cf81c0..bd3f0cfc 100644 --- a/lua/plugins/specs/tools.lua +++ b/lua/plugins/specs/tools.lua @@ -136,36 +136,15 @@ return { end, }, { - "cbochs/grapple.nvim", - opts = { - win_opts = { - border = "solid", - }, - }, + "echasnovski/mini.visits", + opts = true, keys = { { - "ga", - "Grapple toggle", - desc = "Grapple: Toggle", - }, - { - "gt", - "Grapple open_tags", - desc = "Grapple: Open Tags", - }, - { - "gs", - "Grapple open_scopes", - desc = "Grapple: Open scopes", - }, - { - "gl", - "Grapple open_loaded", - desc = "Grapple: Open loaded", + "pp", + function() + require("mini.visits").select_path() + end, }, }, - cmd = { - "Grapple", - }, }, } From 76ca1c495fd1fd68a49ae5f6f888603171c36418 Mon Sep 17 00:00:00 2001 From: asyncedd Date: Mon, 13 May 2024 15:00:43 +0900 Subject: [PATCH 08/56] feat: give telescope buffers desc --- lua/plugins/specs/tools.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/plugins/specs/tools.lua b/lua/plugins/specs/tools.lua index bd3f0cfc..c65d2301 100644 --- a/lua/plugins/specs/tools.lua +++ b/lua/plugins/specs/tools.lua @@ -65,7 +65,7 @@ return { "lua require('telescope').extensions.smart_open.smart_open({ cwd_only = true, filename_first = false })", desc = "telescope: find_files", }, - { "fb", "Telescope buffers" }, + { "fb", "Telescope buffers", desc = "telescope: buffers" }, { "fg", "Telescope live_grep", desc = "telescope: live_grep" }, { "f;", "Telescope resume", desc = "telescope: resume" }, { "fx", "Telescope diagnostics", desc = "telescope: diagnostics" }, From 8010d7335bc9c7d862461b6355ba4b92c3859e11 Mon Sep 17 00:00:00 2001 From: asyncedd Date: Thu, 16 May 2024 10:21:50 +0900 Subject: [PATCH 09/56] rm unneeded mods --- lua/asyncedd/cowboy.lua | 37 ---- lua/utils/intro.lua | 456 ---------------------------------------- 2 files changed, 493 deletions(-) delete mode 100644 lua/asyncedd/cowboy.lua delete mode 100644 lua/utils/intro.lua diff --git a/lua/asyncedd/cowboy.lua b/lua/asyncedd/cowboy.lua deleted file mode 100644 index fcd23732..00000000 --- a/lua/asyncedd/cowboy.lua +++ /dev/null @@ -1,37 +0,0 @@ -return function() - ---@type table? - local id - local ok = true - for _, key in ipairs({ "h", "j", "k", "l", "+", "-" }) do - local count = 0 - local timer = assert(vim.loop.new_timer()) - local map = key - vim.keymap.set("n", key, function() - if vim.v.count > 0 then - count = 0 - end - if key == "j" or key == "k" then - map = vim.v.count == 0 and "g" .. key or key - end - if count >= 10 then - ok, id = pcall(vim.notify, "Hold it Cowboy!", vim.log.levels.WARN, { - icon = "🤠", - replace = id, - keep = function() - return count >= 10 - end, - }) - if not ok then - id = nil - return map - end - else - count = count + 1 - timer:start(2000, 0, function() - count = 0 - end) - return map - end - end, { expr = true, silent = true }) - end -end diff --git a/lua/utils/intro.lua b/lua/utils/intro.lua deleted file mode 100644 index 5c7d5af0..00000000 --- a/lua/utils/intro.lua +++ /dev/null @@ -1,456 +0,0 @@ --- Credits 2 https://gist.github.com/GnikDroy/62556534324f9dc9192f7bba5a88cc43 - -if vim.fn.argc() ~= 0 or #vim.api.nvim_list_wins() ~= 1 then - return -end -vim.opt.shortmess:remove("I") -- Enable default startscreen -local WIDTH = vim.api.nvim_win_get_width(0) -local HEIGHT = vim.api.nvim_win_get_height(0) -if WIDTH < 120 or HEIGHT < 40 then - return -end -- Bail if screen space is at a premium - -vim.api.nvim_set_hl(0, "NvimGreen", { fg = 7054142, default = true }) -vim.api.nvim_set_hl(0, "NvimBlue", { fg = 3054811, default = true }) - -local function shuffle(tbl) - for i = #tbl, 2, -1 do - local j = math.random(i) - tbl[i], tbl[j] = tbl[j], tbl[i] - end - return tbl -end - -local function get_highlight_range(line, pattern) - local results = {} - local start = 1 - while start <= #line do - local s, e = string.find(line, pattern, start) - if e == nil then - return results - end - table.insert(results, { s, e }) - start = e + 1 - end - return results -end - ----@class EphemeralWidget ----@field opts EphemeralWidgetOpts ----@field win number? ----@field buf number? -local EphemeralWidget = {} -EphemeralWidget.__index = EphemeralWidget - ----@class EphemeralWidgetOpts ----@field label string ----@field win_opts table? ----@field lines string[] ----@field highlights table - --- Constructor ----@param opts EphemeralWidgetOpts ----@return EphemeralWidget ----@nodiscard -function EphemeralWidget.new(opts) - local widget = setmetatable({}, EphemeralWidget) - widget.opts = opts - return widget -end - -function EphemeralWidget:render() - local buf = vim.api.nvim_create_buf(false, true) - local win = vim.api.nvim_open_win(buf, false, self.opts.win_opts) - self.buf = buf - self.win = win - vim.wo[win].winhl = "Normal:NONE,EndOfBuffer:NONE" - vim.wo[win].foldenable = false - - vim.api.nvim_buf_set_lines(buf, 0, -1, true, self.opts.lines) - - local ns = vim.api.nvim_create_namespace(self.opts.label) - - for col, line in ipairs(self.opts.lines) do - for _, pattern_hl_pair in ipairs(self.opts.highlights) do - for _, range in ipairs(get_highlight_range(line, pattern_hl_pair[1])) do - vim.api.nvim_buf_add_highlight(buf, ns, pattern_hl_pair[2], col - 1, range[1] - 1, range[2]) - end - end - end - - local augroup = vim.api.nvim_create_augroup(self.opts.label, {}) - - local function cleanup() - if vim.api.nvim_win_is_valid(win) then - vim.api.nvim_win_close(win, true) - end - if vim.api.nvim_buf_is_valid(buf) then - vim.api.nvim_buf_clear_namespace(buf, ns, 0, -1) - vim.api.nvim_buf_delete(buf, { force = true }) - end - vim.on_key(nil, ns) - vim.api.nvim_clear_autocmds({ group = self.opts.label }) - vim.api.nvim_del_augroup_by_id(augroup) - end - - vim.on_key(cleanup, ns) - vim.api.nvim_create_autocmd("VimResized", { group = augroup, callback = cleanup }) -end - -local intro_fmt = [[ -NVIM v%s - -Nvim is open source and freely distributable -https://neovim.io/#chat - -type :help nvim if you are new! -type :checkhealth to optimize Nvim -type :q to exit -type :help for help - -type :help news to see changes in v%s - -Become a registered Vim user! -type :help register for information]] - -local ver = vim.version() - -local ver_str_min = string.format("%d.%d", ver.major, ver.minor) -local intro = vim.split(string.format(intro_fmt, tostring(ver), ver_str_min), "\n") - -local intro_win_width = vim.iter(intro):fold(0, function(acc, line) - return math.max(acc, #line) -end) -intro = vim - .iter(intro) - :map(function(line) - return string.rep(" ", math.ceil((intro_win_width - #line) / 2)) .. line - end) - :totable() -- Center all lines - -EphemeralWidget.new({ - label = "intro", - lines = intro, - win_opts = { - relative = "win", - zindex = 25, - focusable = false, - style = "minimal", - col = (WIDTH - intro_win_width) * 0.5, - row = (HEIGHT - #intro) * 0.5, - width = intro_win_width, - height = #intro, - }, - highlights = { - { "NVIM", "NvimGreen" }, - { "v[0-9]+[0-9.a-zA-z-+]+", "NvimGreen" }, - { "https://neovim.io/#chat", "Underlined" }, - { ":%a+", "NvimBlue" }, - { "<.*>", "NvimGreen" }, - { "if you are new!", "DiagnosticOk" }, - { "to exit", "DiagnosticError" }, - }, -}):render() - -local sysinfo_fmt = [[ -SYSTEM INFO -Hostname │ %s -OS │ %s %s -Memory │ %d Gib -Processor │ %s]] -local hostname = vim.uv.os_gethostname() -local os_ = vim.uv.os_uname() -local mem_gigs = vim.uv.get_total_memory() / 1024 / 1024 / 1024 -local cpu_info = vim.uv.cpu_info() - -local sysinfo = - vim.split(string.format(sysinfo_fmt, hostname, os_.machine, os_.sysname, mem_gigs, cpu_info[1].model), "\n") - -local sysinfo_win_width = vim.iter(sysinfo):fold(0, function(acc, line) - return math.max(acc, vim.api.nvim_strwidth(line)) -end) - -EphemeralWidget.new({ - label = "sysinfo", - lines = sysinfo, - win_opts = { - relative = "win", - zindex = 25, - focusable = false, - style = "minimal", - width = sysinfo_win_width, - height = #sysinfo, - anchor = "SW", - row = HEIGHT - 1, - col = 1, - }, - highlights = { - { "^.*$", "LineNr" }, - { "^SYSTEM INFO$", "NvimGreen" }, - { "^.*│", "NvimBlue" }, - }, -}):render() - -local function parse_keywords_in_section(lines) - local keywords = {} - for _, line in ipairs(lines) do - for w in string.gmatch(line, "|(%S+%(%))|") do - if #w > 40 then -- truncate long function names - w = w:sub(1, 40) .. ".." - end - keywords[#keywords + 1] = w - end - -- You can parse other stuff like option values enclosed in '' - -- I don't care enough to do this - end - return shuffle(keywords) -- Shuffle here to avoid same news sections -end - -local function parse_news() - local lines = {} - for line in io.lines(vim.env.VIMRUNTIME .. "/doc/news.txt") do - lines[#lines + 1] = line - end - - -- Don't want to write a parser for news - -- Perhaps I can do this with treesitter later? - local section_labels = { - "BREAKING CHANGES", - "NEW FEATURES", - "CHANGED FEATURES", - "REMOVED FEATURES", - "DEPRECATIONS", - } - local sections = {} - local current_section = nil - for _, line in ipairs(lines) do - if string.find(line, string.rep("=", 10)) ~= nil then - current_section = nil - end - if current_section ~= nil then - if sections[current_section] == nil then - sections[current_section] = {} - end - table.insert(sections[current_section], line) - end - for _, label in ipairs(section_labels) do - if string.find(line, label) ~= nil then - current_section = label - end - end - end - return sections -end - -local news_fmt = [[ -WHAT'S NEW IN v%s? - -New Features -%s - -Breaking changes -%s - -Deprecations -%s]] - -local keywords = {} -for section, lines in pairs(parse_news()) do - keywords[section] = vim.iter(parse_keywords_in_section(lines)):take(7):totable() -end - -local news = vim.split( - string.format( - news_fmt, - ver_str_min, - table.concat(keywords["NEW FEATURES"], "\n"), - table.concat(keywords["BREAKING CHANGES"], "\n"), - table.concat(keywords["DEPRECATIONS"], "\n") - ), - "\n" -) - -local news_win_width = vim.iter(news):fold(0, function(acc, line) - return math.max(acc, vim.api.nvim_strwidth(line)) -end) - -EphemeralWidget.new({ - label = "news", - lines = news, - win_opts = { - relative = "win", - zindex = 25, - focusable = false, - style = "minimal", - width = news_win_width, - height = HEIGHT - 7, - anchor = "NW", - row = 1, - col = 2, - }, - highlights = { - { "^.*$", "LineNr" }, - { "^WHAT'S NEW IN.*$", "NvimGreen" }, - { "^New Features$", "DiagnosticOk" }, - { "^Breaking changes$", "DiagnosticWarn" }, - { "^Deprecations$", "DiagnosticError" }, - }, -}):render() - -local keyboard_fmt = [[ - Keyboard ❤️ Neovim -╭───┬───┬───┬───┬───┬───┬───┬───┬───┬───╮ -│ Q │ W │ E │ R │ T │ Y │ U │ I │ O │ P │ -╰┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴╮ - │ A │ S │ D │ F │ G │ ← │ ↓ │ ↑ │ → │ ; │ - ╰┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──╯ - │ Z │ X │ C │  │ B │  │ M │ < │ > │ - ╰───┴───┴───┴───┴───┴───┴───╯───┴───╯]] - -local keyboard = vim.split(keyboard_fmt, "\n") - -local keyboard_win_width = vim.iter(keyboard):fold(0, function(acc, line) - return math.max(acc, vim.api.nvim_strwidth(line)) -end) - -local keyboard_widget = EphemeralWidget.new({ - label = "keyboard", - lines = keyboard, - win_opts = { - relative = "win", - style = "minimal", - zindex = 25, - focusable = false, - width = keyboard_win_width, - height = #keyboard, - anchor = "SE", - row = HEIGHT - 1, - col = WIDTH - 1, - }, - highlights = { - { "^.*$", "LineNr" }, - { "[A-Z;<>]", "NvimBlue" }, - { "", "NvimGreen" }, - { "", "NvimGreen" }, - { "←", "NvimGreen" }, - { "↑", "NvimGreen" }, - { "↓", "NvimGreen" }, - { "→", "NvimGreen" }, - { "Neo", "NvimGreen" }, - { "vim", "NvimBlue" }, - { "b", "NvimGreen" }, - }, -}) - -keyboard_widget:render() -vim.wo[keyboard_widget.win].winblend = 50 - -local tools_fmt = [[ -CLI & TOOLCHAINS - -C compiler │ %s - git │ %s - node │ %s - ripgrep │ %s - fd │ %s -]] - -local compiler_present = vim.iter({ "cc", "gcc", "clang", "cl", "zig" }):fold(false, function(acc, exe) - return vim.fn.executable(exe) == 1 or acc -end) -local tools = vim.split( - string.format( - tools_fmt, - compiler_present and "" or "󰅙", - vim.fn.executable("git") == 1 and "" or "󰅙", - vim.fn.executable("node") == 1 and "" or "󰅙", - vim.fn.executable("rg") == 1 and "" or "󰅙", - vim.fn.executable("fd") == 1 and "" or "󰅙" - ), - "\n" -) - -local tools_win_width = vim.iter(tools):fold(0, function(acc, line) - return math.max(acc, vim.api.nvim_strwidth(line)) -end) - -EphemeralWidget.new({ - label = "tools", - lines = tools, - win_opts = { - relative = "win", - style = "minimal", - zindex = 25, - focusable = false, - width = tools_win_width, - height = #tools, - anchor = "NE", - row = 2, - col = WIDTH - 1, - }, - highlights = { - { "^.*$", "LineNr" }, - { "CLI & TOOLCHAINS", "NvimBlue" }, - { "│ $", "DiagnosticOk" }, - { "│ 󰅙$", "DiagnosticError" }, - }, -}):render() - -local features_fmt = [[ - TREESITTER & PLUGINS - - Treesitter ABI │ %d - Scripts Loaded │ %d - - - - - VIM OPTIONS - - mapleader │ [%s] - vim.opt.backup │ %s -vim.opt.swapfile │ %s -vim.opt.autoread │ %s -]] - -local features = vim.split( - string.format( - features_fmt, - vim.treesitter.language_version, - #vim.fn.getscriptinfo(), - vim.g.mapleader, -- keytrans looks ugly - vim.o.backup and "" or "󰅙", - vim.o.swapfile and "" or "󰅙", - vim.o.autoread and "" or "󰅙" - ), - "\n" -) - -local features_win_width = vim.iter(features):fold(0, function(acc, line) - return math.max(acc, vim.api.nvim_strwidth(line)) -end) - -EphemeralWidget.new({ - label = "features", - lines = features, - win_opts = { - relative = "win", - style = "minimal", - zindex = 25, - focusable = false, - width = features_win_width, - height = #features, - anchor = "NE", - row = math.floor((HEIGHT - #features) / 2), - col = WIDTH - 1, - }, - highlights = { - { "^.*$", "LineNr" }, - { "│ %d+", "DiagnosticWarn" }, - { "│ %[.*$", "DiagnosticWarn" }, - { "│%s+$", "DiagnosticOk" }, - { "│%s+󰅙$", "DiagnosticError" }, - { "TREESITTER & PLUGINS", "NvimBlue" }, - { "VIM OPTIONS", "NvimBlue" }, - }, -}):render() From 03027b5961d55bb8bf3c0233a4bb86cc6013998c Mon Sep 17 00:00:00 2001 From: asyncedd Date: Thu, 16 May 2024 10:44:41 +0900 Subject: [PATCH 10/56] perf: use lazyvim's layfile instead of nvchad's --- lua/plugins/init.lua | 6 ++++++ lua/plugins/specs/editor.lua | 4 ++-- lua/plugins/specs/lsp.lua | 2 +- lua/plugins/specs/ui.lua | 2 +- lua/settings/autocmd.lua | 36 +++++++++++++++++++++--------------- 5 files changed, 31 insertions(+), 19 deletions(-) diff --git a/lua/plugins/init.lua b/lua/plugins/init.lua index 8fab385e..2c1c5ce6 100644 --- a/lua/plugins/init.lua +++ b/lua/plugins/init.lua @@ -11,6 +11,12 @@ if not vim.loop.fs_stat(lazypath) then end vim.opt.rtp:prepend(lazypath) +-- Add support for the LazyFile event +local Event = require("lazy.core.handler.event") + +Event.mappings.LazyFile = { id = "LazyFile", event = { "BufReadPost", "BufNewFile", "BufWritePre" } } +Event.mappings["LazyFile"] = Event.mappings.LazyFile + require("lazy").setup({ { import = "plugins.specs" }, dots.languages.enable, diff --git a/lua/plugins/specs/editor.lua b/lua/plugins/specs/editor.lua index 8dfc660f..50b8065f 100644 --- a/lua/plugins/specs/editor.lua +++ b/lua/plugins/specs/editor.lua @@ -18,7 +18,7 @@ return { require("nvim-treesitter.configs").setup(opts) end, priority = 1000, - event = { "BufReadPost", "User FilePost" }, + event = "LazyFile", }, { "folke/flash.nvim", @@ -56,7 +56,7 @@ return { }, { "echasnovski/mini.diff", - event = "User FilePost", + event = "LazyFile", opts = { view = { style = "sign", diff --git a/lua/plugins/specs/lsp.lua b/lua/plugins/specs/lsp.lua index b667de95..2f1e3d21 100644 --- a/lua/plugins/specs/lsp.lua +++ b/lua/plugins/specs/lsp.lua @@ -1,7 +1,7 @@ return { { "neovim/nvim-lspconfig", - event = "User FilePost", + event = "LazyFile", config = function(_, opts) dofile(vim.g.base46_cache .. "lsp") local inlay_hint = vim.lsp.buf.inlay_hint or vim.lsp.inlay_hint diff --git a/lua/plugins/specs/ui.lua b/lua/plugins/specs/ui.lua index a8897548..c5d034f9 100644 --- a/lua/plugins/specs/ui.lua +++ b/lua/plugins/specs/ui.lua @@ -17,7 +17,7 @@ return { }, { "lukas-reineke/indent-blankline.nvim", - event = "User FilePost", + event = "LazyFile", opts = { indent = { highlight = "IblChar" }, scope = { highlight = "IblScopeChar" }, diff --git a/lua/settings/autocmd.lua b/lua/settings/autocmd.lua index 916d8591..dcf25189 100644 --- a/lua/settings/autocmd.lua +++ b/lua/settings/autocmd.lua @@ -38,27 +38,33 @@ autocmd({ "BufWritePre" }, { end, }) --- thx to nvchad --- user event that loads after UIEnter + only if file buf is there -vim.api.nvim_create_autocmd({ "UIEnter", "BufReadPost", "BufNewFile" }, { - group = vim.api.nvim_create_augroup("DotsFilePost", { clear = true }), - callback = function(args) - local file = vim.api.nvim_buf_get_name(args.buf) - local buftype = vim.api.nvim_get_option_value("buftype", { buf = args.buf }) - - if not vim.g.ui_entered and args.event == "UIEnter" then - vim.g.ui_entered = true +-- This autocmd will only trigger when a file was loaded from the cmdline. +-- It will render the file as quickly as possible. +vim.api.nvim_create_autocmd("BufReadPost", { + once = true, + callback = function(event) + -- Skip if we already entered vim + if vim.v.vim_did_enter == 1 then + return end - if file ~= "" and buftype ~= "nofile" and vim.g.ui_entered then - vim.api.nvim_exec_autocmds("User", { pattern = "FilePost", modeline = false }) - vim.api.nvim_del_augroup_by_name("DotsFilePost") + -- Try to guess the filetype (may change later on during Neovim startup) + local ft = vim.filetype.match({ buf = event.buf }) + if ft then + -- Add treesitter highlights and fallback to syntax + local lang = vim.treesitter.language.get_lang(ft) + if not (lang and pcall(vim.treesitter.start, event.buf, lang)) then + vim.bo[event.buf].syntax = ft + end + + -- Trigger early redraw + vim.cmd([[redraw]]) vim.schedule(function() vim.api.nvim_exec_autocmds("FileType", {}) if vim.g.editorconfig then - require("editorconfig").config(args.buf) + require("editorconfig").config(event.buf) end end) end @@ -97,6 +103,6 @@ autocmd("BufWritePost", { end require("base46").load_all_highlights() - -- vim.cmd("redraw!") + vim.cmd("redraw!") end, }) From 95ce485c3490bbcf0ee7870651388a25e7e0e2da Mon Sep 17 00:00:00 2001 From: asyncedd Date: Thu, 16 May 2024 10:57:28 +0900 Subject: [PATCH 11/56] perf: use lazyvim optimizations for nvim-treesitter put mini.extras as a dependency of nvim-treesitter-textobjects --- lua/plugins/specs/editor.lua | 33 ++++++++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/lua/plugins/specs/editor.lua b/lua/plugins/specs/editor.lua index 50b8065f..937a71bc 100644 --- a/lua/plugins/specs/editor.lua +++ b/lua/plugins/specs/editor.lua @@ -11,13 +11,37 @@ return { enable = true, }, }, + lazy = vim.fn.argc(-1) == 0, -- load treesitter early when opening a file from the cmdline + init = function(plugin) + -- PERF: add nvim-treesitter queries to the rtp and it's custom query predicates early + -- This is needed because a bunch of plugins no longer `require("nvim-treesitter")`, which + -- no longer trigger the **nvim-treesitter** module to be loaded in time. + -- Luckily, the only things that those plugins need are the custom queries, which we make available + -- during startup. + require("lazy.core.loader").add_to_rtp(plugin) + require("nvim-treesitter.query_predicates") + end, + build = ":TSUpdate", config = function(_, opts) dofile(vim.g.base46_cache .. "syntax") dofile(vim.g.base46_cache .. "treesitter") + if type(opts.ensure_installed) == "table" then + ---@type table + local added = {} + opts.ensure_installed = vim.tbl_filter(function(lang) + if added[lang] then + return false + end + added[lang] = true + return true + end, opts.ensure_installed) + end require("nvim-treesitter.configs").setup(opts) + vim.schedule(function() + require("lazy").load({ plugins = { "nvim-treesitter-textobjects" } }) + end) end, - priority = 1000, event = "LazyFile", }, { @@ -118,11 +142,10 @@ return { dependencies = { { "nvim-treesitter/nvim-treesitter-textobjects", - init = function() - require("lazy.core.loader").disable_rtp_plugin("nvim-treesitter-textobjects") - end, + dependencies = { + { "echasnovski/mini.extra", opts = true }, + }, }, - { "echasnovski/mini.extra", opts = true }, }, keys = { { "i", mode = { "x", "o" } }, From 562dcaf83406c131df1c18ba4d6af73354d020aa Mon Sep 17 00:00:00 2001 From: asyncedd Date: Thu, 16 May 2024 11:09:53 +0900 Subject: [PATCH 12/56] fix: rm code actions --- lua/plugins/specs/lsp.lua | 24 ------------------------ 1 file changed, 24 deletions(-) diff --git a/lua/plugins/specs/lsp.lua b/lua/plugins/specs/lsp.lua index 2f1e3d21..ecd298bd 100644 --- a/lua/plugins/specs/lsp.lua +++ b/lua/plugins/specs/lsp.lua @@ -141,28 +141,4 @@ return { end, event = "LspAttach", }, - { - "aznhe21/actions-preview.nvim", - opts = function() - return { - diff = { - algorithm = "histogram", - }, - telescope = require("telescope.themes").get_cursor(), - } - end, - keys = { - { "ca", 'lua require("actions-preview").code_actions()', desc = "Code action: open menu" }, - }, - }, - { - "kosayoda/nvim-lightbulb", - opts = { - priority = 40, - autocmd = { - enabled = true, - }, - }, - event = "LspAttach", - }, } From ba53f4f1c47e1eb99b299f19c3878d83c9db4f54 Mon Sep 17 00:00:00 2001 From: asyncedd Date: Thu, 16 May 2024 11:10:04 +0900 Subject: [PATCH 13/56] feat: add folding --- lua/settings/options.lua | 17 +++- lua/utils/ui.lua | 211 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 225 insertions(+), 3 deletions(-) create mode 100644 lua/utils/ui.lua diff --git a/lua/settings/options.lua b/lua/settings/options.lua index 3c5c82de..3dd9f949 100644 --- a/lua/settings/options.lua +++ b/lua/settings/options.lua @@ -35,10 +35,21 @@ o.laststatus = 3 -- Folds -o.foldcolumn = "1" +o.fillchars = { + foldopen = "", + foldclose = "", + fold = " ", + foldsep = " ", + diff = "╱", + eob = " ", +} o.foldlevel = 99 -o.foldlevelstart = 99 -o.foldenable = true + +o.foldmethod = "expr" +o.foldexpr = "v:lua.require'utils.ui'.foldexpr()" +o.foldtext = "" +o.fillchars = "fold: " +o.statuscolumn = [[%!v:lua.require'utils.ui'.statuscolumn()]] -- Scrolloff diff --git a/lua/utils/ui.lua b/lua/utils/ui.lua new file mode 100644 index 00000000..91339ca7 --- /dev/null +++ b/lua/utils/ui.lua @@ -0,0 +1,211 @@ +---@class lazyvim.util.ui +local M = {} + +---@alias Sign {name:string, text:string, texthl:string, priority:number} + +-- Returns a list of regular and extmark signs sorted by priority (low to high) +---@return Sign[] +---@param buf number +---@param lnum number +function M.get_signs(buf, lnum) + -- Get regular signs + ---@type Sign[] + local signs = {} + + if vim.fn.has("nvim-0.10") == 0 then + -- Only needed for Neovim <0.10 + -- Newer versions include legacy signs in nvim_buf_get_extmarks + for _, sign in ipairs(vim.fn.sign_getplaced(buf, { group = "*", lnum = lnum })[1].signs) do + local ret = vim.fn.sign_getdefined(sign.name)[1] --[[@as Sign]] + if ret then + ret.priority = sign.priority + signs[#signs + 1] = ret + end + end + end + + -- Get extmark signs + local extmarks = vim.api.nvim_buf_get_extmarks( + buf, + -1, + { lnum - 1, 0 }, + { lnum - 1, -1 }, + { details = true, type = "sign" } + ) + for _, extmark in pairs(extmarks) do + signs[#signs + 1] = { + name = extmark[4].sign_hl_group or "", + text = extmark[4].sign_text, + texthl = extmark[4].sign_hl_group, + priority = extmark[4].priority, + } + end + + -- Sort by priority + table.sort(signs, function(a, b) + return (a.priority or 0) < (b.priority or 0) + end) + + return signs +end + +---@return Sign? +---@param buf number +---@param lnum number +function M.get_mark(buf, lnum) + local marks = vim.fn.getmarklist(buf) + vim.list_extend(marks, vim.fn.getmarklist()) + for _, mark in ipairs(marks) do + if mark.pos[1] == buf and mark.pos[2] == lnum and mark.mark:match("[a-zA-Z]") then + return { text = mark.mark:sub(2), texthl = "DiagnosticHint" } + end + end +end + +---@param sign? Sign +---@param len? number +function M.icon(sign, len) + sign = sign or {} + len = len or 2 + local text = vim.fn.strcharpart(sign.text or "", 0, len) ---@type string + text = text .. string.rep(" ", len - vim.fn.strchars(text)) + return sign.texthl and ("%#" .. sign.texthl .. "#" .. text .. "%*") or text +end + +function M.foldtext() + local ok = pcall(vim.treesitter.get_parser, vim.api.nvim_get_current_buf()) + local ret = ok and vim.treesitter.foldtext and vim.treesitter.foldtext() + if not ret or type(ret) == "string" then + ret = { { vim.api.nvim_buf_get_lines(0, vim.v.lnum - 1, vim.v.lnum, false)[1], {} } } + end + table.insert(ret, { " " .. require("lazyvim.config").icons.misc.dots }) + + if not vim.treesitter.foldtext then + return table.concat( + vim.tbl_map(function(line) + return line[1] + end, ret), + " " + ) + end + return ret +end + +function M.statuscolumn() + local win = vim.g.statusline_winid + local buf = vim.api.nvim_win_get_buf(win) + local is_file = vim.bo[buf].buftype == "" + local show_signs = vim.wo[win].signcolumn ~= "no" + + local components = { "", "", "" } -- left, middle, right + + if show_signs then + ---@type Sign?,Sign?,Sign? + local left, right, fold + for _, s in ipairs(M.get_signs(buf, vim.v.lnum)) do + if s.name and (s.name:find("GitSign") or s.name:find("MiniDiffSign")) then + right = s + else + left = s + end + end + if vim.v.virtnum ~= 0 then + left = nil + end + vim.api.nvim_win_call(win, function() + if vim.fn.foldclosed(vim.v.lnum) >= 0 then + fold = { text = vim.opt.fillchars:get().foldclose or "", texthl = "Folded" } + end + end) + -- Left: mark or non-git sign + components[1] = M.icon(M.get_mark(buf, vim.v.lnum) or left) + -- Right: fold icon or git sign (only if file) + components[3] = is_file and M.icon(fold or right) or "" + end + + -- Numbers in Neovim are weird + -- They show when either number or relativenumber is true + local is_num = vim.wo[win].number + local is_relnum = vim.wo[win].relativenumber + if (is_num or is_relnum) and vim.v.virtnum == 0 then + if vim.v.relnum == 0 then + components[2] = is_num and "%l" or "%r" -- the current line + else + components[2] = is_relnum and "%r" or "%l" -- other lines + end + components[2] = "%=" .. components[2] .. " " -- right align + end + + if vim.v.virtnum ~= 0 then + components[2] = "%= " + end + + return table.concat(components, "") +end + +---@return {fg?:string}? +function M.fg(name) + local color = M.color(name) + return color and { fg = color } or nil +end + +---@param name string +---@param bg? boolean +---@return string? +function M.color(name, bg) + ---@type {foreground?:number}? + ---@diagnostic disable-next-line: deprecated + local hl = vim.api.nvim_get_hl and vim.api.nvim_get_hl(0, { name = name, link = false }) + or vim.api.nvim_get_hl_by_name(name, true) + ---@diagnostic disable-next-line: undefined-field + ---@type string? + local color = nil + if hl then + if bg then + color = hl.bg or hl.background + else + color = hl.fg or hl.foreground + end + end + return color and string.format("#%06x", color) or nil +end + +M.skip_foldexpr = {} ---@type table +local skip_check = assert(vim.uv.new_check()) + +function M.foldexpr() + local buf = vim.api.nvim_get_current_buf() + + -- still in the same tick and no parser + if M.skip_foldexpr[buf] then + return "0" + end + + -- don't use treesitter folds for non-file buffers + if vim.bo[buf].buftype ~= "" then + return "0" + end + + -- as long as we don't have a filetype, don't bother + -- checking if treesitter is available (it won't) + if vim.bo[buf].filetype == "" then + return "0" + end + + local ok = pcall(vim.treesitter.get_parser, buf) + + if ok then + return vim.treesitter.foldexpr() + end + + -- no parser available, so mark it as skip + -- in the next tick, all skip marks will be reset + M.skip_foldexpr[buf] = true + skip_check:start(function() + M.skip_foldexpr = {} + skip_check:stop() + end) + return "0" +end + +return M From f72c0ad02adff9c81f17951159c9693aa6271264 Mon Sep 17 00:00:00 2001 From: asyncedd Date: Thu, 16 May 2024 11:20:35 +0900 Subject: [PATCH 14/56] feat(cmp): add cr as a mapping to accept un-explictly selected comps --- lua/plugins/specs/coding.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/lua/plugins/specs/coding.lua b/lua/plugins/specs/coding.lua index 08290882..4d12c66d 100644 --- a/lua/plugins/specs/coding.lua +++ b/lua/plugins/specs/coding.lua @@ -85,6 +85,7 @@ return { end end, { "i", "s" }), [""] = cmp.mapping.confirm({ select = true }), + [""] = cmp.mapping.confirm({ select = false }), }), formatting = { fields = { "kind", "abbr", "menu" }, From 1e7c50b713d49035f64d96b9f7571b03c5001234 Mon Sep 17 00:00:00 2001 From: asyncedd Date: Thu, 16 May 2024 11:55:45 +0900 Subject: [PATCH 15/56] feat(cmp): make cmp look more prettier feat(cmp): make the menu more mini --- lazy-lock.json | 43 ++++++++++++++++++------------------ lua/plugins/specs/coding.lua | 18 ++++++++++----- lua/settings/options.lua | 1 - 3 files changed, 34 insertions(+), 28 deletions(-) diff --git a/lazy-lock.json b/lazy-lock.json index d009d0e5..0268a848 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -1,19 +1,19 @@ { - "LuaSnip": { "branch": "master", "commit": "b152822e1a4bafb6bdf11a16cc26525cbd95ee00" }, - "actions-preview.nvim": { "branch": "master", "commit": "ceb6e06d1c8c30d8ddfe3afb03cd2c47b08b2798" }, - "base46": { "branch": "v2.5", "commit": "bcc9ed2e88ef55b7e9d50b2f80f6a2d4b8080b1d" }, + "LuaSnip": { "branch": "master", "commit": "7b1dda0dfdefc10b2501295eba5e463dbd7c338f" }, + "base46": { "branch": "v2.5", "commit": "a2bd5e8896fc7b6110e62dc4efdb3bf0f077baed" }, "cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" }, "cmp-cmdline": { "branch": "main", "commit": "d250c63aa13ead745e3a40f61fdd3470efde3923" }, "cmp-nvim-lsp": { "branch": "main", "commit": "5af77f54de1b16c34b23cba810150689a3a90312" }, "cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" }, "cmp_luasnip": { "branch": "master", "commit": "05a9ab28b53f71d1aece421ef32fee2cb857a843" }, - "conform.nvim": { "branch": "master", "commit": "12b3995537f52ba2810a9857e8ca256881febbda" }, - "crates.nvim": { "branch": "main", "commit": "f00e11e8282b94f2a2e938d32712c99f0e0bdeb4" }, + "conform.nvim": { "branch": "master", "commit": "59d0dd233a2cafacfa1235ab22054c4d80a72319" }, + "crates.nvim": { "branch": "main", "commit": "d556c00d60c9421c913ee54ff690df2a34f6264e" }, "dressing.nvim": { "branch": "master", "commit": "5162edb1442a729a885c45455a07e9a89058be2f" }, - "flash.nvim": { "branch": "main", "commit": "7bb4a9c75d1e20cd24185afedeaa11681829ba23" }, - "friendly-snippets": { "branch": "main", "commit": "fa36367422da5a38560892e3db6d090a635d9d41" }, + "flash.nvim": { "branch": "main", "commit": "11a2e667d19d8f48c93c6ed2e2e525ac6b1b79be" }, + "friendly-snippets": { "branch": "main", "commit": "3e9a3f5a0cfcef1741e352c37bda4e82e5eb846a" }, "indent-blankline.nvim": { "branch": "master", "commit": "3d08501caef2329aba5121b753e903904088f7e6" }, - "lazy.nvim": { "branch": "main", "commit": "d3974346b6cef2116c8e7b08423256a834cb7cbc" }, + "lazy.nvim": { "branch": "main", "commit": "e44636a43376e8a1e851958f7e9cbe996751d59f" }, + "lspkind.nvim": { "branch": "master", "commit": "1735dd5a5054c1fb7feaf8e8658dbab925f4f0cf" }, "mini.ai": { "branch": "main", "commit": "55e9b7217f29e62f734e239bfeed5731a065d801" }, "mini.clue": { "branch": "main", "commit": "bde26d6f142eee03ea63015e73b6ac984d49a382" }, "mini.diff": { "branch": "main", "commit": "10cc9d370737b8b8c8d996fc537394635da0a4b1" }, @@ -22,26 +22,25 @@ "mini.move": { "branch": "main", "commit": "251d541a8ab745e81295a53c128829cb2bff18e3" }, "mini.operators": { "branch": "main", "commit": "2edc808e32fbf3e0d4759bdef26a7a143a19f509" }, "mini.splitjoin": { "branch": "main", "commit": "a6b043b4afb075058a8c49325ff22e07f0e96170" }, - "mini.surround": { "branch": "main", "commit": "0f528eb2e1bab420c0569d9e52615144c51db920" }, + "mini.surround": { "branch": "main", "commit": "eb89a88a51655e46a93595204a9251a012918883" }, "mini.visits": { "branch": "main", "commit": "17bbec0e1669e4b91c1a50bbf56dc94d6f4873e8" }, - "noice.nvim": { "branch": "main", "commit": "f4decbc7a80229ccc9f86026b74bdcf0c39e38a7" }, - "nui.nvim": { "branch": "main", "commit": "274fa89a9b4bed746647c2917091902f882509ec" }, - "nvim-cmp": { "branch": "main", "commit": "8f3c541407e691af6163e2447f3af1bd6e17f9a3" }, - "nvim-lightbulb": { "branch": "master", "commit": "8f00b89dd1b1dbde16872bee5fbcee2e58c9b8e9" }, - "nvim-lint": { "branch": "master", "commit": "861a04313501563bb1b11f125ae9b7237a517b9b" }, - "nvim-lspconfig": { "branch": "master", "commit": "aa5f4f4ee10b2688fb37fa46215672441d5cd5d9" }, + "noice.nvim": { "branch": "main", "commit": "61947de3d5904375ea94e0c13db2537488ad9829" }, + "nui.nvim": { "branch": "main", "commit": "a3597dc88b53489d3fddbddbbd13787355253bb0" }, + "nvim-cmp": { "branch": "main", "commit": "a08882abe1f900c0c7f516725d74c7d84faeaa79" }, + "nvim-lint": { "branch": "master", "commit": "f3bcc28ffccb768212247294acccc106e029fc3c" }, + "nvim-lspconfig": { "branch": "master", "commit": "a27179f56c6f98a4cdcc79ee2971b514815a4940" }, "nvim-notify": { "branch": "master", "commit": "5371f4bfc1f6d3adf4fe9d62cd3a9d44356bfd15" }, "nvim-spectre": { "branch": "master", "commit": "4651801ba37a9407b7257287aec45b6653ffc5e9" }, - "nvim-treesitter": { "branch": "master", "commit": "4e21361e15b1d4147830c5fe571556eb1b14e6f9" }, - "nvim-treesitter-textobjects": { "branch": "master", "commit": "23b820146956b3b681c19e10d3a8bc0cbd9a1d4c" }, - "nvim-web-devicons": { "branch": "master", "commit": "475fbcfcb6ee7c35aa33a6b6207ebd4032791d87" }, + "nvim-treesitter": { "branch": "master", "commit": "aa0c7dd29631ee8c2df738d99bd33b762b3a6e22" }, + "nvim-treesitter-textobjects": { "branch": "master", "commit": "84cc9ed772f1fee2f47c1e076f518829583d8347" }, + "nvim-web-devicons": { "branch": "master", "commit": "e37bb1feee9e7320c76050a55443fa843b4b6f83" }, "plenary.nvim": { "branch": "master", "commit": "08e301982b9a057110ede7a735dd1b5285eb341f" }, "smart-open.nvim": { "branch": "main", "commit": "028bb71d20e8212da3514bf6dabfb17038d81ee4" }, "sqlite.lua": { "branch": "master", "commit": "d0ffd703b56d090d213b497ed4eb840495f14a11" }, "telescope-fzy-native.nvim": { "branch": "master", "commit": "282f069504515eec762ab6d6c89903377252bf5b" }, - "telescope.nvim": { "branch": "master", "commit": "fac83a556e7b710dc31433dec727361ca062dbe9" }, - "ui": { "branch": "v2.5", "commit": "9c16efc915346c7bde5288ad94f0ea40a7267d31" }, - "ultimate-autopair.nvim": { "branch": "v0.6", "commit": "6ecf7461d44513af89f8257f057fcc99e9297612" }, + "telescope.nvim": { "branch": "master", "commit": "52f500110bcf9190b44b4d8640162adc86772ec4" }, + "ui": { "branch": "v2.5", "commit": "4f507775f3935a39d994e7a1d3688e30f7fb8713" }, + "ultimate-autopair.nvim": { "branch": "v0.6", "commit": "042587c63b2b2776a83337748d53dba8b67ec545" }, "vscode-svelte-snippets": { "branch": "master", "commit": "564ac3300bfeda01ff0bf6b89152cef43f85a4ce" }, - "yanky.nvim": { "branch": "main", "commit": "7c5cbf0122ff2dfbb6a92f14885894f65949cc8b" } + "yanky.nvim": { "branch": "main", "commit": "ec4353355d4eabef451d16d46a3e0535176b81aa" } } \ No newline at end of file diff --git a/lua/plugins/specs/coding.lua b/lua/plugins/specs/coding.lua index 4d12c66d..5ef0e20b 100644 --- a/lua/plugins/specs/coding.lua +++ b/lua/plugins/specs/coding.lua @@ -23,7 +23,7 @@ return { event = "InsertEnter", }, { - "hrsh7th/nvim-cmp", + "xzbdmw/nvim-cmp", opts = function() local cmp = require("cmp") local luasnip = require("luasnip") @@ -89,9 +89,16 @@ return { }), formatting = { fields = { "kind", "abbr", "menu" }, - format = function(_, vim_item) - local item = vim_item.kind - vim_item.kind = dots.UI.icons.LSP.kind[item] + format = function(entry, vim_item) + local kind = require("lspkind").cmp_format({ + mode = "symbol_text", + maxwidth = 50, + ellipsis_char = "...", + })(entry, vim_item) + -- vim_item.kind = dots.UI.icons.LSP.kind[item] + local strings = vim.split(kind.kind, "%s", { trimempty = true }) + kind.kind = (strings[1] or "") + kind.concat = kind.abbr return vim_item end, @@ -113,6 +120,7 @@ return { "hrsh7th/cmp-path", "L3MON4D3/LuaSnip", "saadparwaiz1/cmp_luasnip", + "onsails/lspkind.nvim", }, event = "InsertEnter", cmd = "CmpStatus", @@ -136,7 +144,7 @@ return { }) end, dependencies = { - "hrsh7th/nvim-cmp", + "xzbdmw/nvim-cmp", "hrsh7th/cmp-path", "hrsh7th/cmp-buffer", }, diff --git a/lua/settings/options.lua b/lua/settings/options.lua index 3dd9f949..3c027b2f 100644 --- a/lua/settings/options.lua +++ b/lua/settings/options.lua @@ -59,7 +59,6 @@ o.scrolloff = 15 o.ignorecase = true o.smartcase = true -o.pumblend = 10 -- Popup blend o.pumheight = 10 -- Maximum number of entries in a popup -- Sessions From 0665a99b6522ab1680bd1e2b7649f2bc9dc704f6 Mon Sep 17 00:00:00 2001 From: asyncedd Date: Thu, 16 May 2024 12:53:35 +0900 Subject: [PATCH 16/56] perf(lsp): rm unneeded lsps --- lua/plugins/specs/lsp.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lua/plugins/specs/lsp.lua b/lua/plugins/specs/lsp.lua index ecd298bd..d891a7df 100644 --- a/lua/plugins/specs/lsp.lua +++ b/lua/plugins/specs/lsp.lua @@ -2,7 +2,7 @@ return { { "neovim/nvim-lspconfig", event = "LazyFile", - config = function(_, opts) + config = function() dofile(vim.g.base46_cache .. "lsp") local inlay_hint = vim.lsp.buf.inlay_hint or vim.lsp.inlay_hint @@ -106,13 +106,13 @@ return { require("lspconfig")["svelte"].setup({ capabilities = capabilities }) require("lspconfig")["emmet_ls"].setup({ capabilities = capabilities }) require("lspconfig")["tailwindcss"].setup({ capabilities = capabilities }) - require("lspconfig")["taplo"].setup({ capabilities = capabilities }) + -- require("lspconfig")["taplo"].setup({ capabilities = capabilities }) require("lspconfig")["cssls"].setup({ capabilities = capabilities, cmd = { "css-languageserver", "--stdio" }, }) require("lspconfig")["marksman"].setup({ capabilities = capabilities }) - require("lspconfig")["hls"].setup({ capabilities = capabilities }) + -- require("lspconfig")["hls"].setup({ capabilities = capabilities }) end, }, { From 28a4c21a36ac4304cc40345e77ed28405a695647 Mon Sep 17 00:00:00 2001 From: asyncedd Date: Sun, 19 May 2024 14:53:57 +0900 Subject: [PATCH 17/56] fix(nvchad_ui): fix statusline to work ith mini.diff --- init.lua | 28 ++++++++++++++--- lazy-lock.json | 44 +++++++++++++------------- lua/chadrc.lua | 36 +++++++++++++++++++++ lua/settings/autocmd.lua | 33 ------------------- lua/settings/init.lua | 6 ++-- lua/utils/mini/git.lua | 68 ++++++++++++++++++++++++++++++++++++++++ 6 files changed, 152 insertions(+), 63 deletions(-) create mode 100644 lua/utils/mini/git.lua diff --git a/init.lua b/init.lua index 54824ce1..7a04c822 100644 --- a/init.lua +++ b/init.lua @@ -5,12 +5,30 @@ require("settings") require("settings.options") require("settings.autocmd") require("plugins") +require("settings.keymap") -vim.api.nvim_create_autocmd("User", { - group = vim.api.nvim_create_augroup("LazyVim", { clear = true }), - pattern = "VeryLazy", - callback = function() - require("settings.keymap") +-- This autocmd will only trigger when a file was loaded from the cmdline. +-- It will render the file as quickly as possible. +vim.api.nvim_create_autocmd("BufReadPost", { + once = true, + callback = function(event) + -- Skip if we already entered vim + if vim.v.vim_did_enter == 1 then + return + end + + -- Try to guess the filetype (may change later on during Neovim startup) + local ft = vim.filetype.match({ buf = event.buf }) + if ft then + -- Add treesitter highlights and fallback to syntax + local lang = vim.treesitter.language.get_lang(ft) + if not (lang and pcall(vim.treesitter.start, event.buf, lang)) then + vim.bo[event.buf].syntax = ft + end + + -- Trigger early redraw + vim.cmd([[redraw]]) + end end, }) diff --git a/lazy-lock.json b/lazy-lock.json index 0268a848..a9011c31 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -1,46 +1,46 @@ { - "LuaSnip": { "branch": "master", "commit": "7b1dda0dfdefc10b2501295eba5e463dbd7c338f" }, + "LuaSnip": { "branch": "master", "commit": "de1a287c9cb525ae52bc846e8f6207e5ef1da5ac" }, "base46": { "branch": "v2.5", "commit": "a2bd5e8896fc7b6110e62dc4efdb3bf0f077baed" }, "cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" }, "cmp-cmdline": { "branch": "main", "commit": "d250c63aa13ead745e3a40f61fdd3470efde3923" }, - "cmp-nvim-lsp": { "branch": "main", "commit": "5af77f54de1b16c34b23cba810150689a3a90312" }, + "cmp-nvim-lsp": { "branch": "main", "commit": "39e2eda76828d88b773cc27a3f61d2ad782c922d" }, "cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" }, "cmp_luasnip": { "branch": "master", "commit": "05a9ab28b53f71d1aece421ef32fee2cb857a843" }, - "conform.nvim": { "branch": "master", "commit": "59d0dd233a2cafacfa1235ab22054c4d80a72319" }, + "conform.nvim": { "branch": "master", "commit": "00f9d91391b04b1935e2f15948bd96cc111e7d3a" }, "crates.nvim": { "branch": "main", "commit": "d556c00d60c9421c913ee54ff690df2a34f6264e" }, - "dressing.nvim": { "branch": "master", "commit": "5162edb1442a729a885c45455a07e9a89058be2f" }, + "dressing.nvim": { "branch": "master", "commit": "572314728cb1ce012e825fd66331f52c94acac12" }, "flash.nvim": { "branch": "main", "commit": "11a2e667d19d8f48c93c6ed2e2e525ac6b1b79be" }, - "friendly-snippets": { "branch": "main", "commit": "3e9a3f5a0cfcef1741e352c37bda4e82e5eb846a" }, - "indent-blankline.nvim": { "branch": "master", "commit": "3d08501caef2329aba5121b753e903904088f7e6" }, - "lazy.nvim": { "branch": "main", "commit": "e44636a43376e8a1e851958f7e9cbe996751d59f" }, + "friendly-snippets": { "branch": "main", "commit": "dd2fd1281d4b22e7b4a5bfafa3e142d958e251f2" }, + "indent-blankline.nvim": { "branch": "master", "commit": "ece00d5fb44d196680a81fd2761062d2fa44663b" }, + "lazy.nvim": { "branch": "main", "commit": "5d29ffeaa0f2d91f1dfbc21943d19a11e59a6fc6" }, "lspkind.nvim": { "branch": "master", "commit": "1735dd5a5054c1fb7feaf8e8658dbab925f4f0cf" }, - "mini.ai": { "branch": "main", "commit": "55e9b7217f29e62f734e239bfeed5731a065d801" }, - "mini.clue": { "branch": "main", "commit": "bde26d6f142eee03ea63015e73b6ac984d49a382" }, + "mini.ai": { "branch": "main", "commit": "a0262e61f79dfc7bb940d1719c00b0ede042ddd7" }, + "mini.clue": { "branch": "main", "commit": "93f5a3799cf97e5bb1a948f731973a84026fa19d" }, "mini.diff": { "branch": "main", "commit": "10cc9d370737b8b8c8d996fc537394635da0a4b1" }, "mini.extra": { "branch": "main", "commit": "3157df3aaf38f5b040a56fd02c8efb05a043e5ae" }, - "mini.files": { "branch": "main", "commit": "17684f78d0499f11e54fc980838cfef3cf5c7c72" }, + "mini.files": { "branch": "main", "commit": "759e2d213b13914fcd125eb8bfb80e3f3c607367" }, "mini.move": { "branch": "main", "commit": "251d541a8ab745e81295a53c128829cb2bff18e3" }, "mini.operators": { "branch": "main", "commit": "2edc808e32fbf3e0d4759bdef26a7a143a19f509" }, "mini.splitjoin": { "branch": "main", "commit": "a6b043b4afb075058a8c49325ff22e07f0e96170" }, - "mini.surround": { "branch": "main", "commit": "eb89a88a51655e46a93595204a9251a012918883" }, + "mini.surround": { "branch": "main", "commit": "c52aa751daf62d4a9e6ee24c4a91882ef6842f99" }, "mini.visits": { "branch": "main", "commit": "17bbec0e1669e4b91c1a50bbf56dc94d6f4873e8" }, - "noice.nvim": { "branch": "main", "commit": "61947de3d5904375ea94e0c13db2537488ad9829" }, - "nui.nvim": { "branch": "main", "commit": "a3597dc88b53489d3fddbddbbd13787355253bb0" }, + "noice.nvim": { "branch": "main", "commit": "9f6f6ba74f8bfbf7e43d6302cf86b070362f6203" }, + "nui.nvim": { "branch": "main", "commit": "b1b3dcd6ed8f355c78bad3d395ff645be5f8b6ae" }, "nvim-cmp": { "branch": "main", "commit": "a08882abe1f900c0c7f516725d74c7d84faeaa79" }, - "nvim-lint": { "branch": "master", "commit": "f3bcc28ffccb768212247294acccc106e029fc3c" }, - "nvim-lspconfig": { "branch": "master", "commit": "a27179f56c6f98a4cdcc79ee2971b514815a4940" }, - "nvim-notify": { "branch": "master", "commit": "5371f4bfc1f6d3adf4fe9d62cd3a9d44356bfd15" }, - "nvim-spectre": { "branch": "master", "commit": "4651801ba37a9407b7257287aec45b6653ffc5e9" }, - "nvim-treesitter": { "branch": "master", "commit": "aa0c7dd29631ee8c2df738d99bd33b762b3a6e22" }, - "nvim-treesitter-textobjects": { "branch": "master", "commit": "84cc9ed772f1fee2f47c1e076f518829583d8347" }, + "nvim-lint": { "branch": "master", "commit": "1f98d6c863f91706369d74aeb2eb3f02b2e96861" }, + "nvim-lspconfig": { "branch": "master", "commit": "6d2ae9fdc3111a6e8fd5db2467aca11737195a30" }, + "nvim-notify": { "branch": "master", "commit": "d333b6f167900f6d9d42a59005d82919830626bf" }, + "nvim-spectre": { "branch": "master", "commit": "50e96602153f14c913e1969aaf9720e080394eb3" }, + "nvim-treesitter": { "branch": "master", "commit": "1eabe69bfa8f78e14fcf5d42a2b3881babaca30a" }, + "nvim-treesitter-textobjects": { "branch": "master", "commit": "5f9bf4b1ead7707e4e74e5319ee56bdc81fb73db" }, "nvim-web-devicons": { "branch": "master", "commit": "e37bb1feee9e7320c76050a55443fa843b4b6f83" }, "plenary.nvim": { "branch": "master", "commit": "08e301982b9a057110ede7a735dd1b5285eb341f" }, "smart-open.nvim": { "branch": "main", "commit": "028bb71d20e8212da3514bf6dabfb17038d81ee4" }, "sqlite.lua": { "branch": "master", "commit": "d0ffd703b56d090d213b497ed4eb840495f14a11" }, "telescope-fzy-native.nvim": { "branch": "master", "commit": "282f069504515eec762ab6d6c89903377252bf5b" }, - "telescope.nvim": { "branch": "master", "commit": "52f500110bcf9190b44b4d8640162adc86772ec4" }, - "ui": { "branch": "v2.5", "commit": "4f507775f3935a39d994e7a1d3688e30f7fb8713" }, + "telescope.nvim": { "branch": "master", "commit": "0c12735d5aff6a48ffd8111bf144dc2ff44e5975" }, + "ui": { "branch": "v2.5", "commit": "52a3973706caa4d03384cde0a456e8749c8bf42a" }, "ultimate-autopair.nvim": { "branch": "v0.6", "commit": "042587c63b2b2776a83337748d53dba8b67ec545" }, "vscode-svelte-snippets": { "branch": "master", "commit": "564ac3300bfeda01ff0bf6b89152cef43f85a4ce" }, - "yanky.nvim": { "branch": "main", "commit": "ec4353355d4eabef451d16d46a3e0535176b81aa" } + "yanky.nvim": { "branch": "main", "commit": "396ff7ed952a69549f299c7b6f64615a89836733" } } \ No newline at end of file diff --git a/lua/chadrc.lua b/lua/chadrc.lua index 25f7ea6a..f396c2af 100644 --- a/lua/chadrc.lua +++ b/lua/chadrc.lua @@ -1,4 +1,27 @@ local M = {} +local utils = require("nvchad.stl.utils") +require("utils.mini.git") + +local format_summary = function(data) + local summary = vim.b[data.buf].minidiff_summary + if summary == nil then + vim.b[data.buf].minidiff_summary_string = "" + return + end + local t = {} + if summary.add > 0 then + table.insert(t, dots.UI.icons.Git.added .. summary.add) + end + if summary.change > 0 then + table.insert(t, dots.UI.icons.Git.changed .. summary.change) + end + if summary.delete > 0 then + table.insert(t, dots.UI.icons.Git.remove .. summary.delete) + end + vim.b[data.buf].minidiff_summary_string = table.concat(t, " ") +end +local au_opts = { pattern = "MiniDiffUpdated", callback = format_summary } +vim.api.nvim_create_autocmd("User", au_opts) M.ui = { theme = "onedark", @@ -12,6 +35,19 @@ M.ui = { "cwd", "cursor", }, + modules = { + git = function() + if not vim.b[utils.stbufnr()].git_branch or not vim.b[utils.stbufnr()].minidiff_summary_string then + return "" + end + + local git_status = vim.b[utils.stbufnr()].git_branch + + local branch_name = " " .. git_status + + return "%#St_gitIcons# " .. branch_name .. " " .. vim.b[utils.stbufnr()].minidiff_summary_string + end, + }, }, } diff --git a/lua/settings/autocmd.lua b/lua/settings/autocmd.lua index dcf25189..f08c9f52 100644 --- a/lua/settings/autocmd.lua +++ b/lua/settings/autocmd.lua @@ -38,39 +38,6 @@ autocmd({ "BufWritePre" }, { end, }) --- This autocmd will only trigger when a file was loaded from the cmdline. --- It will render the file as quickly as possible. -vim.api.nvim_create_autocmd("BufReadPost", { - once = true, - callback = function(event) - -- Skip if we already entered vim - if vim.v.vim_did_enter == 1 then - return - end - - -- Try to guess the filetype (may change later on during Neovim startup) - local ft = vim.filetype.match({ buf = event.buf }) - if ft then - -- Add treesitter highlights and fallback to syntax - local lang = vim.treesitter.language.get_lang(ft) - if not (lang and pcall(vim.treesitter.start, event.buf, lang)) then - vim.bo[event.buf].syntax = ft - end - - -- Trigger early redraw - vim.cmd([[redraw]]) - - vim.schedule(function() - vim.api.nvim_exec_autocmds("FileType", {}) - - if vim.g.editorconfig then - require("editorconfig").config(event.buf) - end - end) - end - end, -}) - -- reload some chadrc options on-save autocmd("BufWritePost", { pattern = vim.tbl_map(function(path) diff --git a/lua/settings/init.lua b/lua/settings/init.lua index 3bca923a..38028364 100644 --- a/lua/settings/init.lua +++ b/lua/settings/init.lua @@ -49,9 +49,9 @@ M.UI = { unsaved_others = "○ ", }, Git = { - added = " ", - remove = " ", - changed = "󰣕 ", + added = " ", + changed = " ", + remove = " ", }, Gitsigns = { add = "▎", diff --git a/lua/utils/mini/git.lua b/lua/utils/mini/git.lua new file mode 100644 index 00000000..04ee369d --- /dev/null +++ b/lua/utils/mini/git.lua @@ -0,0 +1,68 @@ +local function is_valid_git_repo(buf_id) + -- Check if it's a valid buffer + local path = vim.api.nvim_buf_get_name(buf_id) + if path == "" or vim.fn.filereadable(path) ~= 1 then + return false + end + + -- Check if the current directory is a Git repository + if vim.fn.isdirectory(".git") == 0 then + return false + end + + return true +end + +local branch_cache = {} + +-- Function to clear the Git branch cache +local function clear_git_branch_cache() + -- Clear by doing an empty table :) + branch_cache = {} +end + +-- Autocommand to clear the Git branch cache when the directory changes +vim.api.nvim_create_autocmd("DirChanged", { + callback = clear_git_branch_cache, +}) + +local function update_git_branch(data) + if not is_valid_git_repo(data.buf) then + return + end + + -- Check if branch is already cached + local cached_branch = branch_cache[data.buf] + if cached_branch then + vim.b.git_branch = cached_branch + return + end + + local stdout = vim.uv.new_pipe(false) + local handle, pid + handle, pid = vim.uv.spawn( + "git", + { + args = { "-C", vim.fn.expand("%:p:h"), "branch", "--show-current" }, + stdio = { nil, stdout, nil }, + }, + vim.schedule_wrap(function(code, signal) + if code == 0 then + stdout:read_start(function(err, content) + if content then + vim.b.git_branch = content:gsub("\n", "") -- Remove newline character + branch_cache[data.buf] = vim.b.git_branch -- Cache the branch name + stdout:close() + end + end) + else + stdout:close() + end + end) + ) +end + +-- Call this function when the buffer is opened in a window +vim.api.nvim_create_autocmd("BufWinEnter", { + callback = update_git_branch, +}) From 59e443e30b100fff34a1adafce6965157c37b5cf Mon Sep 17 00:00:00 2001 From: asyncedd Date: Sun, 19 May 2024 22:02:36 +0900 Subject: [PATCH 18/56] perf: rm noice --- lazy-lock.json | 3 ++- lua/plugins/specs/ui.lua | 34 ---------------------------------- 2 files changed, 2 insertions(+), 35 deletions(-) diff --git a/lazy-lock.json b/lazy-lock.json index a9011c31..94d0f262 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -1,5 +1,6 @@ { "LuaSnip": { "branch": "master", "commit": "de1a287c9cb525ae52bc846e8f6207e5ef1da5ac" }, + "actions-preview.nvim": { "branch": "master", "commit": "e8d41b608e24319548637685c7cfa66fadaff2b2" }, "base46": { "branch": "v2.5", "commit": "a2bd5e8896fc7b6110e62dc4efdb3bf0f077baed" }, "cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" }, "cmp-cmdline": { "branch": "main", "commit": "d250c63aa13ead745e3a40f61fdd3470efde3923" }, @@ -13,7 +14,6 @@ "friendly-snippets": { "branch": "main", "commit": "dd2fd1281d4b22e7b4a5bfafa3e142d958e251f2" }, "indent-blankline.nvim": { "branch": "master", "commit": "ece00d5fb44d196680a81fd2761062d2fa44663b" }, "lazy.nvim": { "branch": "main", "commit": "5d29ffeaa0f2d91f1dfbc21943d19a11e59a6fc6" }, - "lspkind.nvim": { "branch": "master", "commit": "1735dd5a5054c1fb7feaf8e8658dbab925f4f0cf" }, "mini.ai": { "branch": "main", "commit": "a0262e61f79dfc7bb940d1719c00b0ede042ddd7" }, "mini.clue": { "branch": "main", "commit": "93f5a3799cf97e5bb1a948f731973a84026fa19d" }, "mini.diff": { "branch": "main", "commit": "10cc9d370737b8b8c8d996fc537394635da0a4b1" }, @@ -27,6 +27,7 @@ "noice.nvim": { "branch": "main", "commit": "9f6f6ba74f8bfbf7e43d6302cf86b070362f6203" }, "nui.nvim": { "branch": "main", "commit": "b1b3dcd6ed8f355c78bad3d395ff645be5f8b6ae" }, "nvim-cmp": { "branch": "main", "commit": "a08882abe1f900c0c7f516725d74c7d84faeaa79" }, + "nvim-lightbulb": { "branch": "master", "commit": "8f00b89dd1b1dbde16872bee5fbcee2e58c9b8e9" }, "nvim-lint": { "branch": "master", "commit": "1f98d6c863f91706369d74aeb2eb3f02b2e96861" }, "nvim-lspconfig": { "branch": "master", "commit": "6d2ae9fdc3111a6e8fd5db2467aca11737195a30" }, "nvim-notify": { "branch": "master", "commit": "d333b6f167900f6d9d42a59005d82919830626bf" }, diff --git a/lua/plugins/specs/ui.lua b/lua/plugins/specs/ui.lua index c5d034f9..6627e8cc 100644 --- a/lua/plugins/specs/ui.lua +++ b/lua/plugins/specs/ui.lua @@ -59,40 +59,6 @@ return { end end, }, - { - "folke/noice.nvim", - opts = { - lsp = { - override = { - ["vim.lsp.util.convert_input_to_markdown_lines"] = true, - ["vim.lsp.util.stylize_markdown"] = true, - ["cmp.entry.get_documentation"] = true, - }, - }, - presets = { - bottom_search = true, - command_palette = true, - long_message_to_split = true, - inc_rename = false, - lsp_doc_border = false, - }, - cmdline = { - view = "cmdline", - }, - views = { - mini = { - win_options = { - winblend = 0, - }, - }, - }, - }, - event = "VeryLazy", - dependencies = { - "MunifTanjim/nui.nvim", - "rcarriga/nvim-notify", - }, - }, -- CREDITS TO: https://www.lazyvim.org/plugins/ui#dressingnvim { "stevearc/dressing.nvim", From b0003a3e54fbaaf40c38e322892dd504023114ef Mon Sep 17 00:00:00 2001 From: asyncedd Date: Mon, 20 May 2024 17:32:41 +0900 Subject: [PATCH 19/56] feat: add a bunch of keymaps --- lazy-lock.json | 6 +- lua/plugins/specs/editor.lua | 137 ++++++++++++++++++++++++++++++++++- lua/settings/keymap.lua | 9 --- 3 files changed, 137 insertions(+), 15 deletions(-) diff --git a/lazy-lock.json b/lazy-lock.json index 94d0f262..01487e4e 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -1,6 +1,5 @@ { "LuaSnip": { "branch": "master", "commit": "de1a287c9cb525ae52bc846e8f6207e5ef1da5ac" }, - "actions-preview.nvim": { "branch": "master", "commit": "e8d41b608e24319548637685c7cfa66fadaff2b2" }, "base46": { "branch": "v2.5", "commit": "a2bd5e8896fc7b6110e62dc4efdb3bf0f077baed" }, "cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" }, "cmp-cmdline": { "branch": "main", "commit": "d250c63aa13ead745e3a40f61fdd3470efde3923" }, @@ -14,6 +13,7 @@ "friendly-snippets": { "branch": "main", "commit": "dd2fd1281d4b22e7b4a5bfafa3e142d958e251f2" }, "indent-blankline.nvim": { "branch": "master", "commit": "ece00d5fb44d196680a81fd2761062d2fa44663b" }, "lazy.nvim": { "branch": "main", "commit": "5d29ffeaa0f2d91f1dfbc21943d19a11e59a6fc6" }, + "lspkind.nvim": { "branch": "master", "commit": "1735dd5a5054c1fb7feaf8e8658dbab925f4f0cf" }, "mini.ai": { "branch": "main", "commit": "a0262e61f79dfc7bb940d1719c00b0ede042ddd7" }, "mini.clue": { "branch": "main", "commit": "93f5a3799cf97e5bb1a948f731973a84026fa19d" }, "mini.diff": { "branch": "main", "commit": "10cc9d370737b8b8c8d996fc537394635da0a4b1" }, @@ -24,16 +24,14 @@ "mini.splitjoin": { "branch": "main", "commit": "a6b043b4afb075058a8c49325ff22e07f0e96170" }, "mini.surround": { "branch": "main", "commit": "c52aa751daf62d4a9e6ee24c4a91882ef6842f99" }, "mini.visits": { "branch": "main", "commit": "17bbec0e1669e4b91c1a50bbf56dc94d6f4873e8" }, - "noice.nvim": { "branch": "main", "commit": "9f6f6ba74f8bfbf7e43d6302cf86b070362f6203" }, - "nui.nvim": { "branch": "main", "commit": "b1b3dcd6ed8f355c78bad3d395ff645be5f8b6ae" }, "nvim-cmp": { "branch": "main", "commit": "a08882abe1f900c0c7f516725d74c7d84faeaa79" }, - "nvim-lightbulb": { "branch": "master", "commit": "8f00b89dd1b1dbde16872bee5fbcee2e58c9b8e9" }, "nvim-lint": { "branch": "master", "commit": "1f98d6c863f91706369d74aeb2eb3f02b2e96861" }, "nvim-lspconfig": { "branch": "master", "commit": "6d2ae9fdc3111a6e8fd5db2467aca11737195a30" }, "nvim-notify": { "branch": "master", "commit": "d333b6f167900f6d9d42a59005d82919830626bf" }, "nvim-spectre": { "branch": "master", "commit": "50e96602153f14c913e1969aaf9720e080394eb3" }, "nvim-treesitter": { "branch": "master", "commit": "1eabe69bfa8f78e14fcf5d42a2b3881babaca30a" }, "nvim-treesitter-textobjects": { "branch": "master", "commit": "5f9bf4b1ead7707e4e74e5319ee56bdc81fb73db" }, + "nvim-various-textobjs": { "branch": "main", "commit": "6a0f594d686685b050320611e6e633ae5e51ebc2" }, "nvim-web-devicons": { "branch": "master", "commit": "e37bb1feee9e7320c76050a55443fa843b4b6f83" }, "plenary.nvim": { "branch": "master", "commit": "08e301982b9a057110ede7a735dd1b5285eb341f" }, "smart-open.nvim": { "branch": "main", "commit": "028bb71d20e8212da3514bf6dabfb17038d81ee4" }, diff --git a/lua/plugins/specs/editor.lua b/lua/plugins/specs/editor.lua index 937a71bc..6ec3c4db 100644 --- a/lua/plugins/specs/editor.lua +++ b/lua/plugins/specs/editor.lua @@ -134,8 +134,8 @@ return { return { n_lines = 500, custom_textobjects = { - f = ai.gen_spec.treesitter({ a = "@function.outer", i = "@function.inner" }, {}), - i = gen_ai_spec.indent(), + F = ai.gen_spec.treesitter({ a = "@function.outer", i = "@function.inner" }, {}), + -- i = gen_ai_spec.indent(), }, } end, @@ -152,6 +152,139 @@ return { { "a", mode = { "x", "o" } }, }, }, + { + "chrisgrieser/nvim-various-textobjs", + keys = { + { + "gG", + function() + require("various-textobjs").entireBuffer() + end, + mode = { "x", "o" }, + }, + { + "ii", + function() + if vim.fn.indent(".") == 0 then + require("various-textobjs").entireBuffer() + else + require("various-textobjs").indentation("inner", "inner") + end + end, + mode = { "x", "o" }, + desc = "in an indent block", + }, + { + "ai", + function() + require("various-textobjs").indentation("outer", "inner") + end, + mode = { "x", "o" }, + desc = "around an indent block", + }, + { + "iI", + function() + require("various-textobjs").indentation("inner", "inner") + end, + mode = { "x", "o" }, + desc = "in an indent block", + }, + { + "aI", + function() + require("various-textobjs").indentation("outer", "outer") + end, + mode = { "x", "o" }, + desc = "around an indent block", + }, + { + "n", + function() + require("various-textobjs").nearEoL() + end, + mode = { "x", "o" }, + desc = "to the eol, excluding the last char", + }, + { + "gn", + function() + require("various-textobjs").diagnostic() + end, + mode = { "x", "o" }, + desc = "next diagnostics", + }, + { -- delete surrounding indentation + "dsi", + function() + -- select outer indentation + require("various-textobjs").indentation("outer", "outer") + + -- plugin only switches to visual mode when a textobj has been found + local indentationFound = vim.fn.mode():find("V") + if not indentationFound then + return + end + + -- dedent indentation + vim.cmd.normal({ "<", bang = true }) + + -- delete surrounding lines + local endBorderLn = vim.api.nvim_buf_get_mark(0, ">")[1] + local startBorderLn = vim.api.nvim_buf_get_mark(0, "<")[1] + vim.cmd(tostring(endBorderLn) .. " delete") -- delete end first so line index is not shifted + vim.cmd(tostring(startBorderLn) .. " delete") + end, + desc = "delete surrounding indent", + }, + { -- yank surrounding inner indentation + "ysii", -- `ysi` would conflict with `ysib` and other textobs + function() + local startPos = vim.api.nvim_win_get_cursor(0) + + -- identify start- and end-border + require("various-textobjs").indentation("outer", "outer") + local indentationFound = vim.fn.mode():find("V") + if not indentationFound then + return + end + vim.cmd.normal({ "V", bang = true }) -- leave visual mode so the `'<` `'>` marks are set + + -- copy them into the + register + local startLn = vim.api.nvim_buf_get_mark(0, "<")[1] - 1 + local endLn = vim.api.nvim_buf_get_mark(0, ">")[1] - 1 + local startLine = vim.api.nvim_buf_get_lines(0, startLn, startLn + 1, false)[1] + local endLine = vim.api.nvim_buf_get_lines(0, endLn, endLn + 1, false)[1] + vim.fn.setreg("+", startLine .. "\n" .. endLine .. "\n") + + -- highlight yanked text + local ns = vim.api.nvim_create_namespace("ysi") + vim.highlight.range(0, ns, "IncSearch", { startLn, 0 }, { startLn, -1 }) + vim.highlight.range(0, ns, "IncSearch", { endLn, 0 }, { endLn, -1 }) + vim.defer_fn(function() + vim.api.nvim_buf_clear_namespace(0, ns, 0, -1) + end, 1000) + + -- restore cursor position + vim.api.nvim_win_set_cursor(0, startPos) + end, + desc = "pank surrounding indent", + }, + { + "rp", + "lua require('various-textobjs').restOfParagraph()", + mode = { "o", "x" }, + desc = "rest of paragraph", + }, + { + "ri", + "lua require('various-textobjs').restOfIndentation()", + mode = { "o", "x" }, + desc = "rest of indentation", + }, + { "rg", "G", mode = { "o", "x" }, desc = "rest of buffer" }, + }, + }, { "echasnovski/mini.operators", opts = true, diff --git a/lua/settings/keymap.lua b/lua/settings/keymap.lua index a180b06d..79578dae 100644 --- a/lua/settings/keymap.lua +++ b/lua/settings/keymap.lua @@ -30,15 +30,6 @@ map( { expr = true, replace_keycodes = false, desc = "Visually select changed text" } ) -map({ "x", "o" }, "gG", function() - vim.api.nvim_win_set_cursor(0, { 1, 0 }) - if not vim.fn.mode():find("V") ~= nil then - vim.cmd("normal! V") - end - vim.cmd("normal! o") - vim.api.nvim_win_set_cursor(0, { vim.fn.line("$"), 0 }) -end) - map("n", "[d", function() vim.diagnostic.goto_prev() end, { desc = "Prev diagnostic" }) From 266af7a4be7697bc5d222960024404022e2dfa43 Mon Sep 17 00:00:00 2001 From: asyncedd Date: Mon, 20 May 2024 22:04:14 +0900 Subject: [PATCH 20/56] feat: use nixd instead of nil --- lua/plugins/specs/lsp.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/plugins/specs/lsp.lua b/lua/plugins/specs/lsp.lua index d891a7df..f587d7fb 100644 --- a/lua/plugins/specs/lsp.lua +++ b/lua/plugins/specs/lsp.lua @@ -69,7 +69,7 @@ return { }, }) - require("lspconfig")["nil_ls"].setup({ capabilities = capabilities }) + require("lspconfig")["nixd"].setup({ capabilities = capabilities }) require("lspconfig")["lua_ls"].setup({ capabilities = capabilities, settings = { From 07f851e44c49ed190e3451f003928cc919ec0758 Mon Sep 17 00:00:00 2001 From: asyncedd Date: Wed, 22 May 2024 16:58:26 +0900 Subject: [PATCH 21/56] feat(mini-git): init --- lazy-lock.json | 19 ++++++++++--------- lua/chadrc.lua | 23 +++++++++++++---------- lua/plugins/specs/editor.lua | 6 ++++++ lua/plugins/specs/lsp.lua | 9 +++++++++ 4 files changed, 38 insertions(+), 19 deletions(-) diff --git a/lazy-lock.json b/lazy-lock.json index 01487e4e..7f2167ce 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -1,44 +1,45 @@ { "LuaSnip": { "branch": "master", "commit": "de1a287c9cb525ae52bc846e8f6207e5ef1da5ac" }, - "base46": { "branch": "v2.5", "commit": "a2bd5e8896fc7b6110e62dc4efdb3bf0f077baed" }, + "base46": { "branch": "v2.5", "commit": "7f9a7092402ae8951877f698f1c2291aa47c2903" }, "cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" }, "cmp-cmdline": { "branch": "main", "commit": "d250c63aa13ead745e3a40f61fdd3470efde3923" }, "cmp-nvim-lsp": { "branch": "main", "commit": "39e2eda76828d88b773cc27a3f61d2ad782c922d" }, "cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" }, "cmp_luasnip": { "branch": "master", "commit": "05a9ab28b53f71d1aece421ef32fee2cb857a843" }, - "conform.nvim": { "branch": "master", "commit": "00f9d91391b04b1935e2f15948bd96cc111e7d3a" }, + "conform.nvim": { "branch": "master", "commit": "b8f3ed3903430033f638b17f7455b8fd3d6a85b5" }, "crates.nvim": { "branch": "main", "commit": "d556c00d60c9421c913ee54ff690df2a34f6264e" }, "dressing.nvim": { "branch": "master", "commit": "572314728cb1ce012e825fd66331f52c94acac12" }, "flash.nvim": { "branch": "main", "commit": "11a2e667d19d8f48c93c6ed2e2e525ac6b1b79be" }, "friendly-snippets": { "branch": "main", "commit": "dd2fd1281d4b22e7b4a5bfafa3e142d958e251f2" }, "indent-blankline.nvim": { "branch": "master", "commit": "ece00d5fb44d196680a81fd2761062d2fa44663b" }, - "lazy.nvim": { "branch": "main", "commit": "5d29ffeaa0f2d91f1dfbc21943d19a11e59a6fc6" }, + "lazy.nvim": { "branch": "main", "commit": "8f19915175395680808de529e4220da8dafc0759" }, "lspkind.nvim": { "branch": "master", "commit": "1735dd5a5054c1fb7feaf8e8658dbab925f4f0cf" }, "mini.ai": { "branch": "main", "commit": "a0262e61f79dfc7bb940d1719c00b0ede042ddd7" }, "mini.clue": { "branch": "main", "commit": "93f5a3799cf97e5bb1a948f731973a84026fa19d" }, "mini.diff": { "branch": "main", "commit": "10cc9d370737b8b8c8d996fc537394635da0a4b1" }, "mini.extra": { "branch": "main", "commit": "3157df3aaf38f5b040a56fd02c8efb05a043e5ae" }, "mini.files": { "branch": "main", "commit": "759e2d213b13914fcd125eb8bfb80e3f3c607367" }, + "mini.git": { "branch": "main", "commit": "746696dd5db769cf6c809995adaab7cbfcdf6492" }, "mini.move": { "branch": "main", "commit": "251d541a8ab745e81295a53c128829cb2bff18e3" }, "mini.operators": { "branch": "main", "commit": "2edc808e32fbf3e0d4759bdef26a7a143a19f509" }, "mini.splitjoin": { "branch": "main", "commit": "a6b043b4afb075058a8c49325ff22e07f0e96170" }, "mini.surround": { "branch": "main", "commit": "c52aa751daf62d4a9e6ee24c4a91882ef6842f99" }, "mini.visits": { "branch": "main", "commit": "17bbec0e1669e4b91c1a50bbf56dc94d6f4873e8" }, "nvim-cmp": { "branch": "main", "commit": "a08882abe1f900c0c7f516725d74c7d84faeaa79" }, - "nvim-lint": { "branch": "master", "commit": "1f98d6c863f91706369d74aeb2eb3f02b2e96861" }, - "nvim-lspconfig": { "branch": "master", "commit": "6d2ae9fdc3111a6e8fd5db2467aca11737195a30" }, + "nvim-lint": { "branch": "master", "commit": "5697e6cb9588b70e260e4cc1f833ebb0bdc07617" }, + "nvim-lspconfig": { "branch": "master", "commit": "0b8165cf95806bc4bb8f745bb0c92021b2ed4b98" }, "nvim-notify": { "branch": "master", "commit": "d333b6f167900f6d9d42a59005d82919830626bf" }, "nvim-spectre": { "branch": "master", "commit": "50e96602153f14c913e1969aaf9720e080394eb3" }, - "nvim-treesitter": { "branch": "master", "commit": "1eabe69bfa8f78e14fcf5d42a2b3881babaca30a" }, + "nvim-treesitter": { "branch": "master", "commit": "14db0433e145c8ea63efc42ddbdf517d6036d372" }, "nvim-treesitter-textobjects": { "branch": "master", "commit": "5f9bf4b1ead7707e4e74e5319ee56bdc81fb73db" }, "nvim-various-textobjs": { "branch": "main", "commit": "6a0f594d686685b050320611e6e633ae5e51ebc2" }, "nvim-web-devicons": { "branch": "master", "commit": "e37bb1feee9e7320c76050a55443fa843b4b6f83" }, - "plenary.nvim": { "branch": "master", "commit": "08e301982b9a057110ede7a735dd1b5285eb341f" }, + "plenary.nvim": { "branch": "master", "commit": "a3e3bc82a3f95c5ed0d7201546d5d2c19b20d683" }, "smart-open.nvim": { "branch": "main", "commit": "028bb71d20e8212da3514bf6dabfb17038d81ee4" }, "sqlite.lua": { "branch": "master", "commit": "d0ffd703b56d090d213b497ed4eb840495f14a11" }, "telescope-fzy-native.nvim": { "branch": "master", "commit": "282f069504515eec762ab6d6c89903377252bf5b" }, - "telescope.nvim": { "branch": "master", "commit": "0c12735d5aff6a48ffd8111bf144dc2ff44e5975" }, - "ui": { "branch": "v2.5", "commit": "52a3973706caa4d03384cde0a456e8749c8bf42a" }, + "telescope.nvim": { "branch": "master", "commit": "4aed63995a69e343b068c7469491a8d1592c339f" }, + "ui": { "branch": "v2.5", "commit": "5fe258afeb248519fc2a1681b48d24208ed22abe" }, "ultimate-autopair.nvim": { "branch": "v0.6", "commit": "042587c63b2b2776a83337748d53dba8b67ec545" }, "vscode-svelte-snippets": { "branch": "master", "commit": "564ac3300bfeda01ff0bf6b89152cef43f85a4ce" }, "yanky.nvim": { "branch": "main", "commit": "396ff7ed952a69549f299c7b6f64615a89836733" } diff --git a/lua/chadrc.lua b/lua/chadrc.lua index f396c2af..13e556e0 100644 --- a/lua/chadrc.lua +++ b/lua/chadrc.lua @@ -1,8 +1,7 @@ local M = {} local utils = require("nvchad.stl.utils") -require("utils.mini.git") -local format_summary = function(data) +local diff_format_summary = function(data) local summary = vim.b[data.buf].minidiff_summary if summary == nil then vim.b[data.buf].minidiff_summary_string = "" @@ -20,8 +19,16 @@ local format_summary = function(data) end vim.b[data.buf].minidiff_summary_string = table.concat(t, " ") end -local au_opts = { pattern = "MiniDiffUpdated", callback = format_summary } -vim.api.nvim_create_autocmd("User", au_opts) +vim.api.nvim_create_autocmd("User", { pattern = "MiniDiffUpdated", callback = diff_format_summary }) + +-- Use only HEAD name as summary string +local git_format_summary = function(data) + -- Utilize buffer-local table summary + local summary = vim.b[data.buf].minigit_summary + vim.b[data.buf].minigit_summary_string = (summary ~= nil and summary.head_name or "") or "" +end + +vim.api.nvim_create_autocmd("User", { pattern = "MiniGitUpdated", callback = git_format_summary }) M.ui = { theme = "onedark", @@ -37,15 +44,11 @@ M.ui = { }, modules = { git = function() - if not vim.b[utils.stbufnr()].git_branch or not vim.b[utils.stbufnr()].minidiff_summary_string then - return "" - end - - local git_status = vim.b[utils.stbufnr()].git_branch + local git_status = vim.b[utils.stbufnr()].minigit_summary_string or "" local branch_name = " " .. git_status - return "%#St_gitIcons# " .. branch_name .. " " .. vim.b[utils.stbufnr()].minidiff_summary_string + return "%#St_gitIcons# " .. branch_name .. " " .. (vim.b[utils.stbufnr()].minidiff_summary_string or "") end, }, }, diff --git a/lua/plugins/specs/editor.lua b/lua/plugins/specs/editor.lua index 6ec3c4db..cb0b2d07 100644 --- a/lua/plugins/specs/editor.lua +++ b/lua/plugins/specs/editor.lua @@ -92,6 +92,12 @@ return { require("mini.diff").setup(opts) end, }, + { + "echasnovski/mini-git", + opts = true, + name = "mini.git", + event = "LazyFile", + }, { "echasnovski/mini.splitjoin", opts = true, diff --git a/lua/plugins/specs/lsp.lua b/lua/plugins/specs/lsp.lua index f587d7fb..2ea9c18d 100644 --- a/lua/plugins/specs/lsp.lua +++ b/lua/plugins/specs/lsp.lua @@ -37,6 +37,15 @@ return { }, } + vim.api.nvim_create_autocmd("LspAttach", { + callback = function(args) + local client = vim.lsp.get_client_by_id(args.data.client_id) + if client ~= nil then + client.server_capabilities.semanticTokensProvider = nil + end + end, + }) + require("lspconfig")["rust_analyzer"].setup({ capabilities = capabilities, settings = { From 214f2af62cc129fbb3cc85cf89dde83fdb8d3930 Mon Sep 17 00:00:00 2001 From: asyncedd Date: Wed, 22 May 2024 19:38:05 +0900 Subject: [PATCH 22/56] fix(mini-git): fix some edge cases --- lua/chadrc.lua | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lua/chadrc.lua b/lua/chadrc.lua index 13e556e0..12d6fc5b 100644 --- a/lua/chadrc.lua +++ b/lua/chadrc.lua @@ -8,13 +8,13 @@ local diff_format_summary = function(data) return end local t = {} - if summary.add > 0 then + if summary.add ~= nil and summary.add > 0 then table.insert(t, dots.UI.icons.Git.added .. summary.add) end - if summary.change > 0 then + if summary.change ~= nil and summary.change > 0 then table.insert(t, dots.UI.icons.Git.changed .. summary.change) end - if summary.delete > 0 then + if summary.delete ~= nil and summary.delete > 0 then table.insert(t, dots.UI.icons.Git.remove .. summary.delete) end vim.b[data.buf].minidiff_summary_string = table.concat(t, " ") @@ -25,7 +25,7 @@ vim.api.nvim_create_autocmd("User", { pattern = "MiniDiffUpdated", callback = di local git_format_summary = function(data) -- Utilize buffer-local table summary local summary = vim.b[data.buf].minigit_summary - vim.b[data.buf].minigit_summary_string = (summary ~= nil and summary.head_name or "") or "" + vim.b[data.buf].minigit_summary_string = (summary ~= nil and summary.head_name) or "" end vim.api.nvim_create_autocmd("User", { pattern = "MiniGitUpdated", callback = git_format_summary }) From 004858bed48906f4b27421eb8c9d076f97064c2f Mon Sep 17 00:00:00 2001 From: asyncedd Date: Wed, 22 May 2024 20:25:39 +0900 Subject: [PATCH 23/56] feat: set css ft for postcss --- init.lua | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/init.lua b/init.lua index 7a04c822..71fcd34a 100644 --- a/init.lua +++ b/init.lua @@ -44,5 +44,11 @@ vim.diagnostic.config({ }, }) +vim.filetype.add({ + extension = { + postcss = "css", + }, +}) + dofile(vim.g.base46_cache .. "defaults") dofile(vim.g.base46_cache .. "statusline") From cf1688172ef33c8f034fd056d69b9c54e4b5c13a Mon Sep 17 00:00:00 2001 From: asyncedd Date: Wed, 22 May 2024 20:26:15 +0900 Subject: [PATCH 24/56] Revert "perf: rm noice" This reverts commit 59e443e30b100fff34a1adafce6965157c37b5cf. * upd lazy-lock --- lazy-lock.json | 2 ++ lua/plugins/specs/ui.lua | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/lazy-lock.json b/lazy-lock.json index 7f2167ce..2790d8b2 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -25,6 +25,8 @@ "mini.splitjoin": { "branch": "main", "commit": "a6b043b4afb075058a8c49325ff22e07f0e96170" }, "mini.surround": { "branch": "main", "commit": "c52aa751daf62d4a9e6ee24c4a91882ef6842f99" }, "mini.visits": { "branch": "main", "commit": "17bbec0e1669e4b91c1a50bbf56dc94d6f4873e8" }, + "noice.nvim": { "branch": "main", "commit": "9f6f6ba74f8bfbf7e43d6302cf86b070362f6203" }, + "nui.nvim": { "branch": "main", "commit": "b1b3dcd6ed8f355c78bad3d395ff645be5f8b6ae" }, "nvim-cmp": { "branch": "main", "commit": "a08882abe1f900c0c7f516725d74c7d84faeaa79" }, "nvim-lint": { "branch": "master", "commit": "5697e6cb9588b70e260e4cc1f833ebb0bdc07617" }, "nvim-lspconfig": { "branch": "master", "commit": "0b8165cf95806bc4bb8f745bb0c92021b2ed4b98" }, diff --git a/lua/plugins/specs/ui.lua b/lua/plugins/specs/ui.lua index 6627e8cc..c5d034f9 100644 --- a/lua/plugins/specs/ui.lua +++ b/lua/plugins/specs/ui.lua @@ -59,6 +59,40 @@ return { end end, }, + { + "folke/noice.nvim", + opts = { + lsp = { + override = { + ["vim.lsp.util.convert_input_to_markdown_lines"] = true, + ["vim.lsp.util.stylize_markdown"] = true, + ["cmp.entry.get_documentation"] = true, + }, + }, + presets = { + bottom_search = true, + command_palette = true, + long_message_to_split = true, + inc_rename = false, + lsp_doc_border = false, + }, + cmdline = { + view = "cmdline", + }, + views = { + mini = { + win_options = { + winblend = 0, + }, + }, + }, + }, + event = "VeryLazy", + dependencies = { + "MunifTanjim/nui.nvim", + "rcarriga/nvim-notify", + }, + }, -- CREDITS TO: https://www.lazyvim.org/plugins/ui#dressingnvim { "stevearc/dressing.nvim", From c47efb12d7520cea8528fb63523c66eb1a6b926a Mon Sep 17 00:00:00 2001 From: asyncedd Date: Sat, 1 Jun 2024 09:28:36 +0900 Subject: [PATCH 25/56] fix(fzy_native): actually load it --- lua/plugins/specs/tools.lua | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lua/plugins/specs/tools.lua b/lua/plugins/specs/tools.lua index c65d2301..3c74245d 100644 --- a/lua/plugins/specs/tools.lua +++ b/lua/plugins/specs/tools.lua @@ -52,7 +52,12 @@ return { "danielfalk/smart-open.nvim", dependencies = { "kkharji/sqlite.lua", - "nvim-telescope/telescope-fzy-native.nvim", + { + "nvim-telescope/telescope-fzy-native.nvim", + config = function() + require("telescope").load_extension("fzy_native") + end, + }, }, config = function() require("telescope").load_extension("smart_open") From a5e616f345efc930b220f7fff93457f006dab982 Mon Sep 17 00:00:00 2001 From: asyncedd Date: Sat, 1 Jun 2024 09:28:50 +0900 Subject: [PATCH 26/56] fix: use spaces instead of tabs --- lua/settings/options.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/lua/settings/options.lua b/lua/settings/options.lua index 3c027b2f..32611f94 100644 --- a/lua/settings/options.lua +++ b/lua/settings/options.lua @@ -10,6 +10,7 @@ o.relativenumber = true -- Tabs o.shiftwidth = 2 o.tabstop = 2 +o.expandtab = true o.undofile = true o.undodir = vim.fn.stdpath("data") .. "/undo//" From 8f64dcc95fb7d565ae7f82dd63827bc5d20984f3 Mon Sep 17 00:00:00 2001 From: asyncedd Date: Sat, 1 Jun 2024 09:28:59 +0900 Subject: [PATCH 27/56] feat: use everblush --- lua/chadrc.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/chadrc.lua b/lua/chadrc.lua index 12d6fc5b..f396db8a 100644 --- a/lua/chadrc.lua +++ b/lua/chadrc.lua @@ -31,7 +31,7 @@ end vim.api.nvim_create_autocmd("User", { pattern = "MiniGitUpdated", callback = git_format_summary }) M.ui = { - theme = "onedark", + theme = "everblush", statusline = { order = { "mode", From 148c6fcab3c5ad4f947f91485da77fff781e0751 Mon Sep 17 00:00:00 2001 From: asyncedd Date: Mon, 3 Jun 2024 16:50:01 +0900 Subject: [PATCH 28/56] perf: optimize cfg --- init.lua | 37 +---- lazy-lock.json | 66 ++++---- lua/chadrc.lua | 10 ++ lua/configs/conform.lua | 17 ++ lua/configs/lazy.lua | 50 ++++++ lua/configs/lspconfig.lua | 148 ++++++++++++++++++ lua/plugins/init.lua | 58 +++---- lua/plugins/specs/editor.lua | 37 ++--- .../specs/goodies/telescope/diagnostics.lua | 17 -- lua/plugins/specs/languages/c.lua | 10 -- lua/plugins/specs/languages/css.lua | 10 -- lua/plugins/specs/languages/fish.lua | 10 -- lua/plugins/specs/languages/javascript.lua | 10 -- lua/plugins/specs/languages/lua.lua | 25 +++ lua/plugins/specs/languages/markdown.lua | 10 -- lua/plugins/specs/languages/nix.lua | 29 ---- lua/plugins/specs/languages/rust.lua | 17 -- lua/plugins/specs/languages/svelte.lua | 25 --- lua/plugins/specs/lsp.lua | 128 +-------------- lua/plugins/specs/ui.lua | 36 +---- lua/settings/autocmd.lua | 26 +++ lua/settings/init.lua | 20 +-- 22 files changed, 362 insertions(+), 434 deletions(-) create mode 100644 lua/configs/conform.lua create mode 100644 lua/configs/lazy.lua create mode 100644 lua/configs/lspconfig.lua delete mode 100644 lua/plugins/specs/goodies/telescope/diagnostics.lua delete mode 100644 lua/plugins/specs/languages/c.lua delete mode 100644 lua/plugins/specs/languages/css.lua delete mode 100644 lua/plugins/specs/languages/fish.lua delete mode 100644 lua/plugins/specs/languages/javascript.lua delete mode 100644 lua/plugins/specs/languages/markdown.lua delete mode 100644 lua/plugins/specs/languages/nix.lua delete mode 100644 lua/plugins/specs/languages/rust.lua delete mode 100644 lua/plugins/specs/languages/svelte.lua diff --git a/init.lua b/init.lua index 71fcd34a..672020b0 100644 --- a/init.lua +++ b/init.lua @@ -3,39 +3,14 @@ vim.g.base46_cache = vim.fn.stdpath("data") .. "/nvchad/base46/" require("settings") require("settings.options") -require("settings.autocmd") require("plugins") -require("settings.keymap") - --- This autocmd will only trigger when a file was loaded from the cmdline. --- It will render the file as quickly as possible. -vim.api.nvim_create_autocmd("BufReadPost", { - once = true, - callback = function(event) - -- Skip if we already entered vim - if vim.v.vim_did_enter == 1 then - return - end - - -- Try to guess the filetype (may change later on during Neovim startup) - local ft = vim.filetype.match({ buf = event.buf }) - if ft then - -- Add treesitter highlights and fallback to syntax - local lang = vim.treesitter.language.get_lang(ft) - if not (lang and pcall(vim.treesitter.start, event.buf, lang)) then - vim.bo[event.buf].syntax = ft - end - -- Trigger early redraw - vim.cmd([[redraw]]) - end - end, -}) - -for name, icon in pairs(dots.UI.icons.LSP.diagnostics) do - name = "DiagnosticSign" .. name - vim.fn.sign_define(name, { text = icon, texthl = name, numhl = "" }) -end +-- for name, icon in pairs(dots.UI.icons.LSP.diagnostics) do +-- name = "DiagnosticSign" .. name +-- vim.fn.sign_define(name, { text = icon, texthl = name, numhl = "" }) +-- end +require("settings.autocmd") +require("settings.keymap") -- https://www.reddit.com/r/neovim/comments/1ayx62p/config_for_diagnostics/ vim.diagnostic.config({ diff --git a/lazy-lock.json b/lazy-lock.json index 2790d8b2..69404b3e 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -1,48 +1,48 @@ { - "LuaSnip": { "branch": "master", "commit": "de1a287c9cb525ae52bc846e8f6207e5ef1da5ac" }, - "base46": { "branch": "v2.5", "commit": "7f9a7092402ae8951877f698f1c2291aa47c2903" }, + "LuaSnip": { "branch": "master", "commit": "878ace11983444d865a72e1759dbcc331d1ace4c" }, + "base46": { "branch": "v2.5", "commit": "87e09eb9e959966397bd9d8aab18d88ef349c913" }, "cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" }, "cmp-cmdline": { "branch": "main", "commit": "d250c63aa13ead745e3a40f61fdd3470efde3923" }, "cmp-nvim-lsp": { "branch": "main", "commit": "39e2eda76828d88b773cc27a3f61d2ad782c922d" }, "cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" }, "cmp_luasnip": { "branch": "master", "commit": "05a9ab28b53f71d1aece421ef32fee2cb857a843" }, - "conform.nvim": { "branch": "master", "commit": "b8f3ed3903430033f638b17f7455b8fd3d6a85b5" }, - "crates.nvim": { "branch": "main", "commit": "d556c00d60c9421c913ee54ff690df2a34f6264e" }, - "dressing.nvim": { "branch": "master", "commit": "572314728cb1ce012e825fd66331f52c94acac12" }, - "flash.nvim": { "branch": "main", "commit": "11a2e667d19d8f48c93c6ed2e2e525ac6b1b79be" }, - "friendly-snippets": { "branch": "main", "commit": "dd2fd1281d4b22e7b4a5bfafa3e142d958e251f2" }, - "indent-blankline.nvim": { "branch": "master", "commit": "ece00d5fb44d196680a81fd2761062d2fa44663b" }, - "lazy.nvim": { "branch": "main", "commit": "8f19915175395680808de529e4220da8dafc0759" }, + "conform.nvim": { "branch": "master", "commit": "63e0a32c85a39484813957dc480f171907aa90b9" }, + "dressing.nvim": { "branch": "master", "commit": "e3714c8049b2243e792492c4149e4cc395c68eb9" }, + "flash.nvim": { "branch": "main", "commit": "0b85b5ea6eaaebab5e012fab3496102094550686" }, + "friendly-snippets": { "branch": "main", "commit": "d0610077b6129cf9f7f78afbe3a1425d60f6e2f1" }, + "indent-blankline.nvim": { "branch": "master", "commit": "d98f537c3492e87b6dc6c2e3f66ac517528f406f" }, + "lazy.nvim": { "branch": "main", "commit": "ad30030b6abca7dac5a493c58b4d183b3fe93202" }, + "lazydev.nvim": { "branch": "main", "commit": "2e715cd4629df2b47d92468935226655cb7e88ed" }, "lspkind.nvim": { "branch": "master", "commit": "1735dd5a5054c1fb7feaf8e8658dbab925f4f0cf" }, - "mini.ai": { "branch": "main", "commit": "a0262e61f79dfc7bb940d1719c00b0ede042ddd7" }, - "mini.clue": { "branch": "main", "commit": "93f5a3799cf97e5bb1a948f731973a84026fa19d" }, - "mini.diff": { "branch": "main", "commit": "10cc9d370737b8b8c8d996fc537394635da0a4b1" }, - "mini.extra": { "branch": "main", "commit": "3157df3aaf38f5b040a56fd02c8efb05a043e5ae" }, - "mini.files": { "branch": "main", "commit": "759e2d213b13914fcd125eb8bfb80e3f3c607367" }, - "mini.git": { "branch": "main", "commit": "746696dd5db769cf6c809995adaab7cbfcdf6492" }, - "mini.move": { "branch": "main", "commit": "251d541a8ab745e81295a53c128829cb2bff18e3" }, - "mini.operators": { "branch": "main", "commit": "2edc808e32fbf3e0d4759bdef26a7a143a19f509" }, - "mini.splitjoin": { "branch": "main", "commit": "a6b043b4afb075058a8c49325ff22e07f0e96170" }, - "mini.surround": { "branch": "main", "commit": "c52aa751daf62d4a9e6ee24c4a91882ef6842f99" }, - "mini.visits": { "branch": "main", "commit": "17bbec0e1669e4b91c1a50bbf56dc94d6f4873e8" }, - "noice.nvim": { "branch": "main", "commit": "9f6f6ba74f8bfbf7e43d6302cf86b070362f6203" }, - "nui.nvim": { "branch": "main", "commit": "b1b3dcd6ed8f355c78bad3d395ff645be5f8b6ae" }, + "luvit-meta": { "branch": "main", "commit": "ce76f6f6cdc9201523a5875a4471dcfe0186eb60" }, + "mini.ai": { "branch": "main", "commit": "7859b6344f5cee567a94f173859d25e20ba1a77e" }, + "mini.clue": { "branch": "main", "commit": "629f7ddb071faf8eba77c5c56a295a0a206df94c" }, + "mini.diff": { "branch": "main", "commit": "441975a43bbec22442a91fe2ab1c7c06984e4d8a" }, + "mini.extra": { "branch": "main", "commit": "a89d2376082cfe4b9d55713beddd5c5f5995ea2a" }, + "mini.files": { "branch": "main", "commit": "2299bf2f55993d899249a585f04bb4ff5386d37e" }, + "mini.git": { "branch": "main", "commit": "625e529c8b6363290e1ffadc91cdf4b50e1cf094" }, + "mini.move": { "branch": "main", "commit": "9670fe1d19af3d9a69ddce920c527c883ca5dc4c" }, + "mini.operators": { "branch": "main", "commit": "ccc67955124dde0ba20cdcb37ea30ff1646da574" }, + "mini.splitjoin": { "branch": "main", "commit": "db26e1c991ff5f8cf377e800ef7fba6b5618306b" }, + "mini.surround": { "branch": "main", "commit": "27096c1a27324ee8f2044ea2adc77366d8a782de" }, + "mini.visits": { "branch": "main", "commit": "20e82e3f4ed1ce96d254c16a8602d7606c618c25" }, "nvim-cmp": { "branch": "main", "commit": "a08882abe1f900c0c7f516725d74c7d84faeaa79" }, - "nvim-lint": { "branch": "master", "commit": "5697e6cb9588b70e260e4cc1f833ebb0bdc07617" }, - "nvim-lspconfig": { "branch": "master", "commit": "0b8165cf95806bc4bb8f745bb0c92021b2ed4b98" }, + "nvim-lint": { "branch": "master", "commit": "2f90fe977ef21db3bf3b7a1ceaf4a1e3aafb2b26" }, + "nvim-lspconfig": { "branch": "master", "commit": "710a8fa7379db32199545f30ea01dd8446b9302f" }, "nvim-notify": { "branch": "master", "commit": "d333b6f167900f6d9d42a59005d82919830626bf" }, - "nvim-spectre": { "branch": "master", "commit": "50e96602153f14c913e1969aaf9720e080394eb3" }, - "nvim-treesitter": { "branch": "master", "commit": "14db0433e145c8ea63efc42ddbdf517d6036d372" }, - "nvim-treesitter-textobjects": { "branch": "master", "commit": "5f9bf4b1ead7707e4e74e5319ee56bdc81fb73db" }, - "nvim-various-textobjs": { "branch": "main", "commit": "6a0f594d686685b050320611e6e633ae5e51ebc2" }, - "nvim-web-devicons": { "branch": "master", "commit": "e37bb1feee9e7320c76050a55443fa843b4b6f83" }, + "nvim-spectre": { "branch": "master", "commit": "366f46fdd4a1593cc237aea13d5ef113739a472c" }, + "nvim-treesitter": { "branch": "master", "commit": "a80fe081b4c5890980561e0de2458f64aaffbfc7" }, + "nvim-treesitter-textobjects": { "branch": "master", "commit": "fd41b7ccc5490a3a99c734d1ee418b68d06c48a9" }, + "nvim-various-textobjs": { "branch": "main", "commit": "5c628394b57dd960c2bf82dcdcf1f4e0d27f2347" }, + "nvim-web-devicons": { "branch": "master", "commit": "b77921fdc44833c994fdb389d658ccbce5490c16" }, "plenary.nvim": { "branch": "master", "commit": "a3e3bc82a3f95c5ed0d7201546d5d2c19b20d683" }, "smart-open.nvim": { "branch": "main", "commit": "028bb71d20e8212da3514bf6dabfb17038d81ee4" }, "sqlite.lua": { "branch": "master", "commit": "d0ffd703b56d090d213b497ed4eb840495f14a11" }, "telescope-fzy-native.nvim": { "branch": "master", "commit": "282f069504515eec762ab6d6c89903377252bf5b" }, - "telescope.nvim": { "branch": "master", "commit": "4aed63995a69e343b068c7469491a8d1592c339f" }, - "ui": { "branch": "v2.5", "commit": "5fe258afeb248519fc2a1681b48d24208ed22abe" }, - "ultimate-autopair.nvim": { "branch": "v0.6", "commit": "042587c63b2b2776a83337748d53dba8b67ec545" }, + "telescope.nvim": { "branch": "master", "commit": "dfa230be84a044e7f546a6c2b0a403c739732b86" }, + "ts-comments.nvim": { "branch": "main", "commit": "e339090c076871069c00e488b11def49aaf4e413" }, + "ui": { "branch": "v2.5", "commit": "0c283b6aed4eed585a497c9031b18b5009bfe4dd" }, + "ultimate-autopair.nvim": { "branch": "v0.6", "commit": "813e1b3391c3f50100345bf3956c618f7e522e74" }, "vscode-svelte-snippets": { "branch": "master", "commit": "564ac3300bfeda01ff0bf6b89152cef43f85a4ce" }, - "yanky.nvim": { "branch": "main", "commit": "396ff7ed952a69549f299c7b6f64615a89836733" } + "yanky.nvim": { "branch": "main", "commit": "79338563e85a868e59cda02c51b54d90a5514a12" } } \ No newline at end of file diff --git a/lua/chadrc.lua b/lua/chadrc.lua index f396db8a..f057be60 100644 --- a/lua/chadrc.lua +++ b/lua/chadrc.lua @@ -1,3 +1,4 @@ +---@type ChadrcConfig local M = {} local utils = require("nvchad.stl.utils") @@ -52,6 +53,15 @@ M.ui = { end, }, }, + hl_override = { + DiffAdd = { fg = "green" }, + DiffModified = { fg = "yellow" }, + }, + hl_add = { + MiniDiffSignAdd = { fg = "green" }, + MiniDiffSignChange = { fg = "yellow" }, + MiniDiffSignDelete = { fg = "red" }, + }, } return M diff --git a/lua/configs/conform.lua b/lua/configs/conform.lua new file mode 100644 index 00000000..c2e0eed4 --- /dev/null +++ b/lua/configs/conform.lua @@ -0,0 +1,17 @@ +local options = { + format_on_save = { timeout_ms = 500, lsp_fallback = true }, + formatters_by_ft = { + c = { "clang_format" }, + javascript = { "prettierd" }, + typescript = { "prettierd" }, + css = { "prettierd" }, + html = { "prettierd" }, + fish = { "fish_indent" }, + nix = { "alejandra" }, + markdown = { { "prettierd", "prettier" } }, + lua = { "stylua" }, + svelte = { { "prettierd", "prettier" } }, + }, +} + +return options diff --git a/lua/configs/lazy.lua b/lua/configs/lazy.lua new file mode 100644 index 00000000..99b047bf --- /dev/null +++ b/lua/configs/lazy.lua @@ -0,0 +1,50 @@ +return { + defaults = { lazy = true }, + install = { colorscheme = { "nvchad", "habamax" } }, + + ui = { + icons = { + ft = "", + lazy = "󰂠 ", + loaded = "", + not_loaded = "", + }, + }, + + performance = { + rtp = { + disabled_plugins = { + "2html_plugin", + "tohtml", + "getscript", + "getscriptPlugin", + "gzip", + "logipat", + "netrw", + "netrwPlugin", + "netrwSettings", + "netrwFileHandlers", + "matchit", + "tar", + "tarPlugin", + "rrhelper", + "spellfile_plugin", + "vimball", + "vimballPlugin", + "zip", + "zipPlugin", + "tutor", + "rplugin", + "syntax", + "synmenu", + "optwin", + "compiler", + "bugreport", + "ftplugin", + }, + }, + }, + change_detection = { + notify = false, + }, +} diff --git a/lua/configs/lspconfig.lua b/lua/configs/lspconfig.lua new file mode 100644 index 00000000..018074ee --- /dev/null +++ b/lua/configs/lspconfig.lua @@ -0,0 +1,148 @@ +local conf = require("nvconfig").ui.lsp +local map = vim.keymap.set +local on_attach = function(client, bufnr) + local function opts(desc) + return { buffer = bufnr, desc = "LSP " .. desc } + end + + map("n", "gD", vim.lsp.buf.declaration, opts("Go to declaration")) + map("n", "gd", vim.lsp.buf.definition, opts("Go to definition")) + map("n", "gi", vim.lsp.buf.implementation, opts("Go to implementation")) + map("n", "sh", vim.lsp.buf.signature_help, opts("Show signature help")) + map("n", "wa", vim.lsp.buf.add_workspace_folder, opts("Add workspace folder")) + map("n", "wr", vim.lsp.buf.remove_workspace_folder, opts("Remove workspace folder")) + + map("n", "wl", function() + print(vim.inspect(vim.lsp.buf.list_workspace_folders())) + end, opts("List workspace folders")) + + map("n", "D", vim.lsp.buf.type_definition, opts("Go to type definition")) + + map("n", "ra", function() + require("nvchad.lsp.renamer")() + end, opts("NvRenamer")) + + map({ "n", "v" }, "ca", vim.lsp.buf.code_action, opts("Code action")) + map("n", "gr", vim.lsp.buf.references, opts("Show references")) + + -- setup signature popup + if conf.signature and client.server_capabilities.signatureHelpProvider then + require("nvchad.lsp.signature").setup(client, bufnr) + end +end + +local on_init = function(client, _) + if client.supports_method("textDocument/semanticTokens") then + client.server_capabilities.semanticTokensProvider = nil + end +end + +local capabilities = vim.lsp.protocol.make_client_capabilities() + +capabilities.textDocument.completion.completionItem = { + documentationFormat = { "markdown", "plaintext" }, + snippetSupport = true, + preselectSupport = true, + insertReplaceSupport = true, + labelDetailsSupport = true, + deprecatedSupport = true, + commitCharactersSupport = true, + tagSupport = { valueSet = { 1 } }, + resolveSupport = { + properties = { + "documentation", + "detail", + "additionalTextEdits", + }, + }, +} + +local lspconfig = require("lspconfig") + +local servers = { + -- "nixd", + -- "clangd", + -- "svelte", + -- "emmet_ls", + -- "tailwindcss", + -- "marksman", +} + +for _, lsp in ipairs(servers) do + lspconfig[lsp].setup({ + on_attach = on_attach, + on_init = on_init, + capabilities = capabilities, + }) +end + +require("lspconfig")["rust_analyzer"].setup({ + capabilities = capabilities, + on_attach = on_attach, + on_init = on_init, + settings = { + ["rust-analyzer"] = { + cargo = { + allFeatures = true, + loadOutDirsFromCheck = true, + runBuildScripts = true, + }, + check = { + command = "clippy", + allFeatures = true, + extraArgs = { + "--", + "-W clippy::pedantic", + "-W clippy::nursery", + "-W clippy::unwrap_used", + "-W clippy::expect_used", + }, + }, + procMacro = { + enable = true, + ignored = { + ["async-trait"] = { "async_trait" }, + ["napi-derive"] = { "napi" }, + ["async-recursion"] = { "async_recursion" }, + }, + }, + }, + }, +}) + +require("lspconfig")["lua_ls"].setup({ + capabilities = capabilities, + on_attach = on_attach, + on_init = on_init, + settings = { + Lua = { + hint = { + enable = true, + arrayIndex = "Disable", + }, + runtime = { + pathStrict = true, + }, + completion = { + callSnippet = "Both", + }, + diagnostics = { + globals = { + "vim", + }, + }, + workspace = { + maxPreload = 100000, + preloadFileSize = 10000, + checkThirdParty = false, + }, + }, + }, +}) + +require("lspconfig")["cssls"].setup({ + capabilities = capabilities, + cmd = { "css-languageserver", "--stdio" }, + on_attach = on_attach, + on_init = on_init, +}) diff --git a/lua/plugins/init.lua b/lua/plugins/init.lua index 2c1c5ce6..5315e187 100644 --- a/lua/plugins/init.lua +++ b/lua/plugins/init.lua @@ -11,36 +11,38 @@ if not vim.loop.fs_stat(lazypath) then end vim.opt.rtp:prepend(lazypath) --- Add support for the LazyFile event -local Event = require("lazy.core.handler.event") +-- -- This autocmd will only trigger when a file was loaded from the cmdline. +-- -- It will render the file as quickly as possible. +-- vim.api.nvim_create_autocmd("BufReadPost", { +-- once = true, +-- callback = function(event) +-- -- Skip if we already entered vim +-- if vim.v.vim_did_enter == 1 then +-- return +-- end +-- +-- -- Try to guess the filetype (may change later on during Neovim startup) +-- local ft = vim.filetype.match({ buf = event.buf }) +-- if ft then +-- -- Add treesitter highlights and fallback to syntax +-- local lang = vim.treesitter.language.get_lang(ft) +-- if not (lang and pcall(vim.treesitter.start, event.buf, lang)) then +-- vim.bo[event.buf].syntax = ft +-- end +-- +-- -- Trigger early redraw +-- vim.cmd([[redraw]]) +-- end +-- end, +-- }) -Event.mappings.LazyFile = { id = "LazyFile", event = { "BufReadPost", "BufNewFile", "BufWritePre" } } -Event.mappings["LazyFile"] = Event.mappings.LazyFile +-- -- Add support for the LazyFile event +-- local Event = require("lazy.core.handler.event") +-- +-- Event.mappings.LazyFile = { id = "LazyFile", event = { "BufReadPost", "BufNewFile", "BufWritePre" } } +-- Event.mappings["LazyFile"] = Event.mappings.LazyFile require("lazy").setup({ { import = "plugins.specs" }, dots.languages.enable, - dots.goodies.enable, -}, { - defaults = { - lazy = true, - }, - install = { - colorscheme = { "nvchad", "habamax" }, - }, - performance = { - rtp = { - disabled_plugins = { - "gzip", - "netrwPlugin", - "tarPlugin", - "tohtml", - "zipPlugin", - "tutor", - }, - }, - }, - change_detection = { - notify = false, - }, -}) +}, require("configs.lazy")) diff --git a/lua/plugins/specs/editor.lua b/lua/plugins/specs/editor.lua index cb0b2d07..c09680a3 100644 --- a/lua/plugins/specs/editor.lua +++ b/lua/plugins/specs/editor.lua @@ -3,46 +3,22 @@ return { "nvim-treesitter/nvim-treesitter", opts = { ensure_installed = { "c", "lua", "vim", "vimdoc", "query" }, - auto_install = true, highlight = { enable = true, + use_languagetree = true, }, indent = { enable = true, }, }, - lazy = vim.fn.argc(-1) == 0, -- load treesitter early when opening a file from the cmdline - init = function(plugin) - -- PERF: add nvim-treesitter queries to the rtp and it's custom query predicates early - -- This is needed because a bunch of plugins no longer `require("nvim-treesitter")`, which - -- no longer trigger the **nvim-treesitter** module to be loaded in time. - -- Luckily, the only things that those plugins need are the custom queries, which we make available - -- during startup. - require("lazy.core.loader").add_to_rtp(plugin) - require("nvim-treesitter.query_predicates") - end, build = ":TSUpdate", config = function(_, opts) dofile(vim.g.base46_cache .. "syntax") dofile(vim.g.base46_cache .. "treesitter") - if type(opts.ensure_installed) == "table" then - ---@type table - local added = {} - opts.ensure_installed = vim.tbl_filter(function(lang) - if added[lang] then - return false - end - added[lang] = true - return true - end, opts.ensure_installed) - end require("nvim-treesitter.configs").setup(opts) - vim.schedule(function() - require("lazy").load({ plugins = { "nvim-treesitter-textobjects" } }) - end) end, - event = "LazyFile", + event = "User LazyFile", }, { "folke/flash.nvim", @@ -80,7 +56,7 @@ return { }, { "echasnovski/mini.diff", - event = "LazyFile", + event = "User LazyFile", opts = { view = { style = "sign", @@ -96,7 +72,7 @@ return { "echasnovski/mini-git", opts = true, name = "mini.git", - event = "LazyFile", + event = "User LazyFile", }, { "echasnovski/mini.splitjoin", @@ -354,4 +330,9 @@ return { }, }, }, + { + "folke/ts-comments.nvim", + opts = {}, + event = "VeryLazy", + }, } diff --git a/lua/plugins/specs/goodies/telescope/diagnostics.lua b/lua/plugins/specs/goodies/telescope/diagnostics.lua deleted file mode 100644 index 5b2e08e2..00000000 --- a/lua/plugins/specs/goodies/telescope/diagnostics.lua +++ /dev/null @@ -1,17 +0,0 @@ -return { - { - "nvim-telescope/telescope.nvim", - optional = true, - opts = { - pickers = { - diagnostics = { - theme = "ivy", - initial_mode = "normal", - layout_config = { - preview_cutoff = 9999, - }, - }, - }, - }, - }, -} diff --git a/lua/plugins/specs/languages/c.lua b/lua/plugins/specs/languages/c.lua deleted file mode 100644 index 8673fc7f..00000000 --- a/lua/plugins/specs/languages/c.lua +++ /dev/null @@ -1,10 +0,0 @@ -return { - { - "stevearc/conform.nvim", - opts = { - formatters_by_ft = { - c = { "clang_format" }, - }, - }, - }, -} diff --git a/lua/plugins/specs/languages/css.lua b/lua/plugins/specs/languages/css.lua deleted file mode 100644 index f925cddf..00000000 --- a/lua/plugins/specs/languages/css.lua +++ /dev/null @@ -1,10 +0,0 @@ -return { - { - "stevearc/conform.nvim", - opts = { - formatters_by_ft = { - css = { { "prettierd", "prettier" } }, - }, - }, - }, -} diff --git a/lua/plugins/specs/languages/fish.lua b/lua/plugins/specs/languages/fish.lua deleted file mode 100644 index 5b4f0288..00000000 --- a/lua/plugins/specs/languages/fish.lua +++ /dev/null @@ -1,10 +0,0 @@ -return { - { - "stevearc/conform.nvim", - opts = { - formatters_by_ft = { - fish = { "fish_indent" }, - }, - }, - }, -} diff --git a/lua/plugins/specs/languages/javascript.lua b/lua/plugins/specs/languages/javascript.lua deleted file mode 100644 index 28a4604c..00000000 --- a/lua/plugins/specs/languages/javascript.lua +++ /dev/null @@ -1,10 +0,0 @@ -return { - { - "conform.nvim", - opts = { - formatters_by_ft = { - javascript = { "prettierd" }, - }, - }, - }, -} diff --git a/lua/plugins/specs/languages/lua.lua b/lua/plugins/specs/languages/lua.lua index b9f7077a..89cadbba 100644 --- a/lua/plugins/specs/languages/lua.lua +++ b/lua/plugins/specs/languages/lua.lua @@ -7,4 +7,29 @@ return { }, }, }, + { + "folke/lazydev.nvim", + ft = "lua", -- only load on lua files + opts = { + library = { + vim.env.LAZY .. "/luvit-meta/library", -- see below + vim.env.LAZY .. "/ui/nvchad_types", + -- You can also add plugins you always want to have loaded. + -- Useful if the plugin has globals or types you want to use + -- vim.env.LAZY .. "/LazyVim", -- see below + }, + }, + }, + { "Bilal2453/luvit-meta", lazy = true }, -- optional `vim.uv` typings + + { -- optional completion source for require statements and module annotations + "nvim-cmp", + opts = function(_, opts) + opts.sources = opts.sources or {} + table.insert(opts.sources, { + name = "lazydev", + group_index = 0, -- set group index to 0 to skip loading LuaLS completions + }) + end, + }, } diff --git a/lua/plugins/specs/languages/markdown.lua b/lua/plugins/specs/languages/markdown.lua deleted file mode 100644 index 716dddc0..00000000 --- a/lua/plugins/specs/languages/markdown.lua +++ /dev/null @@ -1,10 +0,0 @@ -return { - { - "stevearc/conform.nvim", - opts = { - formatters_by_ft = { - markdown = { { "prettierd", "prettier" } }, - }, - }, - }, -} diff --git a/lua/plugins/specs/languages/nix.lua b/lua/plugins/specs/languages/nix.lua deleted file mode 100644 index 7e8bd3c7..00000000 --- a/lua/plugins/specs/languages/nix.lua +++ /dev/null @@ -1,29 +0,0 @@ -return { - -- { - -- "neovim/nvim-lspconfig", - -- optional = true, - -- opts = { - -- servers = { - -- ["nil_ls"] = { - -- ["nil"] = {}, - -- }, - -- }, - -- }, - -- }, - { - "nvim-treesitter/nvim-treesitter", - opts = function(_, opts) - table.insert(opts.ensure_installed, { - "nix", - }) - end, - }, - { - "stevearc/conform.nvim", - opts = { - formatters_by_ft = { - nix = { "alejandra" }, - }, - }, - }, -} diff --git a/lua/plugins/specs/languages/rust.lua b/lua/plugins/specs/languages/rust.lua deleted file mode 100644 index cb4d707c..00000000 --- a/lua/plugins/specs/languages/rust.lua +++ /dev/null @@ -1,17 +0,0 @@ -return { - { - "Saecki/crates.nvim", - event = { "BufRead Cargo.toml" }, - dependencies = { "nvim-lua/plenary.nvim" }, - opts = true, - }, - { - "stevearc/conform.nvim", - optional = true, - opts = { - formatters_by_ft = { - rust = { "rustfmt" }, - }, - }, - }, -} diff --git a/lua/plugins/specs/languages/svelte.lua b/lua/plugins/specs/languages/svelte.lua deleted file mode 100644 index a81dd220..00000000 --- a/lua/plugins/specs/languages/svelte.lua +++ /dev/null @@ -1,25 +0,0 @@ -return { - { - "nvim-treesitter", - optional = true, - opts = function(_, opts) - table.insert(opts.ensure_installed, { - "svelte", - "html", - "css", - "scss", - "javascript", - "typescript", - "rust", - }) - end, - }, - { - "stevearc/conform.nvim", - opts = { - formatters_by_ft = { - svelte = { { "prettierd", "prettier" } }, - }, - }, - }, -} diff --git a/lua/plugins/specs/lsp.lua b/lua/plugins/specs/lsp.lua index 2ea9c18d..0be128b6 100644 --- a/lua/plugins/specs/lsp.lua +++ b/lua/plugins/specs/lsp.lua @@ -1,135 +1,19 @@ return { { "neovim/nvim-lspconfig", - event = "LazyFile", + event = "User LazyFile", config = function() dofile(vim.g.base46_cache .. "lsp") - local inlay_hint = vim.lsp.buf.inlay_hint or vim.lsp.inlay_hint - - if inlay_hint then - vim.api.nvim_create_autocmd("LspAttach", { - callback = function(args) - local client = vim.lsp.get_client_by_id(args.data.client_id) - if client and client.server_capabilities.inlayHintProvider then - inlay_hint.enable(true) - end - end, - }) - end - - local capabilities = vim.lsp.protocol.make_client_capabilities() - - capabilities.textDocument.completion.completionItem = { - documentationFormat = { "markdown", "plaintext" }, - snippetSupport = true, - preselectSupport = true, - insertReplaceSupport = true, - labelDetailsSupport = true, - deprecatedSupport = true, - commitCharactersSupport = true, - tagSupport = { valueSet = { 1 } }, - resolveSupport = { - properties = { - "documentation", - "detail", - "additionalTextEdits", - }, - }, - } - - vim.api.nvim_create_autocmd("LspAttach", { - callback = function(args) - local client = vim.lsp.get_client_by_id(args.data.client_id) - if client ~= nil then - client.server_capabilities.semanticTokensProvider = nil - end - end, - }) - - require("lspconfig")["rust_analyzer"].setup({ - capabilities = capabilities, - settings = { - ["rust-analyzer"] = { - cargo = { - allFeatures = true, - loadOutDirsFromCheck = true, - runBuildScripts = true, - }, - check = { - command = "clippy", - allFeatures = true, - extraArgs = { - "--", - "-W clippy::pedantic", - "-W clippy::nursery", - "-W clippy::unwrap_used", - "-W clippy::expect_used", - }, - }, - procMacro = { - enable = true, - ignored = { - ["async-trait"] = { "async_trait" }, - ["napi-derive"] = { "napi" }, - ["async-recursion"] = { "async_recursion" }, - }, - }, - }, - }, - }) - - require("lspconfig")["nixd"].setup({ capabilities = capabilities }) - require("lspconfig")["lua_ls"].setup({ - capabilities = capabilities, - settings = { - Lua = { - hint = { - enable = true, - arrayIndex = "Disable", - }, - runtime = { - pathStrict = true, - }, - completion = { - callSnippet = "Both", - }, - diagnostics = { - globals = { - "vim", - }, - }, - workspace = { - library = { - [vim.fn.expand("$VIMRUNTIME/lua")] = true, - [vim.fn.expand("$VIMRUNTIME/lua/vim/lsp")] = true, - }, - maxPreload = 100000, - preloadFileSize = 10000, - checkThirdParty = false, - }, - }, - }, - }) - - require("lspconfig")["clangd"].setup({ capabilities = capabilities }) - require("lspconfig")["svelte"].setup({ capabilities = capabilities }) - require("lspconfig")["emmet_ls"].setup({ capabilities = capabilities }) - require("lspconfig")["tailwindcss"].setup({ capabilities = capabilities }) - -- require("lspconfig")["taplo"].setup({ capabilities = capabilities }) - require("lspconfig")["cssls"].setup({ - capabilities = capabilities, - cmd = { "css-languageserver", "--stdio" }, - }) - require("lspconfig")["marksman"].setup({ capabilities = capabilities }) - -- require("lspconfig")["hls"].setup({ capabilities = capabilities }) + require("configs.lspconfig") + require("nvchad.lsp") end, }, { "stevearc/conform.nvim", event = { "BufWritePre" }, - opts = { - format_on_save = { timeout_ms = 500, lsp_fallback = true }, - }, + opts = function() + return require("configs.conform") + end, init = function() vim.opt.formatexpr = "v:lua.require'conform'.formatexpr()" end, diff --git a/lua/plugins/specs/ui.lua b/lua/plugins/specs/ui.lua index c5d034f9..499612e1 100644 --- a/lua/plugins/specs/ui.lua +++ b/lua/plugins/specs/ui.lua @@ -17,7 +17,7 @@ return { }, { "lukas-reineke/indent-blankline.nvim", - event = "LazyFile", + event = "User LazyFile", opts = { indent = { highlight = "IblChar" }, scope = { highlight = "IblScopeChar" }, @@ -59,40 +59,6 @@ return { end end, }, - { - "folke/noice.nvim", - opts = { - lsp = { - override = { - ["vim.lsp.util.convert_input_to_markdown_lines"] = true, - ["vim.lsp.util.stylize_markdown"] = true, - ["cmp.entry.get_documentation"] = true, - }, - }, - presets = { - bottom_search = true, - command_palette = true, - long_message_to_split = true, - inc_rename = false, - lsp_doc_border = false, - }, - cmdline = { - view = "cmdline", - }, - views = { - mini = { - win_options = { - winblend = 0, - }, - }, - }, - }, - event = "VeryLazy", - dependencies = { - "MunifTanjim/nui.nvim", - "rcarriga/nvim-notify", - }, - }, -- CREDITS TO: https://www.lazyvim.org/plugins/ui#dressingnvim { "stevearc/dressing.nvim", diff --git a/lua/settings/autocmd.lua b/lua/settings/autocmd.lua index f08c9f52..64db8c09 100644 --- a/lua/settings/autocmd.lua +++ b/lua/settings/autocmd.lua @@ -73,3 +73,29 @@ autocmd("BufWritePost", { vim.cmd("redraw!") end, }) + +-- user event that loads after UIEnter + only if file buf is there +autocmd({ "UIEnter", "BufReadPost", "BufNewFile" }, { + group = vim.api.nvim_create_augroup("NvLazyFile", { clear = true }), + callback = function(args) + local file = vim.api.nvim_buf_get_name(args.buf) + local buftype = vim.api.nvim_buf_get_option(args.buf, "buftype") + + if not vim.g.ui_entered and args.event == "UIEnter" then + vim.g.ui_entered = true + end + + if file ~= "" and buftype ~= "nofile" and vim.g.ui_entered then + vim.api.nvim_exec_autocmds("User", { pattern = "LazyFile", modeline = false }) + vim.api.nvim_del_augroup_by_name("NvLazyFile") + + vim.schedule(function() + vim.api.nvim_exec_autocmds("FileType", {}) + + if vim.g.editorconfig then + require("editorconfig").config(args.buf) + end + end, 0) + end + end, +}) diff --git a/lua/settings/init.lua b/lua/settings/init.lua index 38028364..32bad009 100644 --- a/lua/settings/init.lua +++ b/lua/settings/init.lua @@ -64,25 +64,7 @@ M.UI = { M.languages = { enable = { -- Use this to enable all language support. - -- { import = "plugins.specs.languages" }, - { import = "plugins.specs.languages.lua" }, - { import = "plugins.specs.languages.svelte" }, - { import = "plugins.specs.languages.rust" }, - { import = "plugins.specs.languages.markdown" }, - { import = "plugins.specs.languages.css" }, - { import = "plugins.specs.languages.nix" }, - { import = "plugins.specs.languages.javascript" }, - -- { import = "plugins.specs.languages.dot" }, - -- { import = "plugins.specs.languages.c" }, - -- { import = "plugins.specs.languages.fish" }, - -- { import = "plugins.specs.languages.haskell" }, - -- { import = "plugins.specs.languages.toml" }, - }, -} - -M.goodies = { - enable = { - { import = "plugins.specs.goodies.telescope.diagnostics" }, + { import = "plugins.specs.languages" }, }, } From 9915b70ab563a64f3a379d396b868aa568d38076 Mon Sep 17 00:00:00 2001 From: asyncedd Date: Mon, 3 Jun 2024 16:52:31 +0900 Subject: [PATCH 29/56] fix: rm unneeded comments --- init.lua | 4 ---- 1 file changed, 4 deletions(-) diff --git a/init.lua b/init.lua index 672020b0..be3fffc6 100644 --- a/init.lua +++ b/init.lua @@ -5,10 +5,6 @@ require("settings") require("settings.options") require("plugins") --- for name, icon in pairs(dots.UI.icons.LSP.diagnostics) do --- name = "DiagnosticSign" .. name --- vim.fn.sign_define(name, { text = icon, texthl = name, numhl = "" }) --- end require("settings.autocmd") require("settings.keymap") From a2ee5be4d8fc4a6551c1b6fc4b89eb5a040abd12 Mon Sep 17 00:00:00 2001 From: asyncedd Date: Thu, 6 Jun 2024 22:45:08 +0900 Subject: [PATCH 30/56] feat: replace nvim-notify with mini.noitfy --- lua/plugins/configs/ui/notify.lua | 55 ------------------------------- lua/plugins/specs/ui.lua | 30 ++++++++++++----- 2 files changed, 21 insertions(+), 64 deletions(-) delete mode 100644 lua/plugins/configs/ui/notify.lua diff --git a/lua/plugins/configs/ui/notify.lua b/lua/plugins/configs/ui/notify.lua deleted file mode 100644 index 94cb9c23..00000000 --- a/lua/plugins/configs/ui/notify.lua +++ /dev/null @@ -1,55 +0,0 @@ -local api = vim.api -local stages = require("notify.stages.fade_in_slide_out")("top_down") -local base = require("notify.render.base") -return { - render = function(bufnr, notif, highlights, config) - local max_message_width = math.max(math.max(unpack(vim.tbl_map(function(line) - return vim.fn.strchars(line) - end, notif.message)))) - local title = notif.title[1] - local title_accum = vim.str_utfindex(title) - - local title_buffer = - string.rep(" ", (math.max(max_message_width, title_accum, config.minimum_width()) - title_accum) / 2) - - local namespace = base.namespace() - - api.nvim_buf_set_lines(bufnr, 0, 1, false, { "", "" }) - api.nvim_buf_set_extmark(bufnr, namespace, 0, 0, { - virt_text = { - { title_buffer .. notif.icon .. " " .. title .. title_buffer, highlights.title }, - }, - virt_text_win_col = 0, - priority = 10, - }) - api.nvim_buf_set_extmark(bufnr, namespace, 1, 0, { - virt_text = { - { - string.rep("━", math.max(max_message_width, title_accum, config.minimum_width())), - highlights.border, - }, - }, - virt_text_win_col = 0, - priority = 10, - }) - api.nvim_buf_set_lines(bufnr, 2, -1, false, notif.message) - - api.nvim_buf_set_extmark(bufnr, namespace, 2, 0, { - hl_group = highlights.body, - end_line = 1 + #notif.message, - end_col = #notif.message[#notif.message], - priority = 50, - }) - end, - stages = { - function(...) - local opts = stages[1](...) - if opts then - opts.row = opts.row + 1 - end - return opts - end, - unpack(stages, 2), - }, - fps = 60, -} diff --git a/lua/plugins/specs/ui.lua b/lua/plugins/specs/ui.lua index 499612e1..491088ba 100644 --- a/lua/plugins/specs/ui.lua +++ b/lua/plugins/specs/ui.lua @@ -43,21 +43,33 @@ return { end, }, { - "rcarriga/nvim-notify", - opts = function() - return require("plugins.configs.ui.notify") - end, - config = function() - vim.notify = require("notify") + "echasnovski/mini.notify", + opts = { + window = { + config = { + border = "none", + }, + winblend = 0, + }, + }, + config = function(_, opts) + local notify = require("mini.notify") + notify.setup(opts) + vim.notify = notify.make_notify({ + ERROR = { duration = 5000 }, + WARN = { duration = 4000 }, + INFO = { duration = 3000 }, + }) end, init = function() vim.notify = function(...) - if not require("lazy.core.config").plugins["nvim-notify"]._.loaded then - require("lazy").load({ plugins = "nvim-notify" }) + if not require("lazy.core.config").plugins["mini.notify"]._.loaded then + require("lazy").load({ plugins = "mini.notify" }) end - require("notify")(...) + vim.notify(...) end end, + event = "LspAttach", }, -- CREDITS TO: https://www.lazyvim.org/plugins/ui#dressingnvim { From 79a1dfb0e28ca77c97e18689fa8eb0190d2f16ea Mon Sep 17 00:00:00 2001 From: asyncedd Date: Thu, 6 Jun 2024 22:45:43 +0900 Subject: [PATCH 31/56] perf(treesitter): load treesitter a bit quicker --- lua/plugins/specs/editor.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/plugins/specs/editor.lua b/lua/plugins/specs/editor.lua index c09680a3..8d46707a 100644 --- a/lua/plugins/specs/editor.lua +++ b/lua/plugins/specs/editor.lua @@ -18,7 +18,7 @@ return { require("nvim-treesitter.configs").setup(opts) end, - event = "User LazyFile", + event = "BufReadPost", }, { "folke/flash.nvim", From a793e505c596c5e6b832f18e62b86ee2ef65d1d1 Mon Sep 17 00:00:00 2001 From: asyncedd Date: Thu, 6 Jun 2024 22:46:15 +0900 Subject: [PATCH 32/56] rm unneeded comments --- lua/plugins/init.lua | 31 ------------------------------- 1 file changed, 31 deletions(-) diff --git a/lua/plugins/init.lua b/lua/plugins/init.lua index 5315e187..4f794c25 100644 --- a/lua/plugins/init.lua +++ b/lua/plugins/init.lua @@ -11,37 +11,6 @@ if not vim.loop.fs_stat(lazypath) then end vim.opt.rtp:prepend(lazypath) --- -- This autocmd will only trigger when a file was loaded from the cmdline. --- -- It will render the file as quickly as possible. --- vim.api.nvim_create_autocmd("BufReadPost", { --- once = true, --- callback = function(event) --- -- Skip if we already entered vim --- if vim.v.vim_did_enter == 1 then --- return --- end --- --- -- Try to guess the filetype (may change later on during Neovim startup) --- local ft = vim.filetype.match({ buf = event.buf }) --- if ft then --- -- Add treesitter highlights and fallback to syntax --- local lang = vim.treesitter.language.get_lang(ft) --- if not (lang and pcall(vim.treesitter.start, event.buf, lang)) then --- vim.bo[event.buf].syntax = ft --- end --- --- -- Trigger early redraw --- vim.cmd([[redraw]]) --- end --- end, --- }) - --- -- Add support for the LazyFile event --- local Event = require("lazy.core.handler.event") --- --- Event.mappings.LazyFile = { id = "LazyFile", event = { "BufReadPost", "BufNewFile", "BufWritePre" } } --- Event.mappings["LazyFile"] = Event.mappings.LazyFile - require("lazy").setup({ { import = "plugins.specs" }, dots.languages.enable, From f19bdfff31451491602f94691f6b7ee03926e29d Mon Sep 17 00:00:00 2001 From: asyncedd Date: Thu, 6 Jun 2024 22:46:32 +0900 Subject: [PATCH 33/56] perf: optimize cfg even more --- init.lua | 37 +++++++++++++++++++++---------------- lua/settings/options.lua | 2 -- 2 files changed, 21 insertions(+), 18 deletions(-) diff --git a/init.lua b/init.lua index be3fffc6..0b3804b5 100644 --- a/init.lua +++ b/init.lua @@ -1,25 +1,30 @@ vim.loader.enable() vim.g.base46_cache = vim.fn.stdpath("data") .. "/nvchad/base46/" +vim.g.mapleader = " " -require("settings") -require("settings.options") -require("plugins") +-- bootstrap lazy and all plugins +local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" -require("settings.autocmd") -require("settings.keymap") +if not vim.loop.fs_stat(lazypath) then + local repo = "https://github.com/folke/lazy.nvim.git" + vim.fn.system({ "git", "clone", "--filter=blob:none", repo, "--branch=stable", lazypath }) +end --- https://www.reddit.com/r/neovim/comments/1ayx62p/config_for_diagnostics/ -vim.diagnostic.config({ - virtual_text = { - source = "if_many", - }, -}) +vim.opt.rtp:prepend(lazypath) + +require("settings") -vim.filetype.add({ - extension = { - postcss = "css", - }, -}) +require("lazy").setup({ + { import = "plugins.specs" }, + dots.languages.enable, +}, require("configs.lazy")) dofile(vim.g.base46_cache .. "defaults") dofile(vim.g.base46_cache .. "statusline") + +require("settings.options") +require("settings.autocmd") + +vim.schedule(function() + require("settings.keymap") +end) diff --git a/lua/settings/options.lua b/lua/settings/options.lua index 32611f94..bf9b4281 100644 --- a/lua/settings/options.lua +++ b/lua/settings/options.lua @@ -28,8 +28,6 @@ o.clipboard = "unnamedplus" o.signcolumn = "yes:1" -vim.g.mapleader = " " - -- Statusline o.cmdheight = 0 o.laststatus = 3 From 0d0992bf31fa20f38a5b1302eded10d2d8f67222 Mon Sep 17 00:00:00 2001 From: asyncedd Date: Thu, 6 Jun 2024 22:46:58 +0900 Subject: [PATCH 34/56] feat(mini.notify): add hl --- lua/chadrc.lua | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lua/chadrc.lua b/lua/chadrc.lua index f057be60..b57c965a 100644 --- a/lua/chadrc.lua +++ b/lua/chadrc.lua @@ -56,11 +56,16 @@ M.ui = { hl_override = { DiffAdd = { fg = "green" }, DiffModified = { fg = "yellow" }, + + FloatBorder = { fg = "darker_black", bg = "darker_black" }, + NormalFloat = { bg = "darker_black" }, }, hl_add = { MiniDiffSignAdd = { fg = "green" }, MiniDiffSignChange = { fg = "yellow" }, MiniDiffSignDelete = { fg = "red" }, + + MiniNotifyNormal = { link = "Normal" }, }, } From 3ed18212e36e6dc810996541d13a4b927add4355 Mon Sep 17 00:00:00 2001 From: asyncedd Date: Thu, 6 Jun 2024 22:47:10 +0900 Subject: [PATCH 35/56] fix: re-add nixd --- lua/configs/lspconfig.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/configs/lspconfig.lua b/lua/configs/lspconfig.lua index 018074ee..243b919c 100644 --- a/lua/configs/lspconfig.lua +++ b/lua/configs/lspconfig.lua @@ -60,7 +60,7 @@ capabilities.textDocument.completion.completionItem = { local lspconfig = require("lspconfig") local servers = { - -- "nixd", + "nixd", -- "clangd", -- "svelte", -- "emmet_ls", From c4a26924d379820c8515a3bc76b369e4c1736b90 Mon Sep 17 00:00:00 2001 From: asyncedd Date: Fri, 7 Jun 2024 15:46:31 +0900 Subject: [PATCH 36/56] feat: use gitui instead of lazygit --- init.lua | 1 + lua/settings/keymap.lua | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/init.lua b/init.lua index 0b3804b5..d68d3d05 100644 --- a/init.lua +++ b/init.lua @@ -14,6 +14,7 @@ vim.opt.rtp:prepend(lazypath) require("settings") +vim.deprecate = function() end ---@diagnostic disable-line: duplicate-set-field require("lazy").setup({ { import = "plugins.specs" }, dots.languages.enable, diff --git a/lua/settings/keymap.lua b/lua/settings/keymap.lua index 79578dae..c06e835b 100644 --- a/lua/settings/keymap.lua +++ b/lua/settings/keymap.lua @@ -11,8 +11,8 @@ if not vim.g.vscode then require("utils.float_term")(nil, { ctrl_hjkl = false }) end, { desc = "Open the terminal" }) map("n", "gg", function() - require("utils.float_term")("lazygit", { ctrl_hjkl = false }) - end, { desc = "Open LazyGit" }) + require("utils.float_term")("gitui", { ctrl_hjkl = false }) + end, { desc = "Open GitUI" }) end map("n", "dd", function() From 47d0b623ab06bf488a998ea075388f9045dec3c4 Mon Sep 17 00:00:00 2001 From: asyncedd Date: Sat, 8 Jun 2024 12:20:33 +0900 Subject: [PATCH 37/56] Revert "feat: use gitui instead of lazygit" This reverts commit c4a26924d379820c8515a3bc76b369e4c1736b90. --- init.lua | 1 - lua/settings/keymap.lua | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/init.lua b/init.lua index d68d3d05..0b3804b5 100644 --- a/init.lua +++ b/init.lua @@ -14,7 +14,6 @@ vim.opt.rtp:prepend(lazypath) require("settings") -vim.deprecate = function() end ---@diagnostic disable-line: duplicate-set-field require("lazy").setup({ { import = "plugins.specs" }, dots.languages.enable, diff --git a/lua/settings/keymap.lua b/lua/settings/keymap.lua index c06e835b..79578dae 100644 --- a/lua/settings/keymap.lua +++ b/lua/settings/keymap.lua @@ -11,8 +11,8 @@ if not vim.g.vscode then require("utils.float_term")(nil, { ctrl_hjkl = false }) end, { desc = "Open the terminal" }) map("n", "gg", function() - require("utils.float_term")("gitui", { ctrl_hjkl = false }) - end, { desc = "Open GitUI" }) + require("utils.float_term")("lazygit", { ctrl_hjkl = false }) + end, { desc = "Open LazyGit" }) end map("n", "dd", function() From d76e4ec85ef31e4328b05fcb4386323dc579b0a5 Mon Sep 17 00:00:00 2001 From: asyncedd Date: Wed, 12 Jun 2024 17:49:50 +0900 Subject: [PATCH 38/56] refactor(chadrc): refactor mini.git and mini.diff integrations --- lua/chadrc.lua | 43 +++++++++++-------------------------------- 1 file changed, 11 insertions(+), 32 deletions(-) diff --git a/lua/chadrc.lua b/lua/chadrc.lua index b57c965a..757a726c 100644 --- a/lua/chadrc.lua +++ b/lua/chadrc.lua @@ -2,35 +2,6 @@ local M = {} local utils = require("nvchad.stl.utils") -local diff_format_summary = function(data) - local summary = vim.b[data.buf].minidiff_summary - if summary == nil then - vim.b[data.buf].minidiff_summary_string = "" - return - end - local t = {} - if summary.add ~= nil and summary.add > 0 then - table.insert(t, dots.UI.icons.Git.added .. summary.add) - end - if summary.change ~= nil and summary.change > 0 then - table.insert(t, dots.UI.icons.Git.changed .. summary.change) - end - if summary.delete ~= nil and summary.delete > 0 then - table.insert(t, dots.UI.icons.Git.remove .. summary.delete) - end - vim.b[data.buf].minidiff_summary_string = table.concat(t, " ") -end -vim.api.nvim_create_autocmd("User", { pattern = "MiniDiffUpdated", callback = diff_format_summary }) - --- Use only HEAD name as summary string -local git_format_summary = function(data) - -- Utilize buffer-local table summary - local summary = vim.b[data.buf].minigit_summary - vim.b[data.buf].minigit_summary_string = (summary ~= nil and summary.head_name) or "" -end - -vim.api.nvim_create_autocmd("User", { pattern = "MiniGitUpdated", callback = git_format_summary }) - M.ui = { theme = "everblush", statusline = { @@ -47,9 +18,17 @@ M.ui = { git = function() local git_status = vim.b[utils.stbufnr()].minigit_summary_string or "" - local branch_name = " " .. git_status - - return "%#St_gitIcons# " .. branch_name .. " " .. (vim.b[utils.stbufnr()].minidiff_summary_string or "") + local summary = vim.b[utils.stbufnr()].minigit_summary + local branch_name = (summary ~= nil and summary.head_name) and (" " .. git_status) or "" + + summary = vim.b.minidiff_summary + return "%#St_gitIcons# " + .. branch_name + .. ( + summary ~= nil + and " " .. ((summary.add ~= nil and summary.add > 0) and dots.UI.icons.Git.added .. summary.add or "") .. ((summary.change ~= nil and summary.change > 0) and dots.UI.icons.Git.changed .. summary.change or "") .. ((summary.delete ~= nil and summary.delete > 0) and dots.UI.icons.Git.remove .. summary.delete or "") + or "" + ) end, }, }, From 30a7aa18a9527e52bdf79653e4a725066387fb13 Mon Sep 17 00:00:00 2001 From: asyncedd Date: Fri, 14 Jun 2024 16:36:20 +0900 Subject: [PATCH 39/56] feat: use nixfmt as the formatter --- lua/configs/conform.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/configs/conform.lua b/lua/configs/conform.lua index c2e0eed4..305eb82f 100644 --- a/lua/configs/conform.lua +++ b/lua/configs/conform.lua @@ -7,7 +7,7 @@ local options = { css = { "prettierd" }, html = { "prettierd" }, fish = { "fish_indent" }, - nix = { "alejandra" }, + nix = { "nixfmt" }, markdown = { { "prettierd", "prettier" } }, lua = { "stylua" }, svelte = { { "prettierd", "prettier" } }, From dab8f13834b09e55f64968367ce73e3baf4286db Mon Sep 17 00:00:00 2001 From: asyncedd Date: Fri, 14 Jun 2024 16:36:35 +0900 Subject: [PATCH 40/56] whatever --- lazy-lock.json | 45 ++++++++-------- lua/chadrc.lua | 18 +++---- lua/configs/lspconfig.lua | 42 ++++++++++++++- lua/plugins/specs/coding.lua | 13 +++-- lua/plugins/specs/editor.lua | 81 +++++++++++++++++++++++++---- lua/plugins/specs/languages/lua.lua | 9 ++-- lua/plugins/specs/ui.lua | 13 +++++ 7 files changed, 170 insertions(+), 51 deletions(-) diff --git a/lazy-lock.json b/lazy-lock.json index 69404b3e..56047ade 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -1,48 +1,49 @@ { - "LuaSnip": { "branch": "master", "commit": "878ace11983444d865a72e1759dbcc331d1ace4c" }, + "LuaSnip": { "branch": "master", "commit": "50fcf17db7c75af80e6b6109acfbfb4504768780" }, "base46": { "branch": "v2.5", "commit": "87e09eb9e959966397bd9d8aab18d88ef349c913" }, "cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" }, "cmp-cmdline": { "branch": "main", "commit": "d250c63aa13ead745e3a40f61fdd3470efde3923" }, "cmp-nvim-lsp": { "branch": "main", "commit": "39e2eda76828d88b773cc27a3f61d2ad782c922d" }, "cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" }, "cmp_luasnip": { "branch": "master", "commit": "05a9ab28b53f71d1aece421ef32fee2cb857a843" }, - "conform.nvim": { "branch": "master", "commit": "63e0a32c85a39484813957dc480f171907aa90b9" }, + "conform.nvim": { "branch": "master", "commit": "07d1298739cd7c616cb683bfd848f6b369f93297" }, "dressing.nvim": { "branch": "master", "commit": "e3714c8049b2243e792492c4149e4cc395c68eb9" }, - "flash.nvim": { "branch": "main", "commit": "0b85b5ea6eaaebab5e012fab3496102094550686" }, - "friendly-snippets": { "branch": "main", "commit": "d0610077b6129cf9f7f78afbe3a1425d60f6e2f1" }, + "flash.nvim": { "branch": "main", "commit": "43f67935d388fbb540f8b40e8cbfd80de54f978a" }, + "friendly-snippets": { "branch": "main", "commit": "700c4a25caacbb4648c9a27972c2fe203948e0c2" }, "indent-blankline.nvim": { "branch": "master", "commit": "d98f537c3492e87b6dc6c2e3f66ac517528f406f" }, - "lazy.nvim": { "branch": "main", "commit": "ad30030b6abca7dac5a493c58b4d183b3fe93202" }, - "lazydev.nvim": { "branch": "main", "commit": "2e715cd4629df2b47d92468935226655cb7e88ed" }, + "lazy.nvim": { "branch": "main", "commit": "eb4957442e3182f051b0ae11da32e06d22c190e3" }, + "lazydev.nvim": { "branch": "main", "commit": "7cbb524c85f87017df9c1ea2377a1d840ad8ed51" }, "lspkind.nvim": { "branch": "master", "commit": "1735dd5a5054c1fb7feaf8e8658dbab925f4f0cf" }, "luvit-meta": { "branch": "main", "commit": "ce76f6f6cdc9201523a5875a4471dcfe0186eb60" }, - "mini.ai": { "branch": "main", "commit": "7859b6344f5cee567a94f173859d25e20ba1a77e" }, + "mini.ai": { "branch": "main", "commit": "a7e90f110e6274262616311b93cef12cd2667a2d" }, "mini.clue": { "branch": "main", "commit": "629f7ddb071faf8eba77c5c56a295a0a206df94c" }, "mini.diff": { "branch": "main", "commit": "441975a43bbec22442a91fe2ab1c7c06984e4d8a" }, "mini.extra": { "branch": "main", "commit": "a89d2376082cfe4b9d55713beddd5c5f5995ea2a" }, - "mini.files": { "branch": "main", "commit": "2299bf2f55993d899249a585f04bb4ff5386d37e" }, + "mini.files": { "branch": "main", "commit": "05c861ff4066a9d20233ec776e9ec894ab9f19fe" }, "mini.git": { "branch": "main", "commit": "625e529c8b6363290e1ffadc91cdf4b50e1cf094" }, "mini.move": { "branch": "main", "commit": "9670fe1d19af3d9a69ddce920c527c883ca5dc4c" }, + "mini.notify": { "branch": "main", "commit": "2d506633f50bd61b1041aa4a6d62e0fe0e6ae09e" }, "mini.operators": { "branch": "main", "commit": "ccc67955124dde0ba20cdcb37ea30ff1646da574" }, "mini.splitjoin": { "branch": "main", "commit": "db26e1c991ff5f8cf377e800ef7fba6b5618306b" }, "mini.surround": { "branch": "main", "commit": "27096c1a27324ee8f2044ea2adc77366d8a782de" }, "mini.visits": { "branch": "main", "commit": "20e82e3f4ed1ce96d254c16a8602d7606c618c25" }, - "nvim-cmp": { "branch": "main", "commit": "a08882abe1f900c0c7f516725d74c7d84faeaa79" }, - "nvim-lint": { "branch": "master", "commit": "2f90fe977ef21db3bf3b7a1ceaf4a1e3aafb2b26" }, - "nvim-lspconfig": { "branch": "master", "commit": "710a8fa7379db32199545f30ea01dd8446b9302f" }, - "nvim-notify": { "branch": "master", "commit": "d333b6f167900f6d9d42a59005d82919830626bf" }, - "nvim-spectre": { "branch": "master", "commit": "366f46fdd4a1593cc237aea13d5ef113739a472c" }, - "nvim-treesitter": { "branch": "master", "commit": "a80fe081b4c5890980561e0de2458f64aaffbfc7" }, - "nvim-treesitter-textobjects": { "branch": "master", "commit": "fd41b7ccc5490a3a99c734d1ee418b68d06c48a9" }, - "nvim-various-textobjs": { "branch": "main", "commit": "5c628394b57dd960c2bf82dcdcf1f4e0d27f2347" }, - "nvim-web-devicons": { "branch": "master", "commit": "b77921fdc44833c994fdb389d658ccbce5490c16" }, + "nvim-cmp": { "branch": "main", "commit": "a110e12d0b58eefcf5b771f533fc2cf3050680ac" }, + "nvim-colorizer.lua": { "branch": "master", "commit": "85855b38011114929f4058efc97af1059ab3e41d" }, + "nvim-lint": { "branch": "master", "commit": "941fa1220a61797a51f3af9ec6b7d74c8c7367ce" }, + "nvim-lspconfig": { "branch": "master", "commit": "4d38bece98300e3e5cd24a9aa0d0ebfea4951c16" }, + "nvim-spectre": { "branch": "master", "commit": "ec67d4b5370094b923dfcf6b09b39142f2964861" }, + "nvim-treesitter": { "branch": "main", "commit": "7a9286e3116015c37a02584df2fb34a89cf83531" }, + "nvim-treesitter-textobjects": { "branch": "main", "commit": "cd8fd01677e0cfe9dc2c715f305d653269232c1a" }, + "nvim-various-textobjs": { "branch": "main", "commit": "3ab25fe20f8f9c2035425d0cf5c9634a063cb98e" }, + "nvim-web-devicons": { "branch": "master", "commit": "c0cfc1738361b5da1cd0a962dd6f774cc444f856" }, "plenary.nvim": { "branch": "master", "commit": "a3e3bc82a3f95c5ed0d7201546d5d2c19b20d683" }, "smart-open.nvim": { "branch": "main", "commit": "028bb71d20e8212da3514bf6dabfb17038d81ee4" }, "sqlite.lua": { "branch": "master", "commit": "d0ffd703b56d090d213b497ed4eb840495f14a11" }, "telescope-fzy-native.nvim": { "branch": "master", "commit": "282f069504515eec762ab6d6c89903377252bf5b" }, - "telescope.nvim": { "branch": "master", "commit": "dfa230be84a044e7f546a6c2b0a403c739732b86" }, - "ts-comments.nvim": { "branch": "main", "commit": "e339090c076871069c00e488b11def49aaf4e413" }, - "ui": { "branch": "v2.5", "commit": "0c283b6aed4eed585a497c9031b18b5009bfe4dd" }, - "ultimate-autopair.nvim": { "branch": "v0.6", "commit": "813e1b3391c3f50100345bf3956c618f7e522e74" }, + "telescope.nvim": { "branch": "master", "commit": "f12b15e1b3a33524eb06a1ae7bc852fb1fd92197" }, + "ts-comments.nvim": { "branch": "main", "commit": "c075b4ee00f6e111b44bf99a8cfd5a4cfce9258a" }, + "ui": { "branch": "v2.5", "commit": "dff8115670efc5051e5db9fef4660b2ceae3a26a" }, + "ultimate-autopair.nvim": { "branch": "v0.6", "commit": "035d92eab05ac1390afef7204e3fcad9a50fa443" }, "vscode-svelte-snippets": { "branch": "master", "commit": "564ac3300bfeda01ff0bf6b89152cef43f85a4ce" }, - "yanky.nvim": { "branch": "main", "commit": "79338563e85a868e59cda02c51b54d90a5514a12" } + "yanky.nvim": { "branch": "main", "commit": "73215b77d22ebb179cef98e7e1235825431d10e4" } } \ No newline at end of file diff --git a/lua/chadrc.lua b/lua/chadrc.lua index 757a726c..a666023f 100644 --- a/lua/chadrc.lua +++ b/lua/chadrc.lua @@ -5,15 +5,15 @@ local utils = require("nvchad.stl.utils") M.ui = { theme = "everblush", statusline = { - order = { - "mode", - "file", - "git", - "%=", - "diagnostics", - "cwd", - "cursor", - }, + -- order = { + -- "mode", + -- "file", + -- "git", + -- "%=", + -- "diagnostics", + -- "cwd", + -- "cursor", + -- }, modules = { git = function() local git_status = vim.b[utils.stbufnr()].minigit_summary_string or "" diff --git a/lua/configs/lspconfig.lua b/lua/configs/lspconfig.lua index 243b919c..ffe23420 100644 --- a/lua/configs/lspconfig.lua +++ b/lua/configs/lspconfig.lua @@ -60,7 +60,6 @@ capabilities.textDocument.completion.completionItem = { local lspconfig = require("lspconfig") local servers = { - "nixd", -- "clangd", -- "svelte", -- "emmet_ls", @@ -76,6 +75,47 @@ for _, lsp in ipairs(servers) do }) end +require("lspconfig")["nil_ls"].setup({ + on_attach = on_attach, + on_init = on_init, + capabilities = capabilities, + + settings = { + ["nil"] = { + nix = { flake = { autoArchive = true } }, + }, + }, +}) + +require("lspconfig")["markdown_oxide"].setup({ + on_attach = function(client, bufnr) + on_attach(client, bufnr) + + vim.api.nvim_create_autocmd({ "TextChanged", "InsertLeave", "CursorHold", "LspAttach" }, { + buffer = bufnr, + callback = vim.lsp.codelens.refresh, + }) + vim.api.nvim_exec_autocmds("User", { pattern = "LspAttached" }) + + -- setup Markdown Oxide daily note commands + if client.name == "markdown_oxide" then + vim.api.nvim_create_user_command("Daily", function(args) + local input = args.args + + vim.lsp.buf.execute_command({ command = "jump", arguments = { input } }) + end, { desc = "Open daily note", nargs = "*" }) + end + end, + on_init = on_init, + capabilities = vim.tbl_deep_extend("force", capabilities, { + workspace = { + didChangeWatchedFiles = { + dynamicRegistration = true, + }, + }, + }), +}) + require("lspconfig")["rust_analyzer"].setup({ capabilities = capabilities, on_attach = on_attach, diff --git a/lua/plugins/specs/coding.lua b/lua/plugins/specs/coding.lua index 5ef0e20b..dc99f995 100644 --- a/lua/plugins/specs/coding.lua +++ b/lua/plugins/specs/coding.lua @@ -23,7 +23,7 @@ return { event = "InsertEnter", }, { - "xzbdmw/nvim-cmp", + "hrsh7th/nvim-cmp", opts = function() local cmp = require("cmp") local luasnip = require("luasnip") @@ -42,7 +42,14 @@ return { end, }, sources = cmp.config.sources({ - { name = "nvim_lsp" }, + { + name = "nvim_lsp", + option = { + markdown_oxide = { + keyword_pattern = [[\(\k\| \|\/\|#\)\+]], + }, + }, + }, { name = "luasnip" }, { name = "path" }, { name = "crates" }, @@ -144,7 +151,7 @@ return { }) end, dependencies = { - "xzbdmw/nvim-cmp", + "nvim-cmp", "hrsh7th/cmp-path", "hrsh7th/cmp-buffer", }, diff --git a/lua/plugins/specs/editor.lua b/lua/plugins/specs/editor.lua index 8d46707a..8441235c 100644 --- a/lua/plugins/specs/editor.lua +++ b/lua/plugins/specs/editor.lua @@ -1,22 +1,80 @@ +local function patch() + local parsers = require("nvim-treesitter.parsers") + parsers.get_parser_configs = setmetatable({}, { + __call = function() + return parsers + end, + }) +end + return { { "nvim-treesitter/nvim-treesitter", - opts = { - ensure_installed = { "c", "lua", "vim", "vimdoc", "query" }, - highlight = { - enable = true, - use_languagetree = true, - }, - indent = { - enable = true, - }, - }, + version = false, -- last release is way too old and doesn't work on Windows + branch = "main", build = ":TSUpdate", + cmd = {}, + opts = function() + patch() + return { + ensure_installed = { + "c", + "lua", + "vim", + "vimdoc", + "query", + "gitcommit", + "gitignore", + "git_config", + "git_rebase", + "git_attributes", + "nix", + "css", + }, + highlight = { enable = true, use_languagetree = true }, + indent = { enable = true }, + } + end, config = function(_, opts) dofile(vim.g.base46_cache .. "syntax") dofile(vim.g.base46_cache .. "treesitter") - require("nvim-treesitter.configs").setup(opts) + local function norm(ensure) + return ensure == nil and {} or type(ensure) == "string" and { ensure } or ensure + end + + ---@generic T + ---@param list T[] + ---@return T[] + local function dedup(list) + local ret = {} + local seen = {} + for _, v in ipairs(list) do + if not seen[v] then + table.insert(ret, v) + seen[v] = true + end + end + return ret + end + + opts.ensure_install = dedup(vim.list_extend(norm(opts.ensure_install), norm(opts.ensure_installed))) + require("nvim-treesitter").setup(opts) + patch() + + -- backwards compatibility with the old treesitter config for indent + if vim.tbl_get(opts, "indent", "enable") then + vim.bo.indentexpr = "v:lua.require'nvim-treesitter'.indentexpr()" + end + + -- backwards compatibility with the old treesitter config for highlight + if vim.tbl_get(opts, "highlight", "enable") then + vim.api.nvim_create_autocmd("FileType", { + callback = function() + pcall(vim.treesitter.start) + end, + }) + end end, event = "BufReadPost", }, @@ -124,6 +182,7 @@ return { dependencies = { { "nvim-treesitter/nvim-treesitter-textobjects", + branch = "main", dependencies = { { "echasnovski/mini.extra", opts = true }, }, diff --git a/lua/plugins/specs/languages/lua.lua b/lua/plugins/specs/languages/lua.lua index 89cadbba..6518562f 100644 --- a/lua/plugins/specs/languages/lua.lua +++ b/lua/plugins/specs/languages/lua.lua @@ -12,11 +12,10 @@ return { ft = "lua", -- only load on lua files opts = { library = { - vim.env.LAZY .. "/luvit-meta/library", -- see below - vim.env.LAZY .. "/ui/nvchad_types", - -- You can also add plugins you always want to have loaded. - -- Useful if the plugin has globals or types you want to use - -- vim.env.LAZY .. "/LazyVim", -- see below + "/luvit-meta/library", -- see below + "/ui/nvchad_types", + { path = "luvit-meta/library", words = { "vim%.uv" } }, + "lazy.nvim", }, }, }, diff --git a/lua/plugins/specs/ui.lua b/lua/plugins/specs/ui.lua index 491088ba..936e815d 100644 --- a/lua/plugins/specs/ui.lua +++ b/lua/plugins/specs/ui.lua @@ -87,4 +87,17 @@ return { end end, }, + { + "NvChad/nvim-colorizer.lua", + event = "User LazyFile", + opts = { user_default_options = { names = false } }, + config = function(_, opts) + require("colorizer").setup(opts) + + -- execute colorizer as soon as possible + vim.defer_fn(function() + require("colorizer").attach_to_buffer(0) + end, 0) + end, + }, } From 67039971eeb4f0fcfb903a6693248dbf87d9f6ca Mon Sep 17 00:00:00 2001 From: asyncedd Date: Fri, 14 Jun 2024 17:02:32 +0900 Subject: [PATCH 41/56] feat(hipatterns): init --- lazy-lock.json | 1 + lua/configs/hipatterns.lua | 7 +++++++ lua/plugins/specs/ui.lua | 11 ++++++----- 3 files changed, 14 insertions(+), 5 deletions(-) create mode 100644 lua/configs/hipatterns.lua diff --git a/lazy-lock.json b/lazy-lock.json index 56047ade..b0e6f5bf 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -21,6 +21,7 @@ "mini.extra": { "branch": "main", "commit": "a89d2376082cfe4b9d55713beddd5c5f5995ea2a" }, "mini.files": { "branch": "main", "commit": "05c861ff4066a9d20233ec776e9ec894ab9f19fe" }, "mini.git": { "branch": "main", "commit": "625e529c8b6363290e1ffadc91cdf4b50e1cf094" }, + "mini.hipatterns": { "branch": "main", "commit": "427712c754bfdccd8da7073576cd8e2586c0fe93" }, "mini.move": { "branch": "main", "commit": "9670fe1d19af3d9a69ddce920c527c883ca5dc4c" }, "mini.notify": { "branch": "main", "commit": "2d506633f50bd61b1041aa4a6d62e0fe0e6ae09e" }, "mini.operators": { "branch": "main", "commit": "ccc67955124dde0ba20cdcb37ea30ff1646da574" }, diff --git a/lua/configs/hipatterns.lua b/lua/configs/hipatterns.lua new file mode 100644 index 00000000..39b88291 --- /dev/null +++ b/lua/configs/hipatterns.lua @@ -0,0 +1,7 @@ +local hi = require("mini.hipatterns") + +return { + highlighters = { + hex_color = hi.gen_highlighter.hex_color(), + }, +} diff --git a/lua/plugins/specs/ui.lua b/lua/plugins/specs/ui.lua index 936e815d..c9c06b4f 100644 --- a/lua/plugins/specs/ui.lua +++ b/lua/plugins/specs/ui.lua @@ -88,15 +88,16 @@ return { end, }, { - "NvChad/nvim-colorizer.lua", + "echasnovski/mini.hipatterns", event = "User LazyFile", - opts = { user_default_options = { names = false } }, + opts = function() + return require("configs.hipatterns") + end, config = function(_, opts) - require("colorizer").setup(opts) + require("mini.hipatterns").setup(opts) - -- execute colorizer as soon as possible vim.defer_fn(function() - require("colorizer").attach_to_buffer(0) + require("mini.hipatterns").enable() end, 0) end, }, From 8f561b82ad6d6709f3b03a6c9bc16502b56e6168 Mon Sep 17 00:00:00 2001 From: asyncedd Date: Thu, 20 Jun 2024 07:35:57 +0900 Subject: [PATCH 42/56] refactor(nvchad): patch from upstream nvchad --- lua/settings/autocmd.lua | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/lua/settings/autocmd.lua b/lua/settings/autocmd.lua index 64db8c09..ce18ab1e 100644 --- a/lua/settings/autocmd.lua +++ b/lua/settings/autocmd.lua @@ -52,25 +52,13 @@ autocmd("BufWritePost", { require("plenary.reload").reload_module("nvconfig") require("plenary.reload").reload_module("base46") + require("plenary.reload").reload_module("nvchad") require("plenary.reload").reload_module(module) - local config = require("nvconfig") - - -- statusline - if config.ui.statusline.theme ~= "custom" then - require("plenary.reload").reload_module("nvchad.stl.utils") - require("plenary.reload").reload_module("nvchad.stl." .. config.ui.statusline.theme) - vim.opt.statusline = "%!v:lua.require('nvchad.stl." .. config.ui.statusline.theme .. "')()" - end - - -- tabufline - if config.ui.tabufline.enabled then - require("plenary.reload").reload_module("nvchad.tabufline.modules") - vim.opt.tabline = "%!v:lua.require('nvchad.tabufline.modules')()" - end + require("nvchad") require("base46").load_all_highlights() - vim.cmd("redraw!") + -- vim.cmd("redraw!") end, }) From 8209c76b61dcac38a29125749a268ef2d7476103 Mon Sep 17 00:00:00 2001 From: asyncedd Date: Thu, 20 Jun 2024 07:38:36 +0900 Subject: [PATCH 43/56] rm depreceated function: buf_get_option --- lua/settings/autocmd.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/settings/autocmd.lua b/lua/settings/autocmd.lua index ce18ab1e..8c5a362f 100644 --- a/lua/settings/autocmd.lua +++ b/lua/settings/autocmd.lua @@ -67,7 +67,7 @@ autocmd({ "UIEnter", "BufReadPost", "BufNewFile" }, { group = vim.api.nvim_create_augroup("NvLazyFile", { clear = true }), callback = function(args) local file = vim.api.nvim_buf_get_name(args.buf) - local buftype = vim.api.nvim_buf_get_option(args.buf, "buftype") + local buftype = vim.api.nvim_get_option_value("buftype", { buf = args.buf }) if not vim.g.ui_entered and args.event == "UIEnter" then vim.g.ui_entered = true From 2a1109907357d10b400e5fed13b3f9208931711e Mon Sep 17 00:00:00 2001 From: asyncedd Date: Sun, 23 Jun 2024 10:53:17 +0900 Subject: [PATCH 44/56] feat(python): init support --- lua/configs/conform.lua | 1 + lua/configs/lspconfig.lua | 12 ++++++++++++ lua/plugins/specs/editor.lua | 5 ++++- 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/lua/configs/conform.lua b/lua/configs/conform.lua index 305eb82f..50d3f91c 100644 --- a/lua/configs/conform.lua +++ b/lua/configs/conform.lua @@ -11,6 +11,7 @@ local options = { markdown = { { "prettierd", "prettier" } }, lua = { "stylua" }, svelte = { { "prettierd", "prettier" } }, + python = { "black" }, }, } diff --git a/lua/configs/lspconfig.lua b/lua/configs/lspconfig.lua index ffe23420..2f099fe4 100644 --- a/lua/configs/lspconfig.lua +++ b/lua/configs/lspconfig.lua @@ -60,6 +60,7 @@ capabilities.textDocument.completion.completionItem = { local lspconfig = require("lspconfig") local servers = { + "basedpyright", -- "clangd", -- "svelte", -- "emmet_ls", @@ -186,3 +187,14 @@ require("lspconfig")["cssls"].setup({ on_attach = on_attach, on_init = on_init, }) + +require("lspconfig")["ruff_lsp"].setup({ + capabilities = capabilities, + on_attach = function(client, bufnr) + on_attach(client, bufnr) + + -- Disable hover in favor of Pyright + client.server_capabilities.hoverProvider = false + end, + on_init = on_init, +}) diff --git a/lua/plugins/specs/editor.lua b/lua/plugins/specs/editor.lua index 8441235c..5e005614 100644 --- a/lua/plugins/specs/editor.lua +++ b/lua/plugins/specs/editor.lua @@ -30,9 +30,12 @@ return { "git_attributes", "nix", "css", + "ninja", + "rst", + "python", }, highlight = { enable = true, use_languagetree = true }, - indent = { enable = true }, + -- indent = { enable = true }, } end, config = function(_, opts) From 22563635fc4ee30b0c4767ff2b085adff31142b6 Mon Sep 17 00:00:00 2001 From: asyncedd Date: Sun, 23 Jun 2024 10:53:31 +0900 Subject: [PATCH 45/56] fix(lazydev): fix config --- lua/plugins/specs/languages/lua.lua | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lua/plugins/specs/languages/lua.lua b/lua/plugins/specs/languages/lua.lua index 6518562f..0c42c857 100644 --- a/lua/plugins/specs/languages/lua.lua +++ b/lua/plugins/specs/languages/lua.lua @@ -12,8 +12,7 @@ return { ft = "lua", -- only load on lua files opts = { library = { - "/luvit-meta/library", -- see below - "/ui/nvchad_types", + "ui/nvchad_types", { path = "luvit-meta/library", words = { "vim%.uv" } }, "lazy.nvim", }, From fa59fb6ceb39c97c8bad24be1ed7eb7dba4330c0 Mon Sep 17 00:00:00 2001 From: asyncedd Date: Sun, 23 Jun 2024 10:53:42 +0900 Subject: [PATCH 46/56] fix(nvim-treesitter): fix lazy-loading --- lua/plugins/specs/editor.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/plugins/specs/editor.lua b/lua/plugins/specs/editor.lua index 5e005614..58a8323f 100644 --- a/lua/plugins/specs/editor.lua +++ b/lua/plugins/specs/editor.lua @@ -79,7 +79,7 @@ return { }) end end, - event = "BufReadPost", + event = { "BufReadPost", "BufNewFile" }, }, { "folke/flash.nvim", From 47426ca994c290e9d161cef30c5b91b006c41a37 Mon Sep 17 00:00:00 2001 From: asyncedd Date: Sun, 23 Jun 2024 10:53:58 +0900 Subject: [PATCH 47/56] feat(gitsigns): use for line blame --- lua/plugins/specs/editor.lua | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lua/plugins/specs/editor.lua b/lua/plugins/specs/editor.lua index 58a8323f..47aab954 100644 --- a/lua/plugins/specs/editor.lua +++ b/lua/plugins/specs/editor.lua @@ -129,6 +129,14 @@ return { require("mini.diff").setup(opts) end, }, + { + "lewis6991/gitsigns.nvim", + opts = { + signcolumn = false, + current_line_blame = true, + }, + event = "VeryLazy", + }, { "echasnovski/mini-git", opts = true, From eb36013637e748f7712bea5ffca7085d5df4a683 Mon Sep 17 00:00:00 2001 From: asyncedd Date: Sun, 23 Jun 2024 10:54:07 +0900 Subject: [PATCH 48/56] chore: update lazy-lock.json --- lazy-lock.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lazy-lock.json b/lazy-lock.json index b0e6f5bf..cd6745a5 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -10,6 +10,7 @@ "dressing.nvim": { "branch": "master", "commit": "e3714c8049b2243e792492c4149e4cc395c68eb9" }, "flash.nvim": { "branch": "main", "commit": "43f67935d388fbb540f8b40e8cbfd80de54f978a" }, "friendly-snippets": { "branch": "main", "commit": "700c4a25caacbb4648c9a27972c2fe203948e0c2" }, + "gitsigns.nvim": { "branch": "main", "commit": "47c8e3e571376b24de62408fd0c9d12f0a9fc0a3" }, "indent-blankline.nvim": { "branch": "master", "commit": "d98f537c3492e87b6dc6c2e3f66ac517528f406f" }, "lazy.nvim": { "branch": "main", "commit": "eb4957442e3182f051b0ae11da32e06d22c190e3" }, "lazydev.nvim": { "branch": "main", "commit": "7cbb524c85f87017df9c1ea2377a1d840ad8ed51" }, @@ -29,7 +30,6 @@ "mini.surround": { "branch": "main", "commit": "27096c1a27324ee8f2044ea2adc77366d8a782de" }, "mini.visits": { "branch": "main", "commit": "20e82e3f4ed1ce96d254c16a8602d7606c618c25" }, "nvim-cmp": { "branch": "main", "commit": "a110e12d0b58eefcf5b771f533fc2cf3050680ac" }, - "nvim-colorizer.lua": { "branch": "master", "commit": "85855b38011114929f4058efc97af1059ab3e41d" }, "nvim-lint": { "branch": "master", "commit": "941fa1220a61797a51f3af9ec6b7d74c8c7367ce" }, "nvim-lspconfig": { "branch": "master", "commit": "4d38bece98300e3e5cd24a9aa0d0ebfea4951c16" }, "nvim-spectre": { "branch": "master", "commit": "ec67d4b5370094b923dfcf6b09b39142f2964861" }, From 9faabadf6e190bd3cfb9e071e457f63201375dbe Mon Sep 17 00:00:00 2001 From: asyncedd Date: Wed, 26 Jun 2024 21:18:43 +0900 Subject: [PATCH 49/56] feat: add inlayhints --- lua/configs/lspconfig.lua | 25 +++++++++++++++++++++++++ lua/nvconfig.lua | 1 + 2 files changed, 26 insertions(+) diff --git a/lua/configs/lspconfig.lua b/lua/configs/lspconfig.lua index 2f099fe4..a4565468 100644 --- a/lua/configs/lspconfig.lua +++ b/lua/configs/lspconfig.lua @@ -35,6 +35,21 @@ local on_init = function(client, _) if client.supports_method("textDocument/semanticTokens") then client.server_capabilities.semanticTokensProvider = nil end + + if conf.inlay_hints then + vim.b.inlay_hints_enabled = true + vim.lsp.inlay_hint.enable(true) + vim.api.nvim_create_autocmd("InsertEnter", { + callback = function() + vim.lsp.inlay_hint.enable(false) + end, + }) + vim.api.nvim_create_autocmd("InsertLeave", { + callback = function() + vim.lsp.inlay_hint.enable(vim.b.inlay_hints_enabled or false) + end, + }) + end end local capabilities = vim.lsp.protocol.make_client_capabilities() @@ -88,6 +103,16 @@ require("lspconfig")["nil_ls"].setup({ }, }) +require("lspconfig")["nixd"].setup({ + on_attach = on_attach, + on_init = function(client, _) + on_init(client, _) + + client.server_capabilities.semanticTokensProvider = nil + end, + capabilities = capabilities, +}) + require("lspconfig")["markdown_oxide"].setup({ on_attach = function(client, bufnr) on_attach(client, bufnr) diff --git a/lua/nvconfig.lua b/lua/nvconfig.lua index 6e51525a..b57ae913 100644 --- a/lua/nvconfig.lua +++ b/lua/nvconfig.lua @@ -66,6 +66,7 @@ M.ui = { lsp = { signature = true, semantic_tokens = false, + inlay_hints = true, }, term = { From 66816f918ed8ebf60165adba4332aeea6e23a7bf Mon Sep 17 00:00:00 2001 From: asyncedd Date: Wed, 26 Jun 2024 21:18:57 +0900 Subject: [PATCH 50/56] feat(treesitter): add nix --- lua/plugins/specs/editor.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/lua/plugins/specs/editor.lua b/lua/plugins/specs/editor.lua index 47aab954..f4a98216 100644 --- a/lua/plugins/specs/editor.lua +++ b/lua/plugins/specs/editor.lua @@ -33,6 +33,7 @@ return { "ninja", "rst", "python", + "nix", }, highlight = { enable = true, use_languagetree = true }, -- indent = { enable = true }, From f4de9564b37a642dc7dedbd8760f080c8f148a9d Mon Sep 17 00:00:00 2001 From: asyncedd Date: Wed, 26 Jun 2024 21:20:16 +0900 Subject: [PATCH 51/56] chore: sync lazylock.json --- lazy-lock.json | 58 +++++++++++++++++++++++++------------------------- 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/lazy-lock.json b/lazy-lock.json index cd6745a5..451d709b 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -1,49 +1,49 @@ { - "LuaSnip": { "branch": "master", "commit": "50fcf17db7c75af80e6b6109acfbfb4504768780" }, - "base46": { "branch": "v2.5", "commit": "87e09eb9e959966397bd9d8aab18d88ef349c913" }, + "LuaSnip": { "branch": "master", "commit": "ba3ea5bcfd969679f38fefb1bc801cd45524045b" }, + "base46": { "branch": "v2.5", "commit": "bbbdde83001701047b88f4978f05ea43ea4462e1" }, "cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" }, "cmp-cmdline": { "branch": "main", "commit": "d250c63aa13ead745e3a40f61fdd3470efde3923" }, "cmp-nvim-lsp": { "branch": "main", "commit": "39e2eda76828d88b773cc27a3f61d2ad782c922d" }, "cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" }, "cmp_luasnip": { "branch": "master", "commit": "05a9ab28b53f71d1aece421ef32fee2cb857a843" }, - "conform.nvim": { "branch": "master", "commit": "07d1298739cd7c616cb683bfd848f6b369f93297" }, - "dressing.nvim": { "branch": "master", "commit": "e3714c8049b2243e792492c4149e4cc395c68eb9" }, + "conform.nvim": { "branch": "master", "commit": "c26dadf8a47a547768d1048a0d698ecec33494ce" }, + "dressing.nvim": { "branch": "master", "commit": "6741f1062d3dc6e4755367a7e9b347b553623f04" }, "flash.nvim": { "branch": "main", "commit": "43f67935d388fbb540f8b40e8cbfd80de54f978a" }, - "friendly-snippets": { "branch": "main", "commit": "700c4a25caacbb4648c9a27972c2fe203948e0c2" }, - "gitsigns.nvim": { "branch": "main", "commit": "47c8e3e571376b24de62408fd0c9d12f0a9fc0a3" }, - "indent-blankline.nvim": { "branch": "master", "commit": "d98f537c3492e87b6dc6c2e3f66ac517528f406f" }, - "lazy.nvim": { "branch": "main", "commit": "eb4957442e3182f051b0ae11da32e06d22c190e3" }, - "lazydev.nvim": { "branch": "main", "commit": "7cbb524c85f87017df9c1ea2377a1d840ad8ed51" }, + "friendly-snippets": { "branch": "main", "commit": "682157939e57bd6a2c86277dfd4d6fbfce63dbac" }, + "gitsigns.nvim": { "branch": "main", "commit": "fa42613096ebfa5fee1ea87d70f8625ab9685d01" }, + "indent-blankline.nvim": { "branch": "master", "commit": "4288ce8128a52650e401dda42fd7651a6038f262" }, + "lazy.nvim": { "branch": "main", "commit": "aa1c9572aa1916e582f9b9c3d43e272b4f23b326" }, + "lazydev.nvim": { "branch": "main", "commit": "78d8a11fbd02ad4eafa07dd8a43a959a69fb3bf8" }, "lspkind.nvim": { "branch": "master", "commit": "1735dd5a5054c1fb7feaf8e8658dbab925f4f0cf" }, "luvit-meta": { "branch": "main", "commit": "ce76f6f6cdc9201523a5875a4471dcfe0186eb60" }, - "mini.ai": { "branch": "main", "commit": "a7e90f110e6274262616311b93cef12cd2667a2d" }, - "mini.clue": { "branch": "main", "commit": "629f7ddb071faf8eba77c5c56a295a0a206df94c" }, - "mini.diff": { "branch": "main", "commit": "441975a43bbec22442a91fe2ab1c7c06984e4d8a" }, - "mini.extra": { "branch": "main", "commit": "a89d2376082cfe4b9d55713beddd5c5f5995ea2a" }, - "mini.files": { "branch": "main", "commit": "05c861ff4066a9d20233ec776e9ec894ab9f19fe" }, - "mini.git": { "branch": "main", "commit": "625e529c8b6363290e1ffadc91cdf4b50e1cf094" }, - "mini.hipatterns": { "branch": "main", "commit": "427712c754bfdccd8da7073576cd8e2586c0fe93" }, - "mini.move": { "branch": "main", "commit": "9670fe1d19af3d9a69ddce920c527c883ca5dc4c" }, - "mini.notify": { "branch": "main", "commit": "2d506633f50bd61b1041aa4a6d62e0fe0e6ae09e" }, - "mini.operators": { "branch": "main", "commit": "ccc67955124dde0ba20cdcb37ea30ff1646da574" }, - "mini.splitjoin": { "branch": "main", "commit": "db26e1c991ff5f8cf377e800ef7fba6b5618306b" }, - "mini.surround": { "branch": "main", "commit": "27096c1a27324ee8f2044ea2adc77366d8a782de" }, - "mini.visits": { "branch": "main", "commit": "20e82e3f4ed1ce96d254c16a8602d7606c618c25" }, + "mini.ai": { "branch": "main", "commit": "ebf806de0292ef89b2756cfb0b55040901d1c441" }, + "mini.clue": { "branch": "main", "commit": "c3eaa29d7e875b3a80b4db4067a04726646ce2db" }, + "mini.diff": { "branch": "main", "commit": "9d451672f2f4f8613c859618b5a7a5bf0c4cfa08" }, + "mini.extra": { "branch": "main", "commit": "2a3dc0293fbbe5a27d54957ed149cbdf4f2ddbbf" }, + "mini.files": { "branch": "main", "commit": "34602e87159c3b0e270da103f37a2860bbfd62bd" }, + "mini.git": { "branch": "main", "commit": "54220269adaf9788175b05877f406dfaba68df09" }, + "mini.hipatterns": { "branch": "main", "commit": "5d28a7e3f399de64c4dbf71f8c6c3b633d986f15" }, + "mini.move": { "branch": "main", "commit": "0977d909000510b9d3c16981e16580b8433c8697" }, + "mini.notify": { "branch": "main", "commit": "08aa3be5b99234715bf8d2e56504dccea8a0e212" }, + "mini.operators": { "branch": "main", "commit": "76ac9104d9773927053ea4eb12fc78ccbb5be813" }, + "mini.splitjoin": { "branch": "main", "commit": "6e0c320c2c3a9cc4beb0db9284f3ee5888371f3a" }, + "mini.surround": { "branch": "main", "commit": "af280fc18792b4d142aab4c1638a8949a38ff33a" }, + "mini.visits": { "branch": "main", "commit": "ba562001b033943f2f0ee943f0d0f1ee621aa90f" }, "nvim-cmp": { "branch": "main", "commit": "a110e12d0b58eefcf5b771f533fc2cf3050680ac" }, "nvim-lint": { "branch": "master", "commit": "941fa1220a61797a51f3af9ec6b7d74c8c7367ce" }, - "nvim-lspconfig": { "branch": "master", "commit": "4d38bece98300e3e5cd24a9aa0d0ebfea4951c16" }, - "nvim-spectre": { "branch": "master", "commit": "ec67d4b5370094b923dfcf6b09b39142f2964861" }, - "nvim-treesitter": { "branch": "main", "commit": "7a9286e3116015c37a02584df2fb34a89cf83531" }, + "nvim-lspconfig": { "branch": "master", "commit": "9c9eb07fecc578e25e28db8dc9002b43fff2ed79" }, + "nvim-spectre": { "branch": "master", "commit": "49fae98ef2bfa8342522b337892992e3495065d5" }, + "nvim-treesitter": { "branch": "main", "commit": "fece55077cd7d6f6e79e0deb4397db248e2f5817" }, "nvim-treesitter-textobjects": { "branch": "main", "commit": "cd8fd01677e0cfe9dc2c715f305d653269232c1a" }, - "nvim-various-textobjs": { "branch": "main", "commit": "3ab25fe20f8f9c2035425d0cf5c9634a063cb98e" }, + "nvim-various-textobjs": { "branch": "main", "commit": "bde0481460bfaf0833bd5df7213e6bddcf9b0d8e" }, "nvim-web-devicons": { "branch": "master", "commit": "c0cfc1738361b5da1cd0a962dd6f774cc444f856" }, "plenary.nvim": { "branch": "master", "commit": "a3e3bc82a3f95c5ed0d7201546d5d2c19b20d683" }, - "smart-open.nvim": { "branch": "main", "commit": "028bb71d20e8212da3514bf6dabfb17038d81ee4" }, + "smart-open.nvim": { "branch": "main", "commit": "f4e39e9a1b05a6b82b1182a013677acc44b27abb" }, "sqlite.lua": { "branch": "master", "commit": "d0ffd703b56d090d213b497ed4eb840495f14a11" }, "telescope-fzy-native.nvim": { "branch": "master", "commit": "282f069504515eec762ab6d6c89903377252bf5b" }, - "telescope.nvim": { "branch": "master", "commit": "f12b15e1b3a33524eb06a1ae7bc852fb1fd92197" }, + "telescope.nvim": { "branch": "master", "commit": "61a4a615366c470a4e9ca8f8b45718b6b92af73f" }, "ts-comments.nvim": { "branch": "main", "commit": "c075b4ee00f6e111b44bf99a8cfd5a4cfce9258a" }, - "ui": { "branch": "v2.5", "commit": "dff8115670efc5051e5db9fef4660b2ceae3a26a" }, + "ui": { "branch": "v2.5", "commit": "a44793fc405d11edc40a694ca9687a36b9dae503" }, "ultimate-autopair.nvim": { "branch": "v0.6", "commit": "035d92eab05ac1390afef7204e3fcad9a50fa443" }, "vscode-svelte-snippets": { "branch": "master", "commit": "564ac3300bfeda01ff0bf6b89152cef43f85a4ce" }, "yanky.nvim": { "branch": "main", "commit": "73215b77d22ebb179cef98e7e1235825431d10e4" } From bc88004bbc364e60369f1994321950b33d208d4c Mon Sep 17 00:00:00 2001 From: asyncedd Date: Sat, 29 Jun 2024 14:37:26 +0900 Subject: [PATCH 52/56] perf: potentially improve startup times for lazydev --- lua/plugins/specs/languages/lua.lua | 30 +++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/lua/plugins/specs/languages/lua.lua b/lua/plugins/specs/languages/lua.lua index 0c42c857..e1320666 100644 --- a/lua/plugins/specs/languages/lua.lua +++ b/lua/plugins/specs/languages/lua.lua @@ -1,15 +1,26 @@ return { - { - "stevearc/conform.nvim", - opts = { - formatters_by_ft = { - lua = { "stylua" }, - }, - }, - }, { "folke/lazydev.nvim", - ft = "lua", -- only load on lua files + init = function() + vim.api.nvim_create_autocmd("User", { + group = vim.api.nvim_create_augroup("LoadLazyFile", { clear = true }), + pattern = "LazyFile", + callback = function() + local function load_lazydev() + if not require("lazy.core.config").plugins["lazydev.nvim"]._.loaded then + require("lazy").load({ plugins = "lazydev.nvim" }) + end + end + vim.api.nvim_create_autocmd("FileType", { + pattern = { "*.lua" }, + callback = load_lazydev, + }) + if vim.bo.filetype == "lua" then + load_lazydev() + end + end, + }) + end, opts = { library = { "ui/nvchad_types", @@ -19,7 +30,6 @@ return { }, }, { "Bilal2453/luvit-meta", lazy = true }, -- optional `vim.uv` typings - { -- optional completion source for require statements and module annotations "nvim-cmp", opts = function(_, opts) From 0401db0da69d9d869e605759a139a46d519fe226 Mon Sep 17 00:00:00 2001 From: asyncedd Date: Sat, 29 Jun 2024 14:47:57 +0900 Subject: [PATCH 53/56] fix: use cmdheight=1 --- lua/plugins/specs/ui.lua | 1 - lua/settings/options.lua | 1 - 2 files changed, 2 deletions(-) diff --git a/lua/plugins/specs/ui.lua b/lua/plugins/specs/ui.lua index c9c06b4f..91a11745 100644 --- a/lua/plugins/specs/ui.lua +++ b/lua/plugins/specs/ui.lua @@ -6,7 +6,6 @@ return { require("base46").load_all_highlights() end, }, - { "NvChad/ui", branch = "v2.5", diff --git a/lua/settings/options.lua b/lua/settings/options.lua index bf9b4281..10f30edf 100644 --- a/lua/settings/options.lua +++ b/lua/settings/options.lua @@ -29,7 +29,6 @@ o.clipboard = "unnamedplus" o.signcolumn = "yes:1" -- Statusline -o.cmdheight = 0 o.laststatus = 3 -- Folds From 28281746d7134c5a02fc3e78cd8e98374f02f09b Mon Sep 17 00:00:00 2001 From: asyncedd Date: Sat, 29 Jun 2024 14:57:07 +0900 Subject: [PATCH 54/56] feat(noice.nvim): re-add for the 33th time --- lazy-lock.json | 2 ++ lua/plugins/specs/ui.lua | 60 +++++++++++++++++++++------------------- 2 files changed, 33 insertions(+), 29 deletions(-) diff --git a/lazy-lock.json b/lazy-lock.json index 451d709b..ddf02f68 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -29,6 +29,8 @@ "mini.splitjoin": { "branch": "main", "commit": "6e0c320c2c3a9cc4beb0db9284f3ee5888371f3a" }, "mini.surround": { "branch": "main", "commit": "af280fc18792b4d142aab4c1638a8949a38ff33a" }, "mini.visits": { "branch": "main", "commit": "ba562001b033943f2f0ee943f0d0f1ee621aa90f" }, + "noice.nvim": { "branch": "main", "commit": "03c6a75661e68012e30b0ed81f050358b1e2233c" }, + "nui.nvim": { "branch": "main", "commit": "61574ce6e60c815b0a0c4b5655b8486ba58089a1" }, "nvim-cmp": { "branch": "main", "commit": "a110e12d0b58eefcf5b771f533fc2cf3050680ac" }, "nvim-lint": { "branch": "master", "commit": "941fa1220a61797a51f3af9ec6b7d74c8c7367ce" }, "nvim-lspconfig": { "branch": "master", "commit": "9c9eb07fecc578e25e28db8dc9002b43fff2ed79" }, diff --git a/lua/plugins/specs/ui.lua b/lua/plugins/specs/ui.lua index 91a11745..00e990e9 100644 --- a/lua/plugins/specs/ui.lua +++ b/lua/plugins/specs/ui.lua @@ -41,35 +41,6 @@ return { require("nvim-web-devicons").setup(opts) end, }, - { - "echasnovski/mini.notify", - opts = { - window = { - config = { - border = "none", - }, - winblend = 0, - }, - }, - config = function(_, opts) - local notify = require("mini.notify") - notify.setup(opts) - vim.notify = notify.make_notify({ - ERROR = { duration = 5000 }, - WARN = { duration = 4000 }, - INFO = { duration = 3000 }, - }) - end, - init = function() - vim.notify = function(...) - if not require("lazy.core.config").plugins["mini.notify"]._.loaded then - require("lazy").load({ plugins = "mini.notify" }) - end - vim.notify(...) - end - end, - event = "LspAttach", - }, -- CREDITS TO: https://www.lazyvim.org/plugins/ui#dressingnvim { "stevearc/dressing.nvim", @@ -100,4 +71,35 @@ return { end, 0) end, }, + { + "folke/noice.nvim", + event = "VeryLazy", + config = function() + require("noice").setup({ + lsp = { + hover = { + enabled = false, + }, + override = { + ["vim.lsp.util.convert_input_to_markdown_lines"] = true, + ["vim.lsp.util.stylize_markdown"] = true, + ["cmp.entry.get_documentation"] = true, + }, + signature = { enabled = false }, + }, + notify = { view = "mini" }, + cmdline = { view = "cmdline" }, + presets = { + bottom_search = true, -- use a classic bottom cmdline for search + command_palette = false, -- position the cmdline and popupmenu together + long_message_to_split = true, -- long messages will be sent to a split + inc_rename = false, -- enables an input dialog for inc-rename.nvim + lsp_doc_border = false, -- add a border to hover docs and signature help + }, + }) + end, + dependencies = { + "MunifTanjim/nui.nvim", + }, + }, } From a3d2ae188276a6bd8570eb28fea3cea0cc7e322a Mon Sep 17 00:00:00 2001 From: asyncedd Date: Sat, 29 Jun 2024 14:57:21 +0900 Subject: [PATCH 55/56] Revert "fix: use cmdheight=1" This reverts commit 0401db0da69d9d869e605759a139a46d519fe226. --- lua/plugins/specs/ui.lua | 1 + lua/settings/options.lua | 1 + 2 files changed, 2 insertions(+) diff --git a/lua/plugins/specs/ui.lua b/lua/plugins/specs/ui.lua index 00e990e9..5b372b08 100644 --- a/lua/plugins/specs/ui.lua +++ b/lua/plugins/specs/ui.lua @@ -6,6 +6,7 @@ return { require("base46").load_all_highlights() end, }, + { "NvChad/ui", branch = "v2.5", diff --git a/lua/settings/options.lua b/lua/settings/options.lua index 10f30edf..bf9b4281 100644 --- a/lua/settings/options.lua +++ b/lua/settings/options.lua @@ -29,6 +29,7 @@ o.clipboard = "unnamedplus" o.signcolumn = "yes:1" -- Statusline +o.cmdheight = 0 o.laststatus = 3 -- Folds From c76eaa936d815a3b69bf991ee032ea0d7cdb0981 Mon Sep 17 00:00:00 2001 From: asyncedd Date: Sat, 29 Jun 2024 14:58:05 +0900 Subject: [PATCH 56/56] fix: remove the lsp progress for statusbar --- lua/chadrc.lua | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/lua/chadrc.lua b/lua/chadrc.lua index a666023f..757a726c 100644 --- a/lua/chadrc.lua +++ b/lua/chadrc.lua @@ -5,15 +5,15 @@ local utils = require("nvchad.stl.utils") M.ui = { theme = "everblush", statusline = { - -- order = { - -- "mode", - -- "file", - -- "git", - -- "%=", - -- "diagnostics", - -- "cwd", - -- "cursor", - -- }, + order = { + "mode", + "file", + "git", + "%=", + "diagnostics", + "cwd", + "cursor", + }, modules = { git = function() local git_status = vim.b[utils.stbufnr()].minigit_summary_string or ""