From b434c7939232f4c8feafc86214ce92bd4ae04c7f Mon Sep 17 00:00:00 2001 From: ClSlaid Date: Tue, 23 May 2023 16:24:10 +0800 Subject: [PATCH 01/72] feat: implement inlay virtual text for rust and go (#759) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat: implement inlay virtual text for rust and go Signed-off-by: 蔡略 * fix: go-nvim use lsp-inlayhints.nvim only Signed-off-by: 蔡略 * refactor: move inlay-hints to `completion` Signed-off-by: 蔡略 * feat: lua support Signed-off-by: 蔡略 * chore(inlay-hints): remove `sumneko_lua` * fix: set inlay-hints debug mode off Signed-off-by: 蔡略 --------- Signed-off-by: 蔡略 Co-authored-by: Charles Chiu --- lazy-lock.json | 6 ++- lua/core/event.lua | 3 ++ .../configs/completion/inlay-hints.lua | 47 +++++++++++++++++++ .../configs/completion/servers/lua_ls.lua | 4 ++ lua/modules/configs/lang/go-nvim.lua | 36 ++++++++++++++ lua/modules/configs/lang/rust-tools.lua | 4 +- lua/modules/configs/lang/vim-go.lua | 5 -- lua/modules/plugins/completion.lua | 7 +++ lua/modules/plugins/lang.lua | 14 ++++-- 9 files changed, 113 insertions(+), 13 deletions(-) create mode 100644 lua/modules/configs/completion/inlay-hints.lua create mode 100644 lua/modules/configs/lang/go-nvim.lua delete mode 100644 lua/modules/configs/lang/vim-go.lua diff --git a/lazy-lock.json b/lazy-lock.json index 0a3968c20..40002111f 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -3,7 +3,7 @@ "LuaSnip": { "branch": "master", "commit": "fcdaa4313305fe20d928551134c1ec2266e7af2a" }, "accelerated-jk.nvim": { "branch": "main", "commit": "8fb5dad4ccc1811766cebf16b544038aeeb7806f" }, "alpha-nvim": { "branch": "main", "commit": "1838ae926e8d49fe5330d1498ee8289ae2c340bc" }, - "auto-session": { "branch": "main", "commit": "571ecb873654554109f63eac3193b133aec2f90c" }, + "auto-session": { "branch": "main", "commit": "a2ca98ceec8b62ae955159ef167b15dd4f28185b" }, "autoclose.nvim": { "branch": "main", "commit": "c4db42ffc0edbd244502be951c142df0c8a7e582" }, "better-escape.nvim": { "branch": "master", "commit": "7031dc734add47bb71c010e0551829fa5799375f" }, "bigfile.nvim": { "branch": "main", "commit": "a34e42616c20bfd52943ed5d6632bb28d22b057e" }, @@ -30,9 +30,12 @@ "friendly-snippets": { "branch": "main", "commit": "ef6547d2f586e08e071efeebac835e545f3015cc" }, "fzy-lua-native": { "branch": "master", "commit": "45148b3f70d244e8b8b5db60df447a2b7ac2de9d" }, "gitsigns.nvim": { "branch": "main", "commit": "c18b7ca0b5b50596722f3a1572eb9b8eb520c0f1" }, + "go.nvim": { "branch": "master", "commit": "1a2530d3e9b29e9e1279a67d27304a05663537fd" }, + "guihua.lua": { "branch": "master", "commit": "ab8b1f09603cc268770efd057115035dc6cfa83d" }, "hop.nvim": { "branch": "v2", "commit": "90db1b2c61b820e230599a04fedcd2679e64bd07" }, "indent-blankline.nvim": { "branch": "master", "commit": "86d1b71c5c26168c3a3a9ff5f69e833889a09c1d" }, "lazy.nvim": { "branch": "main", "commit": "6610b15dfd76f7992423916e2b87f031881d7b25" }, + "lsp-inlayhints.nvim": { "branch": "anticonceal", "commit": "48b76c3c761fffc12ec2a94db7b371b6304e2067" }, "lsp_signature.nvim": { "branch": "master", "commit": "7a26ebaa7e36aa2aefa6c1994b2b866c96de32e6" }, "lspsaga.nvim": { "branch": "main", "commit": "01b9633aefd010f272d6c7e3d8293c44fcfe7696" }, "lualine.nvim": { "branch": "master", "commit": "05d78e9fd0cdfb4545974a5aa14b1be95a86e9c9" }, @@ -82,7 +85,6 @@ "vim-cool": { "branch": "master", "commit": "80536b9f2e23292708a64f2e7bcf5e596f9faf24" }, "vim-easy-align": { "branch": "master", "commit": "12dd6316974f71ce333e360c0260b4e1f81169c3" }, "vim-fugitive": { "branch": "master", "commit": "5f0d280b517cacb16f59316659966c7ca5e2bea2" }, - "vim-go": { "branch": "master", "commit": "2a874910a242fd4a5da021ea32fb1cde3b69f79b" }, "vim-illuminate": { "branch": "master", "commit": "a2907275a6899c570d16e95b9db5fd921c167502" }, "vim-matchup": { "branch": "master", "commit": "b8eca3b588e41e0bb1b3ae200fae88183b91a76d" }, "which-key.nvim": { "branch": "main", "commit": "e271c28118998c93a14d189af3395812a1aa646c" }, diff --git a/lua/core/event.lua b/lua/core/event.lua index 3208992ec..37b5181b3 100644 --- a/lua/core/event.lua +++ b/lua/core/event.lua @@ -18,6 +18,9 @@ vim.api.nvim_create_autocmd("LspAttach", { group = vim.api.nvim_create_augroup("UserLspConfig", {}), callback = function(event) mapping.lsp(event.buf) + local inlay_hints = require("lsp-inlayhints") + local client = vim.lsp.get_client_by_id(event.data.client_id) + inlay_hints.on_attach(client, event.buf) end, }) diff --git a/lua/modules/configs/completion/inlay-hints.lua b/lua/modules/configs/completion/inlay-hints.lua new file mode 100644 index 000000000..c336f269c --- /dev/null +++ b/lua/modules/configs/completion/inlay-hints.lua @@ -0,0 +1,47 @@ +return function() + -- listed below are the default values + local override = { + inlay_hints = { + parameter_hints = { + show = true, + }, + type_hints = { + show = true, + }, + label_formatter = function(tbl, kind, opts, client_name) + if kind == 2 and not opts.parameter_hints.show then + return "" + elseif not opts.type_hints.show then + return "" + end + + return table.concat(tbl, ", ") + end, + virt_text_formatter = function(label, hint, opts, client_name) + if client_name == "lua_ls" then + if hint.kind == 2 then + hint.paddingLeft = false + else + hint.paddingRight = false + end + end + + local vt = {} + vt[#vt + 1] = hint.paddingLeft and { " ", "None" } or nil + vt[#vt + 1] = { label, opts.highlight } + vt[#vt + 1] = hint.paddingRight and { " ", "None" } or nil + + return vt + end, + only_current_line = false, + -- highlight group + highlight = "LspInlayHint", + -- highlight = "Comment", + -- virt_text priority + priority = 0, + }, + enabled_at_startup = true, + debug_mode = false, + } + require("lsp-inlayhints").setup(override) +end diff --git a/lua/modules/configs/completion/servers/lua_ls.lua b/lua/modules/configs/completion/servers/lua_ls.lua index d1d1afc71..06e1d4436 100644 --- a/lua/modules/configs/completion/servers/lua_ls.lua +++ b/lua/modules/configs/completion/servers/lua_ls.lua @@ -2,6 +2,9 @@ return { settings = { Lua = { + runtime = { + version = "LuaJIT", + }, diagnostics = { globals = { "vim" }, disable = { "different-requires" }, @@ -14,6 +17,7 @@ return { maxPreload = 100000, preloadFileSize = 10000, }, + hint = { enable = true, setType = true }, format = { enable = false }, telemetry = { enable = false }, -- Do not override treesitter lua highlighting with lua_ls's highlighting diff --git a/lua/modules/configs/lang/go-nvim.lua b/lua/modules/configs/lang/go-nvim.lua new file mode 100644 index 000000000..2df2f5bde --- /dev/null +++ b/lua/modules/configs/lang/go-nvim.lua @@ -0,0 +1,36 @@ +return function() + require("go").setup({ + lsp_keymaps = false, + dap_debug_keymap = false, + icons = false, + gofmt = "gopls", + goimport = "gopls", + lsp_gofumpt = "true", + lsp_inlay_hints = { enable = false }, + run_in_floaterm = true, + trouble = true, + lsp_cfg = { + flags = { debounce_text_changes = 500 }, + cmd = { "gopls", "-remote=auto" }, + settings = { + gopls = { + usePlaceholders = true, + analyses = { + nilness = true, + shadow = true, + unusedparams = true, + unusewrites = true, + }, + hints = { + assignVariableTypes = true, + compositeLiteralFields = true, + constantValues = true, + functionTypeParameters = true, + parameterNames = true, + rangeVariableTypes = true, + }, + }, + }, + }, + }) +end diff --git a/lua/modules/configs/lang/rust-tools.lua b/lua/modules/configs/lang/rust-tools.lua index f3e5b98c5..239f796f0 100644 --- a/lua/modules/configs/lang/rust-tools.lua +++ b/lua/modules/configs/lang/rust-tools.lua @@ -29,7 +29,7 @@ return function() inlay_hints = { -- automatically set inlay hints (type hints) -- default: true - auto = true, + auto = false, -- Only show inlay hints for the current line only_current_line = false, @@ -46,7 +46,7 @@ return function() -- default: "=>" other_hints_prefix = "=> ", - -- whether to align to the lenght of the longest line in the file + -- whether to align to the length of the longest line in the file max_len_align = false, -- padding from the left if max_len_align is true diff --git a/lua/modules/configs/lang/vim-go.lua b/lua/modules/configs/lang/vim-go.lua deleted file mode 100644 index d5452ea94..000000000 --- a/lua/modules/configs/lang/vim-go.lua +++ /dev/null @@ -1,5 +0,0 @@ -return function() - vim.g.go_doc_keywordprg_enabled = 0 - vim.g.go_def_mapping_enabled = 0 - vim.g.go_code_completion_enabled = 0 -end diff --git a/lua/modules/plugins/completion.lua b/lua/modules/plugins/completion.lua index 3ed980d0d..e8061fa5a 100644 --- a/lua/modules/plugins/completion.lua +++ b/lua/modules/plugins/completion.lua @@ -12,6 +12,13 @@ completion["neovim/nvim-lspconfig"] = { "nvimdev/lspsaga.nvim", config = require("completion.lspsaga"), }, + { + "lvimuser/lsp-inlayhints.nvim", + config = require("completion.inlay-hints"), + lazy = true, + branch = "anticonceal", + event = { "LspAttach" }, + }, }, } completion["jose-elias-alvarez/null-ls.nvim"] = { diff --git a/lua/modules/plugins/lang.lua b/lua/modules/plugins/lang.lua index 5154e9401..3d1cb9b2f 100644 --- a/lua/modules/plugins/lang.lua +++ b/lua/modules/plugins/lang.lua @@ -1,10 +1,16 @@ local lang = {} -lang["fatih/vim-go"] = { +lang["ray-x/go.nvim"] = { lazy = true, - ft = "go", - build = ":GoInstallBinaries", - config = require("lang.vim-go"), + dependencies = { -- optional packages + "ray-x/guihua.lua", + "neovim/nvim-lspconfig", + "nvim-treesitter/nvim-treesitter", + }, + ft = { "go", "gomod" }, + event = { "CmdlineEnter" }, + build = ':lua require("go.install").update_all_sync()', -- if you need to install/update all binaries + config = require("lang.go-nvim"), } lang["simrat39/rust-tools.nvim"] = { lazy = true, From ad57d95bd618b3f23e1e933fad27283efcd9cfc1 Mon Sep 17 00:00:00 2001 From: Xie Zejian Date: Tue, 18 Jul 2023 01:08:09 +0800 Subject: [PATCH 02/72] workaroud for watchfile problem (#871) * workaroud for watchfile problem * fix CI --- lua/core/init.lua | 11 +++++++++++ lua/modules/configs/completion/inlay-hints.lua | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/lua/core/init.lua b/lua/core/init.lua index 2a9846181..f61911390 100644 --- a/lua/core/init.lua +++ b/lua/core/init.lua @@ -143,6 +143,16 @@ You're recommended to install PowerShell for better experience.]], end end +local _v0_10_workarounds = function() + local ok, watchfile = pcall(require, "vim.lsp._watchfiles") + if ok then + -- Disable lsp watcher + watchfile._watchfunc = function() + return function() end + end + end +end + local load_core = function() createdir() disable_distribution_plugins() @@ -151,6 +161,7 @@ local load_core = function() neovide_config() clipboard_config() shell_config() + _v0_10_workarounds() require("core.options") require("core.mapping") diff --git a/lua/modules/configs/completion/inlay-hints.lua b/lua/modules/configs/completion/inlay-hints.lua index c336f269c..e4f49d50d 100644 --- a/lua/modules/configs/completion/inlay-hints.lua +++ b/lua/modules/configs/completion/inlay-hints.lua @@ -8,7 +8,7 @@ return function() type_hints = { show = true, }, - label_formatter = function(tbl, kind, opts, client_name) + label_formatter = function(tbl, kind, opts) if kind == 2 and not opts.parameter_hints.show then return "" elseif not opts.type_hints.show then From 41c2f004dc84420452b15375b60defd2ee4b185a Mon Sep 17 00:00:00 2001 From: Jint-lzxy <50296129+Jint-lzxy@users.noreply.github.com> Date: Tue, 18 Jul 2023 01:09:10 +0800 Subject: [PATCH 03/72] Merge branch 'main' --- lazy-lock.json | 55 ++- lua/core/event.lua | 2 +- lua/core/options.lua | 12 +- lua/core/pack.lua | 2 +- lua/core/settings.lua | 6 +- lua/keymap/completion.lua | 6 +- lua/keymap/editor.lua | 4 +- lua/keymap/tool.lua | 1 + lua/modules/configs/completion/formatting.lua | 15 +- .../configs/completion/lsp-signature.lua | 15 + lua/modules/configs/completion/lsp.lua | 21 +- lua/modules/configs/completion/lspsaga.lua | 95 +++-- lua/modules/configs/completion/null-ls.lua | 1 + lua/modules/configs/editor/auto-session.lua | 24 -- lua/modules/configs/editor/better-escape.lua | 2 +- lua/modules/configs/editor/persisted.lua | 23 ++ lua/modules/configs/editor/rainbow_delims.lua | 39 ++ lua/modules/configs/editor/ts-context.lua | 12 + lua/modules/configs/lang/rust-tools.lua | 18 +- lua/modules/configs/tool/telescope.lua | 1 + lua/modules/configs/tool/trouble.lua | 2 +- lua/modules/configs/ui/bufferline.lua | 8 +- lua/modules/configs/ui/catppuccin.lua | 48 +-- lua/modules/configs/ui/lualine.lua | 371 +++++++++++++----- lua/modules/configs/ui/notify.lua | 14 +- lua/modules/configs/ui/scrollview.lua | 2 +- lua/modules/configs/ui/specs.lua | 2 +- lua/modules/plugins/completion.lua | 13 +- lua/modules/plugins/editor.lua | 37 +- lua/modules/plugins/tool.lua | 4 +- lua/modules/plugins/ui.lua | 4 +- lua/modules/utils/icons.lua | 6 +- lua/modules/utils/init.lua | 19 +- scripts/install.ps1 | 7 +- scripts/install.sh | 7 + dots.tutor => tutor/dots.tutor | 0 36 files changed, 594 insertions(+), 304 deletions(-) create mode 100644 lua/modules/configs/completion/lsp-signature.lua delete mode 100644 lua/modules/configs/editor/auto-session.lua create mode 100644 lua/modules/configs/editor/persisted.lua create mode 100644 lua/modules/configs/editor/rainbow_delims.lua create mode 100644 lua/modules/configs/editor/ts-context.lua rename dots.tutor => tutor/dots.tutor (100%) diff --git a/lazy-lock.json b/lazy-lock.json index c7d23a48b..d47a0dcda 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -3,16 +3,15 @@ "LuaSnip": { "branch": "master", "commit": "6086742e287ce0e40ffa31b1c26b7e8914ffb7a4" }, "accelerated-jk.nvim": { "branch": "main", "commit": "8fb5dad4ccc1811766cebf16b544038aeeb7806f" }, "alpha-nvim": { "branch": "main", "commit": "9e33db324b8bb7a147bce9ea5496686ee859461d" }, - "auto-session": { "branch": "main", "commit": "7afbb149f87be279778689596c781882014f7eef" }, - "autoclose.nvim": { "branch": "main", "commit": "2321727fd10a6b34624723bc4747d8c09c10b7a4" }, + "autoclose.nvim": { "branch": "main", "commit": "469782b0456f0b4f764378ffda94c18599544e09" }, "better-escape.nvim": { "branch": "master", "commit": "7031dc734add47bb71c010e0551829fa5799375f" }, - "bigfile.nvim": { "branch": "main", "commit": "67a03ff3dfbfacaa0b006c7ddc55356c85510b25" }, - "bufferline.nvim": { "branch": "main", "commit": "60734264a8655a7db3595159fb50076dc24c2f2c" }, - "catppuccin": { "branch": "refactor/syntax-highlighting", "commit": "c0f7432052a837c6295a7770e39fdc07ede3305c" }, + "bigfile.nvim": { "branch": "main", "commit": "9616b73670ffeb92679677554ded88854ae42cf8" }, + "bufferline.nvim": { "branch": "main", "commit": "cd27a52ecdfed7f14a41b61b7976f155e3d593c7" }, + "catppuccin": { "branch": "refactor/syntax-highlighting", "commit": "aee0f54a7d3c032312d15eff5f34a5e5eb2f2eab" }, "clever-f.vim": { "branch": "master", "commit": "6a3ac5e3688598af9411ab741737f98c47370c22" }, "cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" }, "cmp-latex-symbols": { "branch": "main", "commit": "165fb66afdbd016eaa1570e41672c4c557b57124" }, - "cmp-nvim-lsp": { "branch": "main", "commit": "0e6b2ed705ddcff9738ec4ea838141654f12eeef" }, + "cmp-nvim-lsp": { "branch": "main", "commit": "44b16d11215dce86f253ce0c30949813c0a90765" }, "cmp-nvim-lua": { "branch": "main", "commit": "f12408bdb54c39c23e67cab726264c10db33ada8" }, "cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" }, "cmp-spell": { "branch": "master", "commit": "60584cb75e5e8bba5a0c9e4c3ab0791e0698bffa" }, @@ -21,13 +20,13 @@ "cmp-under-comparator": { "branch": "master", "commit": "6857f10272c3cfe930cece2afa2406e1385bfef8" }, "cmp_luasnip": { "branch": "master", "commit": "18095520391186d634a0045dacaa346291096566" }, "copilot-cmp": { "branch": "master", "commit": "c2cdb3c0f5078b0619055af192295830a7987790" }, - "copilot.lua": { "branch": "master", "commit": "77e3a4907928f0813024e573b882dc879dfc0c6b" }, - "crates.nvim": { "branch": "main", "commit": "3648f8787656d7572740560331553abdaa8cb982" }, + "copilot.lua": { "branch": "master", "commit": "e48bd7020a98be217d85c006a298656294fd6210" }, + "crates.nvim": { "branch": "main", "commit": "4ce7c51b881e58f1e2f8f437f30e4e583cbac319" }, "csv.vim": { "branch": "master", "commit": "15ff93edf5b26c466affbb356e0696b7d6a3b499" }, - "diffview.nvim": { "branch": "main", "commit": "b3a763f8c7810b352226c95faa7d3ac9fb93b8d9" }, + "diffview.nvim": { "branch": "main", "commit": "b0cc22f5708f6b2b4f873b44fbc5eb93020f4e0c" }, "edge": { "branch": "master", "commit": "358cb6688ac577470a4eafcb53bdd63899dfc937" }, "fidget.nvim": { "branch": "legacy", "commit": "90c22e47be057562ee9566bad313ad42d622c1d3" }, - "friendly-snippets": { "branch": "main", "commit": "70b727d3454cceb3a818b1746be09786568b7e33" }, + "friendly-snippets": { "branch": "main", "commit": "6153166d5a3dcc7e2809ea4f17f9edb34d026026" }, "fzy-lua-native": { "branch": "master", "commit": "820f745b7c442176bcc243e8f38ef4b985febfaf" }, "gitsigns.nvim": { "branch": "main", "commit": "3ef12dfdc293969fac736a7a580d6ae1f57ea406" }, "go.nvim": { "branch": "master", "commit": "a8095eb334495caec3099b717cc7f5b1fbc3e628" }, @@ -37,52 +36,53 @@ "lazy.nvim": { "branch": "main", "commit": "c1aad95243f0d180f41348be26b2417547fb168b" }, "lsp-inlayhints.nvim": { "branch": "anticonceal", "commit": "0fb3b5ef16f2d7e85963cb0b1beacf573ade35de" }, "lsp_signature.nvim": { "branch": "master", "commit": "17ff7a405fea8376b015b8ea7910d2e59958bf68" }, - "lspsaga.nvim": { "branch": "main", "commit": "4f075452c466df263e69ae142f6659dcf9324bf6" }, + "lspsaga.nvim": { "branch": "main", "commit": "ce5bffd65e7eb266263ce364950633aeb60c5b8c" }, "lualine.nvim": { "branch": "master", "commit": "05d78e9fd0cdfb4545974a5aa14b1be95a86e9c9" }, "markdown-preview.nvim": { "branch": "master", "commit": "02cc3874738bc0f86e4b91f09b8a0ac88aef8e96" }, - "mason-lspconfig.nvim": { "branch": "main", "commit": "d381fcb78d7a562c3244e1c8f76406954649db36" }, - "mason-null-ls.nvim": { "branch": "main", "commit": "73c68abdf65279e41526eb152876511a8ae84ea2" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "796008869e67ef27a5aa5ac44c08ce2a60b89f55" }, + "mason-null-ls.nvim": { "branch": "main", "commit": "ae0c5fa57468ac65617f1bf821ba0c3a1e251f0c" }, "mason-nvim-dap.nvim": { "branch": "main", "commit": "e4d56b400e9757b1dc77d620fd3069396e92d5fc" }, - "mason.nvim": { "branch": "main", "commit": "f7f81ab41b153e2902ebded401a8a0a6abe28607" }, + "mason.nvim": { "branch": "main", "commit": "5ad3e113b0c3fde3caba8630599373046f6197e8" }, "neodim": { "branch": "master", "commit": "9477da03b93f1984a81fee3b92e6ac7c6ada6aa4" }, "neoscroll.nvim": { "branch": "master", "commit": "d7601c26c8a183fa8994ed339e70c2d841253e93" }, "nord.nvim": { "branch": "master", "commit": "fab04b2dd4b64f4b1763b9250a8824d0b5194b8f" }, - "null-ls.nvim": { "branch": "main", "commit": "bbaf5a96913aa92281f154b08732be2f57021c45" }, + "null-ls.nvim": { "branch": "main", "commit": "db09b6c691def0038c456551e4e2772186449f35" }, "nvim-bufdel": { "branch": "main", "commit": "96c4f7ab053ddab0025bebe5f7c71e4795430e47" }, "nvim-cmp": { "branch": "main", "commit": "fa492591fecdc41798cd5d3d1713232a5088fba0" }, "nvim-colorizer.lua": { "branch": "master", "commit": "dde3084106a70b9a79d48f426f6d6fec6fd203f7" }, - "nvim-dap": { "branch": "master", "commit": "a6d48d23407fbad7a4c1451803b8f34cab31c441" }, + "nvim-dap": { "branch": "master", "commit": "3bde6f786057fa29d8356559b2ae3a52d9317fba" }, "nvim-dap-ui": { "branch": "master", "commit": "c020f660b02772f9f3d11f599fefad3268628a9e" }, "nvim-lspconfig": { "branch": "master", "commit": "444eab07bb7881cad984c68c89fde276f7a26d81" }, "nvim-notify": { "branch": "master", "commit": "ea9c8ce7a37f2238f934e087c255758659948e0f" }, - "nvim-scrollview": { "branch": "main", "commit": "cb5e6a7692453624beb122f3d154c266a24d9195" }, - "nvim-tree.lua": { "branch": "master", "commit": "c3c6544ee00333b0f1d6a13735d0dd302dba4f70" }, + "nvim-scrollview": { "branch": "main", "commit": "dbd17a6de65c3a149fe5ace10fee311fd8251b06" }, + "nvim-tree.lua": { "branch": "master", "commit": "a708bd2413d467929b5019ec1bce7b1f428438bc" }, "nvim-treehopper": { "branch": "master", "commit": "5a28bff46c05d28bdb4bcaef67e046eb915a9390" }, "nvim-treesitter": { "branch": "master", "commit": "70f161b1dda985d08e106d5e3744b2612755f748" }, "nvim-treesitter-context": { "branch": "master", "commit": "6eccc445394df5ab9b1c1e2c445c033949a6a784" }, "nvim-treesitter-textobjects": { "branch": "master", "commit": "83c59ed1eeae70a55605990993cf4d208948fdf7" }, "nvim-ts-autotag": { "branch": "main", "commit": "6be1192965df35f94b8ea6d323354f7dc7a557e4" }, - "nvim-ts-context-commentstring": { "branch": "main", "commit": "0bf8fbc2ca8f8cdb6efbd0a9e32740d7a991e4c3" }, - "nvim-ts-rainbow": { "branch": "master", "commit": "8312b513ce930e7669a1721befbe56f2e1853301" }, - "nvim-web-devicons": { "branch": "master", "commit": "14b3a5ba63b82b60cde98d0a40319d80f25e8301" }, + "nvim-ts-context-commentstring": { "branch": "main", "commit": "7f625207f225eea97ef7a6abe7611e556c396d2f" }, + "nvim-web-devicons": { "branch": "master", "commit": "9ab9b0b894b2388a9dbcdee5f00ce72e25d85bf9" }, "paint.nvim": { "branch": "main", "commit": "6ce64212804f425073c61ab0d9c2b034f0435260" }, - "plenary.nvim": { "branch": "master", "commit": "36aaceb6e93addd20b1b18f94d86aecc552f30c4" }, + "persisted.nvim": { "branch": "main", "commit": "b03c863731eafacd973912383297ea5d8fdb006a" }, + "plenary.nvim": { "branch": "master", "commit": "bda256fab0eb66a15e8190937e417e6a14ee5d72" }, "project.nvim": { "branch": "main", "commit": "8c6bad7d22eef1b71144b401c9f74ed01526a4fb" }, - "rust-tools.nvim": { "branch": "master", "commit": "71d2cf67b5ed120a0e31b2c8adb210dd2834242f" }, + "rainbow-delimiters.nvim": { "branch": "master", "commit": "862e0f5e867e1a4c93e3efe73d4c71b7b6d3fec8" }, + "rust-tools.nvim": { "branch": "master", "commit": "0cc8adab23117783a0292a0c8a2fbed1005dc645" }, "smartyank.nvim": { "branch": "master", "commit": "7e3905578f646503525b2f7018b8afd17861018c" }, "sniprun": { "branch": "master", "commit": "28d55eeb6786a7037fd3564ced8296a71f1cece7" }, "specs.nvim": { "branch": "main", "commit": "2743e412bbe21c9d73954c403d01e8de7377890d" }, "sqlite.lua": { "branch": "master", "commit": "b7e28c8463254c46a8e61c52d27d6a2040492fc3" }, - "suda.vim": { "branch": "master", "commit": "08abd39dfe1cee681b8ce3e7321da5fa03e045c1" }, + "suda.vim": { "branch": "master", "commit": "8b0fc3711760195aba104e2d190cff9af8267052" }, "tabout.nvim": { "branch": "master", "commit": "0d275c8d25f32457e67b5c66d6ae43f26a61bce5" }, "telescope-frecency.nvim": { "branch": "master", "commit": "62d3381a32ae541233b03a129ece0aeced30ad5e" }, "telescope-fzf-native.nvim": { "branch": "main", "commit": "9bc8237565ded606e6c366a71c64c0af25cd7a50" }, "telescope-live-grep-args.nvim": { "branch": "master", "commit": "0f75ea809c46af8997c64f49c52e3c641d887885" }, "telescope-undo.nvim": { "branch": "main", "commit": "3dec002ea3e7952071d26fbb5d01e2038a58a554" }, "telescope-zoxide": { "branch": "main", "commit": "68966349aa1b8e9ade403e18479ecf79447389a7" }, - "telescope.nvim": { "branch": "master", "commit": "00cf15074a2997487813672a75f946d2ead95eb0" }, - "toggleterm.nvim": { "branch": "main", "commit": "cf146a267a6a7db62b1e2aff40414b20081048a1" }, - "trouble.nvim": { "branch": "main", "commit": "2af0dd9767526410c88c628f1cbfcb6cf22dd683" }, + "telescope.nvim": { "branch": "master", "commit": "276362a8020c6e94c7a76d49aa00d4923b0c02f3" }, + "toggleterm.nvim": { "branch": "main", "commit": "83aa231fa414a5dcb72aed97437446a6ca5a81f2" }, + "trouble.nvim": { "branch": "main", "commit": "d99e2abd10808ef91738ce98a5c767e6a51df449" }, "vim-cool": { "branch": "master", "commit": "04bb7f5dade175a81b47abf4e87aeb30b05b33d8" }, "vim-easy-align": { "branch": "master", "commit": "12dd6316974f71ce333e360c0260b4e1f81169c3" }, "vim-fugitive": { "branch": "master", "commit": "43f18ab9155c853a84ded560c6104e6300ad41da" }, @@ -90,4 +90,3 @@ "vim-matchup": { "branch": "master", "commit": "3a17944bfa3942da805a381750a1be4b314c64d2" }, "which-key.nvim": { "branch": "main", "commit": "d871f2b664afd5aed3dc1d1573bef2fb24ce0484" }, "wilder.nvim": { "branch": "master", "commit": "679f348dc90d80ff9ba0e7c470c40a4d038dcecf" } -} \ No newline at end of file diff --git a/lua/core/event.lua b/lua/core/event.lua index 520e033c0..d725fd83d 100644 --- a/lua/core/event.lua +++ b/lua/core/event.lua @@ -32,7 +32,7 @@ vim.api.nvim_create_autocmd("BufEnter", { local layout = vim.api.nvim_call_function("winlayout", {}) if layout[1] == "leaf" - and vim.api.nvim_buf_get_option(vim.api.nvim_win_get_buf(layout[2]), "filetype") == "NvimTree" + and vim.api.nvim_get_option_value("filetype", { buf = vim.api.nvim_win_get_buf(layout[2]) }) == "NvimTree" and layout[3] == nil then vim.api.nvim_command([[confirm quit]]) diff --git a/lua/core/options.lua b/lua/core/options.lua index 501549eb2..47d7f427d 100644 --- a/lua/core/options.lua +++ b/lua/core/options.lua @@ -4,10 +4,8 @@ local function load_options() local global_local = { -- backupdir = global.cache_dir .. "backup/", -- directory = global.cache_dir .. "swap/", - -- pumblend = 10, -- spellfile = global.cache_dir .. "spell/en.uft-8.add", -- viewdir = global.cache_dir .. "view/", - -- winblend = 10, autoindent = true, autoread = true, autowrite = true, @@ -17,7 +15,7 @@ local function load_options() breakat = [[\ \ ;:,!?]], breakindentopt = "shift:2,min:20", clipboard = "unnamedplus", - cmdheight = 2, -- 0, 1, 2 + cmdheight = 1, -- 0, 1, 2 cmdwinheight = 5, complete = ".,w,b,k", completeopt = "menuone,noselect", @@ -53,12 +51,14 @@ local function load_options() mousescroll = "ver:3,hor:6", number = true, previewheight = 12, + -- Do NOT adjust the following option (pumblend) if you're using transparent background + pumblend = 0, pumheight = 15, redrawtime = 1500, relativenumber = true, ruler = true, scrolloff = 2, - sessionoptions = "buffers,curdir,help,tabpages,winsize", + sessionoptions = "buffers,curdir,folds,help,tabpages,winpos,winsize", shada = "!,'500,<50,@100,s10,h", shiftround = true, shiftwidth = 4, @@ -73,7 +73,7 @@ local function load_options() smarttab = true, softtabstop = 4, splitbelow = true, - splitkeep = "cursor", + splitkeep = "screen", splitright = true, startofline = false, swapfile = false, @@ -95,6 +95,8 @@ local function load_options() whichwrap = "h,l,<,>,[,],~", wildignore = ".git,.hg,.svn,*.pyc,*.o,*.out,*.jpg,*.jpeg,*.png,*.gif,*.zip,**/tmp/**,*.DS_Store,**/node_modules/**,**/bower_modules/**", wildignorecase = true, + -- Do NOT adjust the following option (winblend) if you're using transparent background + winblend = 0, winminwidth = 10, winwidth = 30, wrap = false, diff --git a/lua/core/pack.lua b/lua/core/pack.lua index 2cdea4953..7c1d537a3 100644 --- a/lua/core/pack.lua +++ b/lua/core/pack.lua @@ -73,7 +73,7 @@ function Lazy:load_lazy() install = { -- install missing plugins on startup. This doesn't increase startup time. missing = true, - colorscheme = { "catppuccin" }, + colorscheme = { settings.colorscheme }, }, ui = { -- a number <1 is a percentage., >1 is a fixed size diff --git a/lua/core/settings.lua b/lua/core/settings.lua index 5bb1c9b69..9a88cd7c6 100644 --- a/lua/core/settings.lua +++ b/lua/core/settings.lua @@ -1,5 +1,4 @@ local settings = {} -local home = require("core.global").home -- Set it to false if you want to use https to update plugins and treesitter parsers. ---@type boolean @@ -26,9 +25,11 @@ settings["diagnostics_virtual_text"] = true settings["diagnostics_level"] = "Hint" -- Set the format disabled directories here, files under these dirs won't be formatted on save. +--- NOTE: Directories may contain regular expressions (grammar: vim). |regexp| +--- NOTE: Directories are automatically normalized. |vim.fs.normalize()| ---@type string[] settings["format_disabled_dirs"] = { - home .. "/format_disabled_dir_under_home", + "~/format_disabled_dir", } -- Set it to false if you don't use nvim to open big files. @@ -98,7 +99,6 @@ settings["lsp_deps"] = { settings["null_ls_deps"] = { "clang_format", "prettier", - "rustfmt", "shfmt", "stylua", "vint", diff --git a/lua/keymap/completion.lua b/lua/keymap/completion.lua index a9ce764ea..1b17e58b4 100644 --- a/lua/keymap/completion.lua +++ b/lua/keymap/completion.lua @@ -18,7 +18,9 @@ function mapping.lsp(buf) ["n|go"] = map_cr("Lspsaga outline"):with_buffer(buf):with_desc("lsp: Toggle outline"), ["n|g["] = map_cr("Lspsaga diagnostic_jump_prev"):with_buffer(buf):with_desc("lsp: Prev diagnostic"), ["n|g]"] = map_cr("Lspsaga diagnostic_jump_next"):with_buffer(buf):with_desc("lsp: Next diagnostic"), - ["n|ld"] = map_cr("Lspsaga show_line_diagnostics"):with_buffer(buf):with_desc("lsp: Line diagnostic"), + ["n|ld"] = map_cr("Lspsaga show_line_diagnostics ++unfocus") + :with_buffer(buf) + :with_desc("lsp: Line diagnostic"), ["n|gs"] = map_callback(function() vim.lsp.buf.signature_help() end):with_desc("lsp: Signature help"), @@ -28,7 +30,7 @@ function mapping.lsp(buf) ["nv|ga"] = map_cr("Lspsaga code_action"):with_buffer(buf):with_desc("lsp: Code action for cursor"), ["n|gd"] = map_cr("Lspsaga peek_definition"):with_buffer(buf):with_desc("lsp: Preview definition"), ["n|gD"] = map_cr("Lspsaga goto_definition"):with_buffer(buf):with_desc("lsp: Goto definition"), - ["n|gh"] = map_cr("Lspsaga lsp_finder"):with_buffer(buf):with_desc("lsp: Show reference"), + ["n|gh"] = map_cr("Lspsaga finder"):with_buffer(buf):with_desc("lsp: Show reference"), ["n|ci"] = map_cr("Lspsaga incoming_calls"):with_buffer(buf):with_desc("lsp: Show incoming calls"), ["n|co"] = map_cr("Lspsaga outgoing_calls"):with_buffer(buf):with_desc("lsp: Show outgoing calls"), } diff --git a/lua/keymap/editor.lua b/lua/keymap/editor.lua index 0d067aa54..58e0ac8d6 100644 --- a/lua/keymap/editor.lua +++ b/lua/keymap/editor.lua @@ -14,9 +14,9 @@ local plug_map = { return et("(accelerated_jk_gk)") end):with_expr(), - -- Plugin: auto_session + -- Plugin persisted.nvim ["n|ss"] = map_cu("SessionSave"):with_noremap():with_silent():with_desc("session: Save"), - ["n|sr"] = map_cu("SessionRestore"):with_noremap():with_silent():with_desc("session: Restore"), + ["n|sl"] = map_cu("SessionLoad"):with_noremap():with_silent():with_desc("session: Load current"), ["n|sd"] = map_cu("SessionDelete"):with_noremap():with_silent():with_desc("session: Delete"), -- Plugin: nvim-bufdel diff --git a/lua/keymap/tool.lua b/lua/keymap/tool.lua index 0fe4f0165..6ff95a782 100644 --- a/lua/keymap/tool.lua +++ b/lua/keymap/tool.lua @@ -134,6 +134,7 @@ local plug_map = { :with_desc("edit: Change current direrctory by zoxide"), ["n|fb"] = map_cu("Telescope buffers"):with_noremap():with_silent():with_desc("find: Buffer opened"), ["n|fs"] = map_cu("Telescope grep_string"):with_noremap():with_silent():with_desc("find: Current word"), + ["n|fd"] = map_cu("Telescope persisted"):with_noremap():with_silent():with_desc("find: Session"), -- Plugin: dap ["n|"] = map_callback(function() diff --git a/lua/modules/configs/completion/formatting.lua b/lua/modules/configs/completion/formatting.lua index d2af9c7e4..3e0b9a507 100644 --- a/lua/modules/configs/completion/formatting.lua +++ b/lua/modules/configs/completion/formatting.lua @@ -1,9 +1,9 @@ local M = {} local settings = require("core.settings") -local format_notify = settings.format_notify local disabled_workspaces = settings.format_disabled_dirs local format_on_save = settings.format_on_save +local format_notify = settings.format_notify local server_formatting_block_list = settings.server_formatting_block_list vim.api.nvim_create_user_command("FormatToggle", function() @@ -35,7 +35,7 @@ end, { nargs = 1, complete = "filetype" }) function M.enable_format_on_save(is_configured) local opts = { pattern = "*", timeout = 1000 } - vim.api.nvim_create_augroup("format_on_save", {}) + vim.api.nvim_create_augroup("format_on_save", { clear = true }) vim.api.nvim_create_autocmd("BufWritePre", { group = "format_on_save", pattern = opts.pattern, @@ -100,11 +100,14 @@ function M.format_filter(clients) end function M.format(opts) - local cwd = vim.fn.getcwd() + local filedir = vim.fn.expand("%:p:h") for i = 1, #disabled_workspaces do - if cwd.find(cwd, disabled_workspaces[i]) ~= nil then + if vim.regex(vim.fs.normalize(disabled_workspaces[i])):match_str(filedir) ~= nil then vim.notify( - string.format("[LSP] Formatting support for all files under [%s] is disabled.", disabled_workspaces[i]), + string.format( + "[LSP] Formatting for all files under [%s] has been disabled.", + vim.fs.normalize(disabled_workspaces[i]) + ), vim.log.levels.WARN, { title = "LSP Formatter Warning" } ) @@ -144,7 +147,7 @@ function M.format(opts) if block_list[vim.bo.filetype] == true then vim.notify( string.format( - "[LSP][%s] Formatter for [%s] has been disabled. This file is not being processed.", + "[LSP][%s] Formatting for [%s] has been disabled. This file is not being processed.", client.name, vim.bo.filetype ), diff --git a/lua/modules/configs/completion/lsp-signature.lua b/lua/modules/configs/completion/lsp-signature.lua new file mode 100644 index 000000000..282001322 --- /dev/null +++ b/lua/modules/configs/completion/lsp-signature.lua @@ -0,0 +1,15 @@ +return function() + require("lsp_signature").setup({ + bind = true, + -- TODO: Remove the following line when nvim-cmp#1613 gets resolved + check_completion_visible = false, + floating_window = true, + floating_window_above_cur_line = true, + hi_parameter = "Search", + hint_enable = true, + transparency = nil, -- disabled by default, allow floating win transparent value 1~100 + wrap = true, + zindex = 45, -- avoid overlap with nvim.cmp + handler_opts = { border = "single" }, + }) +end diff --git a/lua/modules/configs/completion/lsp.lua b/lua/modules/configs/completion/lsp.lua index 4870f1ed7..6bd0436c2 100644 --- a/lua/modules/configs/completion/lsp.lua +++ b/lua/modules/configs/completion/lsp.lua @@ -97,9 +97,6 @@ return function() ensure_installed = require("core.settings").lsp_deps, }) - local capabilities = vim.lsp.protocol.make_client_capabilities() - capabilities = require("cmp_nvim_lsp").default_capabilities(capabilities) - vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.with(vim.lsp.diagnostic.on_publish_diagnostics, { signs = true, underline = true, @@ -111,22 +108,8 @@ return function() }) local opts = { - on_attach = function() - require("lsp_signature").on_attach({ - bind = true, - use_lspsaga = false, - floating_window = true, - fix_pos = true, - hint_enable = true, - hi_parameter = "Search", - handler_opts = { - border = "single", - }, - }) - end, - capabilities = capabilities, + capabilities = require("cmp_nvim_lsp").default_capabilities(vim.lsp.protocol.make_client_capabilities()), } - ---A handler to setup all servers defined under `completion/servers/*.lua` ---@param lsp_name string local function mason_lsp_handler(lsp_name) @@ -163,4 +146,6 @@ return function() local final_opts = vim.tbl_deep_extend("keep", _opts, opts) nvim_lsp.dartls.setup(final_opts) end + + vim.api.nvim_command([[LspStart]]) -- Start LSPs end diff --git a/lua/modules/configs/completion/lspsaga.lua b/lua/modules/configs/completion/lspsaga.lua index feb371ef6..47e2fb9ca 100644 --- a/lua/modules/configs/completion/lspsaga.lua +++ b/lua/modules/configs/completion/lspsaga.lua @@ -26,35 +26,42 @@ return function() set_sidebar_icons() require("lspsaga").setup({ - preview = { - lines_above = 1, - lines_below = 17, - }, scroll_preview = { scroll_down = "", scroll_up = "", }, request_timeout = 3000, finder = { + silent = true, + default = "def+ref+imp", + layout = "float", + filter = {}, keys = { + shuttle = "[]", + toggle_or_open = "", jump_to = "e", - expand_or_jump = "", - vsplit = "s", - split = "i", + vsplit = "v", + split = "s", tabe = "t", - quit = { "q", "" }, - close_in_preview = "", + tabnew = "n", + quit = "q", + close = "", }, }, definition = { - edit = "o", - vsplit = "v", - split = "s", - tabe = "t", - quit = "q", + keys = { + edit = "o", + vsplit = "v", + split = "s", + tabe = "t", + close = "q", + quit = "q", + }, }, code_action = { num_shortcut = true, + show_server_name = true, + extend_gitsigns = false, keys = { quit = "q", exec = "", @@ -63,71 +70,93 @@ return function() lightbulb = { enable = false, sign = true, - enable_in_insert = true, sign_priority = 20, virtual_text = false, }, diagnostic = { + max_width = 0.5, + max_height = 0.6, text_hl_follow = true, - on_insert = true, - on_insert_follow = false, show_code_action = true, - show_source = true, border_follow = true, + diagnostic_only_current = false, extend_relatedInformation = false, jump_num_shortcut = true, + show_layout = "float", keys = { exec_action = "r", quit = "q", - expand_or_jump = "", - quit_in_show = { "q", "" }, + toggle_or_jump = "", + quit_in_show = { "q", "" }, }, }, rename = { - quit = "", - mark = "x", - confirm = "", - exec = "", - in_select = true, + in_select = false, + auto_save = false, + keys = { + quit = "", + select = "x", + exec = "", + }, }, hover = { + max_width = 0.3, + max_height = 0.7, open_link = "gl", open_browser = "silent !" .. require("core.settings").external_browser, }, outline = { win_position = "right", - win_with = "_sagaoutline", win_width = 30, auto_preview = false, - auto_refresh = true, auto_close = true, close_after_jump = true, + detail = false, + layout = "normal", keys = { - expand_or_jump = "", + toggle_or_jump = "", + jump = "o", quit = "q", }, }, symbol_in_winbar = { - enable = false, + enable = true, separator = " " .. icons.ui.Separator, - hide_keyword = true, + hide_keyword = false, show_file = false, color_mode = true, }, + implement = { + enable = true, + sign = true, + virtual_text = false, + }, + callhierarchy = { + layout = "float", + keys = { + edit = "e", + vsplit = "v", + split = "s", + tabe = "t", + quit = "q", + shuttle = "[]", + toggle_or_req = "u", + close = "", + }, + }, beacon = { enable = true, frequency = 12, }, ui = { title = false, + devicon = true, border = "single", -- Can be single, double, rounded, solid, shadow. - winblend = 0, actionfix = icons.ui.Spell, expand = icons.ui.ArrowClosed, collapse = icons.ui.ArrowOpen, code_action = icons.ui.CodeAction, - incoming = icons.ui.Incoming, - outgoing = icons.ui.Outgoing, + imp_sign = icons.kind.Implementation, kind = { -- Kind Class = { icons.kind.Class, "LspKindClass" }, diff --git a/lua/modules/configs/completion/null-ls.lua b/lua/modules/configs/completion/null-ls.lua index fa10088fe..68645f393 100644 --- a/lua/modules/configs/completion/null-ls.lua +++ b/lua/modules/configs/completion/null-ls.lua @@ -25,6 +25,7 @@ return function() "markdown", }, }), + btns.formatting.rustfmt, } null_ls.setup({ border = "rounded", diff --git a/lua/modules/configs/editor/auto-session.lua b/lua/modules/configs/editor/auto-session.lua deleted file mode 100644 index 75ee2b21f..000000000 --- a/lua/modules/configs/editor/auto-session.lua +++ /dev/null @@ -1,24 +0,0 @@ -return function() - require("auto-session").setup({ - log_level = "info", - auto_session_enable_last_session = true, - auto_session_root_dir = vim.fn.stdpath("data") .. "/sessions/", - auto_session_enabled = true, - auto_save_enabled = true, - auto_restore_enabled = true, - auto_session_suppress_dirs = nil, - session_lens = { - -- If `load_on_setup` is set to false, please use `SessionLensToggle` to manually load this add-on. - load_on_setup = false, - theme_conf = { border = true }, - previewer = false, - }, - }) - - vim.api.nvim_create_user_command("SessionLensToggle", function() - if not package.loaded["auto-session.session-lens"] then - require("auto-session").setup_session_lens() - end - require("auto-session.session-lens").search_session() - end, { nargs = 0 }) -end diff --git a/lua/modules/configs/editor/better-escape.lua b/lua/modules/configs/editor/better-escape.lua index fb7eb8166..7a80e9276 100644 --- a/lua/modules/configs/editor/better-escape.lua +++ b/lua/modules/configs/editor/better-escape.lua @@ -6,7 +6,7 @@ return function() keys = "", -- keys used for escaping, if it is a function will use the result everytime -- example(recommended) -- keys = function() - -- return vim.api.nvim_win_get_cursor(0)[2] > 1 and 'l' or '' + -- return vim.api.nvim_win_get_cursor(0)[2] > 1 and 'l' or '' -- end, }) end diff --git a/lua/modules/configs/editor/persisted.lua b/lua/modules/configs/editor/persisted.lua new file mode 100644 index 000000000..8b1c9538e --- /dev/null +++ b/lua/modules/configs/editor/persisted.lua @@ -0,0 +1,23 @@ +return function() + require("persisted").setup({ + save_dir = vim.fn.expand(vim.fn.stdpath("data") .. "/sessions/"), -- directory where session files are saved + silent = false, -- silent nvim message when sourcing session file + use_git_branch = true, -- create session files based on the branch of the git enabled repository + autosave = true, -- automatically save session files when exiting Neovim + should_autosave = function() + if vim.bo.filetype == "alpha" then + return false + end + return true + end, -- function to determine if a session should be autosaved + -- Set `lazy = false` in `plugins/editor.lua` to enable this + autoload = false, -- automatically load the session for the cwd on Neovim startup + on_autoload_no_session = nil, -- function to run when `autoload = true` but there is no session to load + follow_cwd = true, -- change session file name to match current working directory if it changes + allowed_dirs = nil, -- table of dirs that the plugin will auto-save and auto-load from + ignored_dirs = nil, -- table of dirs that are ignored when auto-saving and auto-loading + telescope = { -- options for the telescope extension + reset_prompt_after_deletion = true, -- whether to reset prompt after session deleted + }, + }) +end diff --git a/lua/modules/configs/editor/rainbow_delims.lua b/lua/modules/configs/editor/rainbow_delims.lua new file mode 100644 index 000000000..037a81397 --- /dev/null +++ b/lua/modules/configs/editor/rainbow_delims.lua @@ -0,0 +1,39 @@ +return function() + local function init_strategy(check_lines) + return function() + local errors = 200 + vim.treesitter.get_parser():for_each_tree(function(lt) + if lt:root():has_error() and errors >= 0 then + errors = errors - 1 + end + end) + if errors < 0 then + return nil + end + return (check_lines and vim.fn.line("$") > 450) and require("rainbow-delimiters").strategy["global"] + or require("rainbow-delimiters").strategy["local"] + end + end + + vim.g.rainbow_delimiters = { + strategy = { + [""] = init_strategy(false), + c = init_strategy(true), + cpp = init_strategy(true), + }, + query = { + [""] = "rainbow-delimiters", + latex = "rainbow-blocks", + javascript = "rainbow-delimiters-ract", + }, + highlight = { + "RainbowDelimiterRed", + "RainbowDelimiterOrange", + "RainbowDelimiterYellow", + "RainbowDelimiterGreen", + "RainbowDelimiterBlue", + "RainbowDelimiterCyan", + "RainbowDelimiterViolet", + }, + } +end diff --git a/lua/modules/configs/editor/ts-context.lua b/lua/modules/configs/editor/ts-context.lua new file mode 100644 index 000000000..4f31e5a70 --- /dev/null +++ b/lua/modules/configs/editor/ts-context.lua @@ -0,0 +1,12 @@ +return function() + require("treesitter-context").setup({ + enable = true, + max_lines = 0, -- How many lines the window should span. Values <= 0 mean no limit. + min_window_height = 0, -- Minimum editor window height to enable context. Values <= 0 mean no limit. + line_numbers = true, + multiline_threshold = 20, -- Maximum number of lines to collapse for a single context line + trim_scope = "outer", -- Which context lines to discard if `max_lines` is exceeded. Choices: 'inner', 'outer' + mode = "cursor", -- Line used to calculate context. Choices: 'cursor', 'topline' + zindex = 30, + }) +end diff --git a/lua/modules/configs/lang/rust-tools.lua b/lua/modules/configs/lang/rust-tools.lua index 239f796f0..0e7b0f6c5 100644 --- a/lua/modules/configs/lang/rust-tools.lua +++ b/lua/modules/configs/lang/rust-tools.lua @@ -4,23 +4,7 @@ return function() -- how to execute terminal commands -- options right now: termopen / quickfix - executor = require("rust-tools/executors").termopen, - - -- callback to execute once rust-analyzer is done initializing the workspace - -- The callback receives one parameter indicating the `health` of the server: "ok" | "warning" | "error" - on_initialized = function() - require("lsp_signature").on_attach({ - bind = true, - use_lspsaga = false, - floating_window = true, - fix_pos = true, - hint_enable = true, - hi_parameter = "Search", - handler_opts = { - border = "rounded", - }, - }) - end, + executor = require("rust-tools.executors").termopen, -- automatically call RustReloadWorkspace when writing to a Cargo.toml file. reload_workspace_from_cargo_toml = true, diff --git a/lua/modules/configs/tool/telescope.lua b/lua/modules/configs/tool/telescope.lua index 1957e1e71..cdd38cea6 100644 --- a/lua/modules/configs/tool/telescope.lua +++ b/lua/modules/configs/tool/telescope.lua @@ -89,4 +89,5 @@ return function() require("telescope").load_extension("projects") require("telescope").load_extension("undo") require("telescope").load_extension("zoxide") + require("telescope").load_extension("persisted") end diff --git a/lua/modules/configs/tool/trouble.lua b/lua/modules/configs/tool/trouble.lua index 7c4d59785..fe9fb60c0 100644 --- a/lua/modules/configs/tool/trouble.lua +++ b/lua/modules/configs/tool/trouble.lua @@ -19,7 +19,7 @@ return function() -- map to {} to remove a mapping, for example: -- close = {}, close = "q", -- close the list - cancel = "", -- cancel the preview and get back to your last window / buffer / cursor + cancel = "", -- cancel the preview and get back to your last window / buffer / cursor refresh = "r", -- manually refresh jump = { "", "" }, -- jump to the diagnostic or open / close folds open_split = { "" }, -- open buffer in new split diff --git a/lua/modules/configs/ui/bufferline.lua b/lua/modules/configs/ui/bufferline.lua index 68f76f426..41dc9b0ff 100644 --- a/lua/modules/configs/ui/bufferline.lua +++ b/lua/modules/configs/ui/bufferline.lua @@ -8,7 +8,7 @@ return function() buffer_close_icon = icons.ui.Close, left_trunc_marker = icons.ui.Left, right_trunc_marker = icons.ui.Right, - max_name_length = 14, + max_name_length = 20, max_prefix_length = 13, tab_size = 20, color_icons = true, @@ -29,13 +29,13 @@ return function() filetype = "NvimTree", text = "File Explorer", text_align = "center", - padding = 1, + padding = 0, }, { filetype = "lspsagaoutline", text = "Lspsaga Outline", text_align = "center", - padding = 1, + padding = 0, }, }, }, @@ -51,7 +51,7 @@ return function() highlights = require("catppuccin.groups.integrations.bufferline").get({ styles = { "italic", "bold" }, custom = { - mocha = { + all = { -- Hint hint = { fg = cp.rosewater }, hint_visible = { fg = cp.rosewater }, diff --git a/lua/modules/configs/ui/catppuccin.lua b/lua/modules/configs/ui/catppuccin.lua index a95d1c78d..940e16f78 100644 --- a/lua/modules/configs/ui/catppuccin.lua +++ b/lua/modules/configs/ui/catppuccin.lua @@ -79,12 +79,13 @@ return function() nvimtree = true, overseer = false, pounce = false, + rainbow_delimiters = true, semantic_tokens = true, symbols_outline = false, telekasten = false, - telescope = true, + telescope = { enabled = true, style = "nvchad" }, treesitter_context = true, - ts_rainbow = true, + ts_rainbow = false, vim_sneak = false, vimwiki = false, which_key = true, @@ -140,45 +141,18 @@ return function() TroubleNormal = { bg = transparent_background and cp.none or cp.base }, -- For telescope.nvim - TelescopeBorder = { - fg = transparent_background and cp.blue or cp.mantle, - bg = transparent_background and cp.none or cp.mantle, - }, - TelescopePromptBorder = { - fg = transparent_background and cp.blue or cp.surface0, - bg = transparent_background and cp.none or cp.surface0, - }, - TelescopePromptNormal = { - fg = cp.text, - bg = transparent_background and cp.none or cp.surface0, - }, - TelescopePromptPrefix = { - fg = cp.flamingo, - bg = transparent_background and cp.none or cp.surface0, - }, - TelescopeNormal = { - bg = transparent_background and cp.none or cp.mantle, - }, - TelescopePreviewTitle = { - fg = transparent_background and cp.green or cp.base, - bg = transparent_background and cp.none or cp.green, - }, - TelescopePromptTitle = { - fg = transparent_background and cp.red or cp.base, - bg = transparent_background and cp.none or cp.red, - }, - TelescopeResultsTitle = { - fg = cp.mantle, - bg = transparent_background and cp.none or cp.mantle, - }, - TelescopeSelection = { - fg = cp.green, - bg = transparent_background and cp.none or cp.surface0, - }, + TelescopeMatching = { fg = cp.lavender }, TelescopeResultsDiffAdd = { fg = cp.green }, TelescopeResultsDiffChange = { fg = cp.yellow }, TelescopeResultsDiffDelete = { fg = cp.red }, + -- For nvim-treehopper + TSNodeKey = { + fg = cp.peach, + bg = transparent_background and cp.none or cp.base, + style = { "bold", "underline" }, + }, + -- For treesitter ["@keyword.return"] = { fg = cp.pink, style = clear }, } diff --git a/lua/modules/configs/ui/lualine.lua b/lua/modules/configs/ui/lualine.lua index 0d6a3096c..ea09ef778 100644 --- a/lua/modules/configs/ui/lualine.lua +++ b/lua/modules/configs/ui/lualine.lua @@ -2,61 +2,50 @@ return function() local colors = require("modules.utils").get_palette() local icons = { diagnostics = require("modules.utils.icons").get("diagnostics", true), + git = require("modules.utils.icons").get("git", true), + git_nosep = require("modules.utils.icons").get("git"), misc = require("modules.utils.icons").get("misc", true), ui = require("modules.utils.icons").get("ui", true), } - local function escape_status() - local ok, m = pcall(require, "better_escape") - return ok and m.waiting and icons.misc.EscapeST or "" - end + local function custom_theme() + vim.api.nvim_create_autocmd("ColorScheme", { + group = vim.api.nvim_create_augroup("LualineColorScheme", { clear = true }), + pattern = "*", + callback = function() + require("lualine").setup({ options = { theme = custom_theme() } }) + end, + }) - local _cache = { context = "", bufnr = -1 } - local function lspsaga_symbols() - local exclude = { - ["terminal"] = true, - ["toggleterm"] = true, - ["prompt"] = true, - ["NvimTree"] = true, - ["help"] = true, + colors = require("modules.utils").get_palette() + local universal_bg = require("core.settings").transparent_background and "NONE" or colors.mantle + return { + normal = { + a = { fg = colors.lavender, bg = colors.surface0, gui = "bold" }, + b = { fg = colors.text, bg = universal_bg }, + c = { fg = colors.text, bg = universal_bg }, + }, + command = { + a = { fg = colors.peach, bg = colors.surface0, gui = "bold" }, + }, + insert = { + a = { fg = colors.green, bg = colors.surface0, gui = "bold" }, + }, + visual = { + a = { fg = colors.flamingo, bg = colors.surface0, gui = "bold" }, + }, + terminal = { + a = { fg = colors.teal, bg = colors.surface0, gui = "bold" }, + }, + replace = { + a = { fg = colors.red, bg = colors.surface0, gui = "bold" }, + }, + inactive = { + a = { fg = colors.subtext0, bg = universal_bg, gui = "bold" }, + b = { fg = colors.subtext0, bg = universal_bg }, + c = { fg = colors.subtext0, bg = universal_bg }, + }, } - if vim.api.nvim_win_get_config(0).zindex or exclude[vim.bo.filetype] then - return "" -- Excluded filetypes - else - local currbuf = vim.api.nvim_get_current_buf() - local ok, lspsaga = pcall(require, "lspsaga.symbolwinbar") - if ok and lspsaga:get_winbar() ~= nil then - _cache.context = lspsaga:get_winbar() - _cache.bufnr = currbuf - elseif _cache.bufnr ~= currbuf then - _cache.context = "" -- Reset [invalid] cache (usually from another buffer) - end - - return _cache.context - end - end - - local function diff_source() - local gitsigns = vim.b.gitsigns_status_dict - if gitsigns then - return { - added = gitsigns.added, - modified = gitsigns.changed, - removed = gitsigns.removed, - } - end - end - - local function get_cwd() - local cwd = vim.fn.getcwd() - local is_windows = require("core.global").is_windows - if not is_windows then - local home = require("core.global").home - if cwd:find(home, 1, true) == 1 then - cwd = "~" .. cwd:sub(#home + 1) - end - end - return icons.ui.RootFolderOpened .. cwd end local mini_sections = { @@ -76,48 +65,245 @@ return function() filetypes = { "DiffviewFiles" }, } - local function python_venv() - local function env_cleanup(venv) - if string.find(venv, "/") then - local final_venv = venv - for w in venv:gmatch("([^/]+)") do - final_venv = w - end - venv = final_venv - end - return venv - end + local conditionals = { + has_enough_room = function() + return vim.o.columns > 100 + end, + has_comp_before = function() + return vim.bo.filetype ~= "" + end, + has_git = function() + local gitdir = vim.fs.find(".git", { + limit = 1, + upward = true, + type = "directory", + path = vim.fn.expand("%:p:h"), + }) + return #gitdir > 0 + end, + } - if vim.bo.filetype == "python" then - local venv = os.getenv("CONDA_DEFAULT_ENV") - if venv then - return string.format("%s", env_cleanup(venv)) + ---@class lualine_hlgrp + ---@field fg string + ---@field bg string + ---@field gui string? + local utils = { + force_centering = function() + return "%=" + end, + abbreviate_path = function(path) + local home = require("core.global").home + if path:find(home, 1, true) == 1 then + path = "~" .. path:sub(#home + 1) end - venv = os.getenv("VIRTUAL_ENV") - if venv then - return string.format("%s", env_cleanup(venv)) + return path + end, + ---Generate `color` for any component + ---@param fg string @Foreground hl group + ---@param gen_bg boolean @Generate guibg from hl group |StatusLine|? + ---@param special_nobg boolean @Disable guibg for transparent backgrounds? + ---@param bg string? @Background hl group + ---@param gui string? @GUI highlight arguments + ---@return fun():lualine_hlgrp + gen_hl = function(fg, gen_bg, special_nobg, bg, gui) + return function() + local guifg = colors[fg] + local guibg = gen_bg and require("modules.utils").hl_to_rgb("StatusLine", true, colors.mantle) + or colors[bg] + local nobg = special_nobg and require("core.settings").transparent_background + return { + fg = guifg and guifg or colors.none, + bg = (guibg and not nobg) and guibg or colors.none, + gui = gui and gui or nil, + } end + end, + } + + local function diff_source() + local gitsigns = vim.b.gitsigns_status_dict + if gitsigns then + return { + added = gitsigns.added, + modified = gitsigns.changed, + removed = gitsigns.removed, + } end - return "" end + local components = { + separator = { -- use as section separators + function() + return "│" + end, + padding = 0, + color = utils.gen_hl("surface1", true, true), + }, + + file_status = { + function() + local function is_new_file() + local filename = vim.fn.expand("%") + return filename ~= "" and vim.bo.buftype == "" and vim.fn.filereadable(filename) == 0 + end + + local symbols = {} + if vim.bo.modified then + table.insert(symbols, "[+]") + end + if vim.bo.modifiable == false then + table.insert(symbols, "[-]") + end + if vim.bo.readonly == true then + table.insert(symbols, "[RO]") + end + if is_new_file() then + table.insert(symbols, "[New]") + end + return #symbols > 0 and table.concat(symbols, "") or "" + end, + padding = { left = -1, right = 1 }, + cond = conditionals.has_comp_before, + }, + + lsp = { + function() + local buf_ft = vim.api.nvim_get_option_value("filetype", { scope = "local" }) + local clients = vim.lsp.get_active_clients() + local lsp_lists = {} + local available_servers = {} + if next(clients) == nil then + return icons.misc.NoActiveLsp -- No server available + end + for _, client in ipairs(clients) do + local filetypes = client.config.filetypes + local client_name = client.name + if filetypes and vim.fn.index(filetypes, buf_ft) ~= -1 then + -- Avoid adding servers that already exists. + if not lsp_lists[client_name] then + lsp_lists[client_name] = true + table.insert(available_servers, client_name) + end + end + end + return next(available_servers) == nil and icons.misc.NoActiveLsp + or string.format("%s[%s]", icons.misc.LspAvailable, table.concat(available_servers, ", ")) + end, + color = utils.gen_hl("blue", true, true, nil, "bold"), + cond = conditionals.has_enough_room, + }, + + python_venv = { + function() + local function env_cleanup(venv) + if string.find(venv, "/") then + local final_venv = venv + for w in venv:gmatch("([^/]+)") do + final_venv = w + end + venv = final_venv + end + return venv + end + + if vim.api.nvim_get_option_value("filetype", { scope = "local" }) == "python" then + local venv = os.getenv("CONDA_DEFAULT_ENV") + if venv then + return string.format("%s", env_cleanup(venv)) + end + venv = os.getenv("VIRTUAL_ENV") + if venv then + return string.format("%s", env_cleanup(venv)) + end + end + return "" + end, + color = utils.gen_hl("green", true, true), + cond = conditionals.has_enough_room, + }, + + tabwidth = { + function() + return icons.ui.Tab .. vim.api.nvim_get_option_value("shiftwidth", { scope = "local" }) + end, + padding = 1, + }, + + cwd = { + function() + return icons.ui.FolderWithHeart .. utils.abbreviate_path(vim.fs.normalize(vim.fn.getcwd())) + end, + color = utils.gen_hl("subtext0", true, true, nil, "bold"), + }, + + file_location = { + function() + local cursorline = vim.fn.line(".") + local cursorcol = vim.fn.virtcol(".") + local filelines = vim.fn.line("$") + local position + if cursorline == 1 then + position = "Top" + elseif cursorline == filelines then + position = "Bot" + else + position = string.format("%2d%%%%", math.floor(cursorline / filelines * 100)) + end + return string.format("%s · %3d:%-2d", position, cursorline, cursorcol) + end, + }, + } + require("lualine").setup({ options = { icons_enabled = true, - theme = "catppuccin", - disabled_filetypes = {}, - component_separators = "|", - section_separators = { left = "", right = "" }, + theme = custom_theme(), + disabled_filetypes = { statusline = { "alpha" } }, + component_separators = "", + section_separators = { left = "", right = "" }, }, sections = { - lualine_a = { { "mode" } }, - lualine_b = { { "branch" }, { "diff", source = diff_source } }, - lualine_c = { lspsaga_symbols }, - lualine_x = { - { escape_status }, + lualine_a = { "mode" }, + lualine_b = { + { + "filetype", + colored = true, + icon_only = false, + icon = { align = "left" }, + }, + components.file_status, + vim.tbl_extend("force", components.separator, { + cond = function() + return conditionals.has_git() and conditionals.has_comp_before() + end, + }), + }, + lualine_c = { + { + "branch", + icon = icons.git_nosep.Branch, + color = utils.gen_hl("subtext0", true, true, nil, "bold"), + cond = conditionals.has_git, + }, + { + "diff", + symbols = { + added = icons.git.Add, + modified = icons.git.Mod_alt, + removed = icons.git.Remove, + }, + source = diff_source, + colored = false, + color = utils.gen_hl("subtext0", true, true), + cond = conditionals.has_git, + padding = { right = 1 }, + }, + + { utils.force_centering }, { "diagnostics", sources = { "nvim_diagnostic" }, + sections = { "error", "warn", "info", "hint" }, symbols = { error = icons.diagnostics.Error, warn = icons.diagnostics.Warning, @@ -125,23 +311,32 @@ return function() hint = icons.diagnostics.Hint_alt, }, }, - { get_cwd }, + components.lsp, }, - lualine_y = { - { "filetype", colored = true, icon_only = true }, - { python_venv }, - { "encoding" }, + lualine_x = { + { + "encoding", + fmt = string.upper, + padding = { left = 1 }, + cond = conditionals.has_enough_room, + }, { "fileformat", - icons_enabled = true, symbols = { unix = "LF", dos = "CRLF", - mac = "CR", + mac = "CR", -- Legacy macOS }, + padding = { left = 1 }, }, + components.tabwidth, + }, + lualine_y = { + components.separator, + components.python_venv, + components.cwd, }, - lualine_z = { "progress", "location" }, + lualine_z = { components.file_location }, }, inactive_sections = { lualine_a = {}, @@ -162,10 +357,4 @@ return function() diffview, }, }) - - -- Properly set background color for lspsaga - local winbar_bg = require("modules.utils").hl_to_rgb("StatusLine", true, colors.mantle) - for _, hlGroup in pairs(require("lspsaga.lspkind").get_kind_group()) do - require("modules.utils").extend_hl(hlGroup, { bg = winbar_bg }) - end end diff --git a/lua/modules/configs/ui/notify.lua b/lua/modules/configs/ui/notify.lua index 7257fee75..21f6168e9 100644 --- a/lua/modules/configs/ui/notify.lua +++ b/lua/modules/configs/ui/notify.lua @@ -1,5 +1,6 @@ return function() local notify = require("notify") + local colors = require("modules.utils").get_palette() local icons = { diagnostics = require("modules.utils.icons").get("diagnostics"), ui = require("modules.utils.icons").get("ui"), @@ -7,23 +8,26 @@ return function() notify.setup({ ---@usage Animation style one of { "fade", "slide", "fade_in_slide_out", "static" } - stages = "slide", + stages = "fade", ---@usage Function called when a new window is opened, use for changing win settings/config - on_open = nil, + on_open = function(win) + vim.api.nvim_set_option_value("winblend", 0, { scope = "local", win = win }) + vim.api.nvim_win_set_config(win, { zindex = 90 }) + end, ---@usage Function called when a window is closed on_close = nil, ---@usage timeout for notifications in ms, default 5000 timeout = 2000, -- @usage User render fps value - fps = 30, + fps = 20, -- Render function for notifications. See notify-render() render = "default", ---@usage highlight behind the window for stages that change opacity - background_colour = "Normal", + background_colour = colors.base, ---@usage minimum width for notification windows minimum_width = 50, ---@usage notifications with level lower than this would be ignored. [ERROR > WARN > INFO > DEBUG > TRACE] - level = "TRACE", + level = "INFO", ---@usage Icons for the different levels icons = { ERROR = icons.diagnostics.Error, diff --git a/lua/modules/configs/ui/scrollview.lua b/lua/modules/configs/ui/scrollview.lua index b99232731..69a81fd83 100644 --- a/lua/modules/configs/ui/scrollview.lua +++ b/lua/modules/configs/ui/scrollview.lua @@ -4,7 +4,7 @@ return function() require("scrollview").setup({ scrollview_mode = "virtual", excluded_filetypes = { "NvimTree", "terminal", "nofile" }, - winblend = 55, + winblend = 0, signs_on_startup = { "diagnostics", "folds", "marks", "search", "spell" }, diagnostics_error_symbol = icons.diagnostics.Error, diagnostics_warn_symbol = icons.diagnostics.Warning, diff --git a/lua/modules/configs/ui/specs.lua b/lua/modules/configs/ui/specs.lua index 5626c2213..e32382b1b 100644 --- a/lua/modules/configs/ui/specs.lua +++ b/lua/modules/configs/ui/specs.lua @@ -7,7 +7,7 @@ return function() inc_ms = 10, -- time increments used for fade/resize effects blend = 10, -- starting blend, between 0-100 (fully transparent), see :h winblend width = 10, - winhl = "PMenu", + winhl = "PmenuSbar", fader = require("specs").pulse_fader, resizer = require("specs").shrink_resizer, }, diff --git a/lua/modules/plugins/completion.lua b/lua/modules/plugins/completion.lua index de0db9105..75eeef4d3 100644 --- a/lua/modules/plugins/completion.lua +++ b/lua/modules/plugins/completion.lua @@ -2,15 +2,14 @@ local completion = {} completion["neovim/nvim-lspconfig"] = { lazy = true, - event = { "BufReadPost", "BufAdd", "BufNewFile" }, + event = { "CursorHold", "CursorHoldI" }, config = require("completion.lsp"), dependencies = { - { "ray-x/lsp_signature.nvim" }, { "williamboman/mason.nvim" }, { "williamboman/mason-lspconfig.nvim" }, { - "nvimdev/lspsaga.nvim", - config = require("completion.lspsaga"), + "ray-x/lsp_signature.nvim", + config = require("completion.lsp-signature"), }, { "lvimuser/lsp-inlayhints.nvim", @@ -21,6 +20,12 @@ completion["neovim/nvim-lspconfig"] = { }, }, } +completion["nvimdev/lspsaga.nvim"] = { + lazy = true, + event = "LspAttach", + config = require("completion.lspsaga"), + dependencies = { "nvim-tree/nvim-web-devicons" }, +} completion["jose-elias-alvarez/null-ls.nvim"] = { lazy = true, event = { "CursorHold", "CursorHoldI" }, diff --git a/lua/modules/plugins/editor.lua b/lua/modules/plugins/editor.lua index 135e65bd0..5de346cad 100644 --- a/lua/modules/plugins/editor.lua +++ b/lua/modules/plugins/editor.lua @@ -5,10 +5,19 @@ editor["rainbowhxch/accelerated-jk.nvim"] = { event = "VeryLazy", config = require("editor.accelerated-jk"), } -editor["rmagatti/auto-session"] = { +editor["olimorris/persisted.nvim"] = { lazy = true, - cmd = { "SessionSave", "SessionRestore", "SessionDelete" }, - config = require("editor.auto-session"), + cmd = { + "SessionToggle", + "SessionStart", + "SessionStop", + "SessionSave", + "SessionLoad", + "SessionLoadLast", + "SessionLoadFromFile", + "SessionDelete", + }, + config = require("editor.persisted"), } editor["m4xshen/autoclose.nvim"] = { lazy = true, @@ -27,11 +36,11 @@ editor["LunarVim/bigfile.nvim"] = { } editor["ojroques/nvim-bufdel"] = { lazy = true, - event = "BufReadPost", + event = "BufReadPre", } editor["rhysd/clever-f.vim"] = { lazy = true, - event = { "BufReadPost", "BufAdd", "BufNewFile" }, + event = { "CursorHold", "CursorHoldI" }, config = require("editor.cleverf"), } editor["numToStr/Comment.nvim"] = { @@ -47,10 +56,10 @@ editor["junegunn/vim-easy-align"] = { lazy = true, cmd = "EasyAlign", } -editor["phaazon/hop.nvim"] = { +editor["smoka7/hop.nvim"] = { lazy = true, - branch = "v2", - event = "BufReadPost", + version = "*", + event = { "CursorHold", "CursorHoldI" }, config = require("editor.hop"), } editor["RRethy/vim-illuminate"] = { @@ -78,15 +87,21 @@ editor["nvim-treesitter/nvim-treesitter"] = { vim.api.nvim_command("TSUpdate") end end, - event = { "CursorHold", "CursorHoldI" }, + event = "BufReadPost", config = require("editor.treesitter"), dependencies = { { "nvim-treesitter/nvim-treesitter-textobjects" }, - { "nvim-treesitter/nvim-treesitter-context" }, - { "mrjones2014/nvim-ts-rainbow" }, { "JoosepAlviste/nvim-ts-context-commentstring" }, { "mfussenegger/nvim-treehopper" }, { "andymass/vim-matchup" }, + { + "hiphish/rainbow-delimiters.nvim", + config = require("editor.rainbow_delims"), + }, + { + "nvim-treesitter/nvim-treesitter-context", + config = require("editor.ts-context"), + }, { "windwp/nvim-ts-autotag", config = require("editor.autotag"), diff --git a/lua/modules/plugins/tool.lua b/lua/modules/plugins/tool.lua index 02f7ef2aa..5e7916d42 100644 --- a/lua/modules/plugins/tool.lua +++ b/lua/modules/plugins/tool.lua @@ -32,7 +32,7 @@ tool["michaelb/sniprun"] = { -- You need to cd to `~/.local/share/nvim/site/lazy/sniprun/` and execute `bash ./install.sh`, -- if you encountered error about no executable sniprun found. build = "bash ./install.sh", - cmd = { "SnipRun" }, + cmd = "SnipRun", config = require("tool.sniprun"), } tool["akinsho/toggleterm.nvim"] = { @@ -77,7 +77,7 @@ tool["nvim-telescope/telescope.nvim"] = { { "debugloop/telescope-undo.nvim" }, { "ahmedkhalf/project.nvim", - event = "BufReadPost", + event = { "CursorHold", "CursorHoldI" }, config = require("tool.project"), }, { "nvim-telescope/telescope-fzf-native.nvim", build = "make" }, diff --git a/lua/modules/plugins/ui.lua b/lua/modules/plugins/ui.lua index 4230ea31f..c6865acc2 100644 --- a/lua/modules/plugins/ui.lua +++ b/lua/modules/plugins/ui.lua @@ -48,7 +48,7 @@ ui["zbirenbaum/neodim"] = { } ui["karb94/neoscroll.nvim"] = { lazy = true, - event = "BufReadPost", + event = { "CursorHold", "CursorHoldI" }, config = require("ui.neoscroll"), } ui["shaunsingh/nord.nvim"] = { @@ -67,7 +67,7 @@ ui["folke/paint.nvim"] = { } ui["dstein64/nvim-scrollview"] = { lazy = true, - event = "BufReadPost", + event = { "BufReadPost", "BufAdd", "BufNewFile" }, config = require("ui.scrollview"), } ui["edluffy/specs.nvim"] = { diff --git a/lua/modules/utils/icons.lua b/lua/modules/utils/icons.lua index 365143e4f..91671d06c 100644 --- a/lua/modules/utils/icons.lua +++ b/lua/modules/utils/icons.lua @@ -14,6 +14,7 @@ local data = { Folder = "󰉋", Function = "󰊕", Interface = "", + Implementation = "", Keyword = "󰌋", Method = "󰆧", Module = "", @@ -94,6 +95,7 @@ local data = { Fire = "", Folder = "", FolderOpen = "", + FolderWithHeart = "󱃪", Gear = "", History = "󰄉", Incoming = "󰏷", @@ -125,6 +127,7 @@ local data = { Sort = "", Spell = "󰓆", Symlink = "", + Tab = "", Table = "", Telescope = "", }, @@ -144,15 +147,16 @@ local data = { misc = { Campass = "󰀹", Code = "", - EscapeST = "", Gavel = "", Glass = "󰂖", + NoActiveLsp = "󱚧", PyEnv = "󰌠", Squirrel = "", Tag = "", Tree = "", Watch = "", Lego = "", + LspAvailable = "󱜙", Vbar = "│", Add = "+", Added = "", diff --git a/lua/modules/utils/init.lua b/lua/modules/utils/init.lua index 1df349d68..0c8634663 100644 --- a/lua/modules/utils/init.lua +++ b/lua/modules/utils/init.lua @@ -29,12 +29,29 @@ local M = {} ---@field crust string ---@field none "NONE" ----@type palette +---@type nil|palette local palette = nil +-- Indicates if autocmd for refreshing the builtin palette has already been registered +---@type boolean +local _has_autocmd = false + ---Initialize the palette ---@return palette local function init_palette() + -- Reinitialize the palette on event `ColorScheme` + if not _has_autocmd then + _has_autocmd = true + vim.api.nvim_create_autocmd("ColorScheme", { + group = vim.api.nvim_create_augroup("__builtin_palette", { clear = true }), + pattern = "*", + callback = function() + palette = nil + init_palette() + end, + }) + end + if not palette then palette = vim.g.colors_name:find("catppuccin") and require("catppuccin.palettes").get_palette() or { diff --git a/scripts/install.ps1 b/scripts/install.ps1 index 827c78a73..922bba547 100644 --- a/scripts/install.ps1 +++ b/scripts/install.ps1 @@ -397,8 +397,11 @@ Please make sure you have nvim v$REQUIRED_NVIM_VERSION_LEGACY installed at the v } info -Msg "Spawning Neovim and fetching plugins... (You'll be redirected shortly)" - info -Msg 'To make sqlite work with lua, manually grab the dlls from "https://www.sqlite.org/download.html" and' - info_ext -Msg 'replace vim.g.sqlite_clib_path with your path at the bottom of `lua/core/options.lua`' + info -Msg 'To make sqlite work with lua, manually grab the dlls from "https://www.sqlite.org/download.html" and replace' + info_ext -Msg 'vim.g.sqlite_clib_path with your path at the bottom of `lua/core/options.lua`.' + info -Msg 'Also, please make sure you have a Rust Toolchain installed via `rustup`! Otherwise, unexpected things may' + info_ext -Msg 'happen. See: https://www.rust-lang.org/tools/install. ¯¯¯¯¯¯¯¯¯¯¯¯' + info_ext -Msg ' ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯' info -Msg 'If lazy.nvim failed to fetch any plugin(s), maunally execute `:Lazy sync` until everything is up-to-date.' Write-Host @' diff --git a/scripts/install.sh b/scripts/install.sh index 0cedade42..ff55aebac 100755 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -77,6 +77,10 @@ info() { printf "${tty_blue}==>${tty_bold} %s${tty_reset}\n" "$(shell_join "$@")" } +info_ext() { + printf "${tty_bold} %s${tty_reset}\n" "$(shell_join "$@")" +} + warn() { printf "${tty_yellow}Warning${tty_reset}: %s\n" "$(chomp "$1")" } @@ -289,6 +293,9 @@ if [[ "${USE_SSH}" -eq "0" ]]; then fi info "Spawning Neovim and fetching plugins... (You'll be redirected shortly)" +info "NOTE: Please make sure you have a Rust Toolchain installed ${tty_underline}via \`rustup\`${tty_reset}${tty_bold}! Otherwise, unexpected things may" +info_ext " happen. See: ${tty_underline}https://www.rust-lang.org/tools/install${tty_reset}." +info_ext "" info "If lazy.nvim failed to fetch any plugin(s), maunally execute \`:Lazy sync\` until everything is up-to-date." cat < Date: Tue, 9 Jan 2024 23:13:14 +0800 Subject: [PATCH 04/72] chore(neodim): remove pin commit (#1142) Signed-off-by: Charles Chiu --- lua/modules/plugins/ui.lua | 1 - 1 file changed, 1 deletion(-) diff --git a/lua/modules/plugins/ui.lua b/lua/modules/plugins/ui.lua index e3c50fae9..14cf72366 100644 --- a/lua/modules/plugins/ui.lua +++ b/lua/modules/plugins/ui.lua @@ -38,7 +38,6 @@ ui["nvim-lualine/lualine.nvim"] = { } ui["zbirenbaum/neodim"] = { lazy = true, - commit = "9477da0", event = "LspAttach", config = require("ui.neodim"), } From 9bf2c26c437b12b61993abeb32831ca03cb0eb4d Mon Sep 17 00:00:00 2001 From: ayamir Date: Fri, 9 Feb 2024 14:55:19 +0800 Subject: [PATCH 05/72] fix: remove `specs.nvim` due to long time no update. Signed-off-by: ayamir --- lua/modules/configs/ui/specs.lua | 17 ----------------- lua/modules/plugins/ui.lua | 5 ----- 2 files changed, 22 deletions(-) delete mode 100644 lua/modules/configs/ui/specs.lua diff --git a/lua/modules/configs/ui/specs.lua b/lua/modules/configs/ui/specs.lua deleted file mode 100644 index 4fc97ec38..000000000 --- a/lua/modules/configs/ui/specs.lua +++ /dev/null @@ -1,17 +0,0 @@ -return function() - require("modules.utils").load_plugin("specs", { - show_jumps = true, - min_jump = 10, - popup = { - delay_ms = 0, -- delay before popup displays - inc_ms = 10, -- time increments used for fade/resize effects - blend = 10, -- starting blend, between 0-100 (fully transparent), see :h winblend - width = 10, - winhl = "PmenuSbar", - fader = require("specs").pulse_fader, - resizer = require("specs").shrink_resizer, - }, - ignore_filetypes = {}, - ignore_buftypes = { nofile = true }, - }) -end diff --git a/lua/modules/plugins/ui.lua b/lua/modules/plugins/ui.lua index 14cf72366..4c9da9640 100644 --- a/lua/modules/plugins/ui.lua +++ b/lua/modules/plugins/ui.lua @@ -61,10 +61,5 @@ ui["dstein64/nvim-scrollview"] = { event = { "BufReadPost", "BufAdd", "BufNewFile" }, config = require("ui.scrollview"), } -ui["edluffy/specs.nvim"] = { - lazy = true, - event = "CursorMoved", - config = require("ui.specs"), -} return ui From 089cc4669b6fc09d79ab759b762e3aded2c7f8a1 Mon Sep 17 00:00:00 2001 From: ayamir Date: Fri, 9 Feb 2024 15:04:56 +0800 Subject: [PATCH 06/72] Merge branch 'main' into 0.10 Signed-off-by: ayamir --- .github/workflows/update_lockfile.yml | 2 +- lazy-lock.json | 115 +++++++++--------- lua/core/event.lua | 10 -- lua/core/init.lua | 9 +- lua/keymap/completion.lua | 6 +- lua/keymap/editor.lua | 6 +- lua/keymap/helpers.lua | 2 +- lua/keymap/tool.lua | 16 +-- lua/keymap/ui.lua | 16 +-- .../configs/completion/mason-lspconfig.lua | 17 +++ lua/modules/configs/lang/rust.lua | 12 ++ lua/modules/configs/tool/which-key.lua | 33 ++++- lua/modules/configs/ui/alpha.lua | 8 -- lua/modules/configs/ui/bufferline.lua | 4 +- lua/modules/configs/ui/catppuccin.lua | 6 +- lua/modules/configs/ui/notify.lua | 3 +- lua/modules/configs/ui/scrollview.lua | 2 +- lua/modules/plugins/lang.lua | 5 +- lua/modules/utils/icons.lua | 4 +- lua/modules/utils/init.lua | 41 +++++-- 20 files changed, 194 insertions(+), 123 deletions(-) create mode 100644 lua/modules/configs/lang/rust.lua diff --git a/.github/workflows/update_lockfile.yml b/.github/workflows/update_lockfile.yml index 7e1992a0c..200e01994 100644 --- a/.github/workflows/update_lockfile.yml +++ b/.github/workflows/update_lockfile.yml @@ -13,7 +13,7 @@ jobs: - uses: actions/checkout@v4 with: fetch-depth: 0 # Required to count the commits - - uses: andstor/file-existence-action@v2 + - uses: andstor/file-existence-action@v3 id: check_lockfile with: files: "lazy-lock.json" diff --git a/lazy-lock.json b/lazy-lock.json index 63ab74a19..6e32a0f6f 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -1,14 +1,14 @@ { - "Comment.nvim": { "branch": "master", "commit": "176e85eeb63f1a5970d6b88f1725039d85ca0055" }, - "LuaSnip": { "branch": "master", "commit": "0b4950a237ce441a6a3a947d501622453f6860ea" }, + "Comment.nvim": { "branch": "master", "commit": "0236521ea582747b58869cb72f70ccfa967d2e89" }, + "LuaSnip": { "branch": "master", "commit": "2dbef19461198630b3d7c39f414d09fb07d1fdd2" }, "accelerated-jk.nvim": { "branch": "main", "commit": "8fb5dad4ccc1811766cebf16b544038aeeb7806f" }, - "alpha-nvim": { "branch": "main", "commit": "e4fc5e29b731bdf55d204c5c6a11dc3be70f3b65" }, - "autoclose.nvim": { "branch": "main", "commit": "469782b0456f0b4f764378ffda94c18599544e09" }, - "better-escape.nvim": { "branch": "master", "commit": "7031dc734add47bb71c010e0551829fa5799375f" }, - "bigfile.nvim": { "branch": "main", "commit": "9616b73670ffeb92679677554ded88854ae42cf8" }, - "bufferline.nvim": { "branch": "main", "commit": "d24378edc14a675c820a303b4512af3bbc5761e9" }, - "catppuccin": { "branch": "refactor/syntax-highlighting", "commit": "1f76a94691b509acb4bf000cd85ba285c4df1c02" }, - "clever-f.vim": { "branch": "master", "commit": "6a3ac5e3688598af9411ab741737f98c47370c22" }, + "aerial.nvim": { "branch": "master", "commit": "d21482d3be3228dde594aba31106db428292742c" }, + "alpha-nvim": { "branch": "main", "commit": "1356b9ef31b985d541d94314f2cf73c61124bf1d" }, + "autoclose.nvim": { "branch": "main", "commit": "37e11589aac55b0e8810dc5865f898f9cb36fef6" }, + "better-escape.nvim": { "branch": "master", "commit": "7e86edafb8c7e73699e0320f225464a298b96d12" }, + "bigfile.nvim": { "branch": "main", "commit": "33eb067e3d7029ac77e081cfe7c45361887a311a" }, + "bufferline.nvim": { "branch": "main", "commit": "b15c6daf5a64426c69732b31a951f4e438cb6590" }, + "catppuccin": { "branch": "refactor/syntax-highlighting", "commit": "b6f54c74f8aea460b395c4b0ede9392dbab60424" }, "cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" }, "cmp-latex-symbols": { "branch": "main", "commit": "165fb66afdbd016eaa1570e41672c4c557b57124" }, "cmp-nvim-lsp": { "branch": "main", "commit": "5af77f54de1b16c34b23cba810150689a3a90312" }, @@ -18,60 +18,62 @@ "cmp-tmux": { "branch": "main", "commit": "97ec06b8030b8bf6d1fd83d49bdd16c98e04c845" }, "cmp-treesitter": { "branch": "master", "commit": "c8e3a74b51597d69d240085a258636972ce98e15" }, "cmp-under-comparator": { "branch": "master", "commit": "6857f10272c3cfe930cece2afa2406e1385bfef8" }, - "cmp_luasnip": { "branch": "master", "commit": "18095520391186d634a0045dacaa346291096566" }, - "copilot-cmp": { "branch": "master", "commit": "c2cdb3c0f5078b0619055af192295830a7987790" }, - "copilot.lua": { "branch": "master", "commit": "e48bd7020a98be217d85c006a298656294fd6210" }, - "crates.nvim": { "branch": "main", "commit": "4ce7c51b881e58f1e2f8f437f30e4e583cbac319" }, - "csv.vim": { "branch": "master", "commit": "15ff93edf5b26c466affbb356e0696b7d6a3b499" }, - "diffview.nvim": { "branch": "main", "commit": "e91110d2a7f8e2f667666aba6ea089ff823f8748" }, - "edge": { "branch": "master", "commit": "358cb6688ac577470a4eafcb53bdd63899dfc937" }, - "fidget.nvim": { "branch": "legacy", "commit": "90c22e47be057562ee9566bad313ad42d622c1d3" }, - "friendly-snippets": { "branch": "main", "commit": "ea84a710262cb2c286d439070bad37d36fd3db25" }, + "cmp_luasnip": { "branch": "master", "commit": "05a9ab28b53f71d1aece421ef32fee2cb857a843" }, + "copilot-cmp": { "branch": "master", "commit": "72fbaa03695779f8349be3ac54fa8bd77eed3ee3" }, + "copilot.lua": { "branch": "master", "commit": "71382c2efec76647287d46a4fbe0ec8c9809e2ee" }, + "crates.nvim": { "branch": "main", "commit": "2bd990871f0aef159933bd5fe6da421690a832b9" }, + "csv.vim": { "branch": "master", "commit": "962f88787ec6873eba1c7dbbd81d2723f1ee3c4b" }, + "diffview.nvim": { "branch": "main", "commit": "3dc498c9777fe79156f3d32dddd483b8b3dbd95f" }, + "fidget.nvim": { "branch": "main", "commit": "1d1042d418ee8cb70d68f1e38db639844331c093" }, + "flash.nvim": { "branch": "main", "commit": "48817af25f51c0590653bbc290866e4890fe1cbe" }, + "friendly-snippets": { "branch": "main", "commit": "b8fae73a479ae0a1c54f5c98fa687ae8a0addc53" }, + "fzf": { "branch": "master", "commit": "1a43259989fc84c0be85829f71ae21815e8d4620" }, "fzy-lua-native": { "branch": "master", "commit": "820f745b7c442176bcc243e8f38ef4b985febfaf" }, - "gitsigns.nvim": { "branch": "main", "commit": "adcf2c7f2f495f5df148683764bf7cba6a70f34c" }, - "hop.nvim": { "branch": "master", "commit": "31e0e42e629bf16affea747132d9c54f55fb17c8" }, - "indent-blankline.nvim": { "branch": "master", "commit": "4541d690816cb99a7fc248f1486aa87f3abce91c" }, - "lazy.nvim": { "branch": "main", "commit": "25beed5e2e935ebc00d7e3eed1dc502df3c40e39" }, - "lsp_signature.nvim": { "branch": "master", "commit": "17ff7a405fea8376b015b8ea7910d2e59958bf68" }, - "lspsaga.nvim": { "branch": "main", "commit": "20eef6d60780123ac36b3c8b594ca3b2ebf35c9b" }, - "lualine.nvim": { "branch": "master", "commit": "05d78e9fd0cdfb4545974a5aa14b1be95a86e9c9" }, - "markdown-preview.nvim": { "branch": "master", "commit": "02cc3874738bc0f86e4b91f09b8a0ac88aef8e96" }, - "mason-lspconfig.nvim": { "branch": "main", "commit": "828a538ac8419f586c010996aefa5df6eb7c250b" }, - "mason-null-ls.nvim": { "branch": "main", "commit": "ae0c5fa57468ac65617f1bf821ba0c3a1e251f0c" }, - "mason-nvim-dap.nvim": { "branch": "main", "commit": "e4d56b400e9757b1dc77d620fd3069396e92d5fc" }, - "mason.nvim": { "branch": "main", "commit": "5ad3e113b0c3fde3caba8630599373046f6197e8" }, + "gitsigns.nvim": { "branch": "main", "commit": "2c2463dbd82eddd7dbab881c3a62cfbfbe3c67ae" }, + "glance.nvim": { "branch": "master", "commit": "8ed5cf3b3b1231ea696d88c9efd977027429d869" }, + "hop.nvim": { "branch": "master", "commit": "6d853addd6e11df8338b26e869a29b36f2c3e893" }, + "indent-blankline.nvim": { "branch": "master", "commit": "12e92044d313c54c438bd786d11684c88f6f78cd" }, + "lazy.nvim": { "branch": "main", "commit": "aedcd79811d491b60d0a6577a9c1701063c2a609" }, + "lsp-format-modifications.nvim": { "branch": "main", "commit": "006d4cd88f4f09fdc4375fcb75dd5b7d981a723b" }, + "lsp_signature.nvim": { "branch": "master", "commit": "f09644c0390ba49cfe60eafc1f19849dc4c2e814" }, + "lspsaga.nvim": { "branch": "main", "commit": "2198c07124bef27ef81335be511c8abfd75db933" }, + "lualine.nvim": { "branch": "master", "commit": "7d131a8d3ba5016229e8a1d08bf8782acea98852" }, + "markdown-preview.nvim": { "branch": "master", "commit": "a923f5fc5ba36a3b17e289dc35dc17f66d0548ee" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "2b3d247fce06f53934174f5dfe0362c42d65c00c" }, + "mason-null-ls.nvim": { "branch": "main", "commit": "a1e19bf9baa86e8a43dd86cf9689ca9f71b4d1da" }, + "mason-nvim-dap.nvim": { "branch": "main", "commit": "3614a39aae98ccd34124b072939d6283853b3dd2" }, + "mason.nvim": { "branch": "main", "commit": "c43eeb5614a09dc17c03a7fb49de2e05de203924" }, "neodim": { "branch": "master", "commit": "9477da03b93f1984a81fee3b92e6ac7c6ada6aa4" }, - "neoscroll.nvim": { "branch": "master", "commit": "d7601c26c8a183fa8994ed339e70c2d841253e93" }, - "nord.nvim": { "branch": "master", "commit": "fab04b2dd4b64f4b1763b9250a8824d0b5194b8f" }, - "null-ls.nvim": { "branch": "main", "commit": "db09b6c691def0038c456551e4e2772186449f35" }, - "nvim-bufdel": { "branch": "main", "commit": "96c4f7ab053ddab0025bebe5f7c71e4795430e47" }, - "nvim-cmp": { "branch": "main", "commit": "c4e491a87eeacf0408902c32f031d802c7eafce8" }, - "nvim-colorizer.lua": { "branch": "master", "commit": "dde3084106a70b9a79d48f426f6d6fec6fd203f7" }, - "nvim-dap": { "branch": "master", "commit": "d17d1bba23ec72a157bd183c57840c39e323f515" }, - "nvim-dap-ui": { "branch": "master", "commit": "85b16ac2309d85c88577cd8ee1733ce52be8227e" }, - "nvim-lspconfig": { "branch": "master", "commit": "447443a2404adc323ad2efc7c0a346a904ce694c" }, - "nvim-notify": { "branch": "master", "commit": "ea9c8ce7a37f2238f934e087c255758659948e0f" }, - "nvim-scrollview": { "branch": "main", "commit": "9b0b7aeee68700bc7672dfee186d32089a583332" }, - "nvim-tree.lua": { "branch": "master", "commit": "3b62c6bf2c3f2973036aed609d02fd0ca9c3af35" }, + "neoscroll.nvim": { "branch": "master", "commit": "be4ebf855a52f71ca4338694a5696675d807eff9" }, + "none-ls.nvim": { "branch": "main", "commit": "c10b7be7751aee820a02f2d1fafe76bc316fe223" }, + "nvim-bqf": { "branch": "main", "commit": "bdc2a4e5bb670b3c0e33ada9c0eec636d93a0748" }, + "nvim-bufdel": { "branch": "main", "commit": "523d58e94e7212fff3e05c247b962dc8f93bcfde" }, + "nvim-cmp": { "branch": "main", "commit": "04e0ca376d6abdbfc8b52180f8ea236cbfddf782" }, + "nvim-colorizer.lua": { "branch": "master", "commit": "85855b38011114929f4058efc97af1059ab3e41d" }, + "nvim-dap": { "branch": "master", "commit": "9adbfdca13afbe646d09a8d7a86d5d031fb9c5a5" }, + "nvim-dap-ui": { "branch": "master", "commit": "d845ebd798ad1cf30aa4abd4c4eff795cdcfdd4f" }, + "nvim-lspconfig": { "branch": "master", "commit": "9a6279953c82d01b58825a46ede032ab246a5983" }, + "nvim-notify": { "branch": "master", "commit": "80b67b265530632505193553d05127ae7fe09ddd" }, + "nvim-scrollview": { "branch": "main", "commit": "2bc1d94174a977e7147e845156d3c4c12ac06b67" }, + "nvim-tree.lua": { "branch": "master", "commit": "f39f7b6fcd3865ac2146de4cb4045286308f2935" }, "nvim-treehopper": { "branch": "master", "commit": "5a28bff46c05d28bdb4bcaef67e046eb915a9390" }, - "nvim-treesitter": { "branch": "master", "commit": "4115fad9fded72571bdc3e0f7351e64b31799a3d" }, - "nvim-treesitter-context": { "branch": "master", "commit": "6f8f788738b968f24a108ee599c5be0031f94f06" }, - "nvim-treesitter-textobjects": { "branch": "master", "commit": "52f1f3280d9092bfaee5c45be5962fabee3d9654" }, - "nvim-ts-autotag": { "branch": "main", "commit": "6be1192965df35f94b8ea6d323354f7dc7a557e4" }, - "nvim-ts-context-commentstring": { "branch": "main", "commit": "7f625207f225eea97ef7a6abe7611e556c396d2f" }, - "nvim-web-devicons": { "branch": "master", "commit": "efbfed0567ef4bfac3ce630524a0f6c8451c5534" }, + "nvim-treesitter": { "branch": "master", "commit": "4fbf150a1621d52f17b099506e1a32f107079210" }, + "nvim-treesitter-context": { "branch": "master", "commit": "9c06b115abc57c99cf0aa81dc29490f5001f57a1" }, + "nvim-treesitter-textobjects": { "branch": "master", "commit": "8edd5a6d96936bdff23333d3bc177481388839e5" }, + "nvim-ts-autotag": { "branch": "main", "commit": "a65b202cfd08e0e69e531eab737205ff5bc082a4" }, + "nvim-ts-context-commentstring": { "branch": "main", "commit": "7ab799a9792f7cf3883cf28c6a00ad431f3d382a" }, + "nvim-web-devicons": { "branch": "master", "commit": "aaec87dbdaa776bfa0a13c8694bec9bcb7454719" }, "paint.nvim": { "branch": "main", "commit": "6ce64212804f425073c61ab0d9c2b034f0435260" }, - "persisted.nvim": { "branch": "main", "commit": "b03c863731eafacd973912383297ea5d8fdb006a" }, - "plenary.nvim": { "branch": "master", "commit": "267282a9ce242bbb0c5dc31445b6d353bed978bb" }, + "persisted.nvim": { "branch": "main", "commit": "edd8aa41cd87f9da1b6ef0c584068dea192f65b7" }, + "plenary.nvim": { "branch": "master", "commit": "4f71c0c4a196ceb656c824a70792f3df3ce6bb6d" }, "project.nvim": { "branch": "main", "commit": "8c6bad7d22eef1b71144b401c9f74ed01526a4fb" }, - "rainbow-delimiters.nvim": { "branch": "master", "commit": "0d5eb17533a4ed8fe52e3d0e83605cc5875bbe84" }, - "rust-tools.nvim": { "branch": "master", "commit": "0cc8adab23117783a0292a0c8a2fbed1005dc645" }, - "smartyank.nvim": { "branch": "master", "commit": "7e3905578f646503525b2f7018b8afd17861018c" }, - "sniprun": { "branch": "master", "commit": "28d55eeb6786a7037fd3564ced8296a71f1cece7" }, - "specs.nvim": { "branch": "main", "commit": "2743e412bbe21c9d73954c403d01e8de7377890d" }, + "rainbow-delimiters.nvim": { "branch": "master", "commit": "ca8d5ee2b4ee1eec491040a7601d366ddc8a2e02" }, + "rustaceanvim": { "branch": "master", "commit": "bc8c4b8f7606d5b7c067cd8369e25c1a7ff77bd0" }, + "smartyank.nvim": { "branch": "master", "commit": "b048fec8c6b7d122adab6f78606057d59975ece7" }, + "sniprun": { "branch": "master", "commit": "0079f9c4675a6825f84e108bbff866f67dd8762f" }, "suda.vim": { "branch": "master", "commit": "8b0fc3711760195aba104e2d190cff9af8267052" }, "tabout.nvim": { "branch": "master", "commit": "0d275c8d25f32457e67b5c66d6ae43f26a61bce5" }, - "telescope-frecency.nvim": { "branch": "master", "commit": "9c18474d0a4b82435ce141c2a21d9bd7b9189272" }, + "telescope-frecency.nvim": { "branch": "master", "commit": "a61ede8740643f09e1a7706fbb49b152e8f25d42" }, "telescope-fzf-native.nvim": { "branch": "main", "commit": "6c921ca12321edaa773e324ef64ea301a1d0da62" }, "telescope-live-grep-args.nvim": { "branch": "master", "commit": "731a046da7dd3adff9de871a42f9b7fb85f60f47" }, "telescope-undo.nvim": { "branch": "main", "commit": "d3afc1c105535a90caec092ce27a113f77ba7b84" }, @@ -86,3 +88,4 @@ "vim-matchup": { "branch": "master", "commit": "17cc05867cb3314761e4baa20115a27120f8e82c" }, "which-key.nvim": { "branch": "main", "commit": "38b990f6eabf62014018b4aae70a97d7a6c2eb88" }, "wilder.nvim": { "branch": "master", "commit": "679f348dc90d80ff9ba0e7c470c40a4d038dcecf" } +} diff --git a/lua/core/event.lua b/lua/core/event.lua index f4dab4e75..cc977f74f 100644 --- a/lua/core/event.lua +++ b/lua/core/event.lua @@ -67,16 +67,6 @@ vim.api.nvim_create_autocmd("FileType", { end, }) --- Fix fold issue of files opened by telescope -vim.api.nvim_create_autocmd("BufRead", { - callback = function() - vim.api.nvim_create_autocmd("BufWinEnter", { - once = true, - command = "normal! zx", - }) - end, -}) - function autocmd.load_autocmds() local definitions = { lazy = {}, diff --git a/lua/core/init.lua b/lua/core/init.lua index 222b0d954..e9b2e3251 100644 --- a/lua/core/init.lua +++ b/lua/core/init.lua @@ -75,8 +75,11 @@ end local leader_map = function() vim.g.mapleader = " " - vim.api.nvim_set_keymap("n", " ", "", { noremap = true }) - vim.api.nvim_set_keymap("x", " ", "", { noremap = true }) + -- NOTE: + -- > Uncomment the following if you're using a other than , and you wish + -- > to disable advancing one character by pressing in normal/visual mode. + -- vim.api.nvim_set_keymap("n", " ", "", { noremap = true }) + -- vim.api.nvim_set_keymap("x", " ", "", { noremap = true }) end local gui_config = function() @@ -164,9 +167,9 @@ local load_core = function() require("core.options") require("core.mapping") - require("keymap") require("core.event") require("core.pack") + require("keymap") local colorscheme = settings.colorscheme local background = settings.background diff --git a/lua/keymap/completion.lua b/lua/keymap/completion.lua index 5472eba5c..23e81b2bc 100644 --- a/lua/keymap/completion.lua +++ b/lua/keymap/completion.lua @@ -30,7 +30,7 @@ function mapping.lsp(buf) :with_silent() :with_buffer(buf) :with_desc("lsp: Next diagnostic"), - ["n|ld"] = map_cr("Lspsaga show_line_diagnostics ++unfocus") + ["n|lx"] = map_cr("Lspsaga show_line_diagnostics ++unfocus") :with_silent() :with_buffer(buf) :with_desc("lsp: Line diagnostic"), @@ -50,11 +50,11 @@ function mapping.lsp(buf) ["n|gd"] = map_cr("Glance definitions"):with_silent():with_buffer(buf):with_desc("lsp: Preview definition"), ["n|gD"] = map_cr("Lspsaga goto_definition"):with_silent():with_buffer(buf):with_desc("lsp: Goto definition"), ["n|gh"] = map_cr("Glance references"):with_silent():with_buffer(buf):with_desc("lsp: Show reference"), - ["n|ci"] = map_cr("Lspsaga incoming_calls") + ["n|gci"] = map_cr("Lspsaga incoming_calls") :with_silent() :with_buffer(buf) :with_desc("lsp: Show incoming calls"), - ["n|co"] = map_cr("Lspsaga outgoing_calls") + ["n|gco"] = map_cr("Lspsaga outgoing_calls") :with_silent() :with_buffer(buf) :with_desc("lsp: Show outgoing calls"), diff --git a/lua/keymap/editor.lua b/lua/keymap/editor.lua index 1de214678..71158b85e 100644 --- a/lua/keymap/editor.lua +++ b/lua/keymap/editor.lua @@ -57,8 +57,8 @@ local plug_map = { :with_desc("edit: Toggle comment for block with selection"), -- Plugin: diffview - ["n|D"] = map_cr("DiffviewOpen"):with_silent():with_noremap():with_desc("git: Show diff"), - ["n|D"] = map_cr("DiffviewClose"):with_silent():with_noremap():with_desc("git: Close diff"), + ["n|gd"] = map_cr("DiffviewOpen"):with_silent():with_noremap():with_desc("git: Show diff"), + ["n|gD"] = map_cr("DiffviewClose"):with_silent():with_noremap():with_desc("git: Close diff"), -- Plugin: vim-easy-align ["nx|gea"] = map_cr("EasyAlign"):with_desc("edit: Align with delimiter"), @@ -68,7 +68,7 @@ local plug_map = { ["nv|j"] = map_cmd("HopLineMW"):with_noremap():with_desc("jump: Goto line"), ["nv|k"] = map_cmd("HopLineMW"):with_noremap():with_desc("jump: Goto line"), ["nv|c"] = map_cmd("HopChar1MW"):with_noremap():with_desc("jump: Goto one char"), - ["nv|cc"] = map_cmd("HopChar2MW"):with_noremap():with_desc("jump: Goto two chars"), + ["nv|C"] = map_cmd("HopChar2MW"):with_noremap():with_desc("jump: Goto two chars"), -- Plugin: treehopper ["o|m"] = map_cu("lua require('tsht').nodes()"):with_silent():with_desc("jump: Operate across syntax tree"), diff --git a/lua/keymap/helpers.lua b/lua/keymap/helpers.lua index 2604b2146..b411bcd79 100644 --- a/lua/keymap/helpers.lua +++ b/lua/keymap/helpers.lua @@ -18,7 +18,7 @@ _G._flash_esc_or_noh = function() if flash_active and state then state:hide() else - vim.cmd([[noh]]) + pcall(vim.cmd.noh) end end diff --git a/lua/keymap/tool.lua b/lua/keymap/tool.lua index 579acce6e..fcb5307d3 100644 --- a/lua/keymap/tool.lua +++ b/lua/keymap/tool.lua @@ -9,7 +9,7 @@ local plug_map = { -- Plugin: vim-fugitive ["n|gps"] = map_cr("G push"):with_noremap():with_silent():with_desc("git: Push"), ["n|gpl"] = map_cr("G pull"):with_noremap():with_silent():with_desc("git: Pull"), - ["n|G"] = map_cu("Git"):with_noremap():with_silent():with_desc("git: Open git-fugitive"), + ["n|gG"] = map_cu("Git"):with_noremap():with_silent():with_desc("git: Open git-fugitive"), -- Plugin: nvim-tree ["n|"] = map_cr("NvimTreeToggle"):with_noremap():with_silent():with_desc("filetree: Toggle"), @@ -55,7 +55,7 @@ local plug_map = { :with_silent() :with_desc("terminal: Toggle float"), ["t|"] = map_cmd("ToggleTerm"):with_noremap():with_silent():with_desc("terminal: Toggle float"), - ["n|g"] = map_callback(function() + ["n|gg"] = map_callback(function() _toggle_lazygit() end) :with_noremap() @@ -64,23 +64,23 @@ local plug_map = { -- Plugin: trouble ["n|gt"] = map_cr("TroubleToggle"):with_noremap():with_silent():with_desc("lsp: Toggle trouble list"), - ["n|tr"] = map_cr("TroubleToggle lsp_references") + ["n|ll"] = map_cr("TroubleToggle lsp_references") :with_noremap() :with_silent() :with_desc("lsp: Show lsp references"), - ["n|td"] = map_cr("TroubleToggle document_diagnostics") + ["n|ld"] = map_cr("TroubleToggle document_diagnostics") :with_noremap() :with_silent() :with_desc("lsp: Show document diagnostics"), - ["n|tw"] = map_cr("TroubleToggle workspace_diagnostics") + ["n|lw"] = map_cr("TroubleToggle workspace_diagnostics") :with_noremap() :with_silent() :with_desc("lsp: Show workspace diagnostics"), - ["n|tq"] = map_cr("TroubleToggle quickfix") + ["n|lq"] = map_cr("TroubleToggle quickfix") :with_noremap() :with_silent() :with_desc("lsp: Show quickfix list"), - ["n|tl"] = map_cr("TroubleToggle loclist"):with_noremap():with_silent():with_desc("lsp: Show loclist"), + ["n|lL"] = map_cr("TroubleToggle loclist"):with_noremap():with_silent():with_desc("lsp: Show loclist"), -- Plugin: telescope ["n|"] = map_callback(function() @@ -121,7 +121,7 @@ local plug_map = { :with_noremap() :with_silent() :with_desc("ui: Change colorscheme for current session"), - ["n|fn"] = map_cu(":enew"):with_noremap():with_silent():with_desc("buffer: New"), + ["n|bn"] = map_cu(":enew"):with_noremap():with_silent():with_desc("buffer: New"), ["n|fg"] = map_cu("Telescope git_files") :with_noremap() :with_silent() diff --git a/lua/keymap/ui.lua b/lua/keymap/ui.lua index d52e6b289..5521e9bc2 100644 --- a/lua/keymap/ui.lua +++ b/lua/keymap/ui.lua @@ -54,42 +54,42 @@ function mapping.gitsigns(buf) :with_buffer(buf) :with_expr() :with_desc("git: Goto prev hunk"), - ["n|hs"] = bind.map_callback(function() + ["n|gs"] = bind.map_callback(function() actions.stage_hunk() end) :with_buffer(buf) :with_desc("git: Stage hunk"), - ["v|hs"] = bind.map_callback(function() + ["v|gs"] = bind.map_callback(function() actions.stage_hunk({ vim.fn.line("."), vim.fn.line("v") }) end) :with_buffer(buf) :with_desc("git: Stage hunk"), - ["n|hu"] = bind.map_callback(function() + ["n|gu"] = bind.map_callback(function() actions.undo_stage_hunk() end) :with_buffer(buf) :with_desc("git: Undo stage hunk"), - ["n|hr"] = bind.map_callback(function() + ["n|gr"] = bind.map_callback(function() actions.reset_hunk() end) :with_buffer(buf) :with_desc("git: Reset hunk"), - ["v|hr"] = bind.map_callback(function() + ["v|gr"] = bind.map_callback(function() actions.reset_hunk({ vim.fn.line("."), vim.fn.line("v") }) end) :with_buffer(buf) :with_desc("git: Reset hunk"), - ["n|hR"] = bind.map_callback(function() + ["n|gR"] = bind.map_callback(function() actions.reset_buffer() end) :with_buffer(buf) :with_desc("git: Reset buffer"), - ["n|hp"] = bind.map_callback(function() + ["n|gp"] = bind.map_callback(function() actions.preview_hunk() end) :with_buffer(buf) :with_desc("git: Preview hunk"), - ["n|hb"] = bind.map_callback(function() + ["n|gb"] = bind.map_callback(function() actions.blame_line({ full = true }) end) :with_buffer(buf) diff --git a/lua/modules/configs/completion/mason-lspconfig.lua b/lua/modules/configs/completion/mason-lspconfig.lua index fdf54587c..eb534cbf2 100644 --- a/lua/modules/configs/completion/mason-lspconfig.lua +++ b/lua/modules/configs/completion/mason-lspconfig.lua @@ -28,6 +28,23 @@ M.setup = function() ---A handler to setup all servers defined under `completion/servers/*.lua` ---@param lsp_name string local function mason_lsp_handler(lsp_name) + -- rust_analyzer is configured using mrcjkb/rustaceanvim + -- warn users if they have set it up manually + if lsp_name == "rust_analyzer" then + local config_exist = pcall(require, "completion.servers." .. lsp_name) + if config_exist then + vim.notify( + [[ +`rust_analyzer` is configured independently via `mrcjkb/rustaceanvim`. To get rid of this warning, +please REMOVE your LSP configuration (rust_analyzer.lua) from the `servers` directory and configure +`rust_analyzer` using the appropriate init options provided by `rustaceanvim` instead.]], + vim.log.levels.WARN, + { title = "nvim-lspconfig" } + ) + end + return + end + local ok, custom_handler = pcall(require, "user.configs.lsp-servers." .. lsp_name) -- Use preset if there is no user definition if not ok then diff --git a/lua/modules/configs/lang/rust.lua b/lua/modules/configs/lang/rust.lua new file mode 100644 index 000000000..cdcc1c765 --- /dev/null +++ b/lua/modules/configs/lang/rust.lua @@ -0,0 +1,12 @@ +return function() + vim.g.rustaceanvim = { + -- Disable automatic DAP configuration to avoid conflicts with previous user configs + dap = { + adapter = false, + configuration = false, + autoload_configurations = false, + }, + } + + require("modules.utils").load_plugin("rustaceanvim", nil, true) +end diff --git a/lua/modules/configs/tool/which-key.lua b/lua/modules/configs/tool/which-key.lua index 9c9d8d95f..30bbab73a 100644 --- a/lua/modules/configs/tool/which-key.lua +++ b/lua/modules/configs/tool/which-key.lua @@ -2,8 +2,39 @@ return function() local icons = { ui = require("modules.utils.icons").get("ui"), misc = require("modules.utils.icons").get("misc"), + git = require("modules.utils.icons").get("git", true), + cmp = require("modules.utils.icons").get("cmp", true), } + require("which-key").register({ + [""] = { + b = { + name = icons.ui.Buffer .. " Buffer", + }, + d = { + name = icons.ui.Bug .. " Debug", + }, + f = { + name = icons.ui.Telescope .. " Fuzzy Find", + }, + g = { + name = icons.git.Git .. "Git", + }, + l = { + name = icons.misc.LspAvailable .. " Lsp", + }, + n = { + name = icons.ui.FolderOpen .. " Nvim Tree", + }, + p = { + name = icons.ui.Package .. " Package", + }, + s = { + name = icons.cmp.tmux .. "Session", + }, + }, + }) + require("modules.utils").load_plugin("which-key", { plugins = { presets = { @@ -20,7 +51,7 @@ return function() icons = { breadcrumb = icons.ui.Separator, separator = icons.misc.Vbar, - group = icons.misc.Add, + group = "", }, window = { diff --git a/lua/modules/configs/ui/alpha.lua b/lua/modules/configs/ui/alpha.lua index bccbcc72c..c84dbcf06 100644 --- a/lua/modules/configs/ui/alpha.lua +++ b/lua/modules/configs/ui/alpha.lua @@ -80,14 +80,6 @@ return function() require("telescope.builtin").find_files() end, }), - button("space f n", " File new", leader, nil, { - noremap = true, - silent = true, - nowait = true, - callback = function() - vim.api.nvim_command("enew") - end, - }), button("space f w", " Word find", leader, nil, { noremap = true, silent = true, diff --git a/lua/modules/configs/ui/bufferline.lua b/lua/modules/configs/ui/bufferline.lua index b32ace2a9..b01200d3f 100644 --- a/lua/modules/configs/ui/bufferline.lua +++ b/lua/modules/configs/ui/bufferline.lua @@ -4,8 +4,8 @@ return function() local opts = { options = { number = nil, - close_command = "BufDel %d", - right_mouse_command = "BufDel %d", + close_command = "BufDel! %d", + right_mouse_command = "BufDel! %d", modified_icon = icons.ui.Modified, buffer_close_icon = icons.ui.Close, left_trunc_marker = icons.ui.Left, diff --git a/lua/modules/configs/ui/catppuccin.lua b/lua/modules/configs/ui/catppuccin.lua index 20bbe2f32..9d1e8400e 100644 --- a/lua/modules/configs/ui/catppuccin.lua +++ b/lua/modules/configs/ui/catppuccin.lua @@ -3,8 +3,7 @@ return function() local clear = {} require("modules.utils").load_plugin("catppuccin", { - flavour = "mocha", -- Can be one of: latte, frappe, macchiato, mocha - background = { light = "latte", dark = "mocha" }, + background = { light = "latte", dark = "mocha" }, -- latte, frappe, macchiato, mocha dim_inactive = { enabled = false, -- Dim inactive splits/windows/buffers. @@ -138,6 +137,9 @@ return function() FidgetTask = { bg = cp.none, fg = cp.surface2 }, FidgetTitle = { fg = cp.blue, style = { "bold" } }, + -- For nvim-notify + NotifyBackground = { bg = cp.base }, + -- For nvim-tree NvimTreeRootFolder = { fg = cp.pink }, NvimTreeIndentMarker = { fg = cp.surface2 }, diff --git a/lua/modules/configs/ui/notify.lua b/lua/modules/configs/ui/notify.lua index 2eacdfb23..a3dd3b6bb 100644 --- a/lua/modules/configs/ui/notify.lua +++ b/lua/modules/configs/ui/notify.lua @@ -1,6 +1,5 @@ return function() local notify = require("notify") - local colors = require("modules.utils").get_palette() local icons = { diagnostics = require("modules.utils.icons").get("diagnostics"), ui = require("modules.utils.icons").get("ui"), @@ -23,7 +22,7 @@ return function() -- Render function for notifications. See notify-render() render = "default", ---@usage highlight behind the window for stages that change opacity - background_colour = colors.base, + background_colour = "NotifyBackground", ---@usage minimum width for notification windows minimum_width = 50, ---@usage notifications with level lower than this would be ignored. [ERROR > WARN > INFO > DEBUG > TRACE] diff --git a/lua/modules/configs/ui/scrollview.lua b/lua/modules/configs/ui/scrollview.lua index 40678d089..d3a821d53 100644 --- a/lua/modules/configs/ui/scrollview.lua +++ b/lua/modules/configs/ui/scrollview.lua @@ -2,7 +2,7 @@ return function() local icons = { diagnostics = require("modules.utils.icons").get("diagnostics", true) } require("modules.utils").load_plugin("scrollview", { - scrollview_mode = "virtual", + mode = "virtual", excluded_filetypes = { "NvimTree", "terminal", "nofile", "aerial" }, winblend = 0, signs_on_startup = { "diagnostics", "folds", "marks", "search", "spell" }, diff --git a/lua/modules/plugins/lang.lua b/lua/modules/plugins/lang.lua index 3d1cb9b2f..d05fe5fee 100644 --- a/lua/modules/plugins/lang.lua +++ b/lua/modules/plugins/lang.lua @@ -12,10 +12,11 @@ lang["ray-x/go.nvim"] = { build = ':lua require("go.install").update_all_sync()', -- if you need to install/update all binaries config = require("lang.go-nvim"), } -lang["simrat39/rust-tools.nvim"] = { +lang["mrcjkb/rustaceanvim"] = { lazy = true, ft = "rust", - config = require("lang.rust-tools"), + version = "^3", + config = require("lang.rust"), dependencies = { "nvim-lua/plenary.nvim" }, } lang["Saecki/crates.nvim"] = { diff --git a/lua/modules/utils/icons.lua b/lua/modules/utils/icons.lua index 8c7c1d635..e3d6ee028 100644 --- a/lua/modules/utils/icons.lua +++ b/lua/modules/utils/icons.lua @@ -79,16 +79,18 @@ local data = { BigCircle = "", BigUnfilledCircle = "", BookMark = "󰃃", + Buffer = "󰓩", Bug = "", Calendar = "", + Character = "", Check = "󰄳", ChevronRight = "", Circle = "", Close = "󰅖", Close_alt = "", CloudDownload = "", - Comment = "󰅺", CodeAction = "󰌵", + Comment = "󰅺", Dashboard = "", Emoji = "󰱫", EmptyFolder = "", diff --git a/lua/modules/utils/init.lua b/lua/modules/utils/init.lua index c1bfe0ace..f430b3311 100644 --- a/lua/modules/utils/init.lua +++ b/lua/modules/utils/init.lua @@ -48,6 +48,10 @@ local function init_palette() callback = function() palette = nil init_palette() + -- Also refresh hard-coded hl groups + M.gen_alpha_hl() + M.gen_lspkind_hl() + pcall(vim.cmd.AlphaRedraw) end, }) end @@ -92,11 +96,26 @@ local function init_palette() end ---@param c string @The color in hexadecimal. -local function hexToRgb(c) +local function hex_to_rgb(c) c = string.lower(c) return { tonumber(c:sub(2, 3), 16), tonumber(c:sub(4, 5), 16), tonumber(c:sub(6, 7), 16) } end +-- NOTE: If the active colorscheme isn't `catppuccin`, this function won't overwrite existing definitions +---Sets a global highlight group. +---@param name string @Highlight group name, e.g. "ErrorMsg" +---@param foreground string @The foreground color +---@param background? string @The background color +---@param italic? boolean +local function set_global_hl(name, foreground, background, italic) + vim.api.nvim_set_hl(0, name, { + fg = foreground, + bg = background, + italic = italic == true, + default = not vim.g.colors_name:find("catppuccin"), + }) +end + ---Blend foreground with background ---@param foreground string @The foreground color ---@param background string @The background color to blend with @@ -104,15 +123,15 @@ end function M.blend(foreground, background, alpha) ---@diagnostic disable-next-line: cast-local-type alpha = type(alpha) == "string" and (tonumber(alpha, 16) / 0xff) or alpha - local bg = hexToRgb(background) - local fg = hexToRgb(foreground) + local bg = hex_to_rgb(background) + local fg = hex_to_rgb(foreground) - local blendChannel = function(i) + local blend_channel = function(i) local ret = (alpha * fg[i] + ((1 - alpha) * bg[i])) return math.floor(math.min(math.max(0, ret), 255) + 0.5) end - return string.format("#%02x%02x%02x", blendChannel(1), blendChannel(2), blendChannel(3)) + return string.format("#%02x%02x%02x", blend_channel(1), blend_channel(2), blend_channel(3)) end ---Get RGB highlight by highlight group @@ -156,7 +175,7 @@ end ---@return palette function M.get_palette(overwrite) if not overwrite then - return init_palette() + return vim.deepcopy(init_palette()) else return vim.tbl_extend("force", init_palette(), overwrite) end @@ -203,7 +222,7 @@ function M.gen_lspkind_hl() } for kind, color in pairs(dat) do - vim.api.nvim_set_hl(0, "LspKind" .. kind, { fg = color, default = true }) + set_global_hl("LspKind" .. kind, color) end end @@ -211,10 +230,10 @@ end function M.gen_alpha_hl() local colors = M.get_palette() - vim.api.nvim_set_hl(0, "AlphaHeader", { fg = colors.blue, default = true }) - vim.api.nvim_set_hl(0, "AlphaButtons", { fg = colors.green, default = true }) - vim.api.nvim_set_hl(0, "AlphaShortcut", { fg = colors.pink, italic = true, default = true }) - vim.api.nvim_set_hl(0, "AlphaFooter", { fg = colors.yellow, default = true }) + set_global_hl("AlphaHeader", colors.blue) + set_global_hl("AlphaButtons", colors.green) + set_global_hl("AlphaShortcut", colors.pink, nil, true) + set_global_hl("AlphaFooter", colors.yellow) end -- Generate blend_color for neodim. From 2dfc8eafb1c52fcdf8f51c95751d5b2080ff4351 Mon Sep 17 00:00:00 2001 From: ayamir Date: Fri, 9 Feb 2024 15:54:39 +0800 Subject: [PATCH 07/72] refactor: use neovim native inlay-hint. Signed-off-by: ayamir --- lua/core/event.lua | 10 ++-- .../configs/completion/inlay-hints.lua | 47 ------------------- lua/modules/plugins/completion.lua | 7 --- 3 files changed, 6 insertions(+), 58 deletions(-) delete mode 100644 lua/modules/configs/completion/inlay-hints.lua diff --git a/lua/core/event.lua b/lua/core/event.lua index cc977f74f..6989cb633 100644 --- a/lua/core/event.lua +++ b/lua/core/event.lua @@ -18,12 +18,14 @@ local mapping = require("keymap.completion") vim.api.nvim_create_autocmd("LspAttach", { group = vim.api.nvim_create_augroup("LspKeymapLoader", { clear = true }), callback = function(event) + if _G._debugging then + return + end + mapping.lsp(event.buf) - local inlay_hints = require("lsp-inlayhints") local client = vim.lsp.get_client_by_id(event.data.client_id) - inlay_hints.on_attach(client, event.buf) - if not _G._debugging then - mapping.lsp(event.buf) + if client ~= nil and client.server_capabilities.inlayHintProvider ~= nil then + vim.lsp.inlay_hint.enable(event.buf, true) end end, }) diff --git a/lua/modules/configs/completion/inlay-hints.lua b/lua/modules/configs/completion/inlay-hints.lua deleted file mode 100644 index e4f49d50d..000000000 --- a/lua/modules/configs/completion/inlay-hints.lua +++ /dev/null @@ -1,47 +0,0 @@ -return function() - -- listed below are the default values - local override = { - inlay_hints = { - parameter_hints = { - show = true, - }, - type_hints = { - show = true, - }, - label_formatter = function(tbl, kind, opts) - if kind == 2 and not opts.parameter_hints.show then - return "" - elseif not opts.type_hints.show then - return "" - end - - return table.concat(tbl, ", ") - end, - virt_text_formatter = function(label, hint, opts, client_name) - if client_name == "lua_ls" then - if hint.kind == 2 then - hint.paddingLeft = false - else - hint.paddingRight = false - end - end - - local vt = {} - vt[#vt + 1] = hint.paddingLeft and { " ", "None" } or nil - vt[#vt + 1] = { label, opts.highlight } - vt[#vt + 1] = hint.paddingRight and { " ", "None" } or nil - - return vt - end, - only_current_line = false, - -- highlight group - highlight = "LspInlayHint", - -- highlight = "Comment", - -- virt_text priority - priority = 0, - }, - enabled_at_startup = true, - debug_mode = false, - } - require("lsp-inlayhints").setup(override) -end diff --git a/lua/modules/plugins/completion.lua b/lua/modules/plugins/completion.lua index d54b16543..d5c2a968d 100644 --- a/lua/modules/plugins/completion.lua +++ b/lua/modules/plugins/completion.lua @@ -12,13 +12,6 @@ completion["neovim/nvim-lspconfig"] = { "Jint-lzxy/lsp_signature.nvim", config = require("completion.lsp-signature"), }, - { - "lvimuser/lsp-inlayhints.nvim", - config = require("completion.inlay-hints"), - lazy = true, - branch = "anticonceal", - event = { "LspAttach" }, - }, }, } completion["nvimdev/lspsaga.nvim"] = { From 9015a873654d1e6d1c02a3868f7f459094ddedc1 Mon Sep 17 00:00:00 2001 From: ayamir Date: Sat, 23 Mar 2024 21:40:01 +0800 Subject: [PATCH 08/72] fix(lsp): adapt to upstream API, eliminate warning. Signed-off-by: ayamir --- lua/modules/configs/completion/mason-lspconfig.lua | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lua/modules/configs/completion/mason-lspconfig.lua b/lua/modules/configs/completion/mason-lspconfig.lua index eb534cbf2..f0c60349d 100644 --- a/lua/modules/configs/completion/mason-lspconfig.lua +++ b/lua/modules/configs/completion/mason-lspconfig.lua @@ -1,5 +1,12 @@ local M = {} +local severity_map = { + ["Error"] = vim.diagnostic.severity.ERROR, + ["Warning"] = vim.diagnostic.severity.WARN, + ["Information"] = vim.diagnostic.severity.INFO, + ["Hint"] = vim.diagnostic.severity.HINT, +} + M.setup = function() local diagnostics_virtual_text = require("core.settings").diagnostics_virtual_text local diagnostics_level = require("core.settings").diagnostics_level @@ -16,7 +23,9 @@ M.setup = function() signs = true, underline = true, virtual_text = diagnostics_virtual_text and { - severity_limit = diagnostics_level, + severity = { + min = severity_map[diagnostics_level], + }, } or false, -- set update_in_insert to false bacause it was enabled by lspsaga update_in_insert = false, From edb72a9c951ead8b6f38b475a48f5c133e207d10 Mon Sep 17 00:00:00 2001 From: ayamir Date: Sat, 23 Mar 2024 21:48:30 +0800 Subject: [PATCH 09/72] fix(plugins): add nvim-bqf. --- lua/modules/plugins/lang.lua | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lua/modules/plugins/lang.lua b/lua/modules/plugins/lang.lua index 80ab2f856..a9558c9f7 100644 --- a/lua/modules/plugins/lang.lua +++ b/lua/modules/plugins/lang.lua @@ -1,5 +1,13 @@ local lang = {} +lang["kevinhwang91/nvim-bqf"] = { + lazy = true, + ft = "qf", + config = require("lang.bqf"), + dependencies = { + { "junegunn/fzf", build = ":call fzf#install()" }, + }, +} lang["ray-x/go.nvim"] = { lazy = true, dependencies = { -- optional packages From 968ae8854174940104a66040058e596b8b99ef64 Mon Sep 17 00:00:00 2001 From: ayamir Date: Tue, 26 Mar 2024 00:04:30 +0800 Subject: [PATCH 10/72] fix(go.nvim): adapt upstream api. --- lua/modules/configs/lang/go-nvim.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/modules/configs/lang/go-nvim.lua b/lua/modules/configs/lang/go-nvim.lua index 2df2f5bde..2193a17d5 100644 --- a/lua/modules/configs/lang/go-nvim.lua +++ b/lua/modules/configs/lang/go-nvim.lua @@ -4,7 +4,7 @@ return function() dap_debug_keymap = false, icons = false, gofmt = "gopls", - goimport = "gopls", + goimports = "gopls", lsp_gofumpt = "true", lsp_inlay_hints = { enable = false }, run_in_floaterm = true, From 698e8c9684d78629697aea32ce2c245cdbaca78a Mon Sep 17 00:00:00 2001 From: ayamir Date: Fri, 29 Mar 2024 23:03:43 +0800 Subject: [PATCH 11/72] feat(plugins): add dropbar.nvim for winbar. Signed-off-by: ayamir --- lua/modules/configs/completion/lspsaga.lua | 2 +- lua/modules/plugins/tool.lua | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/lua/modules/configs/completion/lspsaga.lua b/lua/modules/configs/completion/lspsaga.lua index bca447da0..c31f280b3 100644 --- a/lua/modules/configs/completion/lspsaga.lua +++ b/lua/modules/configs/completion/lspsaga.lua @@ -28,7 +28,7 @@ return function() require("modules.utils").load_plugin("lspsaga", { -- Breadcrumbs: https://nvimdev.github.io/lspsaga/breadcrumbs/ symbol_in_winbar = { - enable = true, + enable = false, separator = " " .. icons.ui.Separator, hide_keyword = false, show_file = false, diff --git a/lua/modules/plugins/tool.lua b/lua/modules/plugins/tool.lua index 63a11cd2e..6e06a7f2f 100644 --- a/lua/modules/plugins/tool.lua +++ b/lua/modules/plugins/tool.lua @@ -11,6 +11,12 @@ tool["tpope/vim-fugitive"] = { -- cond = vim.fn.executable("fcitx5-remote") == 1, -- config = require("tool.fcitx5"), -- } +tool["Bekaboo/dropbar.nvim"] = { + lazy = false, + dependencies = { + "nvim-telescope/telescope-fzf-native.nvim", + }, +} tool["nvim-tree/nvim-tree.lua"] = { lazy = true, cmd = { From f30e5b9cc80d8d51be8baa529a82015e4194f25b Mon Sep 17 00:00:00 2001 From: ayamir Date: Sat, 30 Mar 2024 20:24:56 +0800 Subject: [PATCH 12/72] feat(settings): make enable_inlayhint configurable. Signed-off-by: ayamir --- lua/core/event.lua | 3 ++- lua/core/settings.lua | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/lua/core/event.lua b/lua/core/event.lua index 7ef409908..6f14d9d5f 100644 --- a/lua/core/event.lua +++ b/lua/core/event.lua @@ -23,9 +23,10 @@ vim.api.nvim_create_autocmd("LspAttach", { end mapping.lsp(event.buf) + local enable_inlayhint = require("core.settings").enable_inlayhint local client = vim.lsp.get_client_by_id(event.data.client_id) if client ~= nil and client.server_capabilities.inlayHintProvider ~= nil then - vim.lsp.inlay_hint.enable(event.buf, true) + vim.lsp.inlay_hint.enable(event.buf, enable_inlayhint) end end, }) diff --git a/lua/core/settings.lua b/lua/core/settings.lua index 5a2890cae..54e9ef1fe 100644 --- a/lua/core/settings.lua +++ b/lua/core/settings.lua @@ -213,4 +213,8 @@ settings["dashboard_image"] = { [[⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠉⠉⠛⢿⣿⣿⠂⠀⠀⠀⠀⠀⢀⣽⣿⣿⣿⣿⣿⣿⣿⣍⠛⠿⣿⣿⣿⣿⣿⣿]], } +-- Set it to false if you don't want to show inlay hint +---@type boolean +settings["enable_inlayhint"] = true + return require("modules.utils").extend_config(settings, "user.settings") From 4d6c75341e75ed301db34ab43959f3de752e82d4 Mon Sep 17 00:00:00 2001 From: ayamir Date: Sat, 30 Mar 2024 20:27:28 +0800 Subject: [PATCH 13/72] fixup: check user input, improve robustness. Signed-off-by: ayamir --- lua/core/event.lua | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lua/core/event.lua b/lua/core/event.lua index 6f14d9d5f..2e1e6c443 100644 --- a/lua/core/event.lua +++ b/lua/core/event.lua @@ -25,7 +25,11 @@ vim.api.nvim_create_autocmd("LspAttach", { mapping.lsp(event.buf) local enable_inlayhint = require("core.settings").enable_inlayhint local client = vim.lsp.get_client_by_id(event.data.client_id) - if client ~= nil and client.server_capabilities.inlayHintProvider ~= nil then + if + client ~= nil + and client.server_capabilities.inlayHintProvider ~= nil + and type(enable_inlayhint) == "boolean" + then vim.lsp.inlay_hint.enable(event.buf, enable_inlayhint) end end, From 4574a9768ce7373d56bdcb97e74a8f6236ae0689 Mon Sep 17 00:00:00 2001 From: ayamir Date: Sat, 30 Mar 2024 23:27:17 +0800 Subject: [PATCH 14/72] fix(clangd): disable clangd for proto. Signed-off-by: ayamir --- lua/modules/configs/completion/servers/clangd.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/lua/modules/configs/completion/servers/clangd.lua b/lua/modules/configs/completion/servers/clangd.lua index 7661177af..a11ba56b1 100644 --- a/lua/modules/configs/completion/servers/clangd.lua +++ b/lua/modules/configs/completion/servers/clangd.lua @@ -39,6 +39,7 @@ return function(options) on_attach = options.on_attach, capabilities = vim.tbl_deep_extend("keep", { offsetEncoding = { "utf-16", "utf-8" } }, options.capabilities), single_file_support = true, + filetypes = { "c", "cpp", "objc", "objcpp", "cuda" }, cmd = { "clangd", "-j=12", From 83192357f0ed6e6737ae6379b29d35db490beb7c Mon Sep 17 00:00:00 2001 From: ayamir Date: Sat, 30 Mar 2024 23:53:13 +0800 Subject: [PATCH 15/72] fixup: clean redundant config files. --- lua/modules/configs/lang/rust-tools.lua | 168 ------------------------ lua/modules/configs/lang/vim-go.lua | 7 - 2 files changed, 175 deletions(-) delete mode 100644 lua/modules/configs/lang/rust-tools.lua delete mode 100644 lua/modules/configs/lang/vim-go.lua diff --git a/lua/modules/configs/lang/rust-tools.lua b/lua/modules/configs/lang/rust-tools.lua deleted file mode 100644 index 16a63b973..000000000 --- a/lua/modules/configs/lang/rust-tools.lua +++ /dev/null @@ -1,168 +0,0 @@ -return function() - local opts = { - tools = { -- rust-tools options - - -- how to execute terminal commands - -- options right now: termopen / quickfix - executor = require("rust-tools.executors").termopen, - - -- automatically call RustReloadWorkspace when writing to a Cargo.toml file. - reload_workspace_from_cargo_toml = true, - - -- These apply to the default RustSetInlayHints command - inlay_hints = { - -- automatically set inlay hints (type hints) - -- default: true - auto = false, - - -- Only show inlay hints for the current line - only_current_line = false, - - -- whether to show parameter hints with the inlay hints or not - -- default: true - show_parameter_hints = true, - - -- prefix for parameter hints - -- default: "<-" - parameter_hints_prefix = "<- ", - - -- prefix for all the other hints (type, chaining) - -- default: "=>" - other_hints_prefix = "=> ", - - -- whether to align to the length of the longest line in the file - max_len_align = false, - - -- padding from the left if max_len_align is true - max_len_align_padding = 1, - - -- whether to align to the extreme right or not - right_align = false, - - -- padding from the right if right_align is true - right_align_padding = 7, - - -- The color of the hints - highlight = "Comment", - }, - - -- options same as lsp hover / vim.lsp.util.open_floating_preview() - hover_actions = { - - -- the border that is used for the hover window - -- see vim.api.nvim_open_win() - border = { - { "╭", "FloatBorder" }, - { "─", "FloatBorder" }, - { "╮", "FloatBorder" }, - { "│", "FloatBorder" }, - { "╯", "FloatBorder" }, - { "─", "FloatBorder" }, - { "╰", "FloatBorder" }, - { "│", "FloatBorder" }, - }, - - -- whether the hover action window gets automatically focused - -- default: false - auto_focus = false, - }, - - -- settings for showing the crate graph based on graphviz and the dot - -- command - crate_graph = { - -- Backend used for displaying the graph - -- see: https://graphviz.org/docs/outputs/ - -- default: x11 - backend = "x11", - -- where to store the output, nil for no output stored (relative - -- path from pwd) - -- default: nil - output = nil, - -- true for all crates.io and external crates, false only the local - -- crates - -- default: true - full = true, - - -- List of backends found on: https://graphviz.org/docs/outputs/ - -- Is used for input validation and autocompletion - -- Last updated: 2021-08-26 - enabled_graphviz_backends = { - "bmp", - "cgimage", - "canon", - "dot", - "gv", - "xdot", - "xdot1.2", - "xdot1.4", - "eps", - "exr", - "fig", - "gd", - "gd2", - "gif", - "gtk", - "ico", - "cmap", - "ismap", - "imap", - "cmapx", - "imap_np", - "cmapx_np", - "jpg", - "jpeg", - "jpe", - "jp2", - "json", - "json0", - "dot_json", - "xdot_json", - "pdf", - "pic", - "pct", - "pict", - "plain", - "plain-ext", - "png", - "pov", - "ps", - "ps2", - "psd", - "sgi", - "svg", - "svgz", - "tga", - "tiff", - "tif", - "tk", - "vml", - "vmlz", - "wbmp", - "webp", - "xlib", - "x11", - }, - }, - }, - - -- all the opts to send to nvim-lspconfig - -- these override the defaults set by rust-tools.nvim - -- see https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#rust_analyzer - server = { - -- standalone file support - -- setting it to false may improve startup time - standalone = true, - }, -- rust-analyer options - - -- debugging stuff - dap = { - adapter = { - type = "executable", - command = "lldb-vscode", - name = "rt_lldb", - }, - }, - } - - require("modules.utils").load_plugin("rust-tools", opts) -end diff --git a/lua/modules/configs/lang/vim-go.lua b/lua/modules/configs/lang/vim-go.lua deleted file mode 100644 index f4279e367..000000000 --- a/lua/modules/configs/lang/vim-go.lua +++ /dev/null @@ -1,7 +0,0 @@ -return function() - vim.g.go_doc_keywordprg_enabled = 0 - vim.g.go_def_mapping_enabled = 0 - vim.g.go_code_completion_enabled = 0 - - require("modules.utils").load_plugin("vim-go", nil, true) -end From 28f6de3fea399b392b65f90e590b5bda63898c97 Mon Sep 17 00:00:00 2001 From: ayamir Date: Sat, 30 Mar 2024 23:57:37 +0800 Subject: [PATCH 16/72] fix(gopls): unify gopls config, allow user overrides. --- .../configs/completion/servers/gopls.lua | 8 ++++++ lua/modules/configs/lang/go-nvim.lua | 27 +++---------------- 2 files changed, 11 insertions(+), 24 deletions(-) diff --git a/lua/modules/configs/completion/servers/gopls.lua b/lua/modules/configs/completion/servers/gopls.lua index c5de67868..9f8e1f75f 100644 --- a/lua/modules/configs/completion/servers/gopls.lua +++ b/lua/modules/configs/completion/servers/gopls.lua @@ -11,6 +11,14 @@ return { unusedparams = true, unusewrites = true, }, + hints = { + assignVariableTypes = true, + compositeLiteralFields = true, + constantValues = true, + functionTypeParameters = true, + parameterNames = true, + rangeVariableTypes = true, + }, }, }, } diff --git a/lua/modules/configs/lang/go-nvim.lua b/lua/modules/configs/lang/go-nvim.lua index 2193a17d5..41f72b2d7 100644 --- a/lua/modules/configs/lang/go-nvim.lua +++ b/lua/modules/configs/lang/go-nvim.lua @@ -1,5 +1,5 @@ return function() - require("go").setup({ + require("modules.utils").load_plugin("go", { lsp_keymaps = false, dap_debug_keymap = false, icons = false, @@ -9,28 +9,7 @@ return function() lsp_inlay_hints = { enable = false }, run_in_floaterm = true, trouble = true, - lsp_cfg = { - flags = { debounce_text_changes = 500 }, - cmd = { "gopls", "-remote=auto" }, - settings = { - gopls = { - usePlaceholders = true, - analyses = { - nilness = true, - shadow = true, - unusedparams = true, - unusewrites = true, - }, - hints = { - assignVariableTypes = true, - compositeLiteralFields = true, - constantValues = true, - functionTypeParameters = true, - parameterNames = true, - rangeVariableTypes = true, - }, - }, - }, - }, + lsp_codelens = false, + lsp_cfg = require("modules.configs.completion.servers.gopls"), }) end From d951f77a34154e97ae48ead75bad51fb598c5000 Mon Sep 17 00:00:00 2001 From: ayamir Date: Sat, 30 Mar 2024 23:58:23 +0800 Subject: [PATCH 17/72] fixup: clean code. --- lua/modules/configs/lang/crates-keymap.lua | 41 ++++++++++++---------- 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/lua/modules/configs/lang/crates-keymap.lua b/lua/modules/configs/lang/crates-keymap.lua index 1c07e9ff2..685eff546 100644 --- a/lua/modules/configs/lang/crates-keymap.lua +++ b/lua/modules/configs/lang/crates-keymap.lua @@ -1,16 +1,19 @@ +---@diagnostic disable: undefined-field local bind = require("keymap.bind") local map_callback = bind.map_callback +local crates = require("crates") + local crates_keymap = { ["n|ct"] = map_callback(function() - require("crates").toggle() + crates.toggle() end) :with_noremap() :with_silent() :with_buffer(0) :with_desc("crates: Toggle spec activities"), ["n|cr"] = map_callback(function() - require("crates").reload() + crates.reload() end) :with_noremap() :with_silent() @@ -18,31 +21,31 @@ local crates_keymap = { :with_desc("crates: Reload crate specs"), ["n|cs"] = map_callback(function() - require("crates").show_popup() + crates.show_popup() end) :with_noremap() :with_silent() :with_buffer(0) :with_desc("crates: Toggle pop-up window"), ["n|cv"] = map_callback(function() - require("crates").show_versions_popup() - require("crates").show_popup() + crates.show_versions_popup() + crates.show_popup() end) :with_noremap() :with_silent() :with_buffer(0) :with_desc("crates: Select spec versions"), ["n|cf"] = map_callback(function() - require("crates").show_features_popup() - require("crates").show_popup() + crates.show_features_popup() + crates.show_popup() end) :with_noremap() :with_silent() :with_buffer(0) :with_desc("crates: Select spec features"), ["n|cd"] = map_callback(function() - require("crates").show_dependencies_popup() - require("crates").show_popup() + crates.show_dependencies_popup() + crates.show_popup() end) :with_noremap() :with_silent() @@ -50,42 +53,42 @@ local crates_keymap = { :with_desc("crates: Show project dependencies"), ["n|cu"] = map_callback(function() - require("crates").update_crate() + crates.update_crate() end) :with_noremap() :with_silent() :with_buffer(0) :with_desc("crates: Update current crate's spec"), ["v|cu"] = map_callback(function() - require("crates").update_crates() + crates.update_crates() end) :with_noremap() :with_silent() :with_buffer(0) :with_desc("crates: Update selected crate's spec"), ["n|ca"] = map_callback(function() - require("crates").update_all_crates() + crates.update_all_crates() end) :with_noremap() :with_silent() :with_buffer(0) :with_desc("crates: Update all crates' specs"), ["n|cU"] = map_callback(function() - require("crates").upgrade_crate() + crates.upgrade_crate() end) :with_noremap() :with_silent() :with_buffer(0) :with_desc("crates: Upgrade current crate"), ["v|cU"] = map_callback(function() - require("crates").upgrade_crates() + crates.upgrade_crates() end) :with_noremap() :with_silent() :with_buffer(0) :with_desc("crates: Upgrade selected crates"), ["n|cA"] = map_callback(function() - require("crates").upgrade_all_crates() + crates.upgrade_all_crates() end) :with_noremap() :with_silent() @@ -93,28 +96,28 @@ local crates_keymap = { :with_desc("crates: Upgrade all crates"), ["n|cH"] = map_callback(function() - require("crates").open_homepage() + crates.open_homepage() end) :with_noremap() :with_silent() :with_buffer(0) :with_desc("crates: Open current crate's homepage"), ["n|cR"] = map_callback(function() - require("crates").open_repository() + crates.open_repository() end) :with_noremap() :with_silent() :with_buffer(0) :with_desc("crates: Open current crate's repository"), ["n|cD"] = map_callback(function() - require("crates").open_documentation() + crates.open_documentation() end) :with_noremap() :with_silent() :with_buffer(0) :with_desc("crates: Open current crate's documentation"), ["n|cC"] = map_callback(function() - require("crates").open_crates_io() + crates.open_crates_io() end) :with_noremap() :with_silent() From 48905de4a03bfd62d03dd78a882f7576fea9eeed Mon Sep 17 00:00:00 2001 From: ayamir Date: Sun, 31 Mar 2024 00:09:28 +0800 Subject: [PATCH 18/72] feat(clang_format): enable clang_format for cuda and protobuf. --- lua/modules/configs/completion/null-ls.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/modules/configs/completion/null-ls.lua b/lua/modules/configs/completion/null-ls.lua index 3ff15f54b..9612d58e9 100644 --- a/lua/modules/configs/completion/null-ls.lua +++ b/lua/modules/configs/completion/null-ls.lua @@ -17,7 +17,7 @@ return function() -- Don't specify any config here if you are using the default one. local sources = { btns.formatting.clang_format.with({ - filetypes = { "c", "cpp" }, + filetypes = { "c", "cpp", "cuda", "proto" }, extra_args = formatter_args("clang_format"), }), btns.formatting.prettier.with({ From 9e3beb220dae17e07e46426ef21712ed3e725a48 Mon Sep 17 00:00:00 2001 From: Mythos_404 Date: Sat, 20 Apr 2024 10:53:42 +0800 Subject: [PATCH 19/72] fix: inlay_hint error (#1236) --- lua/core/event.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/core/event.lua b/lua/core/event.lua index 2e1e6c443..b0fda53c1 100644 --- a/lua/core/event.lua +++ b/lua/core/event.lua @@ -30,7 +30,7 @@ vim.api.nvim_create_autocmd("LspAttach", { and client.server_capabilities.inlayHintProvider ~= nil and type(enable_inlayhint) == "boolean" then - vim.lsp.inlay_hint.enable(event.buf, enable_inlayhint) + vim.lsp.inlay_hint.enable(enable_inlayhint, { bufnr = event.buf }) end end, }) From ce8c31e08e34bda76a7c1f3c712fb3dcc42c05e7 Mon Sep 17 00:00:00 2001 From: ayamir Date: Mon, 20 May 2024 09:41:18 +0800 Subject: [PATCH 20/72] Merge remote-tracking branch 'origin' into 0.10 --- .github/ISSUE_TEMPLATE/bug_report.yml | 2 + .github/ISSUE_TEMPLATE/custom_config.yml | 3 +- .github/ISSUE_TEMPLATE/lsp_issue_report.yml | 2 + .github/workflows/update_flake.yml | 28 +++ .gitignore | 1 + .nixd.json | 7 + README.md | 3 + flake.lock | 154 ++++++++++++ flake.nix | 101 +++++++- lua/core/options.lua | 2 - lua/core/settings.lua | 3 +- lua/keymap/completion.lua | 6 +- lua/keymap/editor.lua | 30 ++- lua/keymap/tool.lua | 2 +- lua/keymap/ui.lua | 2 +- lua/modules/configs/completion/cmp.lua | 12 +- .../configs/completion/mason-lspconfig.lua | 2 +- lua/modules/configs/completion/neoconf.lua | 29 +-- .../configs/completion/servers/gopls.lua | 48 +++- .../configs/completion/servers/lua_ls.lua | 2 +- lua/modules/configs/editor/align.lua | 11 + .../configs/editor/local-highlight.lua | 7 +- lua/modules/configs/editor/mini-align.lua | 8 - lua/modules/configs/editor/smart-splits.lua | 92 ------- lua/modules/configs/editor/splits.lua | 14 ++ lua/modules/configs/lang/go.lua | 21 ++ lua/modules/configs/tool/nvim-tree.lua | 4 + lua/modules/configs/tool/smartyank.lua | 24 ++ lua/modules/configs/tool/toggleterm.lua | 14 +- lua/modules/configs/ui/catppuccin.lua | 4 +- lua/modules/configs/ui/lualine.lua | 3 +- lua/modules/configs/ui/todo.lua | 43 ++++ lua/modules/plugins/completion.lua | 2 +- lua/modules/plugins/editor.lua | 13 +- lua/modules/plugins/lang.lua | 14 +- lua/modules/plugins/tool.lua | 5 + lua/modules/plugins/ui.lua | 5 +- lua/modules/utils/init.lua | 2 +- nixos/neovim/default.nix | 238 ++++++++++-------- nixos/testEnv.nix | 34 +++ 40 files changed, 694 insertions(+), 303 deletions(-) create mode 100644 .github/workflows/update_flake.yml create mode 100644 .nixd.json create mode 100644 flake.lock create mode 100644 lua/modules/configs/editor/align.lua delete mode 100644 lua/modules/configs/editor/mini-align.lua delete mode 100644 lua/modules/configs/editor/smart-splits.lua create mode 100644 lua/modules/configs/editor/splits.lua create mode 100644 lua/modules/configs/lang/go.lua create mode 100644 lua/modules/configs/tool/smartyank.lua create mode 100644 lua/modules/configs/ui/todo.lua create mode 100644 nixos/testEnv.nix diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml index 0be5fc518..5c0f3fff4 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -6,6 +6,8 @@ body: attributes: value: | _Before reporting:_ Search [existing issues](https://github.com/ayamir/nvimdots/issues) and check the [FAQ](https://github.com/ayamir/nvimdots/wiki/Issues). Thank you for helping us improve! + > [!IMPORTANT] + > The `0.10` branch is intended for nightly neovim builds and is **not** stable. It typically harbors subtle issues scattered throughout. Therefore, refrain from submitting issues if you happen to encounter them. They will be closed directly unless a viable solution is proposed or included. - type: checkboxes id: is-latest-commit attributes: diff --git a/.github/ISSUE_TEMPLATE/custom_config.yml b/.github/ISSUE_TEMPLATE/custom_config.yml index 04eb02719..d3dc98dd2 100644 --- a/.github/ISSUE_TEMPLATE/custom_config.yml +++ b/.github/ISSUE_TEMPLATE/custom_config.yml @@ -6,7 +6,8 @@ body: attributes: value: | _Before requesting:_ Make sure you've read through our [Wiki: Usage](https://github.com/ayamir/nvimdots/wiki/Usage) before you start to add things to nvimdots! - + > [!IMPORTANT] + > The `0.10` branch is intended for nightly neovim builds and is **not** stable. It typically harbors subtle issues scattered throughout. Therefore, refrain from submitting issues if you happen to encounter them. They will be closed directly unless a viable solution is proposed or included. - type: checkboxes id: is-latest-commit attributes: diff --git a/.github/ISSUE_TEMPLATE/lsp_issue_report.yml b/.github/ISSUE_TEMPLATE/lsp_issue_report.yml index 068800536..519b0e6de 100644 --- a/.github/ISSUE_TEMPLATE/lsp_issue_report.yml +++ b/.github/ISSUE_TEMPLATE/lsp_issue_report.yml @@ -6,6 +6,8 @@ body: attributes: value: | _Before reporting:_ Search [existing issues](https://github.com/ayamir/nvimdots/issues) and check the [FAQ](https://github.com/ayamir/nvimdots/wiki/Issues). Thank you for helping us improve! + > [!IMPORTANT] + > The `0.10` branch is intended for nightly neovim builds and is **not** stable. It typically harbors subtle issues scattered throughout. Therefore, refrain from submitting issues if you happen to encounter them. They will be closed directly unless a viable solution is proposed or included. - type: checkboxes id: is-latest-commit attributes: diff --git a/.github/workflows/update_flake.yml b/.github/workflows/update_flake.yml new file mode 100644 index 000000000..88090f3b7 --- /dev/null +++ b/.github/workflows/update_flake.yml @@ -0,0 +1,28 @@ +name: update flake.lock +on: + # Scheduled update (1st of every month) + schedule: [{ cron: "30 02 1 * *" }] + +jobs: + update-lockfile: + if: github.repository_owner == 'ayamir' + runs-on: ubuntu-latest + permissions: + contents: write + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 # Required to count the commits + - uses: cachix/install-nix-action@v26 + with: + nix_path: nixpkgs=channel:nixos-unstable + - name: Run flake-update + run: | + nix flake update + - uses: stefanzweifel/git-auto-commit-action@v5 + with: + commit_message: "chore(lockfile): auto update flake.lock" + commit_user_name: "github-actions[bot]" + commit_user_email: "41898282+github-actions[bot]@users.noreply.github.com" + commit_author: "github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>" + file_pattern: "flake.lock" diff --git a/.gitignore b/.gitignore index 8dec07754..51c6018f4 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ lua/modules/plugins/custom.lua lua/modules/configs/custom lua/user +result diff --git a/.nixd.json b/.nixd.json new file mode 100644 index 000000000..f8bee3e2e --- /dev/null +++ b/.nixd.json @@ -0,0 +1,7 @@ +{ + "formatting": { + "command": [ + "nixpkgs-fmt" + ] + } +} diff --git a/README.md b/README.md index 894b7bfa0..05390439a 100644 --- a/README.md +++ b/README.md @@ -51,6 +51,9 @@ Branch info: +> [!IMPORTANT] +> The `0.10` branch is intended for nightly neovim builds and is **not** stable. It typically harbors subtle issues scattered throughout. Therefore, refrain from submitting issues if you happen to encounter them. They will be closed directly unless a viable solution is proposed or included. + We currently manage plugins using [lazy.nvim](https://github.com/folke/lazy.nvim). Chinese introduction is [here](https://zhuanlan.zhihu.com/p/382092667). diff --git a/flake.lock b/flake.lock new file mode 100644 index 000000000..d864abbba --- /dev/null +++ b/flake.lock @@ -0,0 +1,154 @@ +{ + "nodes": { + "devshell": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs" + }, + "locked": { + "lastModified": 1713532798, + "narHash": "sha256-wtBhsdMJA3Wa32Wtm1eeo84GejtI43pMrFrmwLXrsEc=", + "owner": "numtide", + "repo": "devshell", + "rev": "12e914740a25ea1891ec619bb53cf5e6ca922e40", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "devshell", + "type": "github" + } + }, + "flake-parts": { + "inputs": { + "nixpkgs-lib": "nixpkgs-lib" + }, + "locked": { + "lastModified": 1712014858, + "narHash": "sha256-sB4SWl2lX95bExY2gMFG5HIzvva5AVMJd4Igm+GpZNw=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "9126214d0a59633752a136528f5f3b9aa8565b7d", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "flake-parts", + "type": "github" + } + }, + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1701680307, + "narHash": "sha256-kAuep2h5ajznlPMD9rnQyffWG8EM/C73lejGofXvdM8=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "4022d587cbbfd70fe950c1e2083a02621806a725", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "home-manager": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1714377222, + "narHash": "sha256-UsDsjWCKlWn8vbXi8Zza9Hkq3xyk8fpvFNo2VM5S74E=", + "owner": "nix-community", + "repo": "home-manager", + "rev": "2af7c78b7bb9cf18406a193eba13ef9f99388f49", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "home-manager", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1704161960, + "narHash": "sha256-QGua89Pmq+FBAro8NriTuoO/wNaUtugt29/qqA8zeeM=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "63143ac2c9186be6d9da6035fa22620018c85932", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-lib": { + "locked": { + "dir": "lib", + "lastModified": 1711703276, + "narHash": "sha256-iMUFArF0WCatKK6RzfUJknjem0H9m4KgorO/p3Dopkk=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "d8fe5e6c92d0d190646fb9f1056741a229980089", + "type": "github" + }, + "original": { + "dir": "lib", + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_2": { + "locked": { + "lastModified": 1714280680, + "narHash": "sha256-eNTZCX/vK/BQOpY+6n5a6oGxBBe7qfSbtcppepCLAAQ=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "9516f3c963708933abe984df94a925af38916237", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "devshell": "devshell", + "flake-parts": "flake-parts", + "home-manager": "home-manager", + "nixpkgs": "nixpkgs_2" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix index 77e2746db..f24cfc588 100644 --- a/flake.nix +++ b/flake.nix @@ -4,11 +4,102 @@ # because "doq" is not included in the stable version. description = "Provide nixosModules for ayamir/nvimdots"; - inputs = { }; - - outputs = inputs: { - nixosModules = { - nvimdots = ./nixos; + inputs = { + flake-parts.url = "github:hercules-ci/flake-parts"; + devshell.url = "github:numtide/devshell"; + nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable"; + home-manager = { + url = "github:nix-community/home-manager"; + inputs.nixpkgs.follows = "nixpkgs"; }; }; + + outputs = inputs @ { self, flake-parts, ... }: + flake-parts.lib.mkFlake { inherit inputs; } + { + imports = [ + inputs.devshell.flakeModule + ]; + flake = { + homeManagerModules = { + nvimdots = ./nixos; + }; + }; + systems = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ]; + perSystem = { pkgs, system, ... }: { + packages = { + testEnv = (import ./nixos/testEnv.nix { inherit inputs pkgs; }).activationPackage; + check-linker = pkgs.writeShellApplication { + name = "check-linker"; + text = + let + ldd_cmd = if pkgs.stdenv.isDarwin then "otool -L" else "${pkgs.glibc.bin}/bin/ldd"; + in + '' + #shellcheck disable=SC1090 + source <(sed -ne :1 -e 'N;1,1b1' -e 'P;D' "${self.packages.${system}.testEnv}/home-path/bin/nvim") + echo "check file under ''${XDG_DATA_HOME}/''${NVIM_APPNAME:-nvim}/mason/bin" + find "''${XDG_DATA_HOME}/''${NVIM_APPNAME:-nvim}/mason/bin" -type l | while read -r link; do + "${ldd_cmd}" "$(readlink -f "$link")" > /dev/zero 2>&1 || continue + linkers=$("${ldd_cmd}" "$(readlink -f "$link")" | tail -n+2) + echo "$linkers" | while read -r line; do + [ -z "$line" ] && continue + echo "$line" | grep -q "/nix/store" || printf '%s: %s do not link to /nix/store \n' "$(basename "$link")" "$line" + done + done + echo "check done" + ''; + }; + }; + devshells.default = { + commands = [ + { + help = "neovim linked to testEnv."; + name = "nvim"; + command = '' + ${self.packages.${system}.testEnv}/home-path/bin/nvim + ''; + } + { + help = "check-linker"; + package = self.packages.${system}.check-linker; + } + ]; + devshell = { + motd = '' + {202}🔨 Welcome to devshell{reset} + Symlink configs to "''${XDG_CONFIG_HOME}"/nvimdots! + And NVIM_APPNAME=nvimdots is already configured, so neovim will put file under "\$XDG_xxx_HOME"/nvimdots. + To uninstall, remove "\$XDG_xxx_HOME"/nvimdots. + + $(type -p menu &>/dev/null && menu) + ''; + startup = { + mkNvimDir = { + text = '' + mkdir -p "''${XDG_CONFIG_HOME}"/nvimdots + for path in lazy-lock.json init.lua lua snips tutor; do + ln -sf "''${PWD}/''${path}" "''${XDG_CONFIG_HOME}"/nvimdots/ + done + ''; + }; + }; + }; + env = [ + { + name = "NVIM_APPNAME"; + value = "nvimdots"; + } + { + name = "PATH"; + prefix = "${self.packages.${system}.testEnv}/home-path/bin"; + } + ]; + packages = with pkgs; [ + nixd + nixpkgs-fmt + ]; + }; + }; + }; } diff --git a/lua/core/options.lua b/lua/core/options.lua index efbd90129..b3b3e0295 100644 --- a/lua/core/options.lua +++ b/lua/core/options.lua @@ -28,7 +28,6 @@ local function load_options() encoding = "utf-8", equalalways = false, errorbells = true, - expandtab = true, fileformats = "unix,mac,dos", foldenable = true, foldlevelstart = 99, @@ -71,7 +70,6 @@ local function load_options() signcolumn = "yes", smartcase = true, smarttab = true, - softtabstop = 4, splitbelow = true, splitkeep = "screen", splitright = true, diff --git a/lua/core/settings.lua b/lua/core/settings.lua index 54e9ef1fe..f2f6756c9 100644 --- a/lua/core/settings.lua +++ b/lua/core/settings.lua @@ -106,7 +106,7 @@ settings["lsp_deps"] = { "jsonls", "lua_ls", "pylsp", - -- "gopls", + "gopls", } -- Set the general-purpose servers that will be installed during bootstrap here. @@ -148,6 +148,7 @@ settings["treesitter_deps"] = { "html", "javascript", "json", + "jsonc", "latex", "lua", "make", diff --git a/lua/keymap/completion.lua b/lua/keymap/completion.lua index 23e81b2bc..ae67e2aad 100644 --- a/lua/keymap/completion.lua +++ b/lua/keymap/completion.lua @@ -4,7 +4,7 @@ local map_cmd = bind.map_cmd local map_callback = bind.map_callback local plug_map = { - ["n|"] = map_cmd("FormatToggle"):with_noremap():with_desc("Formater: Toggle format on save"), + ["n|"] = map_cmd("FormatToggle"):with_noremap():with_desc("formatter: Toggle format on save"), } bind.nvim_load_mapping(plug_map) @@ -50,6 +50,10 @@ function mapping.lsp(buf) ["n|gd"] = map_cr("Glance definitions"):with_silent():with_buffer(buf):with_desc("lsp: Preview definition"), ["n|gD"] = map_cr("Lspsaga goto_definition"):with_silent():with_buffer(buf):with_desc("lsp: Goto definition"), ["n|gh"] = map_cr("Glance references"):with_silent():with_buffer(buf):with_desc("lsp: Show reference"), + ["n|gm"] = map_cr("Glance implementations") + :with_silent() + :with_buffer(buf) + :with_desc("lsp: Show implementation"), ["n|gci"] = map_cr("Lspsaga incoming_calls") :with_silent() :with_buffer(buf) diff --git a/lua/keymap/editor.lua b/lua/keymap/editor.lua index 76845a616..9b0271cee 100644 --- a/lua/keymap/editor.lua +++ b/lua/keymap/editor.lua @@ -68,28 +68,36 @@ local plug_map = { ["n|"] = map_cu("SmartCursorMoveDown"):with_silent():with_noremap():with_desc("window: Focus down"), ["n|"] = map_cu("SmartCursorMoveUp"):with_silent():with_noremap():with_desc("window: Focus up"), ["n|"] = map_cu("SmartCursorMoveRight"):with_silent():with_noremap():with_desc("window: Focus right"), - ["n|Wh"] = map_cu("SmartSwapLeft"):with_silent():with_noremap():with_desc("window: Move window to left"), - ["n|Wj"] = map_cu("SmartSwapDown"):with_silent():with_noremap():with_desc("window: Move window to down"), - ["n|Wk"] = map_cu("SmartSwapUp"):with_silent():with_noremap():with_desc("window: Move window to up"), - ["n|Wl"] = map_cu("SmartSwapRight"):with_silent():with_noremap():with_desc("window: Move window to right"), + ["n|Wh"] = map_cu("SmartSwapLeft"):with_silent():with_noremap():with_desc("window: Move window leftward"), + ["n|Wj"] = map_cu("SmartSwapDown"):with_silent():with_noremap():with_desc("window: Move window downward"), + ["n|Wk"] = map_cu("SmartSwapUp"):with_silent():with_noremap():with_desc("window: Move window upward"), + ["n|Wl"] = map_cu("SmartSwapRight"):with_silent():with_noremap():with_desc("window: Move window rightward"), -- Plugin: nvim-spectre - ["n|Ss"] = map_cmd([[lua require("spectre").toggle()]]) + ["n|Ss"] = map_callback(function() + require("spectre").toggle() + end) :with_silent() :with_noremap() - :with_desc("editn: Toggle search&replace panel"), - ["n|Sp"] = map_cmd([[lua require("spectre").open_visual({select_word=true})]]) + :with_desc("editn: Toggle search & replace panel"), + ["n|Sp"] = map_callback(function() + require("spectre").open_visual({ select_word = true }) + end) :with_silent() :with_noremap() :with_desc("editn: search&replace current word (project)"), - ["v|Sp"] = map_cmd([[lua require("spectre").open_visual()]]) + ["v|Sp"] = map_callback(function() + require("spectre").open_visual() + end) :with_silent() :with_noremap() - :with_desc("edit: search&replace current word (project)"), - ["n|Sf"] = map_cmd([[lua require("spectre").open_file_search({select_word=true})]]) + :with_desc("edit: search & replace current word (project)"), + ["n|Sf"] = map_callback(function() + require("spectre").open_file_search({ select_word = true }) + end) :with_silent() :with_noremap() - :with_desc("editn: search&replace current word (file)"), + :with_desc("editn: search & replace current word (file)"), -- Plugin: nvim-treehopper ["o|m"] = map_cu("lua require('tsht').nodes()"):with_silent():with_desc("jump: Operate across syntax tree"), diff --git a/lua/keymap/tool.lua b/lua/keymap/tool.lua index 9ec29a30d..6eebff316 100644 --- a/lua/keymap/tool.lua +++ b/lua/keymap/tool.lua @@ -129,7 +129,7 @@ local plug_map = { ["n|fz"] = map_cu("Telescope zoxide list") :with_noremap() :with_silent() - :with_desc("edit: Change current direrctory by zoxide"), + :with_desc("edit: Change current directory by zoxide"), ["n|fb"] = map_cu("Telescope buffers"):with_noremap():with_silent():with_desc("find: Buffer opened"), ["n|fs"] = map_cu("Telescope grep_string"):with_noremap():with_silent():with_desc("find: Current word"), ["v|fs"] = map_callback(function() diff --git a/lua/keymap/ui.lua b/lua/keymap/ui.lua index d45efe812..77df22d2a 100644 --- a/lua/keymap/ui.lua +++ b/lua/keymap/ui.lua @@ -11,7 +11,7 @@ local plug_map = { ["n|"] = map_cr("BufferLineMoveNext"):with_noremap():with_silent():with_desc("buffer: Move current to next"), ["n|"] = map_cr("BufferLineMovePrev"):with_noremap():with_silent():with_desc("buffer: Move current to prev"), ["n|be"] = map_cr("BufferLineSortByExtension"):with_noremap():with_desc("buffer: Sort by extension"), - ["n|bd"] = map_cr("BufferLineSortByDirectory"):with_noremap():with_desc("buffer: Sort by direrctory"), + ["n|bd"] = map_cr("BufferLineSortByDirectory"):with_noremap():with_desc("buffer: Sort by directory"), ["n|"] = map_cr("BufferLineGoToBuffer 1"):with_noremap():with_silent():with_desc("buffer: Goto buffer 1"), ["n|"] = map_cr("BufferLineGoToBuffer 2"):with_noremap():with_silent():with_desc("buffer: Goto buffer 2"), ["n|"] = map_cr("BufferLineGoToBuffer 3"):with_noremap():with_silent():with_desc("buffer: Goto buffer 3"), diff --git a/lua/modules/configs/completion/cmp.lua b/lua/modules/configs/completion/cmp.lua index c8e058ec3..0d926e0ee 100644 --- a/lua/modules/configs/completion/cmp.lua +++ b/lua/modules/configs/completion/cmp.lua @@ -1,4 +1,3 @@ ----@diagnostic disable: undefined-field return function() local icons = { kind = require("modules.utils.icons").get("kind"), @@ -67,7 +66,7 @@ return function() local cmp = require("cmp") require("modules.utils").load_plugin("cmp", { - preselect = cmp.PreselectMode.Item, + preselect = cmp.PreselectMode.None, window = { completion = { border = border("PmenuBorder"), @@ -168,7 +167,14 @@ return function() { name = "spell" }, { name = "tmux" }, { name = "orgmode" }, - { name = "buffer" }, + { + name = "buffer", + option = { + get_bufnrs = function() + return vim.api.nvim_list_bufs() + end, + }, + }, { name = "latex_symbols" }, { name = "copilot" }, -- { name = "codeium" }, diff --git a/lua/modules/configs/completion/mason-lspconfig.lua b/lua/modules/configs/completion/mason-lspconfig.lua index f0c60349d..8a9469d2b 100644 --- a/lua/modules/configs/completion/mason-lspconfig.lua +++ b/lua/modules/configs/completion/mason-lspconfig.lua @@ -27,7 +27,7 @@ M.setup = function() min = severity_map[diagnostics_level], }, } or false, - -- set update_in_insert to false bacause it was enabled by lspsaga + -- set update_in_insert to false because it was enabled by lspsaga update_in_insert = false, }) diff --git a/lua/modules/configs/completion/neoconf.lua b/lua/modules/configs/completion/neoconf.lua index 4deef7695..4db9cc75f 100644 --- a/lua/modules/configs/completion/neoconf.lua +++ b/lua/modules/configs/completion/neoconf.lua @@ -2,6 +2,8 @@ local M = {} M.setup = function() require("modules.utils").load_plugin("neoconf", { + -- send new configuration to lsp clients when changing json settings + live_reload = true, -- name of the local settings files local_settings = ".neoconf.json", -- name of the global settings file in your Neovim config directory @@ -12,33 +14,6 @@ M.setup = function() coc = true, -- global/local coc-settings.json nlsp = true, -- global/local nlsp-settings.nvim json settings }, - -- send new configuration to lsp clients when changing json settings - live_reload = true, - -- set the filetype to jsonc for settings files, so you can use comments - -- make sure you have the jsonc treesitter parser installed! - filetype_jsonc = true, - plugins = { - -- configures lsp clients with settings in the following order: - -- - lua settings passed in lspconfig setup - -- - global json settings - -- - local json settings - lspconfig = { - enabled = true, - }, - -- configures jsonls to get completion in .nvim.settings.json files - jsonls = { - enabled = true, - -- only show completion in json settings for configured lsp servers - configured_servers_only = true, - }, - -- configures lua_ls to get completion of lspconfig server settings - lua_ls = { - -- by default, lua_ls annotations are only enabled in your neovim config directory - enabled_for_neovim_config = true, - -- explicitely enable adding annotations. Mostly relevant to put in your local .nvim.settings.json file - enabled = false, - }, - }, }) end diff --git a/lua/modules/configs/completion/servers/gopls.lua b/lua/modules/configs/completion/servers/gopls.lua index 9f8e1f75f..c2993a7b7 100644 --- a/lua/modules/configs/completion/servers/gopls.lua +++ b/lua/modules/configs/completion/servers/gopls.lua @@ -1,15 +1,49 @@ -- https://github.com/neovim/nvim-lspconfig/blob/master/lua/lspconfig/server_configurations/gopls.lua return { - flags = { debounce_text_changes = 500 }, - cmd = { "gopls", "-remote=auto" }, + cmd = { "gopls", "-remote.debug=:0", "-remote=auto" }, + filetypes = { "go", "gomod", "gosum", "gotmpl", "gohtmltmpl", "gotexttmpl" }, + flags = { allow_incremental_sync = true, debounce_text_changes = 500 }, + capabilities = { + textDocument = { + completion = { + contextSupport = true, + dynamicRegistration = true, + completionItem = { + commitCharactersSupport = true, + deprecatedSupport = true, + preselectSupport = true, + insertReplaceSupport = true, + labelDetailsSupport = true, + snippetSupport = true, + documentationFormat = { "markdown", "plaintext" }, + resolveSupport = { + properties = { + "documentation", + "details", + "additionalTextEdits", + }, + }, + }, + }, + }, + }, settings = { gopls = { + staticcheck = true, + semanticTokens = true, + noSemanticString = true, usePlaceholders = true, - analyses = { - nilness = true, - shadow = true, - unusedparams = true, - unusewrites = true, + completeUnimported = true, + symbolMatcher = "Fuzzy", + buildFlags = { "-tags", "integration" }, + codelenses = { + generate = true, + gc_details = true, + test = true, + tidy = true, + vendor = true, + regenerate_cgo = true, + upgrade_dependency = true, }, hints = { assignVariableTypes = true, diff --git a/lua/modules/configs/completion/servers/lua_ls.lua b/lua/modules/configs/completion/servers/lua_ls.lua index 06e1d4436..4afa72c1f 100644 --- a/lua/modules/configs/completion/servers/lua_ls.lua +++ b/lua/modules/configs/completion/servers/lua_ls.lua @@ -7,7 +7,7 @@ return { }, diagnostics = { globals = { "vim" }, - disable = { "different-requires" }, + disable = { "different-requires", "undefined-field" }, }, workspace = { library = { diff --git a/lua/modules/configs/editor/align.lua b/lua/modules/configs/editor/align.lua new file mode 100644 index 000000000..43c50d8dc --- /dev/null +++ b/lua/modules/configs/editor/align.lua @@ -0,0 +1,11 @@ +return function() + require("modules.utils").load_plugin("mini.align", { + -- Whether to disable showing non-error feedback + silent = false, + -- Module mappings. Use `''` (empty string) to disable one. + mappings = { + start = "gea", + start_with_preview = "geA", + }, + }) +end diff --git a/lua/modules/configs/editor/local-highlight.lua b/lua/modules/configs/editor/local-highlight.lua index 022440396..f8c001f3d 100644 --- a/lua/modules/configs/editor/local-highlight.lua +++ b/lua/modules/configs/editor/local-highlight.lua @@ -1,11 +1,6 @@ return function() require("modules.utils").load_plugin("local-highlight", { - file_types = nil, - hlgroup = "Search", - cw_hlgroup = nil, - -- Whether to display highlights in INSERT mode or not + hlgroup = "IlluminatedWordText", insert_mode = false, - min_match_len = 1, - max_match_len = math.huge, }) end diff --git a/lua/modules/configs/editor/mini-align.lua b/lua/modules/configs/editor/mini-align.lua deleted file mode 100644 index 4cbf7fed6..000000000 --- a/lua/modules/configs/editor/mini-align.lua +++ /dev/null @@ -1,8 +0,0 @@ -return function() - require("mini.align").setup({ - mappings = { - start = "gea", - start_with_preview = "geA", - }, - }) -end diff --git a/lua/modules/configs/editor/smart-splits.lua b/lua/modules/configs/editor/smart-splits.lua deleted file mode 100644 index 3ea0ceb44..000000000 --- a/lua/modules/configs/editor/smart-splits.lua +++ /dev/null @@ -1,92 +0,0 @@ -return function() - require("modules.utils").load_plugin("smart-splits", { - -- Ignored buffer types (only while resizing) - ignored_buftypes = { - "nofile", - "quickfix", - "prompt", - }, - -- Ignored filetypes (only while resizing) - ignored_filetypes = { "NvimTree" }, - -- the default number of lines/columns to resize by at a time - default_amount = 3, - -- Desired behavior when your cursor is at an edge and you - -- are moving towards that same edge: - -- 'wrap' => Wrap to opposite side - -- 'split' => Create a new split in the desired direction - -- 'stop' => Do nothing - -- function => You handle the behavior yourself - -- NOTE: If using a function, the function will be called with - -- a context object with the following fields: - -- { - -- mux = { - -- type:'tmux'|'wezterm'|'kitty' - -- current_pane_id():number, - -- is_in_session(): boolean - -- current_pane_is_zoomed():boolean, - -- -- following methods return a boolean to indicate success or failure - -- current_pane_at_edge(direction:'left'|'right'|'up'|'down'):boolean - -- next_pane(direction:'left'|'right'|'up'|'down'):boolean - -- resize_pane(direction:'left'|'right'|'up'|'down'):boolean - -- split_pane(direction:'left'|'right'|'up'|'down',size:number|nil):boolean - -- }, - -- direction = 'left'|'right'|'up'|'down', - -- split(), -- utility function to split current Neovim pane in the current direction - -- wrap(), -- utility function to wrap to opposite Neovim pane - -- } - -- NOTE: `at_edge = 'wrap'` is not supported on Kitty terminal - -- multiplexer, as there is no way to determine layout via the CLI - at_edge = "wrap", - -- when moving cursor between splits left or right, - -- place the cursor on the same row of the *screen* - -- regardless of line numbers. False by default. - -- Can be overridden via function parameter, see Usage. - move_cursor_same_row = false, - -- whether the cursor should follow the buffer when swapping - -- buffers by default; it can also be controlled by passing - -- `{ move_cursor = true }` or `{ move_cursor = false }` - -- when calling the Lua function. - cursor_follows_swapped_bufs = false, - -- resize mode options - resize_mode = { - -- key to exit persistent resize mode - quit_key = "", - -- keys to use for moving in resize mode - -- in order of left, down, up' right - resize_keys = { "h", "j", "k", "l" }, - -- set to true to silence the notifications - -- when entering/exiting persistent resize mode - silent = false, - -- must be functions, they will be executed when - -- entering or exiting the resize mode - hooks = { - on_enter = nil, - on_leave = nil, - }, - }, - -- ignore these autocmd events (via :h eventignore) while processing - -- smart-splits.nvim computations, which involve visiting different - -- buffers and windows. These events will be ignored during processing, - -- and un-ignored on completed. This only applies to resize events, - -- not cursor movement events. - ignored_events = { - "BufEnter", - "WinEnter", - }, - -- enable or disable a multiplexer integration; - -- automatically determined, unless explicitly disabled or set, - -- by checking the $TERM_PROGRAM environment variable, - -- and the $KITTY_LISTEN_ON environment variable for Kitty - multiplexer_integration = "tmux", - -- disable multiplexer navigation if current multiplexer pane is zoomed - -- this functionality is only supported on tmux and Wezterm due to kitty - -- not having a way to check if a pane is zoomed - disable_multiplexer_nav_when_zoomed = true, - -- Supply a Kitty remote control password if needed, - -- or you can also set vim.g.smart_splits_kitty_password - -- see https://sw.kovidgoyal.net/kitty/conf/#opt-kitty.remote_control_password - kitty_password = nil, - -- default logging level, one of: 'trace'|'debug'|'info'|'warn'|'error'|'fatal' - log_level = "info", - }) -end diff --git a/lua/modules/configs/editor/splits.lua b/lua/modules/configs/editor/splits.lua new file mode 100644 index 000000000..891d01eaf --- /dev/null +++ b/lua/modules/configs/editor/splits.lua @@ -0,0 +1,14 @@ +return function() + require("modules.utils").load_plugin("smart-splits", { + -- Ignored buffer types (only while resizing) + ignored_buftypes = { + "nofile", + "quickfix", + "prompt", + }, + -- Ignored filetypes (only while resizing) + ignored_filetypes = { "NvimTree" }, + -- the default number of lines/columns to resize by at a time + default_amount = 3, + }) +end diff --git a/lua/modules/configs/lang/go.lua b/lua/modules/configs/lang/go.lua new file mode 100644 index 000000000..8ca7b03de --- /dev/null +++ b/lua/modules/configs/lang/go.lua @@ -0,0 +1,21 @@ +return function() + require("modules.utils").load_plugin("go", { + -- By default, we've turned off these options to prevent clashes with our gopls config + icons = false, + diagnostic = false, + lsp_cfg = false, + lsp_gofumpt = false, + lsp_keymaps = false, + lsp_codelens = false, + lsp_document_formatting = false, + lsp_inlay_hints = { enable = false }, + -- DAP-related settings are also turned off here for the same reason + dap_debug = false, + dap_debug_keymap = false, + textobjects = false, + -- Miscellaneous options to seamlessly integrate with other plugins + trouble = true, + luasnip = false, + run_in_floaterm = false, + }) +end diff --git a/lua/modules/configs/tool/nvim-tree.lua b/lua/modules/configs/tool/nvim-tree.lua index c799629c8..3f6f64112 100644 --- a/lua/modules/configs/tool/nvim-tree.lua +++ b/lua/modules/configs/tool/nvim-tree.lua @@ -17,6 +17,10 @@ return function() respect_buf_cwd = false, sort_by = "name", sync_root_with_cwd = true, + on_attach = function(bufnr) + require("nvim-tree.api").config.mappings.default_on_attach(bufnr) + vim.keymap.del("n", "", { buffer = bufnr }) + end, view = { adaptive_size = false, centralize_selection = false, diff --git a/lua/modules/configs/tool/smartyank.lua b/lua/modules/configs/tool/smartyank.lua new file mode 100644 index 000000000..551ae6fab --- /dev/null +++ b/lua/modules/configs/tool/smartyank.lua @@ -0,0 +1,24 @@ +return function() + require("modules.utils").load_plugin("smartyank", { + highlight = { + enabled = false, -- highlight yanked text + higroup = "IncSearch", -- highlight group of yanked text + timeout = 2000, -- timeout for clearing the highlight + }, + clipboard = { + enabled = true, + }, + tmux = { + enabled = true, + -- remove `-w` to disable copy to host client's clipboard + cmd = { "tmux", "set-buffer", "-w" }, + }, + osc52 = { + enabled = true, + escseq = "tmux", -- use tmux escape sequence, only enable if you're using remote tmux and have issues (see #4) + ssh_only = true, -- false to OSC52 yank also in local sessions + silent = false, -- true to disable the "n chars copied" echo + echo_hl = "Directory", -- highlight group of the OSC52 echo message + }, + }) +end diff --git a/lua/modules/configs/tool/toggleterm.lua b/lua/modules/configs/tool/toggleterm.lua index c05c2f64f..8e12a29e2 100644 --- a/lua/modules/configs/tool/toggleterm.lua +++ b/lua/modules/configs/tool/toggleterm.lua @@ -3,16 +3,26 @@ return function() -- size can be a number or function which is passed the current terminal size = function(term) if term.direction == "horizontal" then - return 15 + return vim.o.lines * 0.30 elseif term.direction == "vertical" then return vim.o.columns * 0.40 end end, - on_open = function() + on_open = function(term) -- Prevent infinite calls from freezing neovim. -- Only set these options specific to this terminal buffer. vim.api.nvim_set_option_value("foldmethod", "manual", { scope = "local" }) vim.api.nvim_set_option_value("foldexpr", "0", { scope = "local" }) + + -- Prevent horizontal terminal from obscuring `nvim-tree`. + local api = require("nvim-tree.api") + local tree = require("nvim-tree.view") + if tree.is_visible() and term.direction == "horizontal" then + local width = vim.fn.winwidth(tree.get_winnr()) + api.tree.toggle() + tree.View.width = width + api.tree.toggle(false, true) + end end, highlights = { Normal = { diff --git a/lua/modules/configs/ui/catppuccin.lua b/lua/modules/configs/ui/catppuccin.lua index 4eec738ed..b3a402394 100644 --- a/lua/modules/configs/ui/catppuccin.lua +++ b/lua/modules/configs/ui/catppuccin.lua @@ -17,7 +17,6 @@ return function() compile_path = vim.fn.stdpath("cache") .. "/catppuccin", styles = { comments = { "italic" }, - properties = { "italic" }, functions = { "bold" }, keywords = { "italic" }, operators = { "bold" }, @@ -28,6 +27,7 @@ return function() types = {}, strings = {}, variables = {}, + properties = {}, }, integrations = { treesitter = true, @@ -64,7 +64,7 @@ return function() harpoon = false, headlines = false, hop = true, - illuminate = false, + illuminate = true, indent_blankline = { enabled = true, colored_indent_levels = false }, leap = false, lightspeed = false, diff --git a/lua/modules/configs/ui/lualine.lua b/lua/modules/configs/ui/lualine.lua index d5108ed8a..5681523a3 100644 --- a/lua/modules/configs/ui/lualine.lua +++ b/lua/modules/configs/ui/lualine.lua @@ -132,6 +132,7 @@ return function() end, padding = 0, color = utils.gen_hl("surface1", true, true), + separator = { left = "", right = "" }, }, file_status = { @@ -218,7 +219,7 @@ return function() tabwidth = { function() - return icons.ui.Tab .. vim.api.nvim_get_option_value("shiftwidth", { scope = "local" }) + return icons.ui.Tab .. vim.api.nvim_get_option_value("tabstop", { scope = "local" }) end, padding = 1, }, diff --git a/lua/modules/configs/ui/todo.lua b/lua/modules/configs/ui/todo.lua new file mode 100644 index 000000000..bbd8af4b8 --- /dev/null +++ b/lua/modules/configs/ui/todo.lua @@ -0,0 +1,43 @@ +return function() + local icons = { + diagnostics = require("modules.utils.icons").get("diagnostics"), + ui = require("modules.utils.icons").get("ui"), + } + + require("modules.utils").load_plugin("todo-comments", { + signs = false, -- show icons in the signs column + keywords = { + FIX = { + icon = icons.ui.Bug, + color = "error", + alt = { "FIXME", "BUG", "FIXIT", "ISSUE" }, + }, + TODO = { icon = icons.ui.Accepted, color = "info" }, + -- HACK = { icon = icons.ui.Fire, color = "warning" }, + WARN = { icon = icons.diagnostics.Warning, color = "warning", alt = { "WARNING", "XXX" } }, + PERF = { icon = icons.ui.Perf, alt = { "OPTIM", "PERFORMANCE", "OPTIMIZE" } }, + NOTE = { icon = icons.ui.Note, color = "hint", alt = { "INFO" } }, + TEST = { icon = icons.ui.Lock, color = "test", alt = { "TESTING", "PASSED", "FAILED" } }, + }, + gui_style = { + fg = "NONE", + bg = "BOLD", + }, + merge_keywords = true, + highlight = { + multiline = false, + keyword = "wide", -- "fg", "bg", "wide", "wide_bg", "wide_fg" or empty. + after = "", + comments_only = true, + max_line_len = 500, + exclude = { "big_file_disabled_ft", "checkhealth" }, + }, + colors = { + error = { "DiagnosticError", "ErrorMsg", "#DC2626" }, + warning = { "DiagnosticWarn", "WarningMsg", "#FBBF24" }, + info = { "DiagnosticInfo", "#2563EB" }, + hint = { "DiagnosticHint", "#F5C2E7" }, + default = { "Conditional", "#7C3AED" }, + }, + }) +end diff --git a/lua/modules/plugins/completion.lua b/lua/modules/plugins/completion.lua index 7928615a8..d4b5d088d 100644 --- a/lua/modules/plugins/completion.lua +++ b/lua/modules/plugins/completion.lua @@ -63,7 +63,7 @@ completion["hrsh7th/nvim-cmp"] = { { "f3fora/cmp-spell" }, { "hrsh7th/cmp-buffer" }, { "kdheepak/cmp-latex-symbols" }, - { "ray-x/cmp-treesitter" }, + { "ray-x/cmp-treesitter", commit = "c8e3a74" }, -- { "tzachar/cmp-tabnine", build = "./install.sh", config = require("completion.tabnine") }, -- { -- "jcdickinson/codeium.nvim", diff --git a/lua/modules/plugins/editor.lua b/lua/modules/plugins/editor.lua index 3d0fdd93e..73b273351 100644 --- a/lua/modules/plugins/editor.lua +++ b/lua/modules/plugins/editor.lua @@ -51,8 +51,9 @@ editor["sindrets/diffview.nvim"] = { config = require("editor.diffview"), } editor["echasnovski/mini.align"] = { - version = false, - config = require("editor.mini-align"), + lazy = true, + event = { "CursorHold", "CursorHoldI" }, + config = require("editor.align"), } editor["smoka7/hop.nvim"] = { lazy = true, @@ -72,20 +73,20 @@ editor["romainl/vim-cool"] = { editor["lambdalisue/suda.vim"] = { lazy = true, cmd = { "SudaRead", "SudaWrite" }, - config = require("editor.suda"), + init = require("editor.suda"), } editor["tpope/vim-sleuth"] = { lazy = true, - event = "BufReadPre", + event = { "BufNewFile", "BufReadPost", "BufFilePost" }, } editor["nvim-pack/nvim-spectre"] = { lazy = true, - cmd = { "Spectre" }, + cmd = "Spectre", } editor["mrjones2014/smart-splits.nvim"] = { lazy = true, event = { "CursorHoldI", "CursorHold" }, - config = require("editor.smart-splits"), + config = require("editor.splits"), } ---------------------------------------------------------------------- diff --git a/lua/modules/plugins/lang.lua b/lua/modules/plugins/lang.lua index a9558c9f7..9075ff8f9 100644 --- a/lua/modules/plugins/lang.lua +++ b/lua/modules/plugins/lang.lua @@ -10,20 +10,16 @@ lang["kevinhwang91/nvim-bqf"] = { } lang["ray-x/go.nvim"] = { lazy = true, - dependencies = { -- optional packages - "ray-x/guihua.lua", - "neovim/nvim-lspconfig", - "nvim-treesitter/nvim-treesitter", - }, - ft = { "go", "gomod" }, - build = ':lua require("go.install").update_all_sync()', -- if you need to install/update all binaries - config = require("lang.go-nvim"), + ft = { "go", "gomod", "gosum" }, + build = ":GoInstallBinaries", + config = require("lang.go"), + dependencies = { "ray-x/guihua.lua" }, } lang["mrcjkb/rustaceanvim"] = { lazy = true, ft = "rust", version = "^3", - config = require("lang.rust"), + init = require("lang.rust"), dependencies = { "nvim-lua/plenary.nvim" }, } lang["Saecki/crates.nvim"] = { diff --git a/lua/modules/plugins/tool.lua b/lua/modules/plugins/tool.lua index 080ec93b8..2d8b9555d 100644 --- a/lua/modules/plugins/tool.lua +++ b/lua/modules/plugins/tool.lua @@ -28,6 +28,11 @@ tool["nvim-tree/nvim-tree.lua"] = { }, config = require("tool.nvim-tree"), } +tool["ibhagwan/smartyank.nvim"] = { + lazy = true, + event = "BufReadPost", + config = require("tool.smartyank"), +} tool["michaelb/sniprun"] = { lazy = true, -- You need to cd to `~/.local/share/nvim/site/lazy/sniprun/` and execute `bash ./install.sh`, diff --git a/lua/modules/plugins/ui.lua b/lua/modules/plugins/ui.lua index 222cb3e70..1a5aab469 100644 --- a/lua/modules/plugins/ui.lua +++ b/lua/modules/plugins/ui.lua @@ -58,8 +58,9 @@ ui["folke/paint.nvim"] = { } ui["folke/todo-comments.nvim"] = { lazy = true, - event = { "BufReadPost" }, - opts = {}, + event = { "CursorHold", "CursorHoldI" }, + config = require("ui.todo"), + dependencies = { "nvim-lua/plenary.nvim" }, } ui["dstein64/nvim-scrollview"] = { lazy = true, diff --git a/lua/modules/utils/init.lua b/lua/modules/utils/init.lua index f430b3311..c5a25ca42 100644 --- a/lua/modules/utils/init.lua +++ b/lua/modules/utils/init.lua @@ -277,7 +277,7 @@ local function tbl_recursive_merge(dst, src) for key, value in pairs(src) do if type(dst[key]) == "table" and type(value) == "function" then dst[key] = value(dst[key]) - elseif type(dst[key]) == "table" and vim.tbl_islist(dst[key]) then + elseif type(dst[key]) == "table" and vim.tbl_islist(dst[key]) and key ~= "dashboard_image" then vim.list_extend(dst[key], value) elseif type(dst[key]) == "table" and type(value) == "table" and not vim.tbl_islist(dst[key]) then tbl_recursive_merge(dst[key], value) diff --git a/nixos/neovim/default.nix b/nixos/neovim/default.nix index 8afa2a092..93134d40f 100644 --- a/nixos/neovim/default.nix +++ b/nixos/neovim/default.nix @@ -15,6 +15,11 @@ in Activate "ayamir/nvimdots". Have a look at https://github.com/ayamir/nvimdots for details ''; + bindLazyLock = mkEnableOption '' + Bind lazy-lock.json in your repository to $XDG_CONFIG_HOME/nvim. + Very powerful in terms of keeping the environment consistent, but has the following side effects. + You cannot update it even if you run the Lazy command, because it binds read-only. + ''; setBuildEnv = mkEnableOption '' Sets environment variables that resolve build dependencies as required by `mason.nvim` and `nvim-treesitter` Environment variables are only visible to `nvim` and have no effect on any parent sessions. @@ -31,20 +36,18 @@ in extraHaskellPackages = mkOption { type = with types; let fromType = listOf package; - in - coercedTo fromType + in coercedTo fromType (flip warn const '' - Assigning a plain list to extraRPackages is deprecated. - Please assign a function taking a package set as argument, so - extraHaskellPackages = [ pkgs.haskellPackages.xxx ]; - should be - extraHaskellPackages = hsPkgs: with hsPkgs; [ xxx ]; + Assigning a plain list to extraHaskellPackages is deprecated. + Please assign a function taking a package set as argument, so + extraHaskellPackages = [ pkgs.haskellPackages.xxx ]; + should become + extraHaskellPackages = ps: [ ps.xxx ]; '') (functionTo fromType); default = _: [ ]; defaultText = literalExpression "ps: [ ]"; - example = - literalExpression "hsPkgs: with hsPkgs; [ haskell-language-server ]"; + example = literalExpression "hsPkgs: with hsPkgs; [ mtl ]"; description = '' The extra Haskell packages required for your plugins to work. This option accepts a function that takes a Haskell package set as an argument, @@ -64,121 +67,134 @@ in config = let # Inspired from https://github.com/NixOS/nixpkgs/blob/nixos-unstable/nixos/modules/programs/nix-ld.nix - build-dependent-pkgs = with pkgs; - [ - acl - attr - bzip2 - curl - libsodium - libssh - libxml2 - openssl - stdenv.cc.cc - systemd - util-linux - xz - zlib - zstd - # Packages not included in `nix-ld`'s NixOSModule - glib - libcxx - ] - ++ cfg.extraDependentPackages; + build-dependent-pkgs = with pkgs; builtins.filter (package: !package.meta.unsupported) [ + # manylinux + acl + attr + bzip2 + curl + glibc + libsodium + libssh + libxml2 + openssl + stdenv.cc.cc + stdenv.cc.cc.lib + systemd + util-linux + xz + zlib + zstd + # Packages not included in `nix-ld`'s NixOSModule + glib + libcxx + ] + ++ cfg.extraDependentPackages; makePkgConfigPath = x: makeSearchPathOutput "dev" "lib/pkgconfig" x; makeIncludePath = x: makeSearchPathOutput "dev" "include" x; - nvim-depends-library = pkgs.buildEnv { - name = "nvim-depends-library"; - paths = map lib.getLib build-dependent-pkgs; - extraPrefix = "/lib/nvim-depends"; - pathsToLink = [ "/lib" ]; - ignoreCollisions = true; - }; - nvim-depends-include = pkgs.buildEnv { - name = "nvim-depends-include"; - paths = splitString ":" (makeIncludePath build-dependent-pkgs); - extraPrefix = "/lib/nvim-depends/include"; - ignoreCollisions = true; - }; - nvim-depends-pkgconfig = pkgs.buildEnv { - name = "nvim-depends-pkgconfig"; - paths = splitString ":" (makePkgConfigPath build-dependent-pkgs); - extraPrefix = "/lib/nvim-depends/pkgconfig"; + neovim-build-deps = pkgs.buildEnv { + name = "neovim-build-deps"; + paths = build-dependent-pkgs; + extraOutputsToInstall = [ "dev" ]; + pathsToLink = [ "/lib" "/include" ]; ignoreCollisions = true; }; + buildEnv = [ - "CPATH=${config.home.profileDirectory}/lib/nvim-depends/include" - "CPLUS_INCLUDE_PATH=${config.home.profileDirectory}/lib/nvim-depends/include/c++/v1" - "LD_LIBRARY_PATH=${config.home.profileDirectory}/lib/nvim-depends/lib" - "LIBRARY_PATH=${config.home.profileDirectory}/lib/nvim-depends/lib" - "NIX_LD_LIBRARY_PATH=${config.home.profileDirectory}/lib/nvim-depends/lib" - "PKG_CONFIG_PATH=${config.home.profileDirectory}/lib/nvim-depends/pkgconfig" + ''CPATH=''${CPATH:+''${CPATH}:}${neovim-build-deps}/include'' + ''CPLUS_INCLUDE_PATH=''${CPLUS_INCLUDE_PATH:+''${CPLUS_INCLUDE_PATH}:}:${neovim-build-deps}/include/c++/v1'' + ''LD_LIBRARY_PATH=''${LD_LIBRARY_PATH:+''${LD_LIBRARY_PATH}:}${neovim-build-deps}/lib'' + ''LIBRARY_PATH=''${LIBRARY_PATH:+''${LIBRARY_PATH}:}${neovim-build-deps}/lib'' + ''NIX_LD_LIBRARY_PATH=''${NIX_LD_LIBRARY_PATH:+''${NIX_LD_LIBRARY_PATH}:}${neovim-build-deps}/lib'' + ''PKG_CONFIG_PATH=''${PKG_CONFIG_PATH:+''${PKG_CONFIG_PATH}:}${neovim-build-deps}/include/pkgconfig'' ]; in - mkIf cfg.enable - { - xdg.configFile = { - "nvim/init.lua".source = ../../init.lua; - "nvim/lua".source = ../../lua; - "nvim/snips".source = ../../snips; - "nvim/tutor".source = ../../tutor; - }; - home.packages = with pkgs; [ + mkIf cfg.enable { + xdg.configFile = { + "nvim/init.lua".source = ../../init.lua; + "nvim/lua".source = ../../lua; + "nvim/snips".source = ../../snips; + "nvim/tutor".source = ../../tutor; + } // lib.optionalAttrs cfg.bindLazyLock { + "nvim/lazy-lock.json".source = ../../lazy-lock.json; + }; + home = { + packages = with pkgs; [ ripgrep - ] ++ optionals cfg.setBuildEnv [ - nvim-depends-include - nvim-depends-library - nvim-depends-pkgconfig - patchelf ]; - home.extraOutputsToInstall = optional cfg.setBuildEnv "nvim-depends"; - home.shellAliases.nvim = optionalString cfg.setBuildEnv (concatStringsSep " " buildEnv) + " nvim"; - - programs.neovim = { - enable = true; - - withNodeJs = true; - withPython3 = true; - withRuby = true; + shellAliases = optionalAttrs (cfg.setBuildEnv && (lib.versionOlder config.home.stateVersion "24.05")) { + nvim = concatStringsSep " " buildEnv + " nvim"; + }; + }; + programs.neovim = { + enable = true; - extraPackages = with pkgs; - [ - # Dependent packages used by default plugins - doq - ] - ++ optionals cfg.withBuildTools [ - cargo - clang - cmake - gcc - gnumake - go - ninja - pkg-config - yarn - ] - ++ optionals cfg.withHaskell [ - (pkgs.writeShellApplication { - name = "stack"; - text = '' - exec "${pkgs.stack}/bin/stack" "--extra-include-dirs=${config.home.profileDirectory}/lib/nvim-depends/include" "--extra-lib-dirs=${config.home.profileDirectory}/lib/nvim-depends/lib" "$@" - ''; - }) - (haskellPackages.ghcWithPackages (ps: [ - # ghcup # ghcup is broken - ] ++ cfg.extraHaskellPackages pkgs.haskellPackages)) - ]; + withNodeJs = true; + withPython3 = true; - extraPython3Packages = ps: with ps; [ - docformatter - isort - pynvim + extraPackages = with pkgs; + [ + # Dependent packages used by default plugins + doq + tree-sitter + ] + ++ optionals cfg.withBuildTools [ + cargo + clang + cmake + gcc + gnumake + go + lua51Packages.luarocks + ninja + pkg-config + yarn + ] + ++ optionals cfg.withHaskell [ + (pkgs.writeShellApplication { + name = "stack"; + text = '' + exec "${pkgs.stack}/bin/stack" "--extra-include-dirs=${config.home.profileDirectory}/lib/nvim-depends/include" "--extra-lib-dirs=${config.home.profileDirectory}/lib/nvim-depends/lib" "$@" + ''; + }) + (haskellPackages.ghcWithPackages (ps: cfg.extraHaskellPackages ps)) ]; - extraLuaPackages = ls: with ls; [ - luarocks - ]; - }; + + extraPython3Packages = ps: with ps; [ + docformatter + isort + pynvim + ]; + } + // lib.optionalAttrs (lib.versionAtLeast config.home.stateVersion "24.05") { + extraWrapperArgs = lib.optionals cfg.setBuildEnv [ + "--suffix" + "CPATH" + ":" + "${neovim-build-deps}/include" + "--suffix" + "CPLUS_INCLUDE_PATH" + ":" + "${neovim-build-deps}/include/c++/v1" + "--suffix" + "LD_LIBRARY_PATH" + ":" + "${neovim-build-deps}/lib" + "--suffix" + "LIBRARY_PATH" + ":" + "${neovim-build-deps}/lib" + "--suffix" + "PKG_CONFIG_PATH" + ":" + "${neovim-build-deps}/include/pkgconfig" + "--suffix" + "NIX_LD_LIBRARY_PATH" + ":" + "${neovim-build-deps}/lib" + ]; }; + }; } diff --git a/nixos/testEnv.nix b/nixos/testEnv.nix new file mode 100644 index 000000000..3fed9cf5a --- /dev/null +++ b/nixos/testEnv.nix @@ -0,0 +1,34 @@ +{ inputs, pkgs, ... }: +let + testSettings = { config, ... }: { + warnings = [ + "home-manager version: ${config.home.version.release}" + ]; + home = { + username = "hm-user"; + homeDirectory = "/home/hm-user"; + stateVersion = config.home.version.release; + }; + xdg.enable = true; + programs = { + home-manager.enable = true; + git.enable = true; + neovim = { + enable = true; + nvimdots = { + enable = true; + setBuildEnv = true; + withBuildTools = true; + withHaskell = true; + }; + }; + }; + }; +in +inputs.home-manager.lib.homeManagerConfiguration { + inherit pkgs; + modules = [ + ./default.nix + testSettings + ]; +} From 8ba62c6601cb953ee154e18b649b62465bb54944 Mon Sep 17 00:00:00 2001 From: ayamir Date: Mon, 20 May 2024 22:19:46 +0800 Subject: [PATCH 21/72] fix: lua_ls workspace settings. Signed-off-by: ayamir --- lua/modules/configs/completion/servers/lua_ls.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lua/modules/configs/completion/servers/lua_ls.lua b/lua/modules/configs/completion/servers/lua_ls.lua index 4afa72c1f..a9fa601bd 100644 --- a/lua/modules/configs/completion/servers/lua_ls.lua +++ b/lua/modules/configs/completion/servers/lua_ls.lua @@ -11,8 +11,8 @@ return { }, workspace = { library = { - [vim.fn.expand("$VIMRUNTIME/lua")] = true, - [vim.fn.expand("$VIMRUNTIME/lua/vim/lsp")] = true, + vim.fn.expand("$VIMRUNTIME/lua"), + vim.fn.expand("$VIMRUNTIME/lua/vim/lsp"), }, maxPreload = 100000, preloadFileSize = 10000, From 46380cdc0fa2f5f6751008be63432060de7e49d0 Mon Sep 17 00:00:00 2001 From: ayamir Date: Mon, 20 May 2024 22:23:15 +0800 Subject: [PATCH 22/72] chore: upgrade to new api to judge if is a list. Signed-off-by: ayamir --- lua/modules/utils/init.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lua/modules/utils/init.lua b/lua/modules/utils/init.lua index c5a25ca42..4161752f1 100644 --- a/lua/modules/utils/init.lua +++ b/lua/modules/utils/init.lua @@ -277,9 +277,9 @@ local function tbl_recursive_merge(dst, src) for key, value in pairs(src) do if type(dst[key]) == "table" and type(value) == "function" then dst[key] = value(dst[key]) - elseif type(dst[key]) == "table" and vim.tbl_islist(dst[key]) and key ~= "dashboard_image" then + elseif type(dst[key]) == "table" and vim.islist(dst[key]) and key ~= "dashboard_image" then vim.list_extend(dst[key], value) - elseif type(dst[key]) == "table" and type(value) == "table" and not vim.tbl_islist(dst[key]) then + elseif type(dst[key]) == "table" and type(value) == "table" and not vim.islist(dst[key]) then tbl_recursive_merge(dst[key], value) else dst[key] = value From f4d848a5a27bbc5519ef50c05cddde2153dd1db2 Mon Sep 17 00:00:00 2001 From: ayamir Date: Mon, 20 May 2024 22:50:23 +0800 Subject: [PATCH 23/72] chore: use builtin grep_string to search selection. Signed-off-by: ayamir --- lua/keymap/helpers.lua | 13 ------------- lua/keymap/tool.lua | 8 +------- 2 files changed, 1 insertion(+), 20 deletions(-) diff --git a/lua/keymap/helpers.lua b/lua/keymap/helpers.lua index 68276e2eb..b411bcd79 100644 --- a/lua/keymap/helpers.lua +++ b/lua/keymap/helpers.lua @@ -38,16 +38,3 @@ _G._toggle_lazygit = function() vim.notify("Command [lazygit] not found!", vim.log.levels.ERROR, { title = "toggleterm.nvim" }) end end - --- TODO: Update this function to use `vim.getregion()` when v0.10 is released. -_G._buf_vtext = function() - local a_orig = vim.fn.getreg("a") - local mode = vim.fn.mode() - if mode ~= "v" and mode ~= "V" then - vim.cmd([[normal! gv]]) - end - vim.cmd([[silent! normal! "aygv]]) - local text = vim.fn.getreg("a") - vim.fn.setreg("a", a_orig) - return text -end diff --git a/lua/keymap/tool.lua b/lua/keymap/tool.lua index 6eebff316..a77f0b54f 100644 --- a/lua/keymap/tool.lua +++ b/lua/keymap/tool.lua @@ -131,13 +131,7 @@ local plug_map = { :with_silent() :with_desc("edit: Change current directory by zoxide"), ["n|fb"] = map_cu("Telescope buffers"):with_noremap():with_silent():with_desc("find: Buffer opened"), - ["n|fs"] = map_cu("Telescope grep_string"):with_noremap():with_silent():with_desc("find: Current word"), - ["v|fs"] = map_callback(function() - require("telescope.builtin").grep_string({ search = _buf_vtext() }) - end) - :with_noremap() - :with_silent() - :with_desc("find: Selection text"), + ["nv|fs"] = map_cu("Telescope grep_string"):with_noremap():with_silent():with_desc("find: Current word"), ["n|fd"] = map_cu("Telescope persisted"):with_noremap():with_silent():with_desc("find: Session"), -- Plugin: dap From 66d6fe1300c17a34b6d9f6b3e0cfe5539d5342cb Mon Sep 17 00:00:00 2001 From: Jint-lzxy <50296129+Jint-lzxy@users.noreply.github.com> Date: Wed, 22 May 2024 13:43:24 +0800 Subject: [PATCH 24/72] chore: general cleanup Signed-off-by: Jint-lzxy <50296129+Jint-lzxy@users.noreply.github.com> --- lua/core/event.lua | 23 ++++++++----------- lua/core/settings.lua | 14 +++++------ .../configs/completion/mason-lspconfig.lua | 9 +------- lua/modules/configs/completion/null-ls.lua | 2 +- .../configs/completion/servers/clangd.lua | 1 - .../configs/completion/servers/lua_ls.lua | 4 +--- lua/modules/configs/lang/crates-keymap.lua | 1 - lua/modules/configs/lang/go-nvim.lua | 15 ------------ 8 files changed, 20 insertions(+), 49 deletions(-) delete mode 100644 lua/modules/configs/lang/go-nvim.lua diff --git a/lua/core/event.lua b/lua/core/event.lua index b0fda53c1..294ea3bc3 100644 --- a/lua/core/event.lua +++ b/lua/core/event.lua @@ -13,24 +13,21 @@ function autocmd.nvim_create_augroups(definitions) end end --- defer setting LSP-related keymaps till LspAttach +-- Hold off on configuring anything related to the LSP until LspAttach local mapping = require("keymap.completion") vim.api.nvim_create_autocmd("LspAttach", { group = vim.api.nvim_create_augroup("LspKeymapLoader", { clear = true }), callback = function(event) - if _G._debugging then - return - end + if not _G._debugging then + -- LSP Keymaps + mapping.lsp(event.buf) - mapping.lsp(event.buf) - local enable_inlayhint = require("core.settings").enable_inlayhint - local client = vim.lsp.get_client_by_id(event.data.client_id) - if - client ~= nil - and client.server_capabilities.inlayHintProvider ~= nil - and type(enable_inlayhint) == "boolean" - then - vim.lsp.inlay_hint.enable(enable_inlayhint, { bufnr = event.buf }) + -- LSP Inlay Hints + local inlayhint_enabled = require("core.settings").lsp_inlayhint + local client = vim.lsp.get_client_by_id(event.data.client_id) + if client and client.server_capabilities.inlayHintProvider ~= nil then + vim.lsp.inlay_hint.enable(inlayhint_enabled == true, { bufnr = event.buf }) + end end end, }) diff --git a/lua/core/settings.lua b/lua/core/settings.lua index f2f6756c9..5160e3467 100644 --- a/lua/core/settings.lua +++ b/lua/core/settings.lua @@ -8,7 +8,11 @@ settings["use_ssh"] = true ---@type boolean settings["use_copilot"] = true --- Set it to false if there are no need to format on save. +-- Set it to false if you want to turn off LSP inlay hint +---@type boolean +settings["lsp_inlayhint"] = true + +-- Set it to false if there is no need to format on save. ---@type boolean settings["format_on_save"] = true @@ -42,8 +46,8 @@ settings["diagnostics_virtual_text"] = true -- Priority: `Error` > `Warning` > `Information` > `Hint`. -- > e.g. if you set this option to `Warning`, only lsp warnings and errors will be shown. -- NOTE: This entry only works when `diagnostics_virtual_text` is true. ----@type "Error"|"Warning"|"Information"|"Hint" -settings["diagnostics_level"] = "Hint" +---@type "ERROR"|"WARN"|"INFO"|"HINT" +settings["diagnostics_level"] = "HINT" -- Set the plugins to disable here. -- Example: "Some-User/A-Repo" @@ -214,8 +218,4 @@ settings["dashboard_image"] = { [[⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠉⠉⠛⢿⣿⣿⠂⠀⠀⠀⠀⠀⢀⣽⣿⣿⣿⣿⣿⣿⣿⣍⠛⠿⣿⣿⣿⣿⣿⣿]], } --- Set it to false if you don't want to show inlay hint ----@type boolean -settings["enable_inlayhint"] = true - return require("modules.utils").extend_config(settings, "user.settings") diff --git a/lua/modules/configs/completion/mason-lspconfig.lua b/lua/modules/configs/completion/mason-lspconfig.lua index 8a9469d2b..c345c7f78 100644 --- a/lua/modules/configs/completion/mason-lspconfig.lua +++ b/lua/modules/configs/completion/mason-lspconfig.lua @@ -1,12 +1,5 @@ local M = {} -local severity_map = { - ["Error"] = vim.diagnostic.severity.ERROR, - ["Warning"] = vim.diagnostic.severity.WARN, - ["Information"] = vim.diagnostic.severity.INFO, - ["Hint"] = vim.diagnostic.severity.HINT, -} - M.setup = function() local diagnostics_virtual_text = require("core.settings").diagnostics_virtual_text local diagnostics_level = require("core.settings").diagnostics_level @@ -24,7 +17,7 @@ M.setup = function() underline = true, virtual_text = diagnostics_virtual_text and { severity = { - min = severity_map[diagnostics_level], + min = vim.diagnostic.severity[diagnostics_level], }, } or false, -- set update_in_insert to false because it was enabled by lspsaga diff --git a/lua/modules/configs/completion/null-ls.lua b/lua/modules/configs/completion/null-ls.lua index 9612d58e9..9179da8a7 100644 --- a/lua/modules/configs/completion/null-ls.lua +++ b/lua/modules/configs/completion/null-ls.lua @@ -17,7 +17,7 @@ return function() -- Don't specify any config here if you are using the default one. local sources = { btns.formatting.clang_format.with({ - filetypes = { "c", "cpp", "cuda", "proto" }, + filetypes = { "c", "cpp", "objc", "objcpp", "cs", "java", "cuda", "proto" }, extra_args = formatter_args("clang_format"), }), btns.formatting.prettier.with({ diff --git a/lua/modules/configs/completion/servers/clangd.lua b/lua/modules/configs/completion/servers/clangd.lua index a11ba56b1..7661177af 100644 --- a/lua/modules/configs/completion/servers/clangd.lua +++ b/lua/modules/configs/completion/servers/clangd.lua @@ -39,7 +39,6 @@ return function(options) on_attach = options.on_attach, capabilities = vim.tbl_deep_extend("keep", { offsetEncoding = { "utf-16", "utf-8" } }, options.capabilities), single_file_support = true, - filetypes = { "c", "cpp", "objc", "objcpp", "cuda" }, cmd = { "clangd", "-j=12", diff --git a/lua/modules/configs/completion/servers/lua_ls.lua b/lua/modules/configs/completion/servers/lua_ls.lua index a9fa601bd..cd68c9ee4 100644 --- a/lua/modules/configs/completion/servers/lua_ls.lua +++ b/lua/modules/configs/completion/servers/lua_ls.lua @@ -2,9 +2,7 @@ return { settings = { Lua = { - runtime = { - version = "LuaJIT", - }, + runtime = { version = "LuaJIT" }, diagnostics = { globals = { "vim" }, disable = { "different-requires", "undefined-field" }, diff --git a/lua/modules/configs/lang/crates-keymap.lua b/lua/modules/configs/lang/crates-keymap.lua index 685eff546..150f4da0b 100644 --- a/lua/modules/configs/lang/crates-keymap.lua +++ b/lua/modules/configs/lang/crates-keymap.lua @@ -1,4 +1,3 @@ ----@diagnostic disable: undefined-field local bind = require("keymap.bind") local map_callback = bind.map_callback diff --git a/lua/modules/configs/lang/go-nvim.lua b/lua/modules/configs/lang/go-nvim.lua deleted file mode 100644 index 41f72b2d7..000000000 --- a/lua/modules/configs/lang/go-nvim.lua +++ /dev/null @@ -1,15 +0,0 @@ -return function() - require("modules.utils").load_plugin("go", { - lsp_keymaps = false, - dap_debug_keymap = false, - icons = false, - gofmt = "gopls", - goimports = "gopls", - lsp_gofumpt = "true", - lsp_inlay_hints = { enable = false }, - run_in_floaterm = true, - trouble = true, - lsp_codelens = false, - lsp_cfg = require("modules.configs.completion.servers.gopls"), - }) -end From 4b0b06ef70e91b1b2dcab5795e5f659ad849da80 Mon Sep 17 00:00:00 2001 From: Jint-lzxy <50296129+Jint-lzxy@users.noreply.github.com> Date: Wed, 22 May 2024 13:46:21 +0800 Subject: [PATCH 25/72] fix: `inlayhint` -> `inlayhints` Signed-off-by: Jint-lzxy <50296129+Jint-lzxy@users.noreply.github.com> --- lua/core/event.lua | 4 ++-- lua/core/settings.lua | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lua/core/event.lua b/lua/core/event.lua index 294ea3bc3..18469d7cf 100644 --- a/lua/core/event.lua +++ b/lua/core/event.lua @@ -23,10 +23,10 @@ vim.api.nvim_create_autocmd("LspAttach", { mapping.lsp(event.buf) -- LSP Inlay Hints - local inlayhint_enabled = require("core.settings").lsp_inlayhint + local inlayhints_enabled = require("core.settings").lsp_inlayhints local client = vim.lsp.get_client_by_id(event.data.client_id) if client and client.server_capabilities.inlayHintProvider ~= nil then - vim.lsp.inlay_hint.enable(inlayhint_enabled == true, { bufnr = event.buf }) + vim.lsp.inlay_hint.enable(inlayhints_enabled == true, { bufnr = event.buf }) end end end, diff --git a/lua/core/settings.lua b/lua/core/settings.lua index 5160e3467..3cd9c923b 100644 --- a/lua/core/settings.lua +++ b/lua/core/settings.lua @@ -8,9 +8,9 @@ settings["use_ssh"] = true ---@type boolean settings["use_copilot"] = true --- Set it to false if you want to turn off LSP inlay hint +-- Set it to false if you want to turn off LSP Inlay Hints ---@type boolean -settings["lsp_inlayhint"] = true +settings["lsp_inlayhints"] = true -- Set it to false if there is no need to format on save. ---@type boolean From 3b323fb14a816bd4da96d15dc33e5f2e6e1ee8f1 Mon Sep 17 00:00:00 2001 From: CharlesChiuGit Date: Fri, 24 May 2024 11:18:18 +0800 Subject: [PATCH 26/72] fix(ts-autotag): update config format --- lua/modules/configs/editor/autotag.lua | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/lua/modules/configs/editor/autotag.lua b/lua/modules/configs/editor/autotag.lua index 303b67fd2..0071263f9 100644 --- a/lua/modules/configs/editor/autotag.lua +++ b/lua/modules/configs/editor/autotag.lua @@ -1,12 +1,18 @@ return function() require("modules.utils").load_plugin("nvim-ts-autotag", { - filetypes = { - "html", - "javascript", - "javascriptreact", - "typescriptreact", - "vue", - "xml", + opts = { + -- Defaults + enable_close = true, -- Auto close tags + enable_rename = true, -- Auto rename pairs of tags + enable_close_on_slash = false, -- Auto close on trailing Date: Sun, 26 May 2024 11:01:05 +0800 Subject: [PATCH 27/72] chore: use vim.uv in place of vim.loop. Signed-off-by: ayamir --- lua/core/global.lua | 2 +- lua/core/pack.lua | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lua/core/global.lua b/lua/core/global.lua index 7ab42829c..523fd78d9 100644 --- a/lua/core/global.lua +++ b/lua/core/global.lua @@ -1,5 +1,5 @@ local global = {} -local os_name = vim.loop.os_uname().sysname +local os_name = vim.uv.os_uname().sysname function global:load_variables() self.is_mac = os_name == "Darwin" diff --git a/lua/core/pack.lua b/lua/core/pack.lua index 6046e5fe3..326bf3df9 100644 --- a/lua/core/pack.lua +++ b/lua/core/pack.lua @@ -63,7 +63,7 @@ function Lazy:load_plugins() end function Lazy:load_lazy() - if not vim.loop.fs_stat(lazy_path) then + if not vim.uv.fs_stat(lazy_path) then local lazy_repo = use_ssh and "git@github.com:folke/lazy.nvim.git " or "https://github.com/folke/lazy.nvim.git " api.nvim_command("!git clone --filter=blob:none --branch=stable " .. lazy_repo .. lazy_path) end From cee6354268d64ba55482780442c0088ee8c9625e Mon Sep 17 00:00:00 2001 From: ayamir Date: Sun, 26 May 2024 11:07:07 +0800 Subject: [PATCH 28/72] chore: use vim.iter():flattern in place of vim.tbl_flattern. Signed-off-by: ayamir --- lua/core/event.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/core/event.lua b/lua/core/event.lua index 18469d7cf..5e6afabdf 100644 --- a/lua/core/event.lua +++ b/lua/core/event.lua @@ -6,7 +6,7 @@ function autocmd.nvim_create_augroups(definitions) vim.api.nvim_command("augroup " .. group_name) vim.api.nvim_command("autocmd!") for _, def in ipairs(definition) do - local command = table.concat(vim.tbl_flatten({ "autocmd", def }), " ") + local command = table.concat(vim.iter({ "autocmd", def }):flatten(), " ") vim.api.nvim_command(command) end vim.api.nvim_command("augroup END") From 69e2015a64e6171fa41a3677e33bd3a5b87dc1b2 Mon Sep 17 00:00:00 2001 From: Mohu Date: Sun, 26 May 2024 13:54:12 +0800 Subject: [PATCH 29/72] chore: update install scripts for nvim 0.10 stable. (#1271) Signed-off-by: ayamir --- scripts/install.ps1 | 4 ++-- scripts/install.sh | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/scripts/install.ps1 b/scripts/install.ps1 index 4d725c6e4..600ac358e 100644 --- a/scripts/install.ps1 +++ b/scripts/install.ps1 @@ -8,8 +8,8 @@ Set-StrictMode -Version 3.0 $ErrorActionPreference = "Stop" # Exit when command fails # global-scope vars -$REQUIRED_NVIM_VERSION = [version]'0.9.0' -$REQUIRED_NVIM_VERSION_LEGACY = [version]'0.8.0' +$REQUIRED_NVIM_VERSION = [version]'0.10.0' +$REQUIRED_NVIM_VERSION_LEGACY = [version]'0.9.0' $USE_SSH = $True # package mgr vars diff --git a/scripts/install.sh b/scripts/install.sh index 6796f1a0f..71e9d9514 100755 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -10,8 +10,8 @@ set -u DEST_DIR="${HOME}/.config/nvim" BACKUP_DIR="${DEST_DIR}_backup-$(date +%Y%m%dT%H%M%S)" CLONE_ATTR=("--progress") -REQUIRED_NVIM_VERSION=0.9.0 -REQUIRED_NVIM_VERSION_LEGACY=0.8.0 +REQUIRED_NVIM_VERSION=0.10.0 +REQUIRED_NVIM_VERSION_LEGACY=0.9.0 USE_SSH=1 abort() { @@ -175,7 +175,7 @@ clone_repo() { elif check_nvim_version "${REQUIRED_NVIM_VERSION_LEGACY}"; then warn "You have outdated Nvim installed (< ${REQUIRED_NVIM_VERSION})." info "Automatically redirecting you to the latest compatible version..." - execute "git" "clone" "-b" "0.8" "${CLONE_ATTR[@]}" "$1" "${DEST_DIR}" + execute "git" "clone" "-b" "${REQUIRED_NVIM_VERSION_LEGACY}" "${CLONE_ATTR[@]}" "$1" "${DEST_DIR}" else warn "You have outdated Nvim installed (< ${REQUIRED_NVIM_VERSION_LEGACY})." abort "$( From 13df6c39f497033c322d7189e8aaaf06fbdc38ec Mon Sep 17 00:00:00 2001 From: Mohu Date: Sun, 2 Jun 2024 10:43:24 +0800 Subject: [PATCH 30/72] chore: replace deprecated apis (#1266) * chore: use vim.lsp.get_clients in place of vim.lsp.get_active_clients. Signed-off-by: ayamir * chore: use vim.lsp.get_clients in place of vim.lsp.buf_get_clients. Signed-off-by: ayamir --------- Signed-off-by: ayamir --- lua/modules/configs/completion/formatting.lua | 2 +- lua/modules/configs/ui/lualine.lua | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lua/modules/configs/completion/formatting.lua b/lua/modules/configs/completion/formatting.lua index 9e8018812..4634d0451 100644 --- a/lua/modules/configs/completion/formatting.lua +++ b/lua/modules/configs/completion/formatting.lua @@ -117,7 +117,7 @@ function M.format(opts) end local bufnr = opts.bufnr or vim.api.nvim_get_current_buf() - local clients = vim.lsp.buf_get_clients(bufnr) + local clients = vim.lsp.get_clients({ buffer = bufnr }) if opts.filter then clients = opts.filter(clients) diff --git a/lua/modules/configs/ui/lualine.lua b/lua/modules/configs/ui/lualine.lua index 5681523a3..2d8401ede 100644 --- a/lua/modules/configs/ui/lualine.lua +++ b/lua/modules/configs/ui/lualine.lua @@ -164,7 +164,7 @@ return function() lsp = { function() local buf_ft = vim.api.nvim_get_option_value("filetype", { scope = "local" }) - local clients = vim.lsp.get_active_clients() + local clients = vim.lsp.get_clients() local lsp_lists = {} local available_servers = {} if next(clients) == nil then From 04543b5f4de887e8f51edfb8de5f96a5314b7d4b Mon Sep 17 00:00:00 2001 From: Charles Chiu Date: Sun, 2 Jun 2024 10:43:57 +0800 Subject: [PATCH 31/72] fix(toggleterm): use `""` instead of `nil` to fix auto-exit on Windows (#1267) --- lua/core/init.lua | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/lua/core/init.lua b/lua/core/init.lua index e9b2e3251..646ca9645 100644 --- a/lua/core/init.lua +++ b/lua/core/init.lua @@ -135,12 +135,13 @@ You're recommended to install PowerShell for better experience.]], local basecmd = "-NoLogo -MTA -ExecutionPolicy RemoteSigned" local ctrlcmd = "-Command [console]::InputEncoding = [console]::OutputEncoding = [System.Text.Encoding]::UTF8" - vim.api.nvim_set_option_value("shell", vim.fn.executable("pwsh") == 1 and "pwsh" or "powershell", {}) - vim.api.nvim_set_option_value("shellcmdflag", string.format("%s %s;", basecmd, ctrlcmd), {}) - vim.api.nvim_set_option_value("shellredir", "-RedirectStandardOutput %s -NoNewWindow -Wait", {}) - vim.api.nvim_set_option_value("shellpipe", "2>&1 | Out-File -Encoding UTF8 %s; exit $LastExitCode", {}) - vim.api.nvim_set_option_value("shellquote", nil, {}) - vim.api.nvim_set_option_value("shellxquote", nil, {}) + local set_opts = vim.api.nvim_set_option_value + set_opts("shell", vim.fn.executable("pwsh") == 1 and "pwsh" or "powershell", {}) + set_opts("shellcmdflag", string.format("%s %s;", basecmd, ctrlcmd), {}) + set_opts("shellredir", "-RedirectStandardOutput %s -NoNewWindow -Wait", {}) + set_opts("shellpipe", "2>&1 | Out-File -Encoding UTF8 %s; exit $LastExitCode", {}) + set_opts("shellquote", "", {}) + set_opts("shellxquote", "", {}) end end From a7c136a60d9acf207b2f546ee7f582778e63d857 Mon Sep 17 00:00:00 2001 From: mjkx <52132505+mjkx5@users.noreply.github.com> Date: Sun, 2 Jun 2024 10:44:18 +0800 Subject: [PATCH 32/72] fix: utilize `ts-context` in `glance` preview window (#1265) * set ts-context floatterm zindex to 50 which greater than 45. default zindex of glance [dnlhc/glance.nvim] floatterm is 45. It can display on glance. Signed-off-by: mjkx <291083247@qq.com> * set trim_scope to inner Signed-off-by: mjkx <291083247@qq.com> * perf: add discription --------- Signed-off-by: mjkx <291083247@qq.com> Co-authored-by: CharlesChiuGit --- lua/modules/configs/editor/ts-context.lua | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lua/modules/configs/editor/ts-context.lua b/lua/modules/configs/editor/ts-context.lua index 186a52558..5ad119668 100644 --- a/lua/modules/configs/editor/ts-context.lua +++ b/lua/modules/configs/editor/ts-context.lua @@ -5,8 +5,9 @@ return function() min_window_height = 0, -- Minimum editor window height to enable context. Values <= 0 mean no limit. line_numbers = true, multiline_threshold = 20, -- Maximum number of lines to collapse for a single context line - trim_scope = "outer", -- Which context lines to discard if `max_lines` is exceeded. Choices: 'inner', 'outer' + trim_scope = "inner", -- Which context lines to discard if `max_lines` is exceeded. Choices: 'inner', 'outer' mode = "cursor", -- Line used to calculate context. Choices: 'cursor', 'topline' - zindex = 30, + -- HACK: to make use of `ts-context` in `glance`, set zindex to 50.(glance zindex is 45) + zindex = 50, }) end From a27f8f173bb5775c4b7b53bdfa14ceab9259fa63 Mon Sep 17 00:00:00 2001 From: Mohu Date: Thu, 6 Jun 2024 19:53:00 +0800 Subject: [PATCH 33/72] chore: use vim.o in place of vim.api.nvim_get_option_value. (#1269) Signed-off-by: ayamir --- lua/core/event.lua | 2 +- lua/modules/configs/completion/null-ls.lua | 2 +- lua/modules/configs/ui/lualine.lua | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lua/core/event.lua b/lua/core/event.lua index 5e6afabdf..2ef32b51b 100644 --- a/lua/core/event.lua +++ b/lua/core/event.lua @@ -40,7 +40,7 @@ vim.api.nvim_create_autocmd("BufEnter", { local layout = vim.api.nvim_call_function("winlayout", {}) if layout[1] == "leaf" - and vim.api.nvim_get_option_value("filetype", { buf = vim.api.nvim_win_get_buf(layout[2]) }) == "NvimTree" + and vim.bo[vim.api.nvim_win_get_buf(layout[2])].filetype == "NvimTree" and layout[3] == nil then vim.api.nvim_command([[confirm quit]]) diff --git a/lua/modules/configs/completion/null-ls.lua b/lua/modules/configs/completion/null-ls.lua index 9179da8a7..ff2efab17 100644 --- a/lua/modules/configs/completion/null-ls.lua +++ b/lua/modules/configs/completion/null-ls.lua @@ -49,7 +49,7 @@ return function() -- Setup usercmd to register/deregister available source(s) local function _gen_completion() local sources_cont = null_ls.get_source({ - filetype = vim.api.nvim_get_option_value("filetype", { scope = "local" }), + filetype = vim.bo.filetype, }) local completion_items = {} for _, server in pairs(sources_cont) do diff --git a/lua/modules/configs/ui/lualine.lua b/lua/modules/configs/ui/lualine.lua index 2d8401ede..cf653a012 100644 --- a/lua/modules/configs/ui/lualine.lua +++ b/lua/modules/configs/ui/lualine.lua @@ -163,7 +163,7 @@ return function() lsp = { function() - local buf_ft = vim.api.nvim_get_option_value("filetype", { scope = "local" }) + local buf_ft = vim.bo.filetype local clients = vim.lsp.get_clients() local lsp_lists = {} local available_servers = {} @@ -201,7 +201,7 @@ return function() return venv end - if vim.api.nvim_get_option_value("filetype", { scope = "local" }) == "python" then + if vim.bo.filetype == "python" then local venv = os.getenv("CONDA_DEFAULT_ENV") if venv then return icons.misc.PyEnv .. env_cleanup(venv) @@ -219,7 +219,7 @@ return function() tabwidth = { function() - return icons.ui.Tab .. vim.api.nvim_get_option_value("tabstop", { scope = "local" }) + return icons.ui.Tab .. vim.bo.tabstop end, padding = 1, }, From 0278b2d51e8e7960162b6412e681bd3d15983b8b Mon Sep 17 00:00:00 2001 From: jint_lzxy_ <50296129+Jint-lzxy@users.noreply.github.com> Date: Fri, 7 Jun 2024 16:49:17 +0800 Subject: [PATCH 34/72] fix(0.10): minor cleanup (#1276) Signed-off-by: Jint-lzxy <50296129+Jint-lzxy@users.noreply.github.com> --- LICENSE | 0 lua/modules/configs/editor/ts-context.lua | 5 ++--- lua/modules/configs/ui/lualine.lua | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) mode change 100755 => 100644 LICENSE diff --git a/LICENSE b/LICENSE old mode 100755 new mode 100644 diff --git a/lua/modules/configs/editor/ts-context.lua b/lua/modules/configs/editor/ts-context.lua index 5ad119668..ba96e0312 100644 --- a/lua/modules/configs/editor/ts-context.lua +++ b/lua/modules/configs/editor/ts-context.lua @@ -5,9 +5,8 @@ return function() min_window_height = 0, -- Minimum editor window height to enable context. Values <= 0 mean no limit. line_numbers = true, multiline_threshold = 20, -- Maximum number of lines to collapse for a single context line - trim_scope = "inner", -- Which context lines to discard if `max_lines` is exceeded. Choices: 'inner', 'outer' + trim_scope = "outer", -- Which context lines to discard if `max_lines` is exceeded. Choices: 'inner', 'outer' mode = "cursor", -- Line used to calculate context. Choices: 'cursor', 'topline' - -- HACK: to make use of `ts-context` in `glance`, set zindex to 50.(glance zindex is 45) - zindex = 50, + zindex = 50, -- Ensure compatibility with Glance's preview window }) end diff --git a/lua/modules/configs/ui/lualine.lua b/lua/modules/configs/ui/lualine.lua index cf653a012..39e4b8911 100644 --- a/lua/modules/configs/ui/lualine.lua +++ b/lua/modules/configs/ui/lualine.lua @@ -164,7 +164,7 @@ return function() lsp = { function() local buf_ft = vim.bo.filetype - local clients = vim.lsp.get_clients() + local clients = vim.lsp.get_clients({ buffer = vim.api.nvim_get_current_buf() }) local lsp_lists = {} local available_servers = {} if next(clients) == nil then From d249c862238f045321f9995c320e50621b1d394c Mon Sep 17 00:00:00 2001 From: jint_lzxy_ <50296129+Jint-lzxy@users.noreply.github.com> Date: Fri, 7 Jun 2024 16:49:44 +0800 Subject: [PATCH 35/72] feat(scripts): update frequently used functions (#1277) I recently refactored my frequently used commands and thought it would be great to also port that here lol Signed-off-by: Jint-lzxy <50296129+Jint-lzxy@users.noreply.github.com> --- scripts/install.ps1 | 6 +++--- scripts/install.sh | 34 ++++++++++++++++++---------------- 2 files changed, 21 insertions(+), 19 deletions(-) diff --git a/scripts/install.ps1 b/scripts/install.ps1 index 600ac358e..d5b6354cb 100644 --- a/scripts/install.ps1 +++ b/scripts/install.ps1 @@ -8,9 +8,9 @@ Set-StrictMode -Version 3.0 $ErrorActionPreference = "Stop" # Exit when command fails # global-scope vars +$USE_SSH = $True $REQUIRED_NVIM_VERSION = [version]'0.10.0' $REQUIRED_NVIM_VERSION_LEGACY = [version]'0.9.0' -$USE_SSH = $True # package mgr vars $choco_package_matrix = @{ "gcc" = "mingw"; "git" = "git"; "nvim" = "neovim"; "make" = "make"; "sudo" = "psutils"; "node" = "nodejs"; "pip" = "python3"; "fzf" = "fzf"; "rg" = "ripgrep"; "go" = "go"; "curl" = "curl"; "wget" = "wget"; "tree-sitter" = "tree-sitter"; "ruby" = "ruby"; "rustc" = "rust-ms" } @@ -20,9 +20,9 @@ $installer_pkg_matrix = @{ "NodeJS" = "npm"; "Python" = "pip"; "Ruby" = "gem" } # env vars $env:XDG_CONFIG_HOME ??= $env:LOCALAPPDATA $env:CCPACK_MGR ??= 'unknown' +$env:CCLONE_ATTR ??= 'undef' $env:CCLONE_BRANCH ??= 'main' $env:CCLONE_BRANCH_LEGACY ??= '0.8' -$env:CCLONE_ATTR ??= 'undef' $env:CCDEST_DIR ??= "$env:XDG_CONFIG_HOME\nvim" $env:CCBACKUP_DIR = "$env:CCDEST_DIR" + "_backup-" + (Get-Date).ToUniversalTime().ToString("yyyyMMddTHHmmss") @@ -58,7 +58,7 @@ function info_ext ([Parameter(Mandatory = $True)][ValidateNotNullOrEmpty()] [str } function warn ([Parameter(Mandatory = $True)][ValidateNotNullOrEmpty()] [string]$Msg) { - Write-Host "Warning" -ForegroundColor Yellow -NoNewline; Write-Host ": $(_chomp -Str $Msg)"; + Write-Host "Warning:" -ForegroundColor Yellow -NoNewline; Write-Host " $(_chomp -Str $Msg)"; } function warn_ext ([Parameter(Mandatory = $True)][ValidateNotNullOrEmpty()] [string]$Msg) { diff --git a/scripts/install.sh b/scripts/install.sh index 71e9d9514..48956bbd6 100755 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -4,15 +4,15 @@ # Allow `[[ -n "$(command)" ]]`, `func "$(command)"`, pipes, etc. # shellcheck disable=SC2312 -set -u +set -uo pipefail -# global vars -DEST_DIR="${HOME}/.config/nvim" -BACKUP_DIR="${DEST_DIR}_backup-$(date +%Y%m%dT%H%M%S)" -CLONE_ATTR=("--progress") +# global-scope vars REQUIRED_NVIM_VERSION=0.10.0 REQUIRED_NVIM_VERSION_LEGACY=0.9.0 USE_SSH=1 +CLONE_ATTR=("--progress") +DEST_DIR="${HOME}/.config/nvim" +BACKUP_DIR="${DEST_DIR}_backup-$(date +%Y%m%dT%H%M%S)" abort() { printf "%s\n" "$@" >&2 @@ -31,7 +31,7 @@ if [[ -n "${CI-}" && -n "${INTERACTIVE-}" ]]; then abort "Cannot run force-interactive mode in CI." fi -# string formatters +# String formatters if [[ -t 1 ]]; then tty_escape() { printf "\033[%sm" "$1"; } else @@ -41,6 +41,8 @@ fi tty_mkbold() { tty_escape "1;$1"; } tty_underline="$(tty_escape "4;39")" tty_yellow="$(tty_escape "0;33")" +tty_magenta="$(tty_mkbold 35)" +tty_green="$(tty_mkbold 32)" tty_blue="$(tty_mkbold 34)" tty_red="$(tty_mkbold 31)" tty_bold="$(tty_mkbold 39)" @@ -82,7 +84,7 @@ info_ext() { } warn() { - printf "${tty_yellow}Warning${tty_reset}: %s\n" "$(chomp "$1")" + printf "${tty_yellow}Warning:${tty_reset} %s\n" "$(chomp "$1")" } warn_ext() { @@ -98,7 +100,7 @@ getc() { } ring_bell() { - # Use the shell's audible bell. + # Use the shell's audible bell if [[ -t 1 ]]; then printf "\a" fi @@ -106,13 +108,12 @@ ring_bell() { wait_for_user() { local c - echo + printf "\n" echo "Press ${tty_bold}RETURN${tty_reset}/${tty_bold}ENTER${tty_reset} to continue or any other key to abort..." getc c # we test for \r and \n because some stuff does \r instead - if ! [[ "${c}" == $'\r' || "${c}" == $'\n' ]]; then - echo "${tty_red}Aborted.${tty_reset}" - exit 1 + if ! [[ "$c" == $'\r' || "$c" == $'\n' ]]; then + abort "${tty_red}Aborted.${tty_reset}" fi } @@ -121,9 +122,10 @@ version_ge() { } prompt_confirm() { + local choice while true; do - read -r -p "$1 [Y/n]: " USR_CHOICE - case "${USR_CHOICE}" in + read -r -p "$1 [Y/n]: " choice + case "$choice" in [yY][eE][sS] | [yY]) return 1 ;; @@ -131,10 +133,10 @@ prompt_confirm() { return 0 ;; *) - if [[ -z "${USR_CHOICE}" ]]; then + if [[ -z "$choice" ]]; then return 1 fi - printf "${tty_red}%s\n\n${tty_reset}" "Invalid input! Please enter one of: '[y/yes] / [n/no]'" + printf "${tty_red}%s\n\n${tty_reset}" "Input invalid! Please enter one of the following: '[y/yes]' or '[n/no]'." ;; esac done From fd464262da4001d2f0c9237536237670f2873cc2 Mon Sep 17 00:00:00 2001 From: jint_lzxy_ <50296129+Jint-lzxy@users.noreply.github.com> Date: Fri, 7 Jun 2024 16:50:31 +0800 Subject: [PATCH 36/72] feat(docs): support v0.10 (#1278) * feat(docs): support v0.10 Signed-off-by: Jint-lzxy <50296129+Jint-lzxy@users.noreply.github.com> * fix instructions Signed-off-by: Jint-lzxy <50296129+Jint-lzxy@users.noreply.github.com> --------- Signed-off-by: Jint-lzxy <50296129+Jint-lzxy@users.noreply.github.com> --- .github/ISSUE_TEMPLATE/bug_report.yml | 12 ++++++------ .github/ISSUE_TEMPLATE/custom_config.yml | 10 +++++----- .github/ISSUE_TEMPLATE/lsp_issue_report.yml | 12 ++++++------ README.md | 10 +++++----- 4 files changed, 22 insertions(+), 22 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml index 5c0f3fff4..d4f8280d8 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -7,7 +7,7 @@ body: value: | _Before reporting:_ Search [existing issues](https://github.com/ayamir/nvimdots/issues) and check the [FAQ](https://github.com/ayamir/nvimdots/wiki/Issues). Thank you for helping us improve! > [!IMPORTANT] - > The `0.10` branch is intended for nightly neovim builds and is **not** stable. It typically harbors subtle issues scattered throughout. Therefore, refrain from submitting issues if you happen to encounter them. They will be closed directly unless a viable solution is proposed or included. + > The `0.11` branch is intended for nightly neovim builds and is **not** stable. It typically harbors subtle issues scattered throughout. Therefore, refrain from submitting issues if you happen to encounter them. They will be closed directly unless a viable solution is proposed or included. - type: checkboxes id: is-latest-commit attributes: @@ -38,7 +38,7 @@ body: attributes: label: "Neovim version" description: "Paste the output of `nvim --version` here" - placeholder: "NVIM v0.10.0-dev-873+g71ad771ea" + placeholder: "NVIM v0.11.0-dev-194+g6c7677e5d" validations: required: true - type: input @@ -69,16 +69,16 @@ body: description: "Which branch are you currently on? If you are not sure, check the output of `git rev-parse --abbrev-ref HEAD`" options: - main (Default/Latest) - - 0.8 (Legacy) - - 0.7 (Deprecated) - - 0.10 (Nightly) + - 0.9 (Legacy) + - 0.8 (Deprecated) + - 0.11 (Nightly) validations: required: true - type: dropdown id: fetch-pref attributes: label: "Fetch Preferences" - description: "In what way do you fetch resources? If you are not sure, check the value of `use_ssh` in `lua/core/settings.lua`" + description: "In what way do you fetch resources? If you are not sure, check the value of `use_ssh` in `lua/user/settings.lua`" options: - SSH (use_ssh = true) - HTTPS (use_ssh = false) diff --git a/.github/ISSUE_TEMPLATE/custom_config.yml b/.github/ISSUE_TEMPLATE/custom_config.yml index d3dc98dd2..6b48fcd50 100644 --- a/.github/ISSUE_TEMPLATE/custom_config.yml +++ b/.github/ISSUE_TEMPLATE/custom_config.yml @@ -7,7 +7,7 @@ body: value: | _Before requesting:_ Make sure you've read through our [Wiki: Usage](https://github.com/ayamir/nvimdots/wiki/Usage) before you start to add things to nvimdots! > [!IMPORTANT] - > The `0.10` branch is intended for nightly neovim builds and is **not** stable. It typically harbors subtle issues scattered throughout. Therefore, refrain from submitting issues if you happen to encounter them. They will be closed directly unless a viable solution is proposed or included. + > The `0.11` branch is intended for nightly neovim builds and is **not** stable. It typically harbors subtle issues scattered throughout. Therefore, refrain from submitting issues if you happen to encounter them. They will be closed directly unless a viable solution is proposed or included. - type: checkboxes id: is-latest-commit attributes: @@ -30,7 +30,7 @@ body: attributes: label: "Neovim version" description: "Paste the output of `nvim --version` here" - placeholder: "NVIM v0.10.0-dev-873+g71ad771ea" + placeholder: "NVIM v0.11.0-dev-194+g6c7677e5d" validations: required: true - type: dropdown @@ -40,9 +40,9 @@ body: description: "This issue template mainly targets `main` branch. Check the output of `git rev-parse --abbrev-ref HEAD` if you're not sure." options: - main (Default/Latest) - - 0.8 (Legacy) - - 0.7 (Deprecated) - - 0.10 (Nightly) + - 0.9 (Legacy) + - 0.8 (Deprecated) + - 0.11 (Nightly) validations: required: true diff --git a/.github/ISSUE_TEMPLATE/lsp_issue_report.yml b/.github/ISSUE_TEMPLATE/lsp_issue_report.yml index 519b0e6de..f18124c55 100644 --- a/.github/ISSUE_TEMPLATE/lsp_issue_report.yml +++ b/.github/ISSUE_TEMPLATE/lsp_issue_report.yml @@ -7,7 +7,7 @@ body: value: | _Before reporting:_ Search [existing issues](https://github.com/ayamir/nvimdots/issues) and check the [FAQ](https://github.com/ayamir/nvimdots/wiki/Issues). Thank you for helping us improve! > [!IMPORTANT] - > The `0.10` branch is intended for nightly neovim builds and is **not** stable. It typically harbors subtle issues scattered throughout. Therefore, refrain from submitting issues if you happen to encounter them. They will be closed directly unless a viable solution is proposed or included. + > The `0.11` branch is intended for nightly neovim builds and is **not** stable. It typically harbors subtle issues scattered throughout. Therefore, refrain from submitting issues if you happen to encounter them. They will be closed directly unless a viable solution is proposed or included. - type: checkboxes id: is-latest-commit attributes: @@ -38,7 +38,7 @@ body: attributes: label: "Neovim version" description: "Paste the output of `nvim --version` here" - placeholder: "NVIM v0.10.0-dev-873+g71ad771ea" + placeholder: "NVIM v0.11.0-dev-194+g6c7677e5d" validations: required: true - type: input @@ -69,16 +69,16 @@ body: description: "Which branch are you currently on? If you are not sure, check the output of `git rev-parse --abbrev-ref HEAD`" options: - main (Default/Latest) - - 0.8 (Legacy) - - 0.7 (Deprecated) - - 0.10 (Nightly) + - 0.9 (Legacy) + - 0.8 (Deprecated) + - 0.11 (Nightly) validations: required: true - type: dropdown id: fetch-pref attributes: label: "Fetch Preferences" - description: "In what way do you fetch resources? If you are not sure, check the value of `use_ssh` in `lua/core/settings.lua`" + description: "In what way do you fetch resources? If you are not sure, check the value of `use_ssh` in `lua/user/settings.lua`" options: - SSH (use_ssh = true) - HTTPS (use_ssh = false) diff --git a/README.md b/README.md index 05390439a..9b0303d7f 100644 --- a/README.md +++ b/README.md @@ -42,17 +42,17 @@ Branch info:
-| Branch | Supported neovim version | +| Branch | Supported Neovim version | | :----: | :----------------------: | -| main | nvim 0.9 stable | -| 0.10 | nvim 0.10 nightly | +| main | nvim 0.10 stable | +| 0.11 | nvim 0.11 nightly | +| 0.9 | nvim 0.9 | | 0.8 | nvim 0.8 | -| 0.7 | nvim 0.7 |
> [!IMPORTANT] -> The `0.10` branch is intended for nightly neovim builds and is **not** stable. It typically harbors subtle issues scattered throughout. Therefore, refrain from submitting issues if you happen to encounter them. They will be closed directly unless a viable solution is proposed or included. +> The `0.11` branch is intended for nightly neovim builds and is **not** stable. It typically harbors subtle issues scattered throughout. Therefore, refrain from submitting issues if you happen to encounter them. They will be closed directly unless a viable solution is proposed or included. We currently manage plugins using [lazy.nvim](https://github.com/folke/lazy.nvim). From f2863806554a77624ba81686c981eeb01b577651 Mon Sep 17 00:00:00 2001 From: Jint-lzxy <50296129+Jint-lzxy@users.noreply.github.com> Date: Fri, 7 Jun 2024 19:26:50 +0800 Subject: [PATCH 37/72] fix(scripts): typo Signed-off-by: Jint-lzxy <50296129+Jint-lzxy@users.noreply.github.com> --- README.md | 14 +++++++------- scripts/install.ps1 | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 9b0303d7f..0026d621a 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@
NeoVim Version Capability @@ -36,7 +36,7 @@ ## 🪷 Introduction -This repo hosts our [NeoVim](https://neovim.io/) configuration for Linux [(with NixOS support)](#nixos-support), macOS, and Windows. `init.lua` is the config entry point. +This repo hosts our [Neovim](https://neovim.io/) configuration for Linux [(with NixOS support)](#nixos-support), macOS, and Windows. `init.lua` is the config entry point. Branch info: @@ -45,14 +45,14 @@ Branch info: | Branch | Supported Neovim version | | :----: | :----------------------: | | main | nvim 0.10 stable | -| 0.11 | nvim 0.11 nightly | +| 0.11 | nvim 0.11 nightly | | 0.9 | nvim 0.9 | | 0.8 | nvim 0.8 | > [!IMPORTANT] -> The `0.11` branch is intended for nightly neovim builds and is **not** stable. It typically harbors subtle issues scattered throughout. Therefore, refrain from submitting issues if you happen to encounter them. They will be closed directly unless a viable solution is proposed or included. +> The `0.11` branch is intended for nightly Neovim builds and is **not** stable. It typically harbors subtle issues scattered throughout. Therefore, refrain from submitting issues if you happen to encounter them. They will be closed directly unless a viable solution is proposed or included. We currently manage plugins using [lazy.nvim](https://github.com/folke/lazy.nvim). @@ -61,14 +61,14 @@ Chinese introduction is [here](https://zhuanlan.zhihu.com/p/382092667). ### 🎐 Features - **Fast.** Less than **30ms** to start (Depends on SSD and CPU, tested on Zephyrus G14 2022 version). -- **Simple.** Run out of the box. +- **Simple.** Runs out of the box. - **Modern.** Pure `lua` config. - **Modular.** Easy to customize. - **Powerful.** Full functionality to code. ## 🏗 How to Install -Just run the following interactive bootstrap command, and you're good to go 👍 +Simply run the following interactive bootstrap command, and you should be all set 👍 - **Windows** _(Note: This script REQUIRES `pwsh` > `v7.1`)_ @@ -204,7 +204,7 @@ It's strongly recommended to read [Wiki: Prerequisites](https://github.com/ayami ## 📜 License -This NeoVim configuration is released under the MIT license, which grants the following permissions: +This Neovim configuration is released under the MIT license, which grants the following permissions: - Commercial use - Distribution diff --git a/scripts/install.ps1 b/scripts/install.ps1 index d5b6354cb..184291208 100644 --- a/scripts/install.ps1 +++ b/scripts/install.ps1 @@ -22,7 +22,7 @@ $env:XDG_CONFIG_HOME ??= $env:LOCALAPPDATA $env:CCPACK_MGR ??= 'unknown' $env:CCLONE_ATTR ??= 'undef' $env:CCLONE_BRANCH ??= 'main' -$env:CCLONE_BRANCH_LEGACY ??= '0.8' +$env:CCLONE_BRANCH_LEGACY ??= '0.9' $env:CCDEST_DIR ??= "$env:XDG_CONFIG_HOME\nvim" $env:CCBACKUP_DIR = "$env:CCDEST_DIR" + "_backup-" + (Get-Date).ToUniversalTime().ToString("yyyyMMddTHHmmss") From f8bc12b8caad20dca9a006a41366e18b0a1ecd66 Mon Sep 17 00:00:00 2001 From: Jint-lzxy <50296129+Jint-lzxy@users.noreply.github.com> Date: Fri, 7 Jun 2024 20:38:37 +0800 Subject: [PATCH 38/72] fixup! fix(scripts): typo --- scripts/install.ps1 | 14 +++++++------- scripts/install.sh | 4 +--- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/scripts/install.ps1 b/scripts/install.ps1 index 184291208..910abc8e5 100644 --- a/scripts/install.ps1 +++ b/scripts/install.ps1 @@ -26,9 +26,9 @@ $env:CCLONE_BRANCH_LEGACY ??= '0.9' $env:CCDEST_DIR ??= "$env:XDG_CONFIG_HOME\nvim" $env:CCBACKUP_DIR = "$env:CCDEST_DIR" + "_backup-" + (Get-Date).ToUniversalTime().ToString("yyyyMMddTHHmmss") -function _abort ([Parameter(Mandatory = $True)] [string]$Msg,[Parameter(Mandatory = $True)] [string]$Type,[Parameter(Mandatory = $False)] [string]$Info_msg) { - if ($Info_msg -ne $null) { - Write-Host $Info_msg +function _abort ([Parameter(Mandatory = $True)] [string]$Msg,[Parameter(Mandatory = $True)] [string]$Type,[Parameter(Mandatory = $False)] [string]$ExtMsg) { + if ($ExtMsg -ne $null) { + Write-Host $ExtMsg } Write-Error -Message "Error: $Msg" -Category $Type exit 1 @@ -157,7 +157,7 @@ function query_pack { info -Msg " [Detected] We'll use 'Chocolatey' as the default package mgr." $env:CCPACK_MGR = 'choco' } else { - _abort -Msg "Required executable not found." -Type "NotInstalled" -Info_msg @' + _abort -Msg "Required executable not found." -Type "NotInstalled" -ExtMsg @' You must install a modern package manager before installing this Nvim config. Available choices are: - Chocolatey @@ -292,7 +292,7 @@ function clone_repo ([Parameter(Mandatory = $True)][ValidateNotNullOrEmpty()] [s safe_execute -WithCmd { git clone --progress -b "$env:CCLONE_BRANCH_LEGACY" "$env:CCLONE_ATTR" $WithURL "$env:CCDEST_DIR" } } else { warn -Msg "You have outdated Nvim installed (< $REQUIRED_NVIM_VERSION_LEGACY)." - _abort -Msg "This Neovim distribution is no longer supported." -Type "NotImplemented" -Info_msg @" + _abort -Msg "This Neovim distribution is no longer supported." -Type "NotImplemented" -ExtMsg @" You have a legacy Neovim distribution installed. Please make sure you have nvim v$REQUIRED_NVIM_VERSION_LEGACY installed at the very least. @@ -330,7 +330,7 @@ function _main { # Check dependencies if (-not (check_in_path -WithName "nvim")) { - _abort -Msg "Required executable not found." -Type "NotInstalled" -Info_msg @' + _abort -Msg "Required executable not found." -Type "NotInstalled" -ExtMsg @' You must install Neovim before installing this Nvim config. See: https://github.com/neovim/neovim/wiki/Installing-Neovim ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ @@ -340,7 +340,7 @@ You must install Neovim before installing this Nvim config. See: } if (-not (check_in_path -WithName "git")) { - _abort -Msg "Required executable not found." -Type "NotInstalled" -Info_msg @' + _abort -Msg "Required executable not found." -Type "NotInstalled" -ExtMsg @' You must install Git before installing this Nvim config. See: https://git-scm.com/ ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ diff --git a/scripts/install.sh b/scripts/install.sh index 48956bbd6..0d1e113bb 100755 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -41,8 +41,6 @@ fi tty_mkbold() { tty_escape "1;$1"; } tty_underline="$(tty_escape "4;39")" tty_yellow="$(tty_escape "0;33")" -tty_magenta="$(tty_mkbold 35)" -tty_green="$(tty_mkbold 32)" tty_blue="$(tty_mkbold 34)" tty_red="$(tty_mkbold 31)" tty_bold="$(tty_mkbold 39)" @@ -177,7 +175,7 @@ clone_repo() { elif check_nvim_version "${REQUIRED_NVIM_VERSION_LEGACY}"; then warn "You have outdated Nvim installed (< ${REQUIRED_NVIM_VERSION})." info "Automatically redirecting you to the latest compatible version..." - execute "git" "clone" "-b" "${REQUIRED_NVIM_VERSION_LEGACY}" "${CLONE_ATTR[@]}" "$1" "${DEST_DIR}" + execute "git" "clone" "-b" "0.9" "${CLONE_ATTR[@]}" "$1" "${DEST_DIR}" else warn "You have outdated Nvim installed (< ${REQUIRED_NVIM_VERSION_LEGACY})." abort "$( From 59bc46ba1c8ee3dce4cf767efdb412da46388c5c Mon Sep 17 00:00:00 2001 From: Jint-lzxy <50296129+Jint-lzxy@users.noreply.github.com> Date: Fri, 7 Jun 2024 21:04:48 +0800 Subject: [PATCH 39/72] feat(README): supports `0.9` -> `0.10` Signed-off-by: Jint-lzxy <50296129+Jint-lzxy@users.noreply.github.com> --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 0026d621a..c8c20d666 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ Neovim Version Capability + src="https://img.shields.io/badge/Supports%20Nvim-v0.10-A6D895?style=for-the-badge&colorA=363A4F&logo=neovim&logoColor=D9E0EE"> Date: Fri, 7 Jun 2024 21:43:15 +0800 Subject: [PATCH 40/72] chore: cleanup Signed-off-by: Jint-lzxy <50296129+Jint-lzxy@users.noreply.github.com> --- lua/core/event.lua | 2 +- lua/core/init.lua | 11 ----------- lua/core/options.lua | 2 +- lua/modules/configs/editor/autotag.lua | 9 --------- lua/modules/configs/lang/crates-keymap.lua | 1 - lua/modules/plugins/tool.lua | 3 ++- lua/modules/utils/init.lua | 1 - 7 files changed, 4 insertions(+), 25 deletions(-) diff --git a/lua/core/event.lua b/lua/core/event.lua index 2ef32b51b..25d9eb466 100644 --- a/lua/core/event.lua +++ b/lua/core/event.lua @@ -6,7 +6,7 @@ function autocmd.nvim_create_augroups(definitions) vim.api.nvim_command("augroup " .. group_name) vim.api.nvim_command("autocmd!") for _, def in ipairs(definition) do - local command = table.concat(vim.iter({ "autocmd", def }):flatten(), " ") + local command = table.concat(vim.iter({ "autocmd", def }):flatten(math.huge):totable(), " ") vim.api.nvim_command(command) end vim.api.nvim_command("augroup END") diff --git a/lua/core/init.lua b/lua/core/init.lua index 646ca9645..a6ebc62cc 100644 --- a/lua/core/init.lua +++ b/lua/core/init.lua @@ -145,16 +145,6 @@ You're recommended to install PowerShell for better experience.]], end end -local _v0_10_workarounds = function() - local ok, watchfile = pcall(require, "vim.lsp._watchfiles") - if ok then - -- Disable lsp watcher - watchfile._watchfunc = function() - return function() end - end - end -end - local load_core = function() createdir() disable_distribution_plugins() @@ -164,7 +154,6 @@ local load_core = function() neovide_config() clipboard_config() shell_config() - _v0_10_workarounds() require("core.options") require("core.mapping") diff --git a/lua/core/options.lua b/lua/core/options.lua index b3b3e0295..8ee07be5f 100644 --- a/lua/core/options.lua +++ b/lua/core/options.lua @@ -120,7 +120,7 @@ local function load_options() end for name, value in pairs(require("modules.utils").extend_config(global_local, "user.options")) do - vim.o[name] = value + vim.api.nvim_set_option_value(name, value, {}) end end diff --git a/lua/modules/configs/editor/autotag.lua b/lua/modules/configs/editor/autotag.lua index 0071263f9..42dcd973f 100644 --- a/lua/modules/configs/editor/autotag.lua +++ b/lua/modules/configs/editor/autotag.lua @@ -1,18 +1,9 @@ return function() require("modules.utils").load_plugin("nvim-ts-autotag", { opts = { - -- Defaults enable_close = true, -- Auto close tags enable_rename = true, -- Auto rename pairs of tags enable_close_on_slash = false, -- Auto close on trailing ct"] = map_callback(function() crates.toggle() diff --git a/lua/modules/plugins/tool.lua b/lua/modules/plugins/tool.lua index 2d8b9555d..e0e70fd5e 100644 --- a/lua/modules/plugins/tool.lua +++ b/lua/modules/plugins/tool.lua @@ -4,7 +4,7 @@ tool["tpope/vim-fugitive"] = { lazy = true, cmd = { "Git", "G" }, } --- only for fcitx5 user who uses non-English language during coding +-- This is specifically for fcitx5 users who code in languages other than English -- tool["pysan3/fcitx5.nvim"] = { -- lazy = true, -- event = "BufReadPost", @@ -14,6 +14,7 @@ tool["tpope/vim-fugitive"] = { tool["Bekaboo/dropbar.nvim"] = { lazy = false, dependencies = { + "nvim-tree/nvim-web-devicons", "nvim-telescope/telescope-fzf-native.nvim", }, } diff --git a/lua/modules/utils/init.lua b/lua/modules/utils/init.lua index 4161752f1..c2c9fd53e 100644 --- a/lua/modules/utils/init.lua +++ b/lua/modules/utils/init.lua @@ -121,7 +121,6 @@ end ---@param background string @The background color to blend with ---@param alpha number|string @Number between 0 and 1 for blending amount. function M.blend(foreground, background, alpha) - ---@diagnostic disable-next-line: cast-local-type alpha = type(alpha) == "string" and (tonumber(alpha, 16) / 0xff) or alpha local bg = hex_to_rgb(background) local fg = hex_to_rgb(foreground) From 9be7ffedd1e5f59dd911e0de70d9cfdf9fcd8ae4 Mon Sep 17 00:00:00 2001 From: Jint-lzxy <50296129+Jint-lzxy@users.noreply.github.com> Date: Sat, 8 Jun 2024 01:43:05 +0800 Subject: [PATCH 41/72] fix(lualine): ensure all components are properly aligned Signed-off-by: Jint-lzxy <50296129+Jint-lzxy@users.noreply.github.com> --- lua/modules/configs/ui/lualine.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/lua/modules/configs/ui/lualine.lua b/lua/modules/configs/ui/lualine.lua index 39e4b8911..64c14371f 100644 --- a/lua/modules/configs/ui/lualine.lua +++ b/lua/modules/configs/ui/lualine.lua @@ -265,6 +265,7 @@ return function() colored = true, icon_only = false, icon = { align = "left" }, + padding = { left = 2, right = 1 }, }, components.file_status, vim.tbl_extend("force", components.separator, { From f6ebc056c255869e27750b0773c4c5c798692559 Mon Sep 17 00:00:00 2001 From: Jint-lzxy <50296129+Jint-lzxy@users.noreply.github.com> Date: Sun, 9 Jun 2024 19:58:40 +0800 Subject: [PATCH 42/72] unlock rustaceanvim Signed-off-by: Jint-lzxy <50296129+Jint-lzxy@users.noreply.github.com> --- lua/modules/plugins/lang.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/modules/plugins/lang.lua b/lua/modules/plugins/lang.lua index 6877b0f0a..2cfc3974d 100644 --- a/lua/modules/plugins/lang.lua +++ b/lua/modules/plugins/lang.lua @@ -18,7 +18,7 @@ lang["ray-x/go.nvim"] = { lang["mrcjkb/rustaceanvim"] = { lazy = true, ft = "rust", - version = "^4", + version = "*", init = require("lang.rust"), dependencies = { "nvim-lua/plenary.nvim" }, } From 593c90618751b06dc440a938c3ecfba2c84a2506 Mon Sep 17 00:00:00 2001 From: Jint-lzxy <50296129+Jint-lzxy@users.noreply.github.com> Date: Sun, 9 Jun 2024 22:40:24 +0800 Subject: [PATCH 43/72] feat(lsp): be protective Signed-off-by: Jint-lzxy <50296129+Jint-lzxy@users.noreply.github.com> --- lua/modules/configs/completion/lsp.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/modules/configs/completion/lsp.lua b/lua/modules/configs/completion/lsp.lua index be60436db..ba3c5a873 100644 --- a/lua/modules/configs/completion/lsp.lua +++ b/lua/modules/configs/completion/lsp.lua @@ -19,5 +19,5 @@ return function() pcall(require, "user.configs.lsp") - vim.api.nvim_command([[LspStart]]) -- Start LSPs + pcall(vim.cmd.LspStart) -- Start LSPs end From a50a90e562d8525ee7f89f20b27fbf1c47be3282 Mon Sep 17 00:00:00 2001 From: Jint-lzxy <50296129+Jint-lzxy@users.noreply.github.com> Date: Sun, 9 Jun 2024 22:55:22 +0800 Subject: [PATCH 44/72] fix: `neovim` -> `Neovim` Signed-off-by: Jint-lzxy <50296129+Jint-lzxy@users.noreply.github.com> --- .github/ISSUE_TEMPLATE/bug_report.yml | 2 +- .github/ISSUE_TEMPLATE/custom_config.yml | 2 +- .github/ISSUE_TEMPLATE/lsp_issue_report.yml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml index d4f8280d8..4906f93c9 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -7,7 +7,7 @@ body: value: | _Before reporting:_ Search [existing issues](https://github.com/ayamir/nvimdots/issues) and check the [FAQ](https://github.com/ayamir/nvimdots/wiki/Issues). Thank you for helping us improve! > [!IMPORTANT] - > The `0.11` branch is intended for nightly neovim builds and is **not** stable. It typically harbors subtle issues scattered throughout. Therefore, refrain from submitting issues if you happen to encounter them. They will be closed directly unless a viable solution is proposed or included. + > The `0.11` branch is intended for nightly Neovim builds and is **not** stable. It typically harbors subtle issues scattered throughout. Therefore, refrain from submitting issues if you happen to encounter them. They will be closed directly unless a viable solution is proposed or included. - type: checkboxes id: is-latest-commit attributes: diff --git a/.github/ISSUE_TEMPLATE/custom_config.yml b/.github/ISSUE_TEMPLATE/custom_config.yml index 6b48fcd50..6a95d3903 100644 --- a/.github/ISSUE_TEMPLATE/custom_config.yml +++ b/.github/ISSUE_TEMPLATE/custom_config.yml @@ -7,7 +7,7 @@ body: value: | _Before requesting:_ Make sure you've read through our [Wiki: Usage](https://github.com/ayamir/nvimdots/wiki/Usage) before you start to add things to nvimdots! > [!IMPORTANT] - > The `0.11` branch is intended for nightly neovim builds and is **not** stable. It typically harbors subtle issues scattered throughout. Therefore, refrain from submitting issues if you happen to encounter them. They will be closed directly unless a viable solution is proposed or included. + > The `0.11` branch is intended for nightly Neovim builds and is **not** stable. It typically harbors subtle issues scattered throughout. Therefore, refrain from submitting issues if you happen to encounter them. They will be closed directly unless a viable solution is proposed or included. - type: checkboxes id: is-latest-commit attributes: diff --git a/.github/ISSUE_TEMPLATE/lsp_issue_report.yml b/.github/ISSUE_TEMPLATE/lsp_issue_report.yml index f18124c55..09978612c 100644 --- a/.github/ISSUE_TEMPLATE/lsp_issue_report.yml +++ b/.github/ISSUE_TEMPLATE/lsp_issue_report.yml @@ -7,7 +7,7 @@ body: value: | _Before reporting:_ Search [existing issues](https://github.com/ayamir/nvimdots/issues) and check the [FAQ](https://github.com/ayamir/nvimdots/wiki/Issues). Thank you for helping us improve! > [!IMPORTANT] - > The `0.11` branch is intended for nightly neovim builds and is **not** stable. It typically harbors subtle issues scattered throughout. Therefore, refrain from submitting issues if you happen to encounter them. They will be closed directly unless a viable solution is proposed or included. + > The `0.11` branch is intended for nightly Neovim builds and is **not** stable. It typically harbors subtle issues scattered throughout. Therefore, refrain from submitting issues if you happen to encounter them. They will be closed directly unless a viable solution is proposed or included. - type: checkboxes id: is-latest-commit attributes: From a55678e8594c42511d72f685ce208bf79c57de7c Mon Sep 17 00:00:00 2001 From: Jint-lzxy <50296129+Jint-lzxy@users.noreply.github.com> Date: Mon, 10 Jun 2024 00:23:59 +0800 Subject: [PATCH 45/72] Revert "fix(lualine): ensure all components are properly aligned" This reverts commit 9be7ffedd1e5f59dd911e0de70d9cfdf9fcd8ae4. --- lua/modules/configs/ui/lualine.lua | 1 - 1 file changed, 1 deletion(-) diff --git a/lua/modules/configs/ui/lualine.lua b/lua/modules/configs/ui/lualine.lua index 64c14371f..39e4b8911 100644 --- a/lua/modules/configs/ui/lualine.lua +++ b/lua/modules/configs/ui/lualine.lua @@ -265,7 +265,6 @@ return function() colored = true, icon_only = false, icon = { align = "left" }, - padding = { left = 2, right = 1 }, }, components.file_status, vim.tbl_extend("force", components.separator, { From e11310b0c2d14549bd47ce16b0b506a89cecb77e Mon Sep 17 00:00:00 2001 From: jint_lzxy_ <50296129+Jint-lzxy@users.noreply.github.com> Date: Mon, 10 Jun 2024 22:57:35 +0800 Subject: [PATCH 46/72] feat: support new options (#1279) Signed-off-by: Jint-lzxy <50296129+Jint-lzxy@users.noreply.github.com> --- lua/core/options.lua | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lua/core/options.lua b/lua/core/options.lua index 8ee07be5f..f79004ca2 100644 --- a/lua/core/options.lua +++ b/lua/core/options.lua @@ -17,8 +17,8 @@ local function load_options() clipboard = "unnamedplus", cmdheight = 1, -- 0, 1, 2 cmdwinheight = 5, - complete = ".,w,b,k", - completeopt = "menuone,noselect", + complete = ".,w,b,k,kspell", + completeopt = "menuone,noselect,popup", concealcursor = "niv", conceallevel = 0, cursorcolumn = true, @@ -70,6 +70,7 @@ local function load_options() signcolumn = "yes", smartcase = true, smarttab = true, + smoothscroll = true, splitbelow = true, splitkeep = "screen", splitright = true, From e8976c8cdf81ab22a935abbd6d93349b91705f54 Mon Sep 17 00:00:00 2001 From: jint_lzxy_ <50296129+Jint-lzxy@users.noreply.github.com> Date: Mon, 10 Jun 2024 22:59:49 +0800 Subject: [PATCH 47/72] feat(trouble)!: v3 support (#1281) * feat(trouble)!: v3 support This PR includes the following changes: - *REMOVED* all features unrelated to the original purpose of trouble.nvim, such as LSP References (Glance.nvim covers this) and qf-list preview (bqf handles this). - Added a custom mapping for searching project diagnostics. This is slightly different from workspace diagnostics: one is defined by the language server itself (e.g., see LuaLS's documentation on workspace diagnostics), while the other is determined with assistance from Project.nvim. - General cleanup: I deliberately excluded LspKind support from our config this time bc imho it's a feature we likely won't use and supporting it is a real hassle. Signed-off-by: Jint-lzxy <50296129+Jint-lzxy@users.noreply.github.com> * fixup! Missing one option * fix: invoke `utils.load_plugin` Signed-off-by: Jint-lzxy <50296129+Jint-lzxy@users.noreply.github.com> --------- Signed-off-by: Jint-lzxy <50296129+Jint-lzxy@users.noreply.github.com> --- lua/keymap/tool.lua | 19 +++---- lua/modules/configs/tool/trouble.lua | 75 +++++++++++---------------- lua/modules/configs/ui/catppuccin.lua | 1 + 3 files changed, 37 insertions(+), 58 deletions(-) diff --git a/lua/keymap/tool.lua b/lua/keymap/tool.lua index a77f0b54f..50eead580 100644 --- a/lua/keymap/tool.lua +++ b/lua/keymap/tool.lua @@ -63,24 +63,19 @@ local plug_map = { :with_desc("git: Toggle lazygit"), -- Plugin: trouble - ["n|gt"] = map_cr("TroubleToggle"):with_noremap():with_silent():with_desc("lsp: Toggle trouble list"), - ["n|ll"] = map_cr("TroubleToggle lsp_references") + ["n|gt"] = map_cr("Trouble diagnostics toggle"):with_noremap():with_silent():with_desc("lsp: Toggle trouble list"), + ["n|lw"] = map_cr("Trouble diagnostics toggle") :with_noremap() :with_silent() - :with_desc("lsp: Show lsp references"), - ["n|ld"] = map_cr("TroubleToggle document_diagnostics") - :with_noremap() - :with_silent() - :with_desc("lsp: Show document diagnostics"), - ["n|lw"] = map_cr("TroubleToggle workspace_diagnostics") + :with_desc("lsp: Show workspace diagnostics"), + ["n|lp"] = map_cr("Trouble project_diagnostics toggle") :with_noremap() :with_silent() - :with_desc("lsp: Show workspace diagnostics"), - ["n|lq"] = map_cr("TroubleToggle quickfix") + :with_desc("lsp: Show project diagnostics"), + ["n|ld"] = map_cr("Trouble diagnostics toggle filter.buf=0") :with_noremap() :with_silent() - :with_desc("lsp: Show quickfix list"), - ["n|lL"] = map_cr("TroubleToggle loclist"):with_noremap():with_silent():with_desc("lsp: Show loclist"), + :with_desc("lsp: Show document diagnostics"), -- Plugin: telescope ["n|"] = map_callback(function() diff --git a/lua/modules/configs/tool/trouble.lua b/lua/modules/configs/tool/trouble.lua index 386af479a..6a9bbfcb0 100644 --- a/lua/modules/configs/tool/trouble.lua +++ b/lua/modules/configs/tool/trouble.lua @@ -1,55 +1,38 @@ return function() local icons = { - ui = require("modules.utils.icons").get("ui"), - diagnostics = require("modules.utils.icons").get("diagnostics"), + ui = require("modules.utils.icons").get("ui", true), } require("modules.utils").load_plugin("trouble", { - position = "bottom", -- position of the list can be: bottom, top, left, right - height = 10, -- height of the trouble list when position is top or bottom - width = 50, -- width of the list when position is left or right - icons = true, -- use devicons for filenames - mode = "document_diagnostics", -- "workspace_diagnostics", "document_diagnostics", "quickfix", "lsp_references", "loclist" - fold_open = icons.ui.ArrowOpen, -- icon used for open folds - fold_closed = icons.ui.ArrowClosed, -- icon used for closed folds - group = true, -- group results by file - padding = true, -- add an extra new line on top of the list - action_keys = { - -- key mappings for actions in the trouble list - -- map to {} to remove a mapping, for example: - -- close = {}, - close = "q", -- close the list - cancel = "", -- cancel the preview and get back to your last window / buffer / cursor - refresh = "r", -- manually refresh - jump = { "", "" }, -- jump to the diagnostic or open / close folds - open_split = { "" }, -- open buffer in new split - open_vsplit = { "" }, -- open buffer in new vsplit - open_tab = { "" }, -- open buffer in new tab - jump_close = { "o" }, -- jump to the diagnostic and close the list - toggle_mode = "m", -- toggle between "workspace" and "document" diagnostics mode - toggle_preview = "P", -- toggle auto_preview - hover = "K", -- opens a small popup with the full multiline message - preview = "p", -- preview the diagnostic location - close_folds = { "zM", "zm" }, -- close all folds - open_folds = { "zR", "zr" }, -- open all folds - toggle_fold = { "zA", "za" }, -- toggle fold of current file - previous = "k", -- preview item - next = "j", -- next item + auto_open = false, + auto_close = false, + auto_jump = false, + auto_preview = true, + auto_refresh = true, + focus = false, -- do not focus the window when opened + follow = true, + restore = true, + icons = { + indent = { + fold_open = icons.ui.ArrowOpen, + fold_closed = icons.ui.ArrowClosed, + }, + folder_closed = icons.ui.Folder, + folder_open = icons.ui.FolderOpen, }, - indent_lines = true, -- add an indent guide below the fold icons - auto_open = false, -- automatically open the list when you have diagnostics - auto_close = false, -- automatically close the list when you have no diagnostics - auto_preview = true, -- automatically preview the location of the diagnostic. to close preview and go back to last window - auto_fold = false, -- automatically fold a file trouble list at creation - auto_jump = { "lsp_definitions" }, -- for the given modes, automatically jump if there is only a single result - signs = { - -- icons / text used for a diagnostic - error = icons.diagnostics.Error_alt, - warning = icons.diagnostics.Warning_alt, - hint = icons.diagnostics.Hint_alt, - information = icons.diagnostics.Information_alt, - other = icons.diagnostics.Question_alt, + modes = { + project_diagnostics = { + mode = "diagnostics", + filter = { + any = { + { + function(item) + return item.filename:find(vim.fn.getcwd(), 1, true) + end, + }, + }, + }, + }, }, - use_diagnostic_signs = false, -- enabling this will use the signs defined in your lsp client }) end diff --git a/lua/modules/configs/ui/catppuccin.lua b/lua/modules/configs/ui/catppuccin.lua index b3a402394..c0a9048b1 100644 --- a/lua/modules/configs/ui/catppuccin.lua +++ b/lua/modules/configs/ui/catppuccin.lua @@ -146,6 +146,7 @@ return function() -- For trouble.nvim TroubleNormal = { bg = transparent_background and cp.none or cp.base }, + TroubleNormalNC = { bg = transparent_background and cp.none or cp.base }, -- For telescope.nvim TelescopeMatching = { fg = cp.lavender }, From b74c753d3ff26a8bd3adb881813c9fee03983b82 Mon Sep 17 00:00:00 2001 From: jint_lzxy_ <50296129+Jint-lzxy@users.noreply.github.com> Date: Mon, 10 Jun 2024 23:01:24 +0800 Subject: [PATCH 48/72] refactor: overhaul the icon library (#1282) This PR significantly updates the icon library by expanding its content, removing duplicates, and organizing icons into more cohesive groups. I've also created a custom Dropbar config that uses these icons and adds toggleterm support. * fix typo * Oops... Missing one icon * fix: invoke `utils.load_plugin` Signed-off-by: Jint-lzxy <50296129+Jint-lzxy@users.noreply.github.com> --- lua/modules/configs/completion/lspsaga.lua | 2 +- lua/modules/configs/tool/dropbar.lua | 109 +++++++++++++++++++++ lua/modules/plugins/tool.lua | 1 + lua/modules/utils/icons.lua | 67 +++++++------ 4 files changed, 150 insertions(+), 29 deletions(-) create mode 100644 lua/modules/configs/tool/dropbar.lua diff --git a/lua/modules/configs/completion/lspsaga.lua b/lua/modules/configs/completion/lspsaga.lua index c31f280b3..d389991be 100644 --- a/lua/modules/configs/completion/lspsaga.lua +++ b/lua/modules/configs/completion/lspsaga.lua @@ -148,7 +148,6 @@ return function() Method = { icons.kind.Method, "LspKindMethod" }, Module = { icons.kind.Module, "LspKindModule" }, Namespace = { icons.kind.Namespace, "LspKindNamespace" }, - Number = { icons.kind.Number, "LspKindNumber" }, Operator = { icons.kind.Operator, "LspKindOperator" }, Package = { icons.kind.Package, "LspKindPackage" }, Property = { icons.kind.Property, "LspKindProperty" }, @@ -159,6 +158,7 @@ return function() Array = { icons.type.Array, "LspKindArray" }, Boolean = { icons.type.Boolean, "LspKindBoolean" }, Null = { icons.type.Null, "LspKindNull" }, + Number = { icons.type.Number, "LspKindNumber" }, Object = { icons.type.Object, "LspKindObject" }, String = { icons.type.String, "LspKindString" }, -- ccls-specific icons. diff --git a/lua/modules/configs/tool/dropbar.lua b/lua/modules/configs/tool/dropbar.lua new file mode 100644 index 000000000..a02dcaf04 --- /dev/null +++ b/lua/modules/configs/tool/dropbar.lua @@ -0,0 +1,109 @@ +return function() + local icons = { + kind = require("modules.utils.icons").get("kind", true), + type = require("modules.utils.icons").get("type", true), + misc = require("modules.utils.icons").get("misc", true), + ui = require("modules.utils.icons").get("ui", true), + } + + require("modules.utils").load_plugin("dropbar", { + bar = { + hover = false, + truncate = true, + pick = { pivots = "etovxqpdygfblzhckisuran" }, + }, + sources = { + path = { + relative_to = function() + -- Only show the leaf filename in dropbar + return vim.fn.expand("%:p:h") + end, + }, + terminal = { + name = function(buf) + local name = vim.api.nvim_buf_get_name(buf) + local term = select(2, require("toggleterm.terminal").identify(name)) + -- Trying to "snag" a display name from toggleterm + if term then + return term.display_name or term.name + else + return name + end + end, + }, + }, + icons = { + enable = true, + kinds = { + use_devicons = true, + symbols = { + -- Type + Array = icons.type.Array, + Boolean = icons.type.Boolean, + Null = icons.type.Null, + Number = icons.type.Number, + Object = icons.type.Object, + String = icons.type.String, + Text = icons.type.String, + + -- Kind + BreakStatement = icons.kind.Break, + Call = icons.kind.Call, + CaseStatement = icons.kind.Case, + Class = icons.kind.Class, + Color = icons.kind.Color, + Constant = icons.kind.Constant, + Constructor = icons.kind.Constructor, + ContinueStatement = icons.kind.Continue, + Declaration = icons.kind.Declaration, + Delete = icons.kind.Delete, + DoStatement = icons.kind.Loop, + Enum = icons.kind.Enum, + EnumMember = icons.kind.EnumMember, + Event = icons.kind.Event, + Field = icons.kind.Field, + File = icons.kind.File, + ForStatement = icons.kind.Loop, + Function = icons.kind.Function, + Identifier = icons.kind.Variable, + Interface = icons.kind.Interface, + Keyword = icons.kind.Keyword, + List = icons.kind.List, + Lsp = icons.misc.LspAvailable, + Method = icons.kind.Method, + Module = icons.kind.Module, + Namespace = icons.kind.Namespace, + Operator = icons.kind.Operator, + Package = icons.kind.Package, + Pair = icons.kind.List, + Property = icons.kind.Property, + Reference = icons.kind.Reference, + Regex = icons.kind.Regex, + Repeat = icons.kind.Loop, + Scope = icons.kind.Statement, + Snippet = icons.kind.Snippet, + Statement = icons.kind.Statement, + Struct = icons.kind.Struct, + SwitchStatement = icons.kind.Switch, + Type = icons.kind.Interface, + TypeParameter = icons.kind.TypeParameter, + Unit = icons.kind.Unit, + Value = icons.kind.Value, + Variable = icons.kind.Variable, + WhileStatement = icons.kind.Loop, + + -- Microsoft-specific icons + Folder = icons.kind.Folder, + + -- ccls-specific icons + Macro = icons.kind.Macro, + Terminal = icons.kind.Terminal, + }, + }, + ui = { + bar = { separator = "  " }, + menu = { indicator = icons.ui.ArrowClosed }, + }, + }, + }) +end diff --git a/lua/modules/plugins/tool.lua b/lua/modules/plugins/tool.lua index e0e70fd5e..33fb33424 100644 --- a/lua/modules/plugins/tool.lua +++ b/lua/modules/plugins/tool.lua @@ -13,6 +13,7 @@ tool["tpope/vim-fugitive"] = { -- } tool["Bekaboo/dropbar.nvim"] = { lazy = false, + config = require("tool.dropbar"), dependencies = { "nvim-tree/nvim-web-devicons", "nvim-telescope/telescope-fzf-native.nvim", diff --git a/lua/modules/utils/icons.lua b/lua/modules/utils/icons.lua index 2b24b3cdb..eab8da2c7 100644 --- a/lua/modules/utils/icons.lua +++ b/lua/modules/utils/icons.lua @@ -2,10 +2,16 @@ local icons = {} local data = { kind = { + Break = "󰙧", + Call = "󰃷", + Case = "󰬶", Class = "󰠱", Color = "󰏘", Constant = "󰏿", Constructor = "", + Continue = "󰞘", + Declaration = "󰙠", + Delete = "󱟁", Enum = "", EnumMember = "", Event = "", @@ -14,30 +20,35 @@ local data = { Folder = "󰉋", Fragment = "", Function = "󰊕", - Interface = "", Implementation = "", + Interface = "", Keyword = "󰌋", + List = "󰅪", + Loop = "󰑖", Method = "󰆧", Module = "", Namespace = "󰌗", - Number = "", Operator = "󰆕", Package = "", Property = "󰜢", Reference = "", + Regex = "", Snippet = "", + Statement = "󰅩", Struct = "", + Switch = "", Text = "󰉿", TypeParameter = "󰅲", Undefined = "", Unit = "", Value = "󰎠", Variable = "", - -- ccls-specific icons. - TypeAlias = "", + -- ccls-specific icons + Macro = "", Parameter = "", StaticMethod = "", - Macro = "", + Terminal = "", + TypeAlias = "", }, type = { Array = "󰅪", @@ -92,6 +103,7 @@ local data = { CodeAction = "󰌵", Comment = "󰅺", Dashboard = "", + DoubleSeparator = "󰄾", Emoji = "󰱫", EmptyFolder = "", EmptyFolderOpen = "", @@ -107,8 +119,6 @@ local data = { Keyboard = "", Left = "", List = "", - Square = "", - SymlinkFolder = "", Lock = "󰍁", Modified = "✥", Modified_alt = "", @@ -125,12 +135,13 @@ local data = { RootFolderOpened = "", Search = "󰍉", Separator = "", - DoubleSeparator = "󰄾", SignIn = "", SignOut = "", Sort = "", Spell = "󰓆", + Square = "", Symlink = "", + SymlinkFolder = "", Tab = "", Table = "", Telescope = "", @@ -142,7 +153,7 @@ local data = { Information = "", Question = "", Hint = "󰌵", - -- Holo version + -- Hollow version Error_alt = "󰅚", Warning_alt = "󰀪", Information_alt = "", @@ -150,37 +161,28 @@ local data = { Hint_alt = "󰌶", }, misc = { + Add = "+", + Added = "", Campass = "󰀹", Code = "", Gavel = "", + Ghost = "󰊠", Glass = "󰂖", + Lego = "", + LspAvailable = "󱜙", + ManUp = "", + Neovim = "", NoActiveLsp = "󱚧", PyEnv = "󰢩", Squirrel = "", Tag = "", Tree = "", - Watch = "", - Lego = "", - LspAvailable = "󱜙", Vbar = "│", - Add = "+", - Added = "", - Ghost = "󰊠", - ManUp = "", - Neovim = "", Vim = "", + Watch = "", }, cmp = { - Codeium = "", - TabNine = "", - Copilot = "", - Copilot_alt = "", - -- Add source-specific icons here - buffer = "", - cmp_tabnine = "", - codeium = "", - copilot = "", - copilot_alt = "", + buffer = "󰉿", latex_symbols = "", luasnip = "󰃐", nvim_lsp = "", @@ -191,6 +193,15 @@ local data = { tmux = "", treesitter = "", undefined = "", + -- Add source-specific icons here + codeium = "", + Codeium = "", + copilot = "", + copilot_alt = "", + Copilot = "", + Copilot_alt = "", + TabNine = "", + cmp_tabnine = "", }, dap = { Breakpoint = "󰝥", @@ -211,7 +222,7 @@ local data = { ---Get a specific icon set. ---@param category "kind"|"type"|"documents"|"git"|"ui"|"diagnostics"|"misc"|"cmp"|"dap" ----@param add_space? boolean @Add trailing space after the icon. +---@param add_space? boolean @Add trailing whitespace after the icon. function icons.get(category, add_space) if add_space then return setmetatable({}, { From f639f8776856d94bb13aed6caf4094c8f70bf808 Mon Sep 17 00:00:00 2001 From: jint_lzxy_ <50296129+Jint-lzxy@users.noreply.github.com> Date: Mon, 10 Jun 2024 23:01:43 +0800 Subject: [PATCH 49/72] feat(lsp): correctly configure diagnostic-signs (#1280) Signed-off-by: Jint-lzxy <50296129+Jint-lzxy@users.noreply.github.com> --- lua/modules/configs/completion/lspsaga.lua | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/lua/modules/configs/completion/lspsaga.lua b/lua/modules/configs/completion/lspsaga.lua index d389991be..162cdda2c 100644 --- a/lua/modules/configs/completion/lspsaga.lua +++ b/lua/modules/configs/completion/lspsaga.lua @@ -10,17 +10,17 @@ return function() } local function set_sidebar_icons() - -- Set icons for sidebar. - local diagnostic_icons = { - Error = icons.diagnostics.Error_alt, - Warn = icons.diagnostics.Warning_alt, - Info = icons.diagnostics.Information_alt, - Hint = icons.diagnostics.Hint_alt, - } - for type, icon in pairs(diagnostic_icons) do - local hl = "DiagnosticSign" .. type - vim.fn.sign_define(hl, { text = icon, texthl = hl }) - end + -- Set icons for sidebar + vim.diagnostic.config({ + signs = { + text = { + [vim.diagnostic.severity.ERROR] = icons.diagnostics.Error_alt, + [vim.diagnostic.severity.WARN] = icons.diagnostics.Warning_alt, + [vim.diagnostic.severity.INFO] = icons.diagnostics.Information_alt, + [vim.diagnostic.severity.HINT] = icons.diagnostics.Hint_alt, + }, + }, + }) end set_sidebar_icons() From 2da7aedcf002f0b6bf12c2530576d9230fd05683 Mon Sep 17 00:00:00 2001 From: jint_lzxy_ <50296129+Jint-lzxy@users.noreply.github.com> Date: Tue, 11 Jun 2024 11:44:21 +0800 Subject: [PATCH 50/72] feat: disable more plugins for RO (buf|file)types (#1284) Signed-off-by: Jint-lzxy <50296129+Jint-lzxy@users.noreply.github.com> --- lua/modules/configs/completion/copilot.lua | 8 +++++- lua/modules/configs/editor/autoclose.lua | 18 ++++++++++++- lua/modules/configs/editor/bigfile.lua | 2 +- lua/modules/configs/tool/nvim-tree.lua | 23 ++++++++++++++-- lua/modules/configs/ui/indent-blankline.lua | 29 ++++++++++++--------- lua/modules/configs/ui/neodim.lua | 23 +++++++++++++++- lua/modules/configs/ui/scrollview.lua | 12 ++++++++- lua/modules/configs/ui/todo.lua | 17 +++++++++++- 8 files changed, 112 insertions(+), 20 deletions(-) diff --git a/lua/modules/configs/completion/copilot.lua b/lua/modules/configs/completion/copilot.lua index 96de94fd1..a6ea78c2a 100644 --- a/lua/modules/configs/completion/copilot.lua +++ b/lua/modules/configs/completion/copilot.lua @@ -14,8 +14,14 @@ return function() enabled = false, }, filetypes = { + ["bigfile"] = false, ["dap-repl"] = false, - ["big_file_disabled_ft"] = false, + ["fugitive"] = false, + ["fugitiveblame"] = false, + ["git"] = false, + ["gitcommit"] = false, + ["log"] = false, + ["toggleterm"] = false, }, }) end, 100) diff --git a/lua/modules/configs/editor/autoclose.lua b/lua/modules/configs/editor/autoclose.lua index d5e9b0d46..a43888f49 100644 --- a/lua/modules/configs/editor/autoclose.lua +++ b/lua/modules/configs/editor/autoclose.lua @@ -16,8 +16,24 @@ return function() ["'"] = { escape = true, close = true, pair = "''", disabled_filetypes = { "rust" } }, }, options = { - disabled_filetypes = { "big_file_disabled_ft" }, disable_when_touch = false, + disabled_filetypes = { + "alpha", + "bigfile", + "checkhealth", + "dap-repl", + "diff", + "help", + "log", + "notify", + "NvimTree", + "Outline", + "qf", + "TelescopePrompt", + "toggleterm", + "undotree", + "vimwiki", + }, }, }) end diff --git a/lua/modules/configs/editor/bigfile.lua b/lua/modules/configs/editor/bigfile.lua index c260a4432..28071772a 100644 --- a/lua/modules/configs/editor/bigfile.lua +++ b/lua/modules/configs/editor/bigfile.lua @@ -3,7 +3,7 @@ return function() name = "ftdetect", opts = { defer = true }, disable = function() - vim.api.nvim_set_option_value("filetype", "big_file_disabled_ft", { scope = "local" }) + vim.api.nvim_set_option_value("filetype", "bigfile", { scope = "local" }) end, } diff --git a/lua/modules/configs/tool/nvim-tree.lua b/lua/modules/configs/tool/nvim-tree.lua index 3f6f64112..fcf5288ce 100644 --- a/lua/modules/configs/tool/nvim-tree.lua +++ b/lua/modules/configs/tool/nvim-tree.lua @@ -126,8 +126,27 @@ return function() enable = true, chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890", exclude = { - filetype = { "notify", "qf", "diff", "fugitive", "fugitiveblame" }, - buftype = { "terminal", "help" }, + buftype = { + "help", + "nofile", + "prompt", + "quickfix", + "terminal", + }, + filetype = { + "dap-repl", + "diff", + "fugitive", + "fugitiveblame", + "git", + "notify", + "NvimTree", + "Outline", + "qf", + "TelescopePrompt", + "toggleterm", + "undotree", + }, }, }, }, diff --git a/lua/modules/configs/ui/indent-blankline.lua b/lua/modules/configs/ui/indent-blankline.lua index 1f55ea3a9..0f7b52d07 100644 --- a/lua/modules/configs/ui/indent-blankline.lua +++ b/lua/modules/configs/ui/indent-blankline.lua @@ -63,32 +63,37 @@ return function() }, }, exclude = { + buftypes = { + "help", + "nofile", + "prompt", + "quickfix", + "terminal", + }, filetypes = { "", -- for all buffers without a file type - "aerial", "alpha", - "big_file_disabled_ft", - "dashboard", - "dotooagenda", - "flutterToolsOutline", + "bigfile", + "checkhealth", + "dap-repl", + "diff", "fugitive", + "fugitiveblame", "git", "gitcommit", "help", - "json", "log", "markdown", + "notify", "NvimTree", - "peekaboo", - "startify", + "Outline", + "qf", "TelescopePrompt", - "todoist", - "txt", + "text", + "toggleterm", "undotree", "vimwiki", - "vista", }, - buftypes = { "terminal", "nofile", "quickfix", "prompt" }, }, }) end diff --git a/lua/modules/configs/ui/neodim.lua b/lua/modules/configs/ui/neodim.lua index 17a5b262c..08ee94d66 100644 --- a/lua/modules/configs/ui/neodim.lua +++ b/lua/modules/configs/ui/neodim.lua @@ -11,6 +11,27 @@ return function() underline = false, }, priority = 80, - disable = { "big_file_disabled_ft" }, + disable = { + "alpha", + "bigfile", + "checkhealth", + "dap-repl", + "diff", + "fugitive", + "fugitiveblame", + "git", + "gitcommit", + "help", + "log", + "notify", + "NvimTree", + "Outline", + "qf", + "TelescopePrompt", + "text", + "toggleterm", + "undotree", + "vimwiki", + }, }) end diff --git a/lua/modules/configs/ui/scrollview.lua b/lua/modules/configs/ui/scrollview.lua index d3a821d53..ef11b5992 100644 --- a/lua/modules/configs/ui/scrollview.lua +++ b/lua/modules/configs/ui/scrollview.lua @@ -3,12 +3,22 @@ return function() require("modules.utils").load_plugin("scrollview", { mode = "virtual", - excluded_filetypes = { "NvimTree", "terminal", "nofile", "aerial" }, winblend = 0, signs_on_startup = { "diagnostics", "folds", "marks", "search", "spell" }, diagnostics_error_symbol = icons.diagnostics.Error, diagnostics_warn_symbol = icons.diagnostics.Warning, diagnostics_info_symbol = icons.diagnostics.Information, diagnostics_hint_symbol = icons.diagnostics.Hint, + excluded_filetypes = { + "alpha", + "fugitive", + "git", + "notify", + "NvimTree", + "Outline", + "TelescopePrompt", + "toggleterm", + "undotree", + }, }) end diff --git a/lua/modules/configs/ui/todo.lua b/lua/modules/configs/ui/todo.lua index bbd8af4b8..ebdef8ee3 100644 --- a/lua/modules/configs/ui/todo.lua +++ b/lua/modules/configs/ui/todo.lua @@ -30,7 +30,22 @@ return function() after = "", comments_only = true, max_line_len = 500, - exclude = { "big_file_disabled_ft", "checkhealth" }, + exclude = { + "alpha", + "bigfile", + "checkhealth", + "dap-repl", + "diff", + "help", + "log", + "notify", + "NvimTree", + "Outline", + "qf", + "TelescopePrompt", + "toggleterm", + "undotree", + }, }, colors = { error = { "DiagnosticError", "ErrorMsg", "#DC2626" }, From 281930a05b8fbc391866b1b04fd106b8cde23498 Mon Sep 17 00:00:00 2001 From: jint_lzxy_ <50296129+Jint-lzxy@users.noreply.github.com> Date: Tue, 11 Jun 2024 11:56:50 +0800 Subject: [PATCH 51/72] fix(alpha): cannot cast `string` to `integer` for winheight (#1285) iirc this is deprecated Signed-off-by: Jint-lzxy <50296129+Jint-lzxy@users.noreply.github.com> --- lua/modules/configs/ui/alpha.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/modules/configs/ui/alpha.lua b/lua/modules/configs/ui/alpha.lua index c84dbcf06..73a489c12 100644 --- a/lua/modules/configs/ui/alpha.lua +++ b/lua/modules/configs/ui/alpha.lua @@ -113,7 +113,7 @@ return function() local head_butt_padding = 2 local occu_height = #dashboard.section.header.val + 2 * #dashboard.section.buttons.val + head_butt_padding - local header_padding = math.max(0, math.ceil((vim.fn.winheight("$") - occu_height) * 0.25)) + local header_padding = math.max(0, math.ceil((vim.fn.winheight(0) - occu_height) * 0.25)) local foot_butt_padding = 1 dashboard.config.layout = { From 2e848272b1564720dc0e4cad2d1726f09a956099 Mon Sep 17 00:00:00 2001 From: jint_lzxy_ <50296129+Jint-lzxy@users.noreply.github.com> Date: Wed, 12 Jun 2024 14:09:21 +0800 Subject: [PATCH 52/72] feat(ibl): support per-language indent config (#1287) * feat(ibl): support per-language indent config Signed-off-by: Jint-lzxy <50296129+Jint-lzxy@users.noreply.github.com> * fixup! feat(ibl): support per-language indent config --------- Signed-off-by: Jint-lzxy <50296129+Jint-lzxy@users.noreply.github.com> --- lua/modules/configs/ui/indent-blankline.lua | 498 ++++++++++++++++++-- 1 file changed, 458 insertions(+), 40 deletions(-) diff --git a/lua/modules/configs/ui/indent-blankline.lua b/lua/modules/configs/ui/indent-blankline.lua index 0f7b52d07..987b6fdec 100644 --- a/lua/modules/configs/ui/indent-blankline.lua +++ b/lua/modules/configs/ui/indent-blankline.lua @@ -1,4 +1,414 @@ return function() + -- This list delineates the per-language nodes used for guiding |ibl| in highlighting the current scope + -- It is extracted from each language's `indents.scm` file + -- NOTE: Only a subset of the supported programming languages is included + -- If your preferred language isn't listed, you can add it to the user config + local nodes = { + bibtex = { + "entry", + }, + c = { + "case_statement", + "compound_literal_expression", + "enumerator_list", + "field_declaration_list", + "initializer_list", + "init_declarator", + }, + cmake = { + "block_def", + "foreach_loop", + "function_def", + "if_condition", + "macro_def", + "normal_command", + "while_loop", + }, + cpp = { + "case_statement", + "compound_literal_expression", + "condition_clause", + "enumerator_list", + "field_declaration_list", + "field_initializer_list", + "init_declarator", + "initializer_list", + "namespace_definition", + }, + css = { + "block", + "declaration", + }, + d = { + "aggregate_body", + "block_statement", + "case_statement", + "expression_statement", + "function_body", + "parameters", + "scope_statement", + "template_parameters", + }, + dart = { + "arguments", + "class_body", + "formal_parameter", + "formal_parameter_list", + "function_body", + "function_expression_body", + "initializers", + "list_literal", + "return_statement", + "switch_block", + }, + ecma = { + "arguments", + "array", + "binary_expression", + "call_expression", + "class_body", + "export_clause", + "formal_parameters", + "named_imports", + "object", + "object_pattern", + "parenthesized_expression", + "return_statement", + "switch_case", + "switch_default", + "switch_statement", + "template_substitution", + "ternary_expression", + }, + elixir = { + "arguments", + "block", + "do_block", + "list", + "map", + "tuple", + }, + firrtl = { + "memory", + }, + fortran = { + "derived_type_definition", + "do_loop_statement", + "enum", + "function", + "if_statement", + "module", + "program", + "subroutine", + "where_statement", + }, + go = { + "call_expression", + "communication_case", + "const_declaration", + "default_case", + "expression_case", + "import_declaration", + "literal_value", + "parameter_list", + "struct_type", + "type_case", + "type_declaration", + "var_declaration", + }, + html = { + "start_tag", + }, + java = { + "annotation_argument_list", + "annotation_type_body", + "argument_list", + "array_initializer", + "class_body", + "constructor_body", + "element_value_array_initializer", + "enum_body", + "formal_parameters", + "interface_body", + "method_invocation", + "switch_block", + }, + javascript = { + "arguments", + "array", + "binary_expression", + "call_expression", + "class_body", + "export_clause", + "formal_parameters", + "jsx_expression", + "jsx_self_closing_element", + "named_imports", + "object", + "object_pattern", + "parenthesized_expression", + "return_statement", + "switch_case", + "switch_default", + "switch_statement", + "template_substitution", + "ternary_expression", + }, + julia = { + "assignment", + "call_expression", + "compound_statement", + "comprehension_expression", + "for_binding", + "if_statement", + "matrix_expression", + "parenthesized_expression", + "struct_definition", + "tuple_expression", + "vector_expression", + }, + linkerscript = { + "memory_command", + "output_section", + "phdrs_command", + "sections_command", + }, + lua = { + "arguments", + "field", + "method_index_expression", + "return_statement", + "table_constructor", + }, + matlab = { + "class_definition", + "enumeration", + "events", + "for_statement", + "if_statement", + "methods", + "properties", + "switch_statement", + "try_statement", + "while_statement", + }, + ninja = { + "build", + "pool", + "rule", + }, + pascal = { + "arrInitializer", + "block", + "declArgs", + "declClass", + "declConsts", + "declProc", + "declTypes", + "declUses", + "declVars", + "defaultValue", + "exprArgs", + "exprBrackets", + "exprParens", + "exprSubscript", + "recInitializer", + "statement", + }, + php = { + "arguments", + "array_creation_expression", + "binary_expression", + "case_statement", + "compound_statement", + "declaration_list", + "default_statement", + "enum_declaration_list", + "formal_parameters", + "match_block", + "member_call_expression", + "parenthesized_expression", + "return_statement", + "switch_block", + }, + python = { + "binary_operator", + "case_clause", + "concatenated_string", + "for_statement", + "generator_expression", + "if_statement", + "import_from_statement", + "lambda", + "list_pattern", + "match_statement", + "parenthesized_expression", + "try_statement", + "tuple_pattern", + "while_statement", + "with_statement", + }, + query = { + "list", + "predicate", + }, + r = { + "brace_list", + "call", + "paren_list", + "pipe", + "special", + }, + readline = { + "conditional_construct", + }, + ruby = { + "argument_list", + "array", + "assignment", + "begin", + "call", + "case", + "for", + "hash", + "if", + "module", + "parenthesized_statements", + "singleton_class", + "singleton_method", + "unless", + "until", + "while", + }, + rust = { + "arguments", + "array_expression", + "assignment_expression", + "call_expression", + "enum_variant_list", + "field_declaration_list", + "macro_definition", + "match_block", + "mod_item", + "ordered_field_declaration_list", + "parameters", + "struct_expression", + "struct_pattern", + "token_repetition", + "token_tree", + "trait_item", + "tuple_expression", + "tuple_pattern", + "tuple_struct_pattern", + "tuple_type", + "use_list", + "where_clause", + }, + sql = { + "case", + "column_definitions", + "cte", + "insert", + "select", + "subquery", + "when_clause", + }, + ssh_config = { + "host_declaration", + "match_declaration", + }, + swift = { + "array_literal", + "array_type", + "assignment", + "call_expression", + "class_body", + "computed_getter", + "computed_property", + "computed_setter", + "control_transfer_statement", + "deinit_declaration", + "dictionary_literal", + "dictionary_type", + "didset_clause", + "enum_class_body", + "init_declaration", + "lambda_literal", + "protocol_body", + "subscript_declaration", + "tuple_expression", + "tuple_type", + "type_parameters", + "willset_clause", + "willset_didset_block", + }, + tablegen = { + "assert", + "value_suffix", + }, + tcl = { + "braced_word_simple", + "command", + "command_substitution", + "conditional", + "foreach", + "namespace", + "procedure", + "try", + "while", + }, + teal = { + "record_declaration", + "function_body", + "table_constructor", + "return_statement", + "while_statement", + }, + textproto = { + "message_list", + "message_value", + "scalar_list", + }, + toml = { + "array", + "inline_table", + }, + typescript = { + "arguments", + "array", + "binary_expression", + "call_expression", + "class_body", + "enum_declaration", + "export_clause", + "formal_parameters", + "interface_declaration", + "named_imports", + "object", + "object_pattern", + "object_type", + "parenthesized_expression", + "return_statement", + "switch_case", + "switch_default", + "switch_statement", + "template_substitution", + "ternary_expression", + }, + vue = { + "start_tag", + }, + xml = { + "element", + }, + zig = { + "Block", + "ContainerDecl", + "InitList", + "SwitchExpr", + }, + } + require("modules.utils").load_plugin("ibl", { enabled = true, debounce = 200, @@ -19,46 +429,54 @@ return function() priority = 1000, include = { node_type = { - ["*"] = { - "argument_list", - "arguments", - "assignment_statement", - "Block", - "class", - "ContainerDecl", - "dictionary", - "do_block", - "do_statement", - "element", - "except", - "FnCallArguments", - "for", - "for_statement", - "function", - "function_declaration", - "function_definition", - "if_statement", - "IfExpr", - "IfStatement", - "import", - "InitList", - "list_literal", - "method", - "object", - "ParamDeclList", - "repeat_statement", - "selector", - "SwitchExpr", - "table", - "table_constructor", - "try", - "tuple", - "type", - "var", - "while", - "while_statement", - "with", - }, + angular = nodes.html, + arduino = nodes.cpp, + astro = nodes.html, + bibtex = nodes.bibtex, + c = nodes.c, + cmake = nodes.cmake, + cpp = nodes.cpp, + css = nodes.css, + cuda = nodes.cpp, + d = nodes.d, + dart = nodes.dart, + ecma = nodes.ecma, + elixir = nodes.elixir, + firrtl = nodes.firrtl, + fortran = nodes.fortran, + glsl = nodes.c, + go = nodes.go, + hlsl = nodes.cpp, + html = nodes.html, + java = nodes.java, + javascript = nodes.javascript, + julia = nodes.julia, + linkerscript = nodes.linkerscript, + lua = nodes.lua, + luau = nodes.lua, + matlab = nodes.matlab, + ninja = nodes.ninja, + objc = nodes.c, + pascal = nodes.pascal, + php = nodes.php, + python = nodes.python, + query = nodes.query, + r = nodes.r, + readline = nodes.readline, + ruby = nodes.ruby, + rust = nodes.rust, + sql = nodes.sql, + ssh_config = nodes.ssh_config, + swift = nodes.swift, + tablegen = nodes.tablegen, + tcl = nodes.tcl, + teal = nodes.teal, + textproto = nodes.textproto, + toml = nodes.toml, + typescript = nodes.typescript, + vue = nodes.vue, + xml = nodes.xml, + zig = nodes.zig, }, }, }, From 086bb81a82ffa78812c23e68363ded7b7a305006 Mon Sep 17 00:00:00 2001 From: jint_lzxy_ <50296129+Jint-lzxy@users.noreply.github.com> Date: Thu, 13 Jun 2024 09:39:01 +0800 Subject: [PATCH 53/72] feat(ibl): more language nodes (#1288) * feat(ibl): more language nodes Signed-off-by: Jint-lzxy <50296129+Jint-lzxy@users.noreply.github.com> * feat(ibl): even more language nodes Signed-off-by: Charles Chiu * chore(ibl): sorting Signed-off-by: Charles Chiu --------- Signed-off-by: Jint-lzxy <50296129+Jint-lzxy@users.noreply.github.com> Signed-off-by: Charles Chiu Co-authored-by: Charles Chiu --- lua/modules/configs/ui/indent-blankline.lua | 61 +++++++++++++++++++++ 1 file changed, 61 insertions(+) diff --git a/lua/modules/configs/ui/indent-blankline.lua b/lua/modules/configs/ui/indent-blankline.lua index 987b6fdec..169a56f29 100644 --- a/lua/modules/configs/ui/indent-blankline.lua +++ b/lua/modules/configs/ui/indent-blankline.lua @@ -61,6 +61,10 @@ return function() "return_statement", "switch_block", }, + dot = { + "block", + "attr_list", + }, ecma = { "arguments", "array", @@ -102,6 +106,23 @@ return function() "subroutine", "where_statement", }, + gleam = { + "anonymous_function", + "assert", + "case", + "constant", + "external_function", + "function", + "import", + "let", + "list", + "constant", + "function", + "type_definition", + "type_alias", + "todo", + "tuple", + }, go = { "call_expression", "communication_case", @@ -118,6 +139,7 @@ return function() }, html = { "start_tag", + "self_closing_tag", }, java = { "annotation_argument_list", @@ -167,6 +189,11 @@ return function() "tuple_expression", "vector_expression", }, + just = { + "external_command", + "recipe", + "string", + }, linkerscript = { "memory_command", "output_section", @@ -197,6 +224,20 @@ return function() "pool", "rule", }, + ocaml = { + "application_expression", + "do_clause", + "external", + "field_expression", + "if_expression", + "list_expression", + "parenthesized_expression", + "record_declaration", + "record_expression", + "try_expression", + "type_binding", + "value_specification", + }, pascal = { "arrInitializer", "block", @@ -304,6 +345,13 @@ return function() "use_list", "where_clause", }, + scss = { + "block", + "declaration", + "each_statement", + "mixin_statement", + "while_statement", + }, sql = { "case", "column_definitions", @@ -364,6 +412,12 @@ return function() "return_statement", "while_statement", }, + terraform = { + "block", + "function_call", + "object", + "tuple", + }, textproto = { "message_list", "message_value", @@ -440,23 +494,28 @@ return function() cuda = nodes.cpp, d = nodes.d, dart = nodes.dart, + dot = nodes.dot, ecma = nodes.ecma, elixir = nodes.elixir, firrtl = nodes.firrtl, fortran = nodes.fortran, glsl = nodes.c, + gleam = nodes.gleam, go = nodes.go, hlsl = nodes.cpp, html = nodes.html, java = nodes.java, javascript = nodes.javascript, julia = nodes.julia, + just = nodes.just, linkerscript = nodes.linkerscript, lua = nodes.lua, luau = nodes.lua, matlab = nodes.matlab, ninja = nodes.ninja, objc = nodes.c, + ocaml = nodes.ocaml, + ocaml_interface = nodes.ocaml, pascal = nodes.pascal, php = nodes.php, python = nodes.python, @@ -465,12 +524,14 @@ return function() readline = nodes.readline, ruby = nodes.ruby, rust = nodes.rust, + scss = nodes.scss, sql = nodes.sql, ssh_config = nodes.ssh_config, swift = nodes.swift, tablegen = nodes.tablegen, tcl = nodes.tcl, teal = nodes.teal, + terraform = nodes.terraform, textproto = nodes.textproto, toml = nodes.toml, typescript = nodes.typescript, From 2fedc0861fb0bf4fc2e43886d51cb6bec32ed8dc Mon Sep 17 00:00:00 2001 From: jint_lzxy_ <50296129+Jint-lzxy@users.noreply.github.com> Date: Sun, 16 Jun 2024 16:28:18 +0800 Subject: [PATCH 54/72] feat(luasnip): support ECMAScript regexes (#1291) As per `:h luasnip-lsp-snippets-transformations` Signed-off-by: Jint-lzxy <50296129+Jint-lzxy@users.noreply.github.com> --- lua/modules/plugins/completion.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lua/modules/plugins/completion.lua b/lua/modules/plugins/completion.lua index d4b5d088d..aba34cae3 100644 --- a/lua/modules/plugins/completion.lua +++ b/lua/modules/plugins/completion.lua @@ -51,8 +51,9 @@ completion["hrsh7th/nvim-cmp"] = { dependencies = { { "L3MON4D3/LuaSnip", - dependencies = { "rafamadriz/friendly-snippets" }, + build = "make install_jsregexp", config = require("completion.luasnip"), + dependencies = { "rafamadriz/friendly-snippets" }, }, { "lukas-reineke/cmp-under-comparator" }, { "saadparwaiz1/cmp_luasnip" }, From 9937d589db509b0bc8ae19eaf077aa0ddd428f7f Mon Sep 17 00:00:00 2001 From: jint_lzxy_ <50296129+Jint-lzxy@users.noreply.github.com> Date: Mon, 17 Jun 2024 11:22:03 +0800 Subject: [PATCH 55/72] feat(core): use the lua API to set options (#1292) Signed-off-by: Jint-lzxy <50296129+Jint-lzxy@users.noreply.github.com> --- lua/core/init.lua | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lua/core/init.lua b/lua/core/init.lua index a6ebc62cc..6a49d0da0 100644 --- a/lua/core/init.lua +++ b/lua/core/init.lua @@ -161,10 +161,8 @@ local load_core = function() require("core.pack") require("keymap") - local colorscheme = settings.colorscheme - local background = settings.background - vim.api.nvim_command("set background=" .. background) - vim.api.nvim_command("colorscheme " .. colorscheme) + vim.api.nvim_set_option_value("background", settings.background, {}) + vim.cmd.colorscheme(settings.colorscheme) end load_core() From 80cda843117e1ae957ba2c954a206b6df57aaa92 Mon Sep 17 00:00:00 2001 From: Charles Chiu Date: Tue, 18 Jun 2024 13:39:24 +0800 Subject: [PATCH 56/72] feat: include several new plugins (#1235) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat(cmp): more completion candidates from opened buffers. (#1219) * buffer completion config * opts -> option * chore(lockfile): auto update lazy-lock.json * chore(plugins): tidying up (#1221) This commit mainly tweaks the loading events of some plugins to align with upstream specifications. Additionally, there have been enhancements made to certain documentation. Signed-off-by: Jint-lzxy <50296129+Jint-lzxy@users.noreply.github.com> * fix(plugins): remove duplicate specifications Signed-off-by: Jint-lzxy <50296129+Jint-lzxy@users.noreply.github.com> * fix: use `init` for vim plugins (#1222) Signed-off-by: ayamir * chore(lockfile): auto update lazy-lock.json * docs: mention the experimental nature of the 0.10 branch (#1215) * docs: add note for 0.10 nightly branch in readme. Signed-off-by: ayamir * chore(issue_template): add nightly warning Signed-off-by: Charles Chiu * chore(issue_tempate): linting Signed-off-by: Charles Chiu * docs: update readme for 0.10 branch. Co-authored-by: Jint-lzxy <50296129+Jint-lzxy@users.noreply.github.com> Signed-off-by: Mohu * chore(issue_template): add nightly warning Signed-off-by: Charles Chiu * chore(issue_template): add nightly warning Signed-off-by: Charles Chiu --------- Signed-off-by: ayamir Signed-off-by: Charles Chiu Signed-off-by: Mohu Signed-off-by: Jint-lzxy <50296129+Jint-lzxy@users.noreply.github.com> Co-authored-by: Charles Chiu Co-authored-by: Jint-lzxy <50296129+Jint-lzxy@users.noreply.github.com> * fix(ISSUE_TEMPLATE): format code Signed-off-by: Jint-lzxy <50296129+Jint-lzxy@users.noreply.github.com> * fix(README): misplaced content Signed-off-by: Jint-lzxy <50296129+Jint-lzxy@users.noreply.github.com> * fix(todo-comment): add missing keywords (#1225) Signed-off-by: Charles Chiu * chore(lockfile): auto update lazy-lock.json * fix(options): remove options managed by `vim-sleuth` (#1229) Since all tab-related stuff is now managed by `vim-sleuth`, I think it is better to remove the relevant options to avoid confusion. Signed-off-by: Jint-lzxy <50296129+Jint-lzxy@users.noreply.github.com> * chore(lockfile): auto update lazy-lock.json * fix(rustaceanvim): use `init` for its config (#1231) Signed-off-by: Jint-lzxy <50296129+Jint-lzxy@users.noreply.github.com> * chore(lockfile): auto update lazy-lock.json * feat!: improve go development experience (#1226) * chore(go): replace vim-go with go.nvim. Signed-off-by: ayamir * fix: install gopls by mason by default. Signed-off-by: ayamir * feat(keymap): set `n|gi` to goto implementation. Signed-off-by: ayamir * chore(keymap): use `gm` to jump to lsp implementations Co-authored-by: 冷酔閑吟 <50296129+Jint-lzxy@users.noreply.github.com> Signed-off-by: Mohu * fixup: remove unused `map_cu`. * chore: use gopls instead of null-ls to format. Signed-off-by: ayamir * chore: add notes for config options. Signed-off-by: ayamir * fixup: tidy settings for go.nvim and gopls. * docs: update more notes for how to config go.nvim. * chore: cleanup Signed-off-by: Jint-lzxy <50296129+Jint-lzxy@users.noreply.github.com> * fix: enable only the options that are truly necessary Signed-off-by: Jint-lzxy <50296129+Jint-lzxy@users.noreply.github.com> * fixup! chore: cleanup * fix(gopls): invalid config entry Signed-off-by: Jint-lzxy <50296129+Jint-lzxy@users.noreply.github.com> --------- Signed-off-by: ayamir Signed-off-by: Mohu Signed-off-by: Jint-lzxy <50296129+Jint-lzxy@users.noreply.github.com> Co-authored-by: 冷酔閑吟 <50296129+Jint-lzxy@users.noreply.github.com> Co-authored-by: neogtliu * feat!: add `advanced-git-search.nvim` * feat!: add `search.nvim` to enhance `telescope`. * feat: reorganize keymaps for telescope search collections. Signed-off-by: ayamir * fixup: update descriptions for modified keymaps. * chore: remove single diagnostic disable for undefined-field. Co-authored-by: jint_lzxy_ <50296129+Jint-lzxy@users.noreply.github.com> Signed-off-by: Mohu * chore: remove diagnostic disable for undefined-field. * feat!: replace `colorizer.lua` with `nvim-highlight-colors` * fix: invoke `utils.load_plugin` Signed-off-by: Jint-lzxy <50296129+Jint-lzxy@users.noreply.github.com> * chore(advanced-git-search): remove unused options Signed-off-by: Jint-lzxy <50296129+Jint-lzxy@users.noreply.github.com> * feat(telescope): add collection panel for `search.nvim` * chore: typo * feat: more documentation Signed-off-by: Jint-lzxy <50296129+Jint-lzxy@users.noreply.github.com> * chore: clean up * feat: don't hard-code collection names * chore: use custom loader * fix: disable warning * fix: CI & cleanup Signed-off-by: Jint-lzxy <50296129+Jint-lzxy@users.noreply.github.com> * Revert `lazy-lock.json` Signed-off-by: Jint-lzxy <50296129+Jint-lzxy@users.noreply.github.com> * fix: make luaJIT happy Signed-off-by: Jint-lzxy <50296129+Jint-lzxy@users.noreply.github.com> --------- Signed-off-by: Jint-lzxy <50296129+Jint-lzxy@users.noreply.github.com> Signed-off-by: ayamir Signed-off-by: Charles Chiu Signed-off-by: Mohu Co-authored-by: mjkx <52132505+mjkx5@users.noreply.github.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: 冷酔閑吟 <50296129+Jint-lzxy@users.noreply.github.com> Co-authored-by: Mohu Co-authored-by: neogtliu --- .github/workflows/lint_code.yml | 2 +- lua/core/mapping.lua | 1 + lua/keymap/helpers.lua | 27 ++++ lua/keymap/tool.lua | 44 +----- lua/modules/configs/editor/colorizer.lua | 3 - .../configs/editor/highlight-colors.lua | 31 +++++ lua/modules/configs/tool/search.lua | 130 ++++++++++++++++++ lua/modules/configs/tool/telescope.lua | 13 +- lua/modules/plugins/editor.lua | 11 +- lua/modules/plugins/tool.lua | 23 +++- 10 files changed, 224 insertions(+), 61 deletions(-) delete mode 100644 lua/modules/configs/editor/colorizer.lua create mode 100644 lua/modules/configs/editor/highlight-colors.lua create mode 100644 lua/modules/configs/tool/search.lua diff --git a/.github/workflows/lint_code.yml b/.github/workflows/lint_code.yml index 9e88fa59e..71d11c5e2 100644 --- a/.github/workflows/lint_code.yml +++ b/.github/workflows/lint_code.yml @@ -8,4 +8,4 @@ jobs: - uses: actions/checkout@v4 - uses: lunarmodules/luacheck@v1 with: - args: . --std luajit --globals vim _toggle_lazygit _buf_vtext _command_panel _flash_esc_or_noh _debugging --max-line-length 150 --no-config + args: . --std luajit --globals vim _debugging _command_panel _flash_esc_or_noh _telescope_collections _toggle_lazygit --max-line-length 150 --no-config diff --git a/lua/core/mapping.lua b/lua/core/mapping.lua index cb0c061de..351216925 100644 --- a/lua/core/mapping.lua +++ b/lua/core/mapping.lua @@ -34,6 +34,7 @@ local core_map = { ["n|"] = map_cr("wq"):with_desc("edit: Save file and quit"), ["n|"] = map_cr("q!"):with_desc("edit: Force quit"), ["n|o"] = map_cr("setlocal spell! spelllang=en_us"):with_desc("edit: Toggle spell check"), + ["n|bn"] = map_cu("enew"):with_noremap():with_silent():with_desc("buffer: New"), ["n|tn"] = map_cr("tabnew"):with_noremap():with_silent():with_desc("tab: Create a new tab"), ["n|tk"] = map_cr("tabnext"):with_noremap():with_silent():with_desc("tab: Move to next tab"), ["n|tj"] = map_cr("tabprevious"):with_noremap():with_silent():with_desc("tab: Move to previous tab"), diff --git a/lua/keymap/helpers.lua b/lua/keymap/helpers.lua index b411bcd79..60d99e46f 100644 --- a/lua/keymap/helpers.lua +++ b/lua/keymap/helpers.lua @@ -11,6 +11,33 @@ _G._command_panel = function() }) end +_G._telescope_collections = function(picker_type) + local actions = require("telescope.actions") + local action_state = require("telescope.actions.state") + local conf = require("telescope.config").values + local finder = require("telescope.finders") + local pickers = require("telescope.pickers") + picker_type = picker_type or {} + + local collections = vim.tbl_keys(require("search.tabs").collections) + pickers + .new(picker_type, { + prompt_title = "Telescope Collections", + finder = finder.new_table({ results = collections }), + sorter = conf.generic_sorter(picker_type), + attach_mappings = function(bufnr) + actions.select_default:replace(function() + actions.close(bufnr) + local selection = action_state.get_selected_entry() + require("search").open({ collection = selection[1] }) + end) + + return true + end, + }) + :find() +end + _G._flash_esc_or_noh = function() local flash_active, state = pcall(function() return require("flash.plugins.char").state diff --git a/lua/keymap/tool.lua b/lua/keymap/tool.lua index 50eead580..bd928f082 100644 --- a/lua/keymap/tool.lua +++ b/lua/keymap/tool.lua @@ -84,50 +84,12 @@ local plug_map = { :with_noremap() :with_silent() :with_desc("tool: Toggle command panel"), - ["n|u"] = map_callback(function() - require("telescope").extensions.undo.undo() + ["n|f"] = map_callback(function() + _telescope_collections(require("telescope.themes").get_dropdown()) end) :with_noremap() :with_silent() - :with_desc("edit: Show undo history"), - ["n|fp"] = map_callback(function() - require("telescope").extensions.projects.projects({}) - end) - :with_noremap() - :with_silent() - :with_desc("find: Project"), - ["n|fr"] = map_callback(function() - require("telescope").extensions.frecency.frecency({}) - end) - :with_noremap() - :with_silent() - :with_desc("find: File by frecency"), - ["n|fw"] = map_callback(function() - require("telescope").extensions.live_grep_args.live_grep_args() - end) - :with_noremap() - :with_silent() - :with_desc("find: Word in project"), - ["n|fe"] = map_cu("Telescope oldfiles"):with_noremap():with_silent():with_desc("find: File by history"), - ["n|ff"] = map_cu("Telescope find_files"):with_noremap():with_silent():with_desc("find: File in project"), - ["n|fc"] = map_callback(function() - require("telescope.builtin").colorscheme({ enable_preview = true }) - end) - :with_noremap() - :with_silent() - :with_desc("ui: Change colorscheme for current session"), - ["n|bn"] = map_cu(":enew"):with_noremap():with_silent():with_desc("buffer: New"), - ["n|fg"] = map_cu("Telescope git_files") - :with_noremap() - :with_silent() - :with_desc("find: file in git project"), - ["n|fz"] = map_cu("Telescope zoxide list") - :with_noremap() - :with_silent() - :with_desc("edit: Change current directory by zoxide"), - ["n|fb"] = map_cu("Telescope buffers"):with_noremap():with_silent():with_desc("find: Buffer opened"), - ["nv|fs"] = map_cu("Telescope grep_string"):with_noremap():with_silent():with_desc("find: Current word"), - ["n|fd"] = map_cu("Telescope persisted"):with_noremap():with_silent():with_desc("find: Session"), + :with_desc("tool: Open Telescope"), -- Plugin: dap ["n|"] = map_callback(function() diff --git a/lua/modules/configs/editor/colorizer.lua b/lua/modules/configs/editor/colorizer.lua deleted file mode 100644 index efee45019..000000000 --- a/lua/modules/configs/editor/colorizer.lua +++ /dev/null @@ -1,3 +0,0 @@ -return function() - require("modules.utils").load_plugin("colorizer", {}) -end diff --git a/lua/modules/configs/editor/highlight-colors.lua b/lua/modules/configs/editor/highlight-colors.lua new file mode 100644 index 000000000..06a0f6acd --- /dev/null +++ b/lua/modules/configs/editor/highlight-colors.lua @@ -0,0 +1,31 @@ +return function() + require("modules.utils").load_plugin("nvim-highlight-colors", { + render = "background", + enable_hex = true, + enable_short_hex = true, + enable_rgb = true, + enable_hsl = true, + enable_var_usage = true, + enable_named_colors = false, + enable_tailwind = false, + -- Exclude filetypes or buftypes from highlighting + exclude_filetypes = { + "alpha", + "bigfile", + "dap-repl", + "fugitive", + "git", + "notify", + "NvimTree", + "Outline", + "TelescopePrompt", + "toggleterm", + "undotree", + }, + exclude_buftypes = { + "nofile", + "prompt", + "terminal", + }, + }) +end diff --git a/lua/modules/configs/tool/search.lua b/lua/modules/configs/tool/search.lua new file mode 100644 index 000000000..e01f50437 --- /dev/null +++ b/lua/modules/configs/tool/search.lua @@ -0,0 +1,130 @@ +return function() + local builtin = require("telescope.builtin") + local extensions = require("telescope").extensions + + require("modules.utils").load_plugin("search", { + collections = { + file = { + initial_tab = 1, + tabs = { + { + name = "Files", + tele_func = function(opts) + opts = opts or {} + if vim.fn.isdirectory(".git") == 1 then + builtin.git_files(opts) + else + builtin.find_files(opts) + end + end, + }, + { + name = "Frecency", + tele_func = function() + extensions.frecency.frecency() + end, + }, + { + name = "Oldfiles", + tele_func = function() + builtin.oldfiles() + end, + }, + }, + }, + live_grep = { + initial_tab = 1, + tabs = { + { + name = "Word in project", + tele_func = function() + extensions.live_grep_args.live_grep_args() + end, + }, + { + name = "Word under cursor", + tele_func = function(opts) + opts = opts or {} + builtin.grep_string(opts) + end, + }, + }, + }, + git = { + initial_tab = 1, + tabs = { + { + name = "Branches", + tele_func = function() + builtin.git_branches() + end, + }, + { + name = "Commits", + tele_func = function() + builtin.git_commits() + end, + }, + { + name = "Commit content", + tele_func = function() + extensions.advanced_git_search.search_log_content() + end, + }, + { + name = "Diff current file with commit", + tele_func = function() + extensions.advanced_git_search.diff_commit_file() + end, + }, + }, + }, + workspace = { + initial_tab = 1, + tabs = { + { + name = "Buffers", + tele_func = function() + builtin.buffers() + end, + }, + { + name = "Sessions", + tele_func = function() + extensions.persisted.persisted() + end, + }, + { + name = "Projects", + tele_func = function() + extensions.projects.projects({}) + end, + }, + { + name = "Zoxide", + tele_func = function() + extensions.zoxide.list() + end, + }, + }, + }, + misc = { + initial_tab = 1, + tabs = { + { + name = "Colorschemes", + tele_func = function() + builtin.colorscheme({ enable_preview = true }) + end, + }, + { + name = "Undo History", + tele_func = function() + extensions.undo.undo() + end, + }, + }, + }, + }, + }) +end diff --git a/lua/modules/configs/tool/telescope.lua b/lua/modules/configs/tool/telescope.lua index d8fdddd44..71884d085 100644 --- a/lua/modules/configs/tool/telescope.lua +++ b/lua/modules/configs/tool/telescope.lua @@ -64,7 +64,6 @@ return function() }, live_grep_args = { auto_quoting = true, -- enable/disable auto-quoting - -- define mappings, e.g. mappings = { -- extend mappings i = { [""] = lga_actions.quote_prompt(), @@ -74,18 +73,19 @@ return function() }, undo = { side_by_side = true, - mappings = { -- this whole table is the default + mappings = { i = { - -- IMPORTANT: Note that telescope-undo must be available when telescope is configured if - -- you want to use the following actions. This means installing as a dependency of - -- telescope in it's `requirements` and loading this extension from there instead of - -- having the separate plugin definition as outlined above. See issue #6. [""] = require("telescope-undo.actions").yank_additions, [""] = require("telescope-undo.actions").yank_deletions, [""] = require("telescope-undo.actions").restore, }, }, }, + advanced_git_search = { + diff_plugin = "diffview", + git_flags = { "-c", "delta.side-by-side=true" }, + entry_default_author_or_date = "author", -- one of "author" or "date" + }, }, }) @@ -98,4 +98,5 @@ return function() require("telescope").load_extension("zoxide") require("telescope").load_extension("persisted") require("telescope").load_extension("aerial") + require("telescope").load_extension("advanced_git_search") end diff --git a/lua/modules/plugins/editor.lua b/lua/modules/plugins/editor.lua index 73b273351..b25003e12 100644 --- a/lua/modules/plugins/editor.lua +++ b/lua/modules/plugins/editor.lua @@ -63,9 +63,14 @@ editor["smoka7/hop.nvim"] = { } editor["tzachar/local-highlight.nvim"] = { lazy = true, - event = { "CursorHold", "CursorHoldI" }, + event = { "BufReadPost", "BufAdd", "BufNewFile" }, config = require("editor.local-highlight"), } +editor["brenoprata10/nvim-highlight-colors"] = { + lazy = true, + event = { "CursorHold", "CursorHoldI" }, + config = require("editor.highlight-colors"), +} editor["romainl/vim-cool"] = { lazy = true, event = { "CursorMoved", "InsertEnter" }, @@ -109,10 +114,6 @@ editor["nvim-treesitter/nvim-treesitter"] = { "windwp/nvim-ts-autotag", config = require("editor.autotag"), }, - { - "NvChad/nvim-colorizer.lua", - config = require("editor.colorizer"), - }, { "hiphish/rainbow-delimiters.nvim", config = require("editor.rainbow_delims"), diff --git a/lua/modules/plugins/tool.lua b/lua/modules/plugins/tool.lua index 33fb33424..37be1ed8e 100644 --- a/lua/modules/plugins/tool.lua +++ b/lua/modules/plugins/tool.lua @@ -80,18 +80,31 @@ tool["nvim-telescope/telescope.nvim"] = { cmd = "Telescope", config = require("tool.telescope"), dependencies = { - { "nvim-tree/nvim-web-devicons" }, { "nvim-lua/plenary.nvim" }, + { "nvim-tree/nvim-web-devicons" }, + { "jvgrootveld/telescope-zoxide" }, { "debugloop/telescope-undo.nvim" }, + { "nvim-telescope/telescope-frecency.nvim" }, + { "nvim-telescope/telescope-live-grep-args.nvim" }, + { "nvim-telescope/telescope-fzf-native.nvim", build = "make" }, + { + "FabianWirth/search.nvim", + config = require("tool.search"), + }, { "ahmedkhalf/project.nvim", event = { "CursorHold", "CursorHoldI" }, config = require("tool.project"), }, - { "jvgrootveld/telescope-zoxide" }, - { "nvim-telescope/telescope-frecency.nvim" }, - { "nvim-telescope/telescope-live-grep-args.nvim" }, - { "nvim-telescope/telescope-fzf-native.nvim", build = "make" }, + { + "aaronhallaert/advanced-git-search.nvim", + cmd = { "AdvancedGitSearch" }, + dependencies = { + "tpope/vim-rhubarb", + "tpope/vim-fugitive", + "sindrets/diffview.nvim", + }, + }, }, } From 3166eefed81cb954bd51d7f3113cc55e0b93af0b Mon Sep 17 00:00:00 2001 From: jint_lzxy_ <50296129+Jint-lzxy@users.noreply.github.com> Date: Tue, 18 Jun 2024 22:09:09 +0800 Subject: [PATCH 57/72] feat: better way to check if the (T|G)UI is running (#1297) Signed-off-by: Jint-lzxy <50296129+Jint-lzxy@users.noreply.github.com> --- lua/modules/plugins/editor.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/modules/plugins/editor.lua b/lua/modules/plugins/editor.lua index b25003e12..f396fc0ad 100644 --- a/lua/modules/plugins/editor.lua +++ b/lua/modules/plugins/editor.lua @@ -100,7 +100,7 @@ editor["mrjones2014/smart-splits.nvim"] = { editor["nvim-treesitter/nvim-treesitter"] = { lazy = true, build = function() - if #vim.api.nvim_list_uis() ~= 0 then + if vim.fn.has("gui_running") == 1 then vim.api.nvim_command([[TSUpdate]]) end end, From 7e11cdcf58df62646839137fe14ae5eb9745ed81 Mon Sep 17 00:00:00 2001 From: jint_lzxy_ <50296129+Jint-lzxy@users.noreply.github.com> Date: Tue, 18 Jun 2024 22:09:47 +0800 Subject: [PATCH 58/72] chore(global): cleanup legacy code (#1296) Signed-off-by: Jint-lzxy <50296129+Jint-lzxy@users.noreply.github.com> --- lua/core/global.lua | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/lua/core/global.lua b/lua/core/global.lua index 523fd78d9..0f01edc16 100644 --- a/lua/core/global.lua +++ b/lua/core/global.lua @@ -7,12 +7,10 @@ function global:load_variables() self.is_windows = os_name == "Windows_NT" self.is_wsl = vim.fn.has("wsl") == 1 self.vim_path = vim.fn.stdpath("config") - local path_sep = self.is_windows and "\\" or "/" - local home = self.is_windows and os.getenv("USERPROFILE") or os.getenv("HOME") - self.cache_dir = home .. path_sep .. ".cache" .. path_sep .. "nvim" .. path_sep - self.modules_dir = self.vim_path .. path_sep .. "modules" - self.home = home + self.cache_dir = vim.fn.stdpath("cache") self.data_dir = string.format("%s/site/", vim.fn.stdpath("data")) + self.modules_dir = self.vim_path .. "/modules" + self.home = self.is_windows and os.getenv("USERPROFILE") or os.getenv("HOME") end global:load_variables() From 4d76779768b48af36a8c71771d3c3239b89bcbb5 Mon Sep 17 00:00:00 2001 From: jint_lzxy_ <50296129+Jint-lzxy@users.noreply.github.com> Date: Tue, 18 Jun 2024 22:10:46 +0800 Subject: [PATCH 59/72] feat: reduce the use of direct syscalls (#1294) * feat: reduce the use of direct syscalls Signed-off-by: Jint-lzxy <50296129+Jint-lzxy@users.noreply.github.com> * fix: typo Signed-off-by: Jint-lzxy <50296129+Jint-lzxy@users.noreply.github.com> --------- Signed-off-by: Jint-lzxy <50296129+Jint-lzxy@users.noreply.github.com> --- lua/core/init.lua | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lua/core/init.lua b/lua/core/init.lua index 6a49d0da0..59dbf37d7 100644 --- a/lua/core/init.lua +++ b/lua/core/init.lua @@ -3,7 +3,7 @@ local global = require("core.global") -- Create cache dir and data dirs local createdir = function() - local data_dir = { + local data_dirs = { global.cache_dir .. "backup", global.cache_dir .. "session", global.cache_dir .. "swap", @@ -12,10 +12,11 @@ local createdir = function() } -- Only check whether cache_dir exists, this would be enough. if vim.fn.isdirectory(global.cache_dir) == 0 then - os.execute("mkdir -p " .. global.cache_dir) - for _, v in pairs(data_dir) do - if vim.fn.isdirectory(v) == 0 then - os.execute("mkdir -p " .. v) + ---@diagnostic disable-next-line: param-type-mismatch + vim.fn.mkdir(global.cache_dir, "p") + for _, dir in pairs(data_dirs) do + if vim.fn.isdirectory(dir) == 0 then + vim.fn.mkdir(dir, "p") end end end From 4e614a37028fe5bb2c17eae98bf2ba7f9a364ddf Mon Sep 17 00:00:00 2001 From: jint_lzxy_ <50296129+Jint-lzxy@users.noreply.github.com> Date: Tue, 18 Jun 2024 22:11:08 +0800 Subject: [PATCH 60/72] fix(events): avoid name clashes (#1295) Signed-off-by: Jint-lzxy <50296129+Jint-lzxy@users.noreply.github.com> --- lua/core/event.lua | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lua/core/event.lua b/lua/core/event.lua index d94506829..b7ba7788c 100644 --- a/lua/core/event.lua +++ b/lua/core/event.lua @@ -3,7 +3,8 @@ local autocmd = {} function autocmd.nvim_create_augroups(definitions) for group_name, definition in pairs(definitions) do - vim.api.nvim_command("augroup " .. group_name) + -- Prepend an underscore to avoid name clashes + vim.api.nvim_command("augroup _" .. group_name) vim.api.nvim_command("autocmd!") for _, def in ipairs(definition) do local command = table.concat(vim.iter({ "autocmd", def }):flatten(math.huge):totable(), " ") @@ -67,7 +68,7 @@ vim.api.nvim_create_autocmd("FileType", { }, callback = function(event) vim.bo[event.buf].buflisted = false - vim.api.nvim_buf_set_keymap(event.buf, "n", "q", "close", { silent = true }) + vim.api.nvim_buf_set_keymap(event.buf, "n", "q", "close", { silent = true }) end, }) From 93c06cd954e7a73cc3fad0799ab49f1a1fc10d73 Mon Sep 17 00:00:00 2001 From: Charles Chiu Date: Thu, 20 Jun 2024 09:39:21 +0800 Subject: [PATCH 61/72] Feat/telescope collections keymaps (#1299) * feat(telescope): add some new plugins for `search.nvim` * fixup: correct alpha-nvim config. * feat: more resonable keymap, add notify to misc. Signed-off-by: ayamir --------- Signed-off-by: ayamir Co-authored-by: ayamir --- lua/keymap/tool.lua | 38 +++++++++- lua/modules/configs/completion/cmp.lua | 35 ++++------ lua/modules/configs/tool/search.lua | 26 ++++--- lua/modules/configs/ui/alpha.lua | 97 +++++++++++++------------- lua/modules/utils/icons.lua | 2 + 5 files changed, 120 insertions(+), 78 deletions(-) diff --git a/lua/keymap/tool.lua b/lua/keymap/tool.lua index bd928f082..7e76cd8e3 100644 --- a/lua/keymap/tool.lua +++ b/lua/keymap/tool.lua @@ -84,12 +84,46 @@ local plug_map = { :with_noremap() :with_silent() :with_desc("tool: Toggle command panel"), - ["n|f"] = map_callback(function() + ["n|fc"] = map_callback(function() _telescope_collections(require("telescope.themes").get_dropdown()) end) :with_noremap() :with_silent() - :with_desc("tool: Open Telescope"), + :with_desc("tool: Open Telescope (collections)"), + ["n|ff"] = map_callback(function() + require("search").open({ collection = "file" }) + end) + :with_noremap() + :with_silent() + :with_desc("tool: Open Telescope (file)"), + ["n|fw"] = map_callback(function() + require("search").open({ collection = "word" }) + end) + :with_noremap() + :with_silent() + :with_desc("tool: Open Telescope (word)"), + ["v|fs"] = map_cu("Telescope grep_string") + :with_noremap() + :with_silent() + :with_desc("tool: Open Telescope (selected)"), + ["n|fg"] = map_callback(function() + require("search").open({ collection = "git" }) + end) + :with_noremap() + :with_silent() + :with_desc("tool: Open Telescope (git)"), + ["n|fr"] = map_callback(function() + require("search").open({ collection = "rootdir" }) + end) + :with_noremap() + :with_silent() + :with_desc("tool: Open Telescope (rootdir)"), + ["n|fm"] = map_callback(function() + require("search").open({ collection = "misc" }) + end) + :with_noremap() + :with_silent() + :with_desc("tool: Open Telescope (misc)"), -- Plugin: dap ["n|"] = map_callback(function() diff --git a/lua/modules/configs/completion/cmp.lua b/lua/modules/configs/completion/cmp.lua index 0d926e0ee..7e6c14cf0 100644 --- a/lua/modules/configs/completion/cmp.lua +++ b/lua/modules/configs/completion/cmp.lua @@ -162,28 +162,23 @@ return function() { name = "nvim_lsp", max_item_count = 350 }, { name = "nvim_lua" }, { name = "luasnip" }, - { name = "path" }, - { name = "treesitter" }, - { name = "spell" }, - { name = "tmux" }, - { name = "orgmode" }, - { - name = "buffer", - option = { - get_bufnrs = function() - return vim.api.nvim_list_bufs() - end, - }, - }, - { name = "latex_symbols" }, - { name = "copilot" }, + -- { name = "path" }, + -- { name = "treesitter" }, + -- { name = "spell" }, + -- { name = "tmux" }, + -- { name = "orgmode" }, + -- { + -- name = "buffer", + -- option = { + -- get_bufnrs = function() + -- return vim.api.nvim_list_bufs() + -- end, + -- }, + -- }, + -- { name = "latex_symbols" }, + -- { name = "copilot" }, -- { name = "codeium" }, -- { name = "cmp_tabnine" }, }, - experimental = { - ghost_text = { - hl_group = "Whitespace", - }, - }, }) end diff --git a/lua/modules/configs/tool/search.lua b/lua/modules/configs/tool/search.lua index e01f50437..a81726082 100644 --- a/lua/modules/configs/tool/search.lua +++ b/lua/modules/configs/tool/search.lua @@ -4,6 +4,7 @@ return function() require("modules.utils").load_plugin("search", { collections = { + -- Search by file name file = { initial_tab = 1, tabs = { @@ -30,9 +31,16 @@ return function() builtin.oldfiles() end, }, + { + name = "Buffers", + tele_func = function() + builtin.buffers() + end, + }, }, }, - live_grep = { + -- Search by word + word = { initial_tab = 1, tabs = { { @@ -50,6 +58,7 @@ return function() }, }, }, + -- Search by git (branches, commits) git = { initial_tab = 1, tabs = { @@ -79,15 +88,10 @@ return function() }, }, }, - workspace = { + -- Search by rootdir name + rootdir = { initial_tab = 1, tabs = { - { - name = "Buffers", - tele_func = function() - builtin.buffers() - end, - }, { name = "Sessions", tele_func = function() @@ -117,6 +121,12 @@ return function() builtin.colorscheme({ enable_preview = true }) end, }, + { + name = "Notify", + tele_func = function() + extensions.notify.notify() + end, + }, { name = "Undo History", tele_func = function() diff --git a/lua/modules/configs/ui/alpha.lua b/lua/modules/configs/ui/alpha.lua index 73a489c12..d50310d81 100644 --- a/lua/modules/configs/ui/alpha.lua +++ b/lua/modules/configs/ui/alpha.lua @@ -39,55 +39,56 @@ return function() end local leader = " " + local icons = { + documents = require("modules.utils.icons").get("documents", true), + git = require("modules.utils.icons").get("git", true), + ui = require("modules.utils.icons").get("ui", true), + misc = require("modules.utils.icons").get("misc", true), + } + dashboard.section.buttons.val = { - button("space f c", " Scheme change", leader, nil, { - noremap = true, - silent = true, - nowait = true, - callback = function() - require("telescope.builtin").colorscheme() - end, - }), - button("space f r", " File frecency", leader, nil, { - noremap = true, - silent = true, - nowait = true, - callback = function() - require("telescope").extensions.frecency.frecency({}) - end, - }), - button("space f e", "󰋚 File history", leader, nil, { - noremap = true, - silent = true, - nowait = true, - callback = function() - require("telescope.builtin").oldfiles() - end, - }), - button("space f p", " Project find", leader, nil, { - noremap = true, - silent = true, - nowait = true, - callback = function() - require("telescope").extensions.projects.projects({}) - end, - }), - button("space f f", "󰈞 File find", leader, nil, { - noremap = true, - silent = true, - nowait = true, - callback = function() - require("telescope.builtin").find_files() - end, - }), - button("space f w", " Word find", leader, nil, { - noremap = true, - silent = true, - nowait = true, - callback = function() - require("telescope.builtin").live_grep() - end, - }), + button( + "space f c", + icons.misc.Neovim .. "Telescope collections", + leader, + nil, + { noremap = true, silent = true, nowait = true } + ), + button( + "space f g", + icons.git.Git .. "Telescope git", + leader, + nil, + { noremap = true, silent = true, nowait = true } + ), + button( + "space f w", + icons.ui.FolderWithHeart .. "Telescope workspace", + leader, + nil, + { noremap = true, silent = true, nowait = true } + ), + button( + "space f f", + icons.documents.FileFind .. "Telescope file", + leader, + nil, + { noremap = true, silent = true, nowait = true } + ), + button( + "space f l", + icons.documents.Word .. "Telescope live_grep", + leader, + nil, + { noremap = true, silent = true, nowait = true } + ), + button( + "space f m", + icons.misc.Ghost .. "Telescope misc", + leader, + nil, + { noremap = true, silent = true, nowait = true } + ), } dashboard.section.buttons.opts.hl = "AlphaButtons" diff --git a/lua/modules/utils/icons.lua b/lua/modules/utils/icons.lua index eab8da2c7..60acedbbc 100644 --- a/lua/modules/utils/icons.lua +++ b/lua/modules/utils/icons.lua @@ -63,6 +63,8 @@ local data = { File = "", Files = "", FileTree = "󰙅", + FileFind = "󰈞", + Word = "", Import = "", Symlink = "", }, From 64e85d15ced074e1c285fd99b409ac3f831893d0 Mon Sep 17 00:00:00 2001 From: jint_lzxy_ <50296129+Jint-lzxy@users.noreply.github.com> Date: Thu, 20 Jun 2024 09:39:56 +0800 Subject: [PATCH 62/72] fix(gitsigns): upstream breaking changes (#1300) See https://github.com/lewis6991/gitsigns.nvim/commit/3d7e49c201537ee0293a1a3abe67b67f8e7648a5 Signed-off-by: Jint-lzxy <50296129+Jint-lzxy@users.noreply.github.com> --- lua/modules/configs/ui/gitsigns.lua | 45 +++++++---------------------- 1 file changed, 11 insertions(+), 34 deletions(-) diff --git a/lua/modules/configs/ui/gitsigns.lua b/lua/modules/configs/ui/gitsigns.lua index c70684266..de14cd5f5 100644 --- a/lua/modules/configs/ui/gitsigns.lua +++ b/lua/modules/configs/ui/gitsigns.lua @@ -2,45 +2,22 @@ return function() local mapping = require("keymap.ui") require("modules.utils").load_plugin("gitsigns", { signs = { - add = { - hl = "GitSignsAdd", - text = "│", - numhl = "GitSignsAddNr", - linehl = "GitSignsAddLn", - }, - change = { - hl = "GitSignsChange", - text = "│", - numhl = "GitSignsChangeNr", - linehl = "GitSignsChangeLn", - }, - delete = { - hl = "GitSignsDelete", - text = "_", - numhl = "GitSignsDeleteNr", - linehl = "GitSignsDeleteLn", - }, - topdelete = { - hl = "GitSignsDelete", - text = "‾", - numhl = "GitSignsDeleteNr", - linehl = "GitSignsDeleteLn", - }, - changedelete = { - hl = "GitSignsChange", - text = "~", - numhl = "GitSignsChangeNr", - linehl = "GitSignsChangeLn", - }, + add = { text = "┃" }, + change = { text = "┃" }, + delete = { text = "_" }, + topdelete = { text = "‾" }, + changedelete = { text = "~" }, + untracked = { text = "┆" }, }, + auto_attach = true, on_attach = mapping.gitsigns, - watch_gitdir = { interval = 1000, follow_files = true }, - current_line_blame = true, - current_line_blame_opts = { delay = 1000, virtual_text_pos = "eol" }, + signcolumn = true, sign_priority = 6, update_debounce = 100, - status_formatter = nil, -- Use default word_diff = false, + current_line_blame = true, diff_opts = { internal = true }, + watch_gitdir = { follow_files = true }, + current_line_blame_opts = { delay = 1000, virt_text = true, virtual_text_pos = "eol" }, }) end From c42151f63406b3c720a3aa097497381388f6701f Mon Sep 17 00:00:00 2001 From: jint_lzxy_ <50296129+Jint-lzxy@users.noreply.github.com> Date: Thu, 20 Jun 2024 09:40:22 +0800 Subject: [PATCH 63/72] fix(core): missing leading path separator (#1301) Signed-off-by: Jint-lzxy <50296129+Jint-lzxy@users.noreply.github.com> --- lua/core/init.lua | 10 +++++----- lua/core/options.lua | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/lua/core/init.lua b/lua/core/init.lua index 59dbf37d7..a5fa32813 100644 --- a/lua/core/init.lua +++ b/lua/core/init.lua @@ -4,11 +4,11 @@ local global = require("core.global") -- Create cache dir and data dirs local createdir = function() local data_dirs = { - global.cache_dir .. "backup", - global.cache_dir .. "session", - global.cache_dir .. "swap", - global.cache_dir .. "tags", - global.cache_dir .. "undo", + global.cache_dir .. "/backup", + global.cache_dir .. "/session", + global.cache_dir .. "/swap", + global.cache_dir .. "/tags", + global.cache_dir .. "/undo", } -- Only check whether cache_dir exists, this would be enough. if vim.fn.isdirectory(global.cache_dir) == 0 then diff --git a/lua/core/options.lua b/lua/core/options.lua index f79004ca2..d025abf07 100644 --- a/lua/core/options.lua +++ b/lua/core/options.lua @@ -2,10 +2,10 @@ local global = require("core.global") local function load_options() local global_local = { - -- backupdir = global.cache_dir .. "backup/", - -- directory = global.cache_dir .. "swap/", - -- spellfile = global.cache_dir .. "spell/en.uft-8.add", - -- viewdir = global.cache_dir .. "view/", + -- backupdir = global.cache_dir .. "/backup/", + -- directory = global.cache_dir .. "/swap/", + -- spellfile = global.cache_dir .. "/spell/en.uft-8.add", + -- viewdir = global.cache_dir .. "/view/", autoindent = true, autoread = true, autowrite = true, @@ -84,7 +84,7 @@ local function load_options() timeoutlen = 300, ttimeout = true, ttimeoutlen = 0, - undodir = global.cache_dir .. "undo/", + undodir = global.cache_dir .. "/undo/", undofile = true, -- Please do NOT set `updatetime` to above 500, otherwise most plugins may not function correctly updatetime = 200, From 3bf00f04b5d3a1eb18ec738dc62038994b5e1eec Mon Sep 17 00:00:00 2001 From: Mohu Date: Thu, 20 Jun 2024 09:42:36 +0800 Subject: [PATCH 64/72] Revert "Feat/telescope collections keymaps (#1299)" (#1302) This reverts commit 93c06cd954e7a73cc3fad0799ab49f1a1fc10d73. --- lua/keymap/tool.lua | 38 +--------- lua/modules/configs/completion/cmp.lua | 35 ++++++---- lua/modules/configs/tool/search.lua | 26 +++---- lua/modules/configs/ui/alpha.lua | 97 +++++++++++++------------- lua/modules/utils/icons.lua | 2 - 5 files changed, 78 insertions(+), 120 deletions(-) diff --git a/lua/keymap/tool.lua b/lua/keymap/tool.lua index 7e76cd8e3..bd928f082 100644 --- a/lua/keymap/tool.lua +++ b/lua/keymap/tool.lua @@ -84,46 +84,12 @@ local plug_map = { :with_noremap() :with_silent() :with_desc("tool: Toggle command panel"), - ["n|fc"] = map_callback(function() + ["n|f"] = map_callback(function() _telescope_collections(require("telescope.themes").get_dropdown()) end) :with_noremap() :with_silent() - :with_desc("tool: Open Telescope (collections)"), - ["n|ff"] = map_callback(function() - require("search").open({ collection = "file" }) - end) - :with_noremap() - :with_silent() - :with_desc("tool: Open Telescope (file)"), - ["n|fw"] = map_callback(function() - require("search").open({ collection = "word" }) - end) - :with_noremap() - :with_silent() - :with_desc("tool: Open Telescope (word)"), - ["v|fs"] = map_cu("Telescope grep_string") - :with_noremap() - :with_silent() - :with_desc("tool: Open Telescope (selected)"), - ["n|fg"] = map_callback(function() - require("search").open({ collection = "git" }) - end) - :with_noremap() - :with_silent() - :with_desc("tool: Open Telescope (git)"), - ["n|fr"] = map_callback(function() - require("search").open({ collection = "rootdir" }) - end) - :with_noremap() - :with_silent() - :with_desc("tool: Open Telescope (rootdir)"), - ["n|fm"] = map_callback(function() - require("search").open({ collection = "misc" }) - end) - :with_noremap() - :with_silent() - :with_desc("tool: Open Telescope (misc)"), + :with_desc("tool: Open Telescope"), -- Plugin: dap ["n|"] = map_callback(function() diff --git a/lua/modules/configs/completion/cmp.lua b/lua/modules/configs/completion/cmp.lua index 7e6c14cf0..0d926e0ee 100644 --- a/lua/modules/configs/completion/cmp.lua +++ b/lua/modules/configs/completion/cmp.lua @@ -162,23 +162,28 @@ return function() { name = "nvim_lsp", max_item_count = 350 }, { name = "nvim_lua" }, { name = "luasnip" }, - -- { name = "path" }, - -- { name = "treesitter" }, - -- { name = "spell" }, - -- { name = "tmux" }, - -- { name = "orgmode" }, - -- { - -- name = "buffer", - -- option = { - -- get_bufnrs = function() - -- return vim.api.nvim_list_bufs() - -- end, - -- }, - -- }, - -- { name = "latex_symbols" }, - -- { name = "copilot" }, + { name = "path" }, + { name = "treesitter" }, + { name = "spell" }, + { name = "tmux" }, + { name = "orgmode" }, + { + name = "buffer", + option = { + get_bufnrs = function() + return vim.api.nvim_list_bufs() + end, + }, + }, + { name = "latex_symbols" }, + { name = "copilot" }, -- { name = "codeium" }, -- { name = "cmp_tabnine" }, }, + experimental = { + ghost_text = { + hl_group = "Whitespace", + }, + }, }) end diff --git a/lua/modules/configs/tool/search.lua b/lua/modules/configs/tool/search.lua index a81726082..e01f50437 100644 --- a/lua/modules/configs/tool/search.lua +++ b/lua/modules/configs/tool/search.lua @@ -4,7 +4,6 @@ return function() require("modules.utils").load_plugin("search", { collections = { - -- Search by file name file = { initial_tab = 1, tabs = { @@ -31,16 +30,9 @@ return function() builtin.oldfiles() end, }, - { - name = "Buffers", - tele_func = function() - builtin.buffers() - end, - }, }, }, - -- Search by word - word = { + live_grep = { initial_tab = 1, tabs = { { @@ -58,7 +50,6 @@ return function() }, }, }, - -- Search by git (branches, commits) git = { initial_tab = 1, tabs = { @@ -88,10 +79,15 @@ return function() }, }, }, - -- Search by rootdir name - rootdir = { + workspace = { initial_tab = 1, tabs = { + { + name = "Buffers", + tele_func = function() + builtin.buffers() + end, + }, { name = "Sessions", tele_func = function() @@ -121,12 +117,6 @@ return function() builtin.colorscheme({ enable_preview = true }) end, }, - { - name = "Notify", - tele_func = function() - extensions.notify.notify() - end, - }, { name = "Undo History", tele_func = function() diff --git a/lua/modules/configs/ui/alpha.lua b/lua/modules/configs/ui/alpha.lua index d50310d81..73a489c12 100644 --- a/lua/modules/configs/ui/alpha.lua +++ b/lua/modules/configs/ui/alpha.lua @@ -39,56 +39,55 @@ return function() end local leader = " " - local icons = { - documents = require("modules.utils.icons").get("documents", true), - git = require("modules.utils.icons").get("git", true), - ui = require("modules.utils.icons").get("ui", true), - misc = require("modules.utils.icons").get("misc", true), - } - dashboard.section.buttons.val = { - button( - "space f c", - icons.misc.Neovim .. "Telescope collections", - leader, - nil, - { noremap = true, silent = true, nowait = true } - ), - button( - "space f g", - icons.git.Git .. "Telescope git", - leader, - nil, - { noremap = true, silent = true, nowait = true } - ), - button( - "space f w", - icons.ui.FolderWithHeart .. "Telescope workspace", - leader, - nil, - { noremap = true, silent = true, nowait = true } - ), - button( - "space f f", - icons.documents.FileFind .. "Telescope file", - leader, - nil, - { noremap = true, silent = true, nowait = true } - ), - button( - "space f l", - icons.documents.Word .. "Telescope live_grep", - leader, - nil, - { noremap = true, silent = true, nowait = true } - ), - button( - "space f m", - icons.misc.Ghost .. "Telescope misc", - leader, - nil, - { noremap = true, silent = true, nowait = true } - ), + button("space f c", " Scheme change", leader, nil, { + noremap = true, + silent = true, + nowait = true, + callback = function() + require("telescope.builtin").colorscheme() + end, + }), + button("space f r", " File frecency", leader, nil, { + noremap = true, + silent = true, + nowait = true, + callback = function() + require("telescope").extensions.frecency.frecency({}) + end, + }), + button("space f e", "󰋚 File history", leader, nil, { + noremap = true, + silent = true, + nowait = true, + callback = function() + require("telescope.builtin").oldfiles() + end, + }), + button("space f p", " Project find", leader, nil, { + noremap = true, + silent = true, + nowait = true, + callback = function() + require("telescope").extensions.projects.projects({}) + end, + }), + button("space f f", "󰈞 File find", leader, nil, { + noremap = true, + silent = true, + nowait = true, + callback = function() + require("telescope.builtin").find_files() + end, + }), + button("space f w", " Word find", leader, nil, { + noremap = true, + silent = true, + nowait = true, + callback = function() + require("telescope.builtin").live_grep() + end, + }), } dashboard.section.buttons.opts.hl = "AlphaButtons" diff --git a/lua/modules/utils/icons.lua b/lua/modules/utils/icons.lua index 60acedbbc..eab8da2c7 100644 --- a/lua/modules/utils/icons.lua +++ b/lua/modules/utils/icons.lua @@ -63,8 +63,6 @@ local data = { File = "", Files = "", FileTree = "󰙅", - FileFind = "󰈞", - Word = "", Import = "", Symlink = "", }, From 6c59c1624a2803d42834de124162e4473e47ff9a Mon Sep 17 00:00:00 2001 From: Mohu Date: Fri, 21 Jun 2024 17:20:33 +0800 Subject: [PATCH 65/72] Feat/telescope collections keymaps (#1303) * feat(telescope): add some new plugins for `search.nvim` * fixup: correct alpha-nvim config. * feat: more resonable keymap, add notify to misc. Signed-off-by: ayamir * revert: local cmp changes. * fix: update alpha-nvim config. * chore: update doc strings Signed-off-by: Jint-lzxy <50296129+Jint-lzxy@users.noreply.github.com> * Update lua/modules/configs/ui/alpha.lua Co-authored-by: jint_lzxy_ <50296129+Jint-lzxy@users.noreply.github.com> Signed-off-by: Mohu * Update lua/modules/configs/ui/alpha.lua Co-authored-by: jint_lzxy_ <50296129+Jint-lzxy@users.noreply.github.com> Signed-off-by: Mohu * Update lua/modules/configs/ui/alpha.lua Co-authored-by: jint_lzxy_ <50296129+Jint-lzxy@users.noreply.github.com> Signed-off-by: Mohu * Update lua/modules/configs/ui/alpha.lua Co-authored-by: jint_lzxy_ <50296129+Jint-lzxy@users.noreply.github.com> Signed-off-by: Mohu * Update lua/modules/configs/ui/alpha.lua Co-authored-by: jint_lzxy_ <50296129+Jint-lzxy@users.noreply.github.com> Signed-off-by: Mohu * feat: update dotstutor. Signed-off-by: ayamir * feat: correct several minor issues Signed-off-by: Jint-lzxy <50296129+Jint-lzxy@users.noreply.github.com> * chore: cleanup Signed-off-by: Jint-lzxy <50296129+Jint-lzxy@users.noreply.github.com> * feat!: mnemonic keymaps Signed-off-by: Jint-lzxy <50296129+Jint-lzxy@users.noreply.github.com> --------- Signed-off-by: ayamir Signed-off-by: Jint-lzxy <50296129+Jint-lzxy@users.noreply.github.com> Signed-off-by: Mohu Co-authored-by: CharlesChiuGit Co-authored-by: Jint-lzxy <50296129+Jint-lzxy@users.noreply.github.com> --- lua/keymap/tool.lua | 38 ++++++++++- lua/modules/configs/tool/search.lua | 27 +++++--- lua/modules/configs/ui/alpha.lua | 97 +++++++++++++++-------------- lua/modules/utils/icons.lua | 2 + tutor/dots.tutor | 57 ++++++++--------- 5 files changed, 135 insertions(+), 86 deletions(-) diff --git a/lua/keymap/tool.lua b/lua/keymap/tool.lua index bd928f082..617a2d082 100644 --- a/lua/keymap/tool.lua +++ b/lua/keymap/tool.lua @@ -84,12 +84,46 @@ local plug_map = { :with_noremap() :with_silent() :with_desc("tool: Toggle command panel"), - ["n|f"] = map_callback(function() + ["n|fc"] = map_callback(function() _telescope_collections(require("telescope.themes").get_dropdown()) end) :with_noremap() :with_silent() - :with_desc("tool: Open Telescope"), + :with_desc("tool: Open Telescope collections"), + ["n|ff"] = map_callback(function() + require("search").open({ collection = "file" }) + end) + :with_noremap() + :with_silent() + :with_desc("tool: Find files"), + ["n|fp"] = map_callback(function() + require("search").open({ collection = "pattern" }) + end) + :with_noremap() + :with_silent() + :with_desc("tool: Find patterns"), + ["v|fs"] = map_cu("Telescope grep_string") + :with_noremap() + :with_silent() + :with_desc("tool: Find word under cursor"), + ["n|fg"] = map_callback(function() + require("search").open({ collection = "git" }) + end) + :with_noremap() + :with_silent() + :with_desc("tool: Locate Git objects"), + ["n|fd"] = map_callback(function() + require("search").open({ collection = "dossier" }) + end) + :with_noremap() + :with_silent() + :with_desc("tool: Retrieve dossiers"), + ["n|fm"] = map_callback(function() + require("search").open({ collection = "misc" }) + end) + :with_noremap() + :with_silent() + :with_desc("tool: Miscellaneous"), -- Plugin: dap ["n|"] = map_callback(function() diff --git a/lua/modules/configs/tool/search.lua b/lua/modules/configs/tool/search.lua index e01f50437..ffad69cbc 100644 --- a/lua/modules/configs/tool/search.lua +++ b/lua/modules/configs/tool/search.lua @@ -4,6 +4,7 @@ return function() require("modules.utils").load_plugin("search", { collections = { + -- Search using filenames file = { initial_tab = 1, tabs = { @@ -30,9 +31,16 @@ return function() builtin.oldfiles() end, }, + { + name = "Buffers", + tele_func = function() + builtin.buffers() + end, + }, }, }, - live_grep = { + -- Search using patterns + pattern = { initial_tab = 1, tabs = { { @@ -50,6 +58,7 @@ return function() }, }, }, + -- Search Git objects (branches, commits) git = { initial_tab = 1, tabs = { @@ -79,15 +88,10 @@ return function() }, }, }, - workspace = { + -- Retrieve dossiers + dossier = { initial_tab = 1, tabs = { - { - name = "Buffers", - tele_func = function() - builtin.buffers() - end, - }, { name = "Sessions", tele_func = function() @@ -108,6 +112,7 @@ return function() }, }, }, + -- Miscellaneous misc = { initial_tab = 1, tabs = { @@ -117,6 +122,12 @@ return function() builtin.colorscheme({ enable_preview = true }) end, }, + { + name = "Notify", + tele_func = function() + extensions.notify.notify() + end, + }, { name = "Undo History", tele_func = function() diff --git a/lua/modules/configs/ui/alpha.lua b/lua/modules/configs/ui/alpha.lua index 73a489c12..befcbd2e3 100644 --- a/lua/modules/configs/ui/alpha.lua +++ b/lua/modules/configs/ui/alpha.lua @@ -39,55 +39,56 @@ return function() end local leader = " " + local icons = { + documents = require("modules.utils.icons").get("documents", true), + git = require("modules.utils.icons").get("git", true), + ui = require("modules.utils.icons").get("ui", true), + misc = require("modules.utils.icons").get("misc", true), + } + dashboard.section.buttons.val = { - button("space f c", " Scheme change", leader, nil, { - noremap = true, - silent = true, - nowait = true, - callback = function() - require("telescope.builtin").colorscheme() - end, - }), - button("space f r", " File frecency", leader, nil, { - noremap = true, - silent = true, - nowait = true, - callback = function() - require("telescope").extensions.frecency.frecency({}) - end, - }), - button("space f e", "󰋚 File history", leader, nil, { - noremap = true, - silent = true, - nowait = true, - callback = function() - require("telescope.builtin").oldfiles() - end, - }), - button("space f p", " Project find", leader, nil, { - noremap = true, - silent = true, - nowait = true, - callback = function() - require("telescope").extensions.projects.projects({}) - end, - }), - button("space f f", "󰈞 File find", leader, nil, { - noremap = true, - silent = true, - nowait = true, - callback = function() - require("telescope.builtin").find_files() - end, - }), - button("space f w", " Word find", leader, nil, { - noremap = true, - silent = true, - nowait = true, - callback = function() - require("telescope.builtin").live_grep() - end, - }), + button( + "space f c", + icons.misc.Neovim .. "Telescope collections", + leader, + nil, + { noremap = true, silent = true, nowait = true } + ), + button( + "space f f", + icons.documents.FileFind .. "Find files", + leader, + nil, + { noremap = true, silent = true, nowait = true } + ), + button( + "space f d", + icons.ui.FolderWithHeart .. "Retrieve dossiers", + leader, + nil, + { noremap = true, silent = true, nowait = true } + ), + button( + "space f p", + icons.documents.Word .. "Find patterns", + leader, + nil, + { noremap = true, silent = true, nowait = true } + ), + button( + "space f g", + icons.git.Git .. "Locate Git objects", + leader, + nil, + { noremap = true, silent = true, nowait = true } + ), + button( + "space f m", + icons.misc.Ghost .. "Miscellaneous artifacts", + leader, + nil, + { noremap = true, silent = true, nowait = true } + ), } dashboard.section.buttons.opts.hl = "AlphaButtons" diff --git a/lua/modules/utils/icons.lua b/lua/modules/utils/icons.lua index eab8da2c7..a050401b6 100644 --- a/lua/modules/utils/icons.lua +++ b/lua/modules/utils/icons.lua @@ -62,9 +62,11 @@ local data = { Default = "", File = "", Files = "", + FileFind = "󰈞", FileTree = "󰙅", Import = "", Symlink = "", + Word = "", }, git = { Add = "", diff --git a/tutor/dots.tutor b/tutor/dots.tutor index 7def1078d..c4232b100 100644 --- a/tutor/dots.tutor +++ b/tutor/dots.tutor @@ -1,6 +1,6 @@ # Welcome to the nvimdots Tutor -Nvimdots is a [neovim](https://neovim.io/) config suite designed for extensibility, performance, and ease +Nvimdots is a [Neovim](https://neovim.io/) config suite designed for extensibility, performance, and ease of use. It provides the ability to work with text files yet feels like you are working within an IDE environment. @@ -64,7 +64,7 @@ Consequently, this segment of the status line provides insight into the context your cursor position. It's important to note that this feature relies on LSP, so it is disabled if the corresponding LSP is not attached to the current buffer. -You can press `li`{normal} to check LSP info. Upon doing so, you will notice that +You can press ``{normal}`l`{normal}`i`{normal} to check LSP info. Upon doing so, you will notice that there are two active clients attached to this buffer. Now, press [go](go) to toggle the code outline, which displays all symbols defined in @@ -85,32 +85,33 @@ to the next topic, which covers the basic workflow. # Lesson 1.2: FIND AND SEARCH -Nvimdots utilizes [telescope.nvim](https://github.com/nvim-telescope/telescope.nvim) as the primary fuzzy finder. It offers numerous -features for finding and searching. To open the file finder under the current -working directory, press `ff`{normal}. Then, input the keyword you wish to find and use -``{normal} and ``{normal} to navigate up and down the list of results. You can preview the -content of the selected file in the right window and press ``{normal} to open it -in a new buffer. - -Nvimdots also provide several additional search features. One commonly used keymap is -`fr`{normal}, especially if you frequently edit files across different projects. This -command lists files you have previously opened and sorts them by "frecency," a -concept similar to that used in Firefox's address bar. This feature utilizes "Lua -Bytecode" to permanently store the key-value pairs of file paths and their "frecency" -values at **~/.local/share/nvim/file_frecency.bin**. - -You can press `fw`{normal} to search for a word in the current working directory. This -feature utilizes [ripgrep](https://github.com/BurntSushi/ripgrep) for searching, allowing you to use it naturally as you would -with ripgrep. - -Nvimdots also provides project management features and integrates them seamlessly -with telescope. Press `fp`{normal} to open the recent project list. Please refrain from -quitting this interface; instead, you can add the current working directory to the -project list by pressing ``{normal}, and remove it by pressing ``{normal}. Typically, the -current working directory corresponds to the project directory, which is identified -by LSP and patterns such as *.git/*. However, you have the flexibility to set your own -patterns. Consequently, the project directory will automatically change when you -switch to another buffer whose file belongs to a different project. +Nvimdots utilizes [telescope.nvim](https://github.com/nvim-telescope/telescope.nvim) as the primary fuzzy finder, offering numerous +features for efficient finding and searching. To access the "file finder collection" +within the current working directory, press ``{normal}`f`{normal}`f`{normal}. Subsequently, enter the +desired keyword and use ``{normal} and ``{normal} to navigate through the list of results. The +content of the selected file can be previewed in the adjacent window, and pressing +``{normal} will open it in a new buffer. Additionally, ``{normal} and ``{normal} allow you to +switch between various tabs to locate files with different properties. For instance, +the "Frecency" and "Oldfiles" tabs enable searches based on the most frequently and +recently opened files, respectively, while the "Buffers" tab facilitates searches +among currently opened buffers. + +For pattern searches within the current working directory, press ``{normal}`f`{normal}`p`{normal}. This +functionality leverages [ripgrep](https://github.com/BurntSushi/ripgrep) for its search capabilities, making it as intuitive +to use as ripgrep itself. As with the "file finder collection", ``{normal} and ``{normal} can +be used to cycle through the search tabs. The "Word under cursor" tab displays all +instances of the word located under the current cursor position. + +Nvimdots also offers comprehensive dossier management, seamlessly integrated with +Telescope. Press ``{normal}`f`{normal}`d`{normal} to access the recent dossiers list. The first tab +presents the currently saved sessions; select a session and press ``{normal} to restore +the corresponding session. The second tab lists various projects. Instead of exiting +this interface, you can add the current working directory to the project list by +pressing ``{normal}, and remove it by pressing ``{normal}. Generally, the current working +directory corresponds to the current project's directory, identified by the LSP or +patterns such as *.git/*. You can also define your own patterns. Consequently, the +current working directory will automatically switch when you move to another buffer +containing a file from a different project. # Lesson 1.3: EDIT AND FORMAT From a6a33561ad20fb322b34a3a90edc9129be70cbf0 Mon Sep 17 00:00:00 2001 From: jint_lzxy_ <50296129+Jint-lzxy@users.noreply.github.com> Date: Mon, 24 Jun 2024 10:43:25 +0800 Subject: [PATCH 66/72] feat(treesitter): lessened performance restrictions (#1305) * feat(treesitter): lessened performance restrictions This commit lifts some of the performance restrictions previously imposed on Treesitter when incremental parsing was not yet supported. Specifically: Treesitter will now only be disabled by default for files exceeding 7,500 lines or 2 MiB in size. Testing on an Intel i9-9880H with an APPLE SSD AP1024N shows noticeable lag at these thresholds. Signed-off-by: Jint-lzxy <50296129+Jint-lzxy@users.noreply.github.com> * fixup: return correct value. --------- Signed-off-by: Jint-lzxy <50296129+Jint-lzxy@users.noreply.github.com> Co-authored-by: ayamir --- lua/modules/configs/completion/cmp.lua | 2 +- lua/modules/configs/editor/bigfile.lua | 7 ++++--- lua/modules/configs/editor/rainbow_delims.lua | 15 ++++++++++++--- lua/modules/configs/editor/treesitter.lua | 12 ++++++++---- 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/lua/modules/configs/completion/cmp.lua b/lua/modules/configs/completion/cmp.lua index 0d926e0ee..0c84b0199 100644 --- a/lua/modules/configs/completion/cmp.lua +++ b/lua/modules/configs/completion/cmp.lua @@ -171,7 +171,7 @@ return function() name = "buffer", option = { get_bufnrs = function() - return vim.api.nvim_list_bufs() + return vim.api.nvim_buf_line_count(0) < 7500 and vim.api.nvim_list_bufs() or {} end, }, }, diff --git a/lua/modules/configs/editor/bigfile.lua b/lua/modules/configs/editor/bigfile.lua index 28071772a..6c4e79d1f 100644 --- a/lua/modules/configs/editor/bigfile.lua +++ b/lua/modules/configs/editor/bigfile.lua @@ -16,15 +16,16 @@ return function() } require("modules.utils").load_plugin("bigfile", { - filesize = 1, -- size of the file in MiB + filesize = 2, -- size of the file in MiB pattern = { "*" }, -- autocmd pattern features = { -- features to disable + "indent_blankline", "lsp", - "treesitter", "syntax", + "treesitter", "vimopts", - ftdetect, cmp, + ftdetect, }, }) end diff --git a/lua/modules/configs/editor/rainbow_delims.lua b/lua/modules/configs/editor/rainbow_delims.lua index 0f1a50aa2..d2e681d23 100644 --- a/lua/modules/configs/editor/rainbow_delims.lua +++ b/lua/modules/configs/editor/rainbow_delims.lua @@ -2,6 +2,13 @@ return function() ---@param threshold number @Use global strategy if nr of lines exceeds this value local function init_strategy(threshold) return function() + -- Disable on very large files + local line_count = vim.api.nvim_buf_line_count(0) + if line_count > 7500 then + return nil + end + + -- Disable on parser error local errors = 200 vim.treesitter.get_parser():for_each_tree(function(lt) if lt:root():has_error() and errors >= 0 then @@ -11,7 +18,8 @@ return function() if errors < 0 then return nil end - return vim.fn.line("$") > threshold and require("rainbow-delimiters").strategy["global"] + + return line_count > threshold and require("rainbow-delimiters").strategy["global"] or require("rainbow-delimiters").strategy["local"] end end @@ -19,8 +27,8 @@ return function() vim.g.rainbow_delimiters = { strategy = { [""] = init_strategy(500), - c = init_strategy(200), - cpp = init_strategy(200), + c = init_strategy(300), + cpp = init_strategy(300), lua = init_strategy(500), vimdoc = init_strategy(300), vim = init_strategy(300), @@ -40,5 +48,6 @@ return function() "RainbowDelimiterViolet", }, } + require("modules.utils").load_plugin("rainbow_delimiters", nil, true) end diff --git a/lua/modules/configs/editor/treesitter.lua b/lua/modules/configs/editor/treesitter.lua index e9fe90151..5b25ebe95 100644 --- a/lua/modules/configs/editor/treesitter.lua +++ b/lua/modules/configs/editor/treesitter.lua @@ -9,7 +9,10 @@ return vim.schedule_wrap(function() highlight = { enable = true, disable = function(ft, bufnr) - if vim.tbl_contains({ "vim" }, ft) then + if + vim.tbl_contains({ "gitcommit" }, ft) + or (vim.api.nvim_buf_line_count(bufnr) > 7500 and ft ~= "vimdoc") + then return true end @@ -21,6 +24,7 @@ return vim.schedule_wrap(function() textobjects = { select = { enable = true, + lookahead = true, keymaps = { ["af"] = "@function.outer", ["if"] = "@function.inner", @@ -30,7 +34,7 @@ return vim.schedule_wrap(function() }, move = { enable = true, - set_jumps = true, -- whether to set jumps in the jumplist + set_jumps = true, goto_next_start = { ["]["] = "@function.outer", ["]m"] = "@class.outer", @@ -55,8 +59,8 @@ return vim.schedule_wrap(function() require("nvim-treesitter.install").prefer_git = true if use_ssh then local parsers = require("nvim-treesitter.parsers").get_parser_configs() - for _, p in pairs(parsers) do - p.install_info.url = p.install_info.url:gsub("https://github.com/", "git@github.com:") + for _, parser in pairs(parsers) do + parser.install_info.url = parser.install_info.url:gsub("https://github.com/", "git@github.com:") end end end) From 57f647e9d302ed03bc80edc676be7c49f1f986ad Mon Sep 17 00:00:00 2001 From: Charles Chiu Date: Tue, 25 Jun 2024 16:01:34 +0800 Subject: [PATCH 67/72] chore: update plugin author's name Signed-off-by: Charles Chiu --- lua/modules/plugins/completion.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/modules/plugins/completion.lua b/lua/modules/plugins/completion.lua index aba34cae3..af694f73f 100644 --- a/lua/modules/plugins/completion.lua +++ b/lua/modules/plugins/completion.lua @@ -26,7 +26,7 @@ completion["stevearc/aerial.nvim"] = { event = "LspAttach", config = require("completion.aerial"), } -completion["dnlhc/glance.nvim"] = { +completion["DNLHC/glance.nvim"] = { lazy = true, event = "LspAttach", config = require("completion.glance"), From 07a165b3fe16494dbb6616c6c0d4dc247afb50dc Mon Sep 17 00:00:00 2001 From: MiSumiSumi Date: Sun, 30 Jun 2024 13:31:01 +0900 Subject: [PATCH 68/72] feat(nixos): add `mergeLazyLock` option (#1310) * feat(nixos): add copyLazyLock option * fix(nixos): fix code style accepted modification proposed by nixd see more nix's code style best practice below url https://nix.dev/guides/best-practices * fix(nixos): rename copyLazyLock to mergeLazyLock * fix(nixos): fix discription --- nixos/neovim/default.nix | 152 +++++++++++++++++++++++---------------- 1 file changed, 92 insertions(+), 60 deletions(-) diff --git a/nixos/neovim/default.nix b/nixos/neovim/default.nix index 93134d40f..420e7fac3 100644 --- a/nixos/neovim/default.nix +++ b/nixos/neovim/default.nix @@ -4,8 +4,15 @@ , pkgs , ... }: -with lib; let +let cfg = config.programs.neovim.nvimdots; + inherit (lib) flip warn const; + inherit (lib.attrsets) optionalAttrs; + inherit (lib.lists) optionals; + inherit (lib.modules) mkIf; + inherit (lib.options) mkEnableOption mkOption literalExpression; + inherit (lib.strings) concatStringsSep versionOlder versionAtLeast; + inherit (lib.types) listOf coercedTo package functionTo; in { options = { @@ -19,6 +26,15 @@ in Bind lazy-lock.json in your repository to $XDG_CONFIG_HOME/nvim. Very powerful in terms of keeping the environment consistent, but has the following side effects. You cannot update it even if you run the Lazy command, because it binds read-only. + You need to remove lazy-lock.json before enabling this option if `mergeLazyLock` is set. + ''; + mergeLazyLock = mkEnableOption '' + Merges the managed lazy-lock.json with the existing one under $XDG_CONFIG_HOME/nvim if its hash has changed on activation. + Upstream package version changes have high priority. + This means changes to lazy-lock.json in the config directory (likely due to installing package) will be preserved. + In other words, it achieves environment consistency while remaining adaptable to changes. + You need to unlink lazy-lock.json before enabling this option if `bindLazyLock` is set. + Please refer to the wiki for details on the behavior. ''; setBuildEnv = mkEnableOption '' Sets environment variables that resolve build dependencies as required by `mason.nvim` and `nvim-treesitter` @@ -34,9 +50,11 @@ in use Haskell plugins. ''; extraHaskellPackages = mkOption { - type = with types; - let fromType = listOf package; - in coercedTo fromType + type = + let + fromType = listOf package; + in + coercedTo fromType (flip warn const '' Assigning a plain list to extraHaskellPackages is deprecated. Please assign a function taking a package set as argument, so @@ -56,7 +74,7 @@ in ''; }; extraDependentPackages = mkOption { - type = with types; listOf package; + type = listOf package; default = [ ]; example = literalExpression "[ pkgs.openssl ]"; description = "Extra build depends to add `LIBRARY_PATH` and `CPATH`."; @@ -67,33 +85,30 @@ in config = let # Inspired from https://github.com/NixOS/nixpkgs/blob/nixos-unstable/nixos/modules/programs/nix-ld.nix - build-dependent-pkgs = with pkgs; builtins.filter (package: !package.meta.unsupported) [ + build-dependent-pkgs = builtins.filter (package: !package.meta.unsupported) [ # manylinux - acl - attr - bzip2 - curl - glibc - libsodium - libssh - libxml2 - openssl - stdenv.cc.cc - stdenv.cc.cc.lib - systemd - util-linux - xz - zlib - zstd + pkgs.acl + pkgs.attr + pkgs.bzip2 + pkgs.curl + pkgs.glibc + pkgs.libsodium + pkgs.libssh + pkgs.libxml2 + pkgs.openssl + pkgs.stdenv.cc.cc + pkgs.stdenv.cc.cc.lib + pkgs.systemd + pkgs.util-linux + pkgs.xz + pkgs.zlib + pkgs.zstd # Packages not included in `nix-ld`'s NixOSModule - glib - libcxx + pkgs.glib + pkgs.libcxx ] ++ cfg.extraDependentPackages; - makePkgConfigPath = x: makeSearchPathOutput "dev" "lib/pkgconfig" x; - makeIncludePath = x: makeSearchPathOutput "dev" "include" x; - neovim-build-deps = pkgs.buildEnv { name = "neovim-build-deps"; paths = build-dependent-pkgs; @@ -112,19 +127,37 @@ in ]; in mkIf cfg.enable { + assertions = [ + { + assertion = ! (cfg.bindLazyLock && cfg.mergeLazyLock); + message = "bindLazyLock and mergeLazyLock cannot be enabled at the same time."; + } + ]; xdg.configFile = { "nvim/init.lua".source = ../../init.lua; "nvim/lua".source = ../../lua; "nvim/snips".source = ../../snips; "nvim/tutor".source = ../../tutor; - } // lib.optionalAttrs cfg.bindLazyLock { + } // optionalAttrs cfg.bindLazyLock { "nvim/lazy-lock.json".source = ../../lazy-lock.json; + } // optionalAttrs cfg.mergeLazyLock { + "nvim/lazy-lock.fixed.json" = { + source = ../../lazy-lock.json; + onChange = '' + if [ -f ${config.xdg.configHome}/nvim/lazy-lock.json ]; then + tmp=$(mktemp) + ${pkgs.jq}/bin/jq -r -s '.[0] * .[1]' ${config.xdg.configHome}/nvim/lazy-lock.json ${config.xdg.configFile."nvim/lazy-lock.fixed.json".source} > "''${tmp}" && mv "''${tmp}" ${config.xdg.configHome}/nvim/lazy-lock.json + else + ${pkgs.rsync}/bin/rsync --chmod 644 ${config.xdg.configFile."nvim/lazy-lock.fixed.json".source} ${config.xdg.configHome}/nvim/lazy-lock.json + fi + ''; + }; }; home = { - packages = with pkgs; [ - ripgrep + packages = [ + pkgs.ripgrep ]; - shellAliases = optionalAttrs (cfg.setBuildEnv && (lib.versionOlder config.home.stateVersion "24.05")) { + shellAliases = optionalAttrs (cfg.setBuildEnv && (versionOlder config.home.stateVersion "24.05")) { nvim = concatStringsSep " " buildEnv + " nvim"; }; }; @@ -134,33 +167,32 @@ in withNodeJs = true; withPython3 = true; - extraPackages = with pkgs; - [ - # Dependent packages used by default plugins - doq - tree-sitter - ] - ++ optionals cfg.withBuildTools [ - cargo - clang - cmake - gcc - gnumake - go - lua51Packages.luarocks - ninja - pkg-config - yarn - ] - ++ optionals cfg.withHaskell [ - (pkgs.writeShellApplication { - name = "stack"; - text = '' - exec "${pkgs.stack}/bin/stack" "--extra-include-dirs=${config.home.profileDirectory}/lib/nvim-depends/include" "--extra-lib-dirs=${config.home.profileDirectory}/lib/nvim-depends/lib" "$@" - ''; - }) - (haskellPackages.ghcWithPackages (ps: cfg.extraHaskellPackages ps)) - ]; + extraPackages = [ + # Dependent packages used by default plugins + pkgs.doq + pkgs.tree-sitter + ] + ++ optionals cfg.withBuildTools [ + pkgs.cargo + pkgs.clang + pkgs.cmake + pkgs.gcc + pkgs.gnumake + pkgs.go + pkgs.lua51Packages.luarocks + pkgs.ninja + pkgs.pkg-config + pkgs.yarn + ] + ++ optionals cfg.withHaskell [ + (pkgs.writeShellApplication { + name = "stack"; + text = '' + exec "${pkgs.stack}/bin/stack" "--extra-include-dirs=${config.home.profileDirectory}/lib/nvim-depends/include" "--extra-lib-dirs=${config.home.profileDirectory}/lib/nvim-depends/lib" "$@" + ''; + }) + (pkgs.haskellPackages.ghcWithPackages (ps: cfg.extraHaskellPackages ps)) + ]; extraPython3Packages = ps: with ps; [ docformatter @@ -168,8 +200,8 @@ in pynvim ]; } - // lib.optionalAttrs (lib.versionAtLeast config.home.stateVersion "24.05") { - extraWrapperArgs = lib.optionals cfg.setBuildEnv [ + // optionalAttrs (versionAtLeast config.home.stateVersion "24.05") { + extraWrapperArgs = optionals cfg.setBuildEnv [ "--suffix" "CPATH" ":" From b1406ca2b189d7c923ffe832adb6bf6358940158 Mon Sep 17 00:00:00 2001 From: Charles Chiu Date: Mon, 1 Jul 2024 09:09:01 +0800 Subject: [PATCH 69/72] fix: cmp snippets source selecting issue (#1309) * migrate(cmp): `cmp_nvim_lsp` capabilities API update * feat(cmp): make `` safer --- lua/modules/configs/completion/cmp.lua | 12 +++++++++++- lua/modules/configs/completion/mason-lspconfig.lua | 6 +++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/lua/modules/configs/completion/cmp.lua b/lua/modules/configs/completion/cmp.lua index 0c84b0199..d9676a107 100644 --- a/lua/modules/configs/completion/cmp.lua +++ b/lua/modules/configs/completion/cmp.lua @@ -127,7 +127,6 @@ return function() }, -- You can set mappings if you want mapping = cmp.mapping.preset.insert({ - [""] = cmp.mapping.confirm({ select = false, behavior = cmp.ConfirmBehavior.Replace }), [""] = cmp.mapping.select_prev_item(), [""] = cmp.mapping.select_next_item(), [""] = cmp.mapping.scroll_docs(-4), @@ -151,6 +150,17 @@ return function() fallback() end end, { "i", "s" }), + [""] = cmp.mapping({ + i = function(fallback) + if cmp.visible() and cmp.get_active_entry() then + cmp.confirm({ behavior = cmp.ConfirmBehavior.Insert, select = false }) + else + fallback() + end + end, + s = cmp.mapping.confirm({ select = true }), + c = cmp.mapping.confirm({ behavior = cmp.ConfirmBehavior.Insert, select = true }), + }), }), snippet = { expand = function(args) diff --git a/lua/modules/configs/completion/mason-lspconfig.lua b/lua/modules/configs/completion/mason-lspconfig.lua index c345c7f78..567ff9f94 100644 --- a/lua/modules/configs/completion/mason-lspconfig.lua +++ b/lua/modules/configs/completion/mason-lspconfig.lua @@ -25,7 +25,11 @@ M.setup = function() }) local opts = { - capabilities = require("cmp_nvim_lsp").default_capabilities(vim.lsp.protocol.make_client_capabilities()), + capabilities = vim.tbl_deep_extend( + "force", + vim.lsp.protocol.make_client_capabilities(), + require("cmp_nvim_lsp").default_capabilities() + ), } ---A handler to setup all servers defined under `completion/servers/*.lua` ---@param lsp_name string From 757a36e97a254286074fa49ca53bd485b45aac9c Mon Sep 17 00:00:00 2001 From: jint_lzxy_ <50296129+Jint-lzxy@users.noreply.github.com> Date: Mon, 1 Jul 2024 09:10:10 +0800 Subject: [PATCH 70/72] fix(cmp): occasional inability to select completion items (#1315) Signed-off-by: Jint-lzxy <50296129+Jint-lzxy@users.noreply.github.com> Signed-off-by: ayamir Co-authored-by: ayamir --- lua/modules/configs/completion/cmp.lua | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lua/modules/configs/completion/cmp.lua b/lua/modules/configs/completion/cmp.lua index d9676a107..f20e7b60d 100644 --- a/lua/modules/configs/completion/cmp.lua +++ b/lua/modules/configs/completion/cmp.lua @@ -127,14 +127,14 @@ return function() }, -- You can set mappings if you want mapping = cmp.mapping.preset.insert({ - [""] = cmp.mapping.select_prev_item(), - [""] = cmp.mapping.select_next_item(), + [""] = cmp.mapping.select_prev_item({ behavior = cmp.SelectBehavior.Select }), + [""] = cmp.mapping.select_next_item({ behavior = cmp.SelectBehavior.Select }), [""] = cmp.mapping.scroll_docs(-4), [""] = cmp.mapping.scroll_docs(4), - [""] = cmp.mapping.close(), + [""] = cmp.mapping.abort(), [""] = cmp.mapping(function(fallback) if cmp.visible() then - cmp.select_next_item() + cmp.select_next_item({ behavior = cmp.SelectBehavior.Select }) elseif require("luasnip").expand_or_locally_jumpable() then require("luasnip").expand_or_jump() else @@ -143,7 +143,7 @@ return function() end, { "i", "s" }), [""] = cmp.mapping(function(fallback) if cmp.visible() then - cmp.select_prev_item() + cmp.select_prev_item({ behavior = cmp.SelectBehavior.Select }) elseif require("luasnip").jumpable(-1) then require("luasnip").jump(-1) else From f0369f5bc46c9fd2a92b5b3ed051de831e94a216 Mon Sep 17 00:00:00 2001 From: jint_lzxy_ <50296129+Jint-lzxy@users.noreply.github.com> Date: Mon, 1 Jul 2024 09:10:41 +0800 Subject: [PATCH 71/72] feat: credit all collaborators as copyright holders (#1316) Signed-off-by: Jint-lzxy <50296129+Jint-lzxy@users.noreply.github.com> --- LICENSE | 41 +++++++++++++++++++++++++---------------- README.md | 4 +++- 2 files changed, 28 insertions(+), 17 deletions(-) diff --git a/LICENSE b/LICENSE index 0203a8bed..33895b644 100644 --- a/LICENSE +++ b/LICENSE @@ -1,21 +1,30 @@ -MIT License +BSD 3-Clause License Copyright (c) 2021 ayamir +Copyright (c) 2022 Jint-lzxy, CharlesChiuGit +Copyright (c) 2023 aarnphm, misumisumi -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. +1. Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. +2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +3. Neither the name of the copyright holder nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/README.md b/README.md index c8c20d666..c450710be 100644 --- a/README.md +++ b/README.md @@ -197,6 +197,8 @@ It's strongly recommended to read [Wiki: Prerequisites](https://github.com/ayami - [ayamir](https://github.com/ayamir) - [Jint-lzxy](https://github.com/Jint-lzxy) - [CharlesChiuGit](https://github.com/CharlesChiuGit) +- [aarnphm](https://github.com/aarnphm) +- [misumisumi](https://github.com/misumisumi) ## 🎉 Acknowledgement @@ -204,7 +206,7 @@ It's strongly recommended to read [Wiki: Prerequisites](https://github.com/ayami ## 📜 License -This Neovim configuration is released under the MIT license, which grants the following permissions: +This Neovim configuration is released under the BSD 3-Clause license, which grants the following permissions: - Commercial use - Distribution From 8f30baec4483444d38ab4dc244f47d428a63647e Mon Sep 17 00:00:00 2001 From: ayamir Date: Mon, 1 Jul 2024 10:03:57 +0800 Subject: [PATCH 72/72] feat: make format timeout configurable (#1275) * feat&refactor: make format timeout configurable, refactor format-related options. * chore(settings): set `format_modifications_only` to `false` to prevent possible ci issues Signed-off-by: Charles Chiu * fix: set timeout for null-ls considering range format capability. this commit also revert the settings structure b/c we can refactor it in another PR. * fixup: fix ci. * fix: remove redundant notification. * fixup: fix notify logic and CI. * fixup: merge judgements. Co-authored-by: jint_lzxy_ <50296129+Jint-lzxy@users.noreply.github.com> Signed-off-by: Mohu * fixup: remove redundant judge. * docs: more accurate comment note. Co-authored-by: jint_lzxy_ <50296129+Jint-lzxy@users.noreply.github.com> Signed-off-by: ayamir * fix: wrong require source. Co-authored-by: jint_lzxy_ <50296129+Jint-lzxy@users.noreply.github.com> Signed-off-by: ayamir --------- Signed-off-by: Charles Chiu Signed-off-by: Mohu Signed-off-by: ayamir Co-authored-by: Charles Chiu Co-authored-by: jint_lzxy_ <50296129+Jint-lzxy@users.noreply.github.com> --- lua/core/settings.lua | 40 ++++++++++--------- lua/modules/configs/completion/formatting.lua | 9 +++-- lua/modules/configs/completion/null-ls.lua | 1 + 3 files changed, 29 insertions(+), 21 deletions(-) diff --git a/lua/core/settings.lua b/lua/core/settings.lua index 3cd9c923b..125416008 100644 --- a/lua/core/settings.lua +++ b/lua/core/settings.lua @@ -8,14 +8,14 @@ settings["use_ssh"] = true ---@type boolean settings["use_copilot"] = true --- Set it to false if you want to turn off LSP Inlay Hints ----@type boolean -settings["lsp_inlayhints"] = true - -- Set it to false if there is no need to format on save. ---@type boolean settings["format_on_save"] = true +-- Set format timeout here (in ms). +---@type number +settings["format_timeout"] = 1000 + -- Set it to false if the notification after formatting is annoying. ---@type boolean settings["format_notify"] = true @@ -37,6 +37,24 @@ settings["format_disabled_dirs"] = { "~/format_disabled_dir", } +-- Filetypes in this list will skip lsp formatting if rhs is true. +---@type table +settings["formatter_block_list"] = { + lua = false, -- example +} + +-- Servers in this list will skip setting formatting capabilities if rhs is true. +---@type table +settings["server_formatting_block_list"] = { + lua_ls = true, + tsserver = true, + clangd = true, +} + +-- Set it to false if you want to turn off LSP Inlay Hints +---@type boolean +settings["lsp_inlayhints"] = true + -- Set it to false if diagnostics virtual text is annoying. -- If disabled, you may browse lsp diagnostics using trouble.nvim (press `gt` to toggle it). ---@type boolean @@ -85,20 +103,6 @@ settings["background"] = "dark" ---@type string settings["external_browser"] = "chrome-cli open" --- Filetypes in this list will skip lsp formatting if rhs is true. ----@type table -settings["formatter_block_list"] = { - lua = false, -- example -} - --- Servers in this list will skip setting formatting capabilities if rhs is true. ----@type table -settings["server_formatting_block_list"] = { - lua_ls = true, - tsserver = true, - clangd = true, -} - -- Set the language servers that will be installed during bootstrap here. -- check the below link for all the supported LSPs: -- https://github.com/neovim/nvim-lspconfig/tree/master/lua/lspconfig/server_configurations diff --git a/lua/modules/configs/completion/formatting.lua b/lua/modules/configs/completion/formatting.lua index 4634d0451..0368efef7 100644 --- a/lua/modules/configs/completion/formatting.lua +++ b/lua/modules/configs/completion/formatting.lua @@ -6,12 +6,13 @@ local format_on_save = settings.format_on_save local format_notify = settings.format_notify local format_modifications_only = settings.format_modifications_only local server_formatting_block_list = settings.server_formatting_block_list +local format_timeout = settings.format_timeout vim.api.nvim_create_user_command("FormatToggle", function() M.toggle_format_on_save() end, {}) -local block_list = require("core.settings").formatter_block_list +local block_list = settings.formatter_block_list vim.api.nvim_create_user_command("FormatterToggleFt", function(opts) if block_list[opts.args] == nil then vim.notify( @@ -35,7 +36,7 @@ vim.api.nvim_create_user_command("FormatterToggleFt", function(opts) end, { nargs = 1, complete = "filetype" }) function M.enable_format_on_save(is_configured) - local opts = { pattern = "*", timeout = 1000 } + local opts = { pattern = "*", timeout = format_timeout } vim.api.nvim_create_augroup("format_on_save", { clear = true }) vim.api.nvim_create_autocmd("BufWritePre", { group = "format_on_save", @@ -156,7 +157,9 @@ function M.format(opts) { title = "LSP Formatter Warning" } ) return - elseif + end + + if format_modifications_only and require("lsp-format-modifications").format_modifications(client, bufnr).success then diff --git a/lua/modules/configs/completion/null-ls.lua b/lua/modules/configs/completion/null-ls.lua index ff2efab17..72982d6ea 100644 --- a/lua/modules/configs/completion/null-ls.lua +++ b/lua/modules/configs/completion/null-ls.lua @@ -42,6 +42,7 @@ return function() log_level = "warn", update_in_insert = false, sources = sources, + default_timeout = require("core.settings").format_timeout, }) require("completion.mason-null-ls").setup()