From cec7c7b135595b34cef28437934c4377c57eb16a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=86=B7=E9=85=94=E9=96=91=E5=90=9F?= <50296129+Jint-lzxy@users.noreply.github.com> Date: Sun, 9 Apr 2023 13:06:41 +0800 Subject: [PATCH 01/39] chore(README): bump supported version --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 9ce3fc4cf..3ab8f9e4c 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ NeoVim Version Capability + src="https://img.shields.io/badge/Supports%20Nvim-v0.9-A6D895?style=for-the-badge&colorA=363A4F&logo=neovim&logoColor=D9E0EE"> Date: Sat, 8 Apr 2023 22:38:16 +0800 Subject: [PATCH 02/39] feat(options): support new options shipped with v0.9 --- lua/core/init.lua | 3 +++ lua/core/options.lua | 3 ++- lua/core/settings.lua | 1 - 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/lua/core/init.lua b/lua/core/init.lua index 3b3f75bff..f63db01b5 100644 --- a/lua/core/init.lua +++ b/lua/core/init.lua @@ -62,6 +62,9 @@ local disable_distribution_plugins = function() -- Disable sql omni completion. vim.g.loaded_sql_completion = 1 + -- Disable EditorConfig support + vim.g.editorconfig = 1 + -- Disable remote plugins -- NOTE: Disabling rplugin.vim will show error for `wilder.nvim` in :checkhealth, -- NOTE: but since it's config doesn't require python rtp, it's fine to ignore. diff --git a/lua/core/options.lua b/lua/core/options.lua index 2462f1252..4b968b155 100644 --- a/lua/core/options.lua +++ b/lua/core/options.lua @@ -25,7 +25,7 @@ local function load_options() conceallevel = 0, cursorcolumn = true, cursorline = true, - diffopt = "filler,iwhite,internal,algorithm:patience", + diffopt = "filler,iwhite,internal,linematch:60,algorithm:patience", display = "lastline", encoding = "utf-8", equalalways = false, @@ -73,6 +73,7 @@ local function load_options() smarttab = true, softtabstop = 4, splitbelow = true, + splitkeep = "cursor", splitright = true, startofline = false, swapfile = false, diff --git a/lua/core/settings.lua b/lua/core/settings.lua index 6b834a6ee..88fa3392e 100644 --- a/lua/core/settings.lua +++ b/lua/core/settings.lua @@ -79,7 +79,6 @@ settings["lsp_deps"] = { settings["null_ls_deps"] = { "black", "clang_format", - "editorconfig_checker", "prettier", "rustfmt", "shfmt", From d1798dfe459d6a83c92fb59be21a2f74c173d59e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=86=B7=E9=85=94=E9=96=91=E5=90=9F?= <50296129+Jint-lzxy@users.noreply.github.com> Date: Sat, 8 Apr 2023 22:01:14 +0800 Subject: [PATCH 03/39] feat(scripts): support v0.9 --- .github/ISSUE_TEMPLATE/bug_report.yml | 3 +- .github/ISSUE_TEMPLATE/lsp_issue_report.yml | 3 +- scripts/install.ps1 | 27 ++++++++++------ scripts/install.sh | 35 +++++++++++++-------- 4 files changed, 44 insertions(+), 24 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml index 5ba7d5db8..cbc6da01b 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -59,7 +59,8 @@ 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.7 (Legacy) + - 0.8 (Legacy) + - 0.7 (Bug fixes only) validations: required: true - type: dropdown diff --git a/.github/ISSUE_TEMPLATE/lsp_issue_report.yml b/.github/ISSUE_TEMPLATE/lsp_issue_report.yml index 2b51f27dc..523b745ac 100644 --- a/.github/ISSUE_TEMPLATE/lsp_issue_report.yml +++ b/.github/ISSUE_TEMPLATE/lsp_issue_report.yml @@ -59,7 +59,8 @@ 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.7 (Legacy) + - 0.8 (Legacy) + - 0.7 (Bug fixes only) validations: required: true - type: dropdown diff --git a/scripts/install.ps1 b/scripts/install.ps1 index a431964cf..765aadc52 100644 --- a/scripts/install.ps1 +++ b/scripts/install.ps1 @@ -8,7 +8,8 @@ Set-StrictMode -Version 3.0 $ErrorActionPreference = "Stop" # Exit when command fails # global-scope vars -$REQUIRED_NVIM_VERSION = [version]'0.8.0' +$REQUIRED_NVIM_VERSION = [version]'0.9.0' +$REQUIRED_NVIM_VERSION_LEGACY = [version]'0.8.0' $USE_SSH = $True # package mgr vars @@ -270,14 +271,14 @@ function fetch_deps { $env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path","User") } -function is_latest { +function check_nvim_version ([Parameter(Mandatory = $True)][ValidateNotNullOrEmpty()] [version]$RequiredVersionMin) { $nvim_version = Invoke-Command -ErrorAction SilentlyContinue -ScriptBlock { nvim --version } # First get neovim version $nvim_version = $nvim_version.Split([System.Environment]::NewLine) | Select-Object -First 1 # Then do head -n1 $nvim_version = $nvim_version.Split('-') | Select-Object -First 1 # Special for dev branches $nvim_version = $nvim_version -replace '[^(\d+(\.\d+)*)]','' # Then do regex replacement similar to sed $nvim_version = [version]$nvim_version - return ($nvim_version -ge $REQUIRED_NVIM_VERSION) + return ($nvim_version -ge $RequiredVersionMin) } function ring_bell { @@ -351,19 +352,27 @@ You must install Git before installing this Nvim config. See: info -Msg "Fetching in progress..." if ($USE_SSH) { - if ((is_latest)) { + if ((check_nvim_version -RequiredVersionMin $REQUIRED_NVIM_VERSION)) { safe_execute -WithCmd { git clone --progress -b "$env:CCLONE_BRANCH" "$env:CCLONE_ATTR" 'git@github.com:ayamir/nvimdots.git' "$env:CCDEST_DIR" } - } else { + } elseif ((check_nvim_version -RequiredVersionMin $REQUIRED_NVIM_VERSION_LEGACY)) { warn -Msg "You have outdated Nvim installed (< $REQUIRED_NVIM_VERSION)." - info -Msg "Automatically redirecting you to legacy version..." + info -Msg "Automatically redirecting you to the latest compatible version..." + safe_execute -WithCmd { git clone --progress -b 0.8 "$env:CCLONE_ATTR" 'git@github.com:ayamir/nvimdots.git' "$env:CCDEST_DIR" } + } else { + warn -Msg "You have outdated Nvim installed (< $REQUIRED_NVIM_VERSION_LEGACY)." + info -Msg "Automatically redirecting you to the latest compatible version..." safe_execute -WithCmd { git clone --progress -b 0.7 "$env:CCLONE_ATTR" 'git@github.com:ayamir/nvimdots.git' "$env:CCDEST_DIR" } } } else { - if ((is_latest)) { + if ((check_nvim_version -RequiredVersionMin $REQUIRED_NVIM_VERSION)) { safe_execute -WithCmd { git clone --progress -b "$env:CCLONE_BRANCH" "$env:CCLONE_ATTR" 'https://github.com/ayamir/nvimdots.git' "$env:CCDEST_DIR" } - } else { + } elseif ((check_nvim_version -RequiredVersionMin $REQUIRED_NVIM_VERSION_LEGACY)) { warn -Msg "You have outdated Nvim installed (< $REQUIRED_NVIM_VERSION)." - info -Msg "Automatically redirecting you to legacy version..." + info -Msg "Automatically redirecting you to the latest compatible version..." + safe_execute -WithCmd { git clone --progress -b 0.8 "$env:CCLONE_ATTR" 'https://github.com/ayamir/nvimdots.git' "$env:CCDEST_DIR" } + } else { + warn -Msg "You have outdated Nvim installed (< $REQUIRED_NVIM_VERSION_LEGACY)." + info -Msg "Automatically redirecting you to the latest compatible version..." safe_execute -WithCmd { git clone --progress -b 0.7 "$env:CCLONE_ATTR" 'https://github.com/ayamir/nvimdots.git' "$env:CCDEST_DIR" } } } diff --git a/scripts/install.sh b/scripts/install.sh index 64dc4d6d1..e06fde2b4 100755 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -10,7 +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.8 +REQUIRED_NVIM_VERSION=0.9.0 +REQUIRED_NVIM_VERSION_LEGACY=0.8.0 USE_SSH=1 abort() { @@ -118,7 +119,7 @@ version_ge() { prompt_confirm() { while true; do read -r -p "$1 [Y/n]: " USR_CHOICE - case "$USR_CHOICE" in + case "${USR_CHOICE}" in [yY][eE][sS] | [yY]) return 1 ;; @@ -126,10 +127,10 @@ prompt_confirm() { return 0 ;; *) - if [[ -z "$USR_CHOICE" ]]; then + if [[ -z "${USR_CHOICE}" ]]; then return 1 fi - printf "${tty_red}%s\n\n${tty_reset}" "Invalid input! Please enter one of: '[yY]/[yY][eE][sS] / [nN]/[nN][oO]'" + printf "${tty_red}%s\n\n${tty_reset}" "Invalid input! Please enter one of: '[y/yes] / [n/no]'" ;; esac done @@ -154,10 +155,10 @@ clone_pref() { fi } -is_latest() { +check_nvim_version() { local nvim_version nvim_version="$(nvim --version | head -n1 | sed -e 's|^[^0-9]*||' -e 's| .*||')" - if version_ge "$(major_minor "${nvim_version##* }")" "$(major_minor "${REQUIRED_NVIM_VERSION}")"; then + if version_ge "$(major_minor "${nvim_version##* }")" "$(major_minor "$1")"; then return 0 else return 1 @@ -246,19 +247,27 @@ if [[ -d "${DEST_DIR}" ]]; then fi info "Fetching in progress..." -if [[ "$USE_SSH" -eq "1" ]]; then - if is_latest; then +if [[ "${USE_SSH}" -eq "1" ]]; then + if check_nvim_version "${REQUIRED_NVIM_VERSION}"; then execute "git" "clone" "-b" "main" "${CLONE_ATTR[@]}" "git@github.com:ayamir/nvimdots.git" "${DEST_DIR}" - else + elif check_nvim_version "${REQUIRED_NVIM_VERSION_LEGACY}"; then warn "You have outdated Nvim installed (< ${REQUIRED_NVIM_VERSION})." - info "Automatically redirecting you to legacy version..." + info "Automatically redirecting you to the latest compatible version..." + execute "git" "clone" "-b" "0.8" "${CLONE_ATTR[@]}" "git@github.com:ayamir/nvimdots.git" "${DEST_DIR}" + else + warn "You have outdated Nvim installed (< ${REQUIRED_NVIM_VERSION_LEGACY})." + info "Automatically redirecting you to the latest compatible version..." execute "git" "clone" "-b" "0.7" "${CLONE_ATTR[@]}" "git@github.com:ayamir/nvimdots.git" "${DEST_DIR}" fi else - if is_latest; then + if check_nvim_version "${REQUIRED_NVIM_VERSION}"; then execute "git" "clone" "-b" "main" "${CLONE_ATTR[@]}" "https://github.com/ayamir/nvimdots.git" "${DEST_DIR}" - else + 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[@]}" "https://github.com/ayamir/nvimdots.git" "${DEST_DIR}" + else + warn "You have outdated Nvim installed (< ${REQUIRED_NVIM_VERSION_LEGACY})." info "Automatically redirecting you to legacy version..." execute "git" "clone" "-b" "0.7" "${CLONE_ATTR[@]}" "https://github.com/ayamir/nvimdots.git" "${DEST_DIR}" fi @@ -266,7 +275,7 @@ fi cd "${DEST_DIR}" || return -if [[ "$USE_SSH" -eq "0" ]]; then +if [[ "${USE_SSH}" -eq "0" ]]; then info "Changing default fetching method to HTTPS..." execute "perl" "-pi" "-e" "s/\[\"use_ssh\"\] \= true/\[\"use_ssh\"\] \= false/g" "${DEST_DIR}/lua/core/settings.lua" fi From 7155d968f719af7259f0cedc0d2c5c685eebfefb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=86=B7=E9=85=94=E9=96=91=E5=90=9F?= <50296129+Jint-lzxy@users.noreply.github.com> Date: Mon, 10 Apr 2023 18:02:36 +0800 Subject: [PATCH 04/39] feat!: add initial support for lsp semantic tokens (#633) --- lua/modules/configs/completion/lspsaga.lua | 1 + lua/modules/configs/ui/catppuccin.lua | 13 ++++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/lua/modules/configs/completion/lspsaga.lua b/lua/modules/configs/completion/lspsaga.lua index 248ccc326..d2d960171 100644 --- a/lua/modules/configs/completion/lspsaga.lua +++ b/lua/modules/configs/completion/lspsaga.lua @@ -120,6 +120,7 @@ return function() frequency = 12, }, ui = { + title = false, border = "single", -- Can be single, double, rounded, solid, shadow. winblend = 0, actionfix = icons.ui.Spell, diff --git a/lua/modules/configs/ui/catppuccin.lua b/lua/modules/configs/ui/catppuccin.lua index db7c632ba..3895ca023 100644 --- a/lua/modules/configs/ui/catppuccin.lua +++ b/lua/modules/configs/ui/catppuccin.lua @@ -77,7 +77,7 @@ return function() nvimtree = true, overseer = false, pounce = false, - semantic_tokens = false, + semantic_tokens = true, symbols_outline = false, telekasten = false, telescope = true, @@ -150,6 +150,17 @@ return function() -- For trouble.nvim TroubleNormal = { bg = cp.base }, + -- For lsp semantic tokens + ["@lsp.type.comment"] = { fg = cp.overlay0 }, + ["@lsp.type.enum"] = { link = "@type" }, + ["@lsp.type.property"] = { link = "@property" }, + ["@lsp.type.macro"] = { link = "@constant" }, + ["@lsp.typemod.function.defaultLibrary"] = { fg = cp.blue, style = { "bold", "italic" } }, + ["@lsp.typemod.function.defaultLibrary.c"] = { fg = cp.blue, style = { "bold" } }, + ["@lsp.typemod.function.defaultLibrary.cpp"] = { fg = cp.blue, style = { "bold" } }, + ["@lsp.typemod.method.defaultLibrary"] = { link = "@lsp.typemod.function.defaultLibrary" }, + ["@lsp.typemod.variable.defaultLibrary"] = { fg = cp.flamingo }, + -- For treesitter. ["@field"] = { fg = cp.rosewater }, ["@property"] = { fg = cp.yellow }, From 32febc1ecc02172b7c46f3fc0f65785c303902f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=86=B7=E9=85=94=E9=96=91=E5=90=9F?= <50296129+Jint-lzxy@users.noreply.github.com> Date: Mon, 10 Apr 2023 18:02:50 +0800 Subject: [PATCH 05/39] feat(utils): use neovim builtin to get highlights (#632) --- lua/modules/utils/init.lua | 46 ++++---------------------------------- 1 file changed, 4 insertions(+), 42 deletions(-) diff --git a/lua/modules/utils/init.lua b/lua/modules/utils/init.lua index 7cfcecba2..b6f674a1c 100644 --- a/lua/modules/utils/init.lua +++ b/lua/modules/utils/init.lua @@ -80,44 +80,6 @@ local function hexToRgb(c) return { tonumber(c:sub(2, 3), 16), tonumber(c:sub(4, 5), 16), tonumber(c:sub(6, 7), 16) } end ----Parse the `style` string into nvim_set_hl options ----@param style string @The style config ----@return table -local function parse_style(style) - if not style or style == "NONE" then - return {} - end - - local result = {} - for field in string.gmatch(style, "([^,]+)") do - result[field] = true - end - - return result -end - ----Wrapper function for nvim_get_hl_by_name ----@param hl_group string @Highlight group name ----@return table -local function get_highlight(hl_group) - local hl = vim.api.nvim_get_hl_by_name(hl_group, true) - if hl.link then - return get_highlight(hl.link) - end - - local result = parse_style(hl.style) - result.fg = hl.foreground and string.format("#%06x", hl.foreground) - result.bg = hl.background and string.format("#%06x", hl.background) - result.sp = hl.special and string.format("#%06x", hl.special) - for attr, val in pairs(hl) do - if type(attr) == "string" and attr ~= "foreground" and attr ~= "background" and attr ~= "special" then - result[attr] = val - end - end - - return result -end - ---Blend foreground with background ---@param foreground string @The foreground color ---@param background string @The background color to blend with @@ -143,10 +105,10 @@ end ---@return string function M.hl_to_rgb(hl_group, use_bg, fallback_hl) local hex = fallback_hl or "#000000" - local hlexists = pcall(vim.api.nvim_get_hl_by_name, hl_group, true) + local hlexists = pcall(vim.api.nvim_get_hl, 0, { name = hl_group, link = false }) if hlexists then - local result = get_highlight(hl_group) + local result = vim.api.nvim_get_hl(0, { name = hl_group, link = false }) if use_bg then hex = result.bg and result.bg or "NONE" else @@ -161,12 +123,12 @@ end ---@param name string @Target highlight group name ---@param def table @Attributes to be extended function M.extend_hl(name, def) - local hlexists = pcall(vim.api.nvim_get_hl_by_name, name, true) + local hlexists = pcall(vim.api.nvim_get_hl, 0, { name = name, link = false }) if not hlexists then -- Do nothing if highlight group not found return end - local current_def = get_highlight(name) + local current_def = vim.api.nvim_get_hl(0, { name = name, link = false }) local combined_def = vim.tbl_deep_extend("force", current_def, def) vim.api.nvim_set_hl(0, name, combined_def) From 7e4bfa28252188ba10ff89227cb7f401c1e923ed Mon Sep 17 00:00:00 2001 From: ayamir Date: Tue, 11 Apr 2023 15:15:39 +0800 Subject: [PATCH 06/39] fix: remove deprecated options for nvim-tree. --- lua/modules/configs/tool/nvim-tree.lua | 4 ---- 1 file changed, 4 deletions(-) diff --git a/lua/modules/configs/tool/nvim-tree.lua b/lua/modules/configs/tool/nvim-tree.lua index 8c4f58271..810e9cce9 100644 --- a/lua/modules/configs/tool/nvim-tree.lua +++ b/lua/modules/configs/tool/nvim-tree.lua @@ -13,9 +13,6 @@ return function() hijack_cursor = true, hijack_netrw = true, hijack_unnamed_buffer_when_opening = true, - ignore_buffer_on_setup = false, - open_on_setup = false, - open_on_setup_file = false, open_on_tab = false, respect_buf_cwd = false, sort_by = "name", @@ -108,7 +105,6 @@ return function() update_root = true, ignore_list = {}, }, - ignore_ft_on_setup = {}, filters = { dotfiles = false, custom = { ".DS_Store" }, From 55dc993ead37d74348d9d6c1b84d1399eb5a7b7a Mon Sep 17 00:00:00 2001 From: Charles Chiu Date: Tue, 11 Apr 2023 15:19:07 +0800 Subject: [PATCH 07/39] fix(cmp): support dynamic `kind_text` from cmp source: `treesitter`, fix #624 #634 (#637) --- lua/modules/configs/completion/cmp.lua | 59 ++++++++++++++++++++++---- lua/modules/plugins/completion.lua | 3 +- lua/modules/utils/icons.lua | 15 ++++++- 3 files changed, 64 insertions(+), 13 deletions(-) diff --git a/lua/modules/configs/completion/cmp.lua b/lua/modules/configs/completion/cmp.lua index 6c134d298..eae2cc35f 100644 --- a/lua/modules/configs/completion/cmp.lua +++ b/lua/modules/configs/completion/cmp.lua @@ -41,7 +41,37 @@ return function() return (diff < 0) end - local lspkind = require("lspkind") + local function cmp_kind(opts) + if opts == nil then + opts = {} + end + + return function(entry, vim_item) + if opts.before then + vim_item = opts.before(entry, vim_item) + end + + local kind_symbol = opts.symbol_map[vim_item.kind] or icons.kind.Undefinded + local source_symbol = opts.symbol_map[entry.source.name] or icons.cmp.Undefinded + + vim_item.menu = " " .. source_symbol .. " |" + vim_item.kind = string.format(" ⟬ %s %s ⟭", kind_symbol, vim_item.kind) + + if opts.maxwidth ~= nil then + if opts.ellipsis_char == nil then + vim_item.abbr = string.sub(vim_item.abbr, 1, opts.maxwidth) + else + local label = vim_item.abbr + local truncated_label = vim.fn.strcharpart(label, 0, opts.maxwidth) + if truncated_label ~= label then + vim_item.abbr = truncated_label .. opts.ellipsis_char + end + end + end + return vim_item + end + end + local cmp = require("cmp") cmp.setup({ @@ -72,16 +102,13 @@ return function() }, }, formatting = { - fields = { "kind", "abbr", "menu" }, + fields = { "menu", "abbr", "kind" }, format = function(entry, vim_item) - local kind = lspkind.cmp_format({ - mode = "symbol_text", + local kind_map = vim.tbl_deep_extend("force", icons.kind, icons.type, icons.cmp) + local kind = cmp_kind({ maxwidth = 50, - symbol_map = vim.tbl_deep_extend("force", icons.kind, icons.type, icons.cmp), + symbol_map = kind_map, })(entry, vim_item) - local strings = vim.split(kind.kind, "%s", { trimempty = true }) - kind.kind = " " .. strings[1] .. " " - kind.menu = " (" .. strings[2] .. ")" return kind end, }, @@ -123,7 +150,21 @@ return function() { name = "nvim_lua" }, { name = "luasnip" }, { name = "path" }, - { name = "treesitter" }, + { + name = "treesitter", + ---@diagnostic disable-next-line: unused-local + entry_filter = function(entry, _ctx) + local banned_kinds = { + "Error", + "Comment", + } + local kind = entry:get_completion_item().cmp.kind_text + if vim.tbl_contains(banned_kinds, kind) then + return false + end + return true + end, + }, { name = "spell" }, { name = "tmux" }, { name = "orgmode" }, diff --git a/lua/modules/plugins/completion.lua b/lua/modules/plugins/completion.lua index 2487742c0..187c93dbb 100644 --- a/lua/modules/plugins/completion.lua +++ b/lua/modules/plugins/completion.lua @@ -33,7 +33,6 @@ completion["hrsh7th/nvim-cmp"] = { dependencies = { "rafamadriz/friendly-snippets" }, config = require("completion.luasnip"), }, - { "onsails/lspkind.nvim" }, { "lukas-reineke/cmp-under-comparator" }, { "saadparwaiz1/cmp_luasnip" }, { "hrsh7th/cmp-nvim-lsp" }, @@ -43,7 +42,7 @@ completion["hrsh7th/nvim-cmp"] = { { "f3fora/cmp-spell" }, { "hrsh7th/cmp-buffer" }, { "kdheepak/cmp-latex-symbols" }, - { "ray-x/cmp-treesitter", commit = "c8e3a74" }, + { "ray-x/cmp-treesitter" }, -- { "tzachar/cmp-tabnine", build = "./install.sh", config = require("completion.tabnine") }, -- { -- "jcdickinson/codeium.nvim", diff --git a/lua/modules/utils/icons.lua b/lua/modules/utils/icons.lua index c59b14975..fb0f20aab 100644 --- a/lua/modules/utils/icons.lua +++ b/lua/modules/utils/icons.lua @@ -28,6 +28,7 @@ local data = { Text = "", TypeParameter = "", Unit = "", + Undefinded = "", Value = "", Variable = "", -- ccls-specific icons. @@ -160,16 +161,26 @@ local data = { Vim = "", }, cmp = { + -- kind_text Codeium = "", TabNine = "", Copilot = "", Copilot_alt = "", + -- User needs to add a icon according to the source after adding it. + -- sources + Undefinded = "", + buffer = "", + cmp_tabnine = "", + codeium = "", + copilot = "", + latex_symbols = "", + luasnip = "", nvim_lsp = "", nvim_lua = "", + orgmode = "", path = "", - buffer = "", spell = "暈", - luasnip = "", + tmux = "", treesitter = "", }, dap = { From 7dd7f0ff9cdfa368718e1657b5c9b95586f3d10f Mon Sep 17 00:00:00 2001 From: ayamir Date: Mon, 10 Apr 2023 23:40:17 +0800 Subject: [PATCH 08/39] fix&feat: introduce suda.vim to write file with sudo --- lua/core/mapping.lua | 4 ---- lua/keymap/editor.lua | 3 +++ lua/modules/configs/editor/suda.lua | 3 +++ lua/modules/plugins/editor.lua | 5 +++++ 4 files changed, 11 insertions(+), 4 deletions(-) create mode 100644 lua/modules/configs/editor/suda.lua diff --git a/lua/core/mapping.lua b/lua/core/mapping.lua index da5820db7..20318007c 100644 --- a/lua/core/mapping.lua +++ b/lua/core/mapping.lua @@ -7,10 +7,6 @@ local core_map = { -- Suckless ["n|"] = map_cr("normal za"):with_noremap():with_silent():with_desc("editn: Toggle code fold"), ["n|"] = map_cu("write"):with_noremap():with_silent():with_desc("editn: Save file"), - ["n|"] = map_cmd("execute 'silent! write !sudo tee % >/dev/null' edit!") - :with_silent() - :with_noremap() - :with_desc("editn: Save file using sudo"), ["n|Y"] = map_cmd("y$"):with_desc("editn: Yank text to EOL"), ["n|D"] = map_cmd("d$"):with_desc("editn: Delete text to EOL"), ["n|n"] = map_cmd("nzzzv"):with_noremap():with_desc("editn: Next search result"), diff --git a/lua/keymap/editor.lua b/lua/keymap/editor.lua index b98235aaf..27fb19368 100644 --- a/lua/keymap/editor.lua +++ b/lua/keymap/editor.lua @@ -84,6 +84,9 @@ local plug_map = { -- Plugin: tabout ["i|"] = map_cmd("(TaboutMulti)"):with_silent():with_noremap():with_desc("edit: Goto end of pair"), ["i|"] = map_cmd("(TaboutBackMulti)"):with_silent():with_noremap():with_desc("edit: Goto begin of pair"), + + -- Plugin suda.vim + ["n|"] = map_cu("SudaWrite"):with_silent():with_noremap():with_desc("editn: Save file using sudo"), } bind.nvim_load_mapping(plug_map) diff --git a/lua/modules/configs/editor/suda.lua b/lua/modules/configs/editor/suda.lua new file mode 100644 index 000000000..bf77b65b1 --- /dev/null +++ b/lua/modules/configs/editor/suda.lua @@ -0,0 +1,3 @@ +return function() + vim.g["suda#prompt"] = "Enter administrator password: " +end diff --git a/lua/modules/plugins/editor.lua b/lua/modules/plugins/editor.lua index bbba26665..0322b8be1 100644 --- a/lua/modules/plugins/editor.lua +++ b/lua/modules/plugins/editor.lua @@ -66,6 +66,11 @@ editor["romainl/vim-cool"] = { lazy = true, event = { "CursorMoved", "InsertEnter" }, } +editor["lambdalisue/suda.vim"] = { + lazy = true, + cmd = { "SudaRead", "SudaWrite" }, + config = require("editor.suda"), +} ---------------------------------------------------------------------- --  :treesitter related plugins -- From 80573d6e55ac982252c7d06d37fe9dca3e1dfd81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=86=B7=E9=85=94=E9=96=91=E5=90=9F?= <50296129+Jint-lzxy@users.noreply.github.com> Date: Tue, 11 Apr 2023 21:04:35 +0800 Subject: [PATCH 09/39] chore(kind_text): cleanup (#648) --- lua/modules/configs/completion/cmp.lua | 24 ++++++++---------------- lua/modules/utils/icons.lua | 8 +++----- 2 files changed, 11 insertions(+), 21 deletions(-) diff --git a/lua/modules/configs/completion/cmp.lua b/lua/modules/configs/completion/cmp.lua index eae2cc35f..d0e02a44f 100644 --- a/lua/modules/configs/completion/cmp.lua +++ b/lua/modules/configs/completion/cmp.lua @@ -41,18 +41,14 @@ return function() return (diff < 0) end - local function cmp_kind(opts) - if opts == nil then - opts = {} - end + local function cmp_format(opts) + opts = opts or {} return function(entry, vim_item) - if opts.before then - vim_item = opts.before(entry, vim_item) - end + vim_item = opts.before and opts.before(entry, vim_item) local kind_symbol = opts.symbol_map[vim_item.kind] or icons.kind.Undefinded - local source_symbol = opts.symbol_map[entry.source.name] or icons.cmp.Undefinded + local source_symbol = opts.symbol_map[entry.source.name] or icons.cmp.undefined vim_item.menu = " " .. source_symbol .. " |" vim_item.kind = string.format(" ⟬ %s %s ⟭", kind_symbol, vim_item.kind) @@ -105,7 +101,7 @@ return function() fields = { "menu", "abbr", "kind" }, format = function(entry, vim_item) local kind_map = vim.tbl_deep_extend("force", icons.kind, icons.type, icons.cmp) - local kind = cmp_kind({ + local kind = cmp_format({ maxwidth = 50, symbol_map = kind_map, })(entry, vim_item) @@ -152,17 +148,13 @@ return function() { name = "path" }, { name = "treesitter", - ---@diagnostic disable-next-line: unused-local - entry_filter = function(entry, _ctx) - local banned_kinds = { + entry_filter = function(entry) + local ignore_list = { "Error", "Comment", } local kind = entry:get_completion_item().cmp.kind_text - if vim.tbl_contains(banned_kinds, kind) then - return false - end - return true + return not vim.tbl_contains(ignore_list, kind) end, }, { name = "spell" }, diff --git a/lua/modules/utils/icons.lua b/lua/modules/utils/icons.lua index fb0f20aab..bc41811ef 100644 --- a/lua/modules/utils/icons.lua +++ b/lua/modules/utils/icons.lua @@ -28,7 +28,7 @@ local data = { Text = "", TypeParameter = "", Unit = "", - Undefinded = "", + Undefined = "", Value = "", Variable = "", -- ccls-specific icons. @@ -161,14 +161,12 @@ local data = { Vim = "", }, cmp = { - -- kind_text Codeium = "", TabNine = "", Copilot = "", Copilot_alt = "", - -- User needs to add a icon according to the source after adding it. - -- sources - Undefinded = "", + -- Add source-specific icons here + undefined = "", buffer = "", cmp_tabnine = "", codeium = "", From 0f101a1956e7a64d64abb3c2c61cf8c68588afd2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=86=B7=E9=85=94=E9=96=91=E5=90=9F?= <50296129+Jint-lzxy@users.noreply.github.com> Date: Tue, 11 Apr 2023 21:45:00 +0800 Subject: [PATCH 10/39] feat(alpha): add custom highlight groups (#650) --- lua/modules/configs/ui/alpha.lua | 10 ++++++---- lua/modules/utils/init.lua | 11 +++++++++++ 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/lua/modules/configs/ui/alpha.lua b/lua/modules/configs/ui/alpha.lua index ddd22a5dd..aad83724d 100644 --- a/lua/modules/configs/ui/alpha.lua +++ b/lua/modules/configs/ui/alpha.lua @@ -1,6 +1,7 @@ return function() local alpha = require("alpha") local dashboard = require("alpha.themes.dashboard") + require("modules.utils").gen_alpha_hl() dashboard.section.header.val = { [[⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⠿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿]], @@ -23,7 +24,7 @@ return function() [[⠿⠛⠛⠛⠛⠛⠛⠻⢿⣿⣿⣿⣿⣯⣟⠷⢷⣿⡿⠋⠀⠀⠀⠀⣵⡀⢠⡿⠋⢻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿]], [[⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠉⠉⠛⢿⣿⣿⠂⠀⠀⠀⠀⠀⢀⣽⣿⣿⣿⣿⣿⣿⣿⣍⠛⠿⣿⣿⣿⣿⣿⣿]], } - dashboard.section.header.opts.hl = "Type" + dashboard.section.header.opts.hl = "AlphaHeader" local function button(sc, txt, leader_txt, keybind, keybind_opts) local sc_after = sc:gsub("%s", ""):gsub(leader_txt, "") @@ -34,7 +35,8 @@ return function() cursor = 5, width = 50, align_shortcut = "right", - hl_shortcut = "Keyword", + hl = "AlphaButton", + hl_shortcut = "AlphaAttr", } if nil == keybind then @@ -116,7 +118,7 @@ return function() end, }), } - dashboard.section.buttons.opts.hl = "String" + dashboard.section.buttons.opts.hl = "AlphaButton" local function footer() local stats = require("lazy").stats() @@ -136,7 +138,7 @@ return function() end dashboard.section.footer.val = footer() - dashboard.section.footer.opts.hl = "Function" + dashboard.section.footer.opts.hl = "AlphaFooter" local head_butt_padding = 2 local occu_height = #dashboard.section.header.val + 2 * #dashboard.section.buttons.val + head_butt_padding diff --git a/lua/modules/utils/init.lua b/lua/modules/utils/init.lua index b6f674a1c..c2ea0726b 100644 --- a/lua/modules/utils/init.lua +++ b/lua/modules/utils/init.lua @@ -145,6 +145,7 @@ function M.get_palette(overwrite) end end +-- Generate highlight groups for lspsaga. Existing attributes will NOT be overwritten function M.gen_lspkind_hl() local colors = M.get_palette() local dat = { @@ -189,6 +190,16 @@ function M.gen_lspkind_hl() end end +-- Generate highlight groups for alpha. Existing attributes will NOT be overwritten +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, "AlphaButton", { fg = colors.green, default = true }) + vim.api.nvim_set_hl(0, "AlphaAttr", { fg = colors.pink, italic = true, default = true }) + vim.api.nvim_set_hl(0, "AlphaFooter", { fg = colors.yellow, default = true }) +end + ---Convert number (0/1) to boolean ---@param value number @The value to check ---@return boolean|nil @Returns nil if failed From a9752b7bbd8f97738390bef1ac849ea52578f65c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=86=B7=E9=85=94=E9=96=91=E5=90=9F?= <50296129+Jint-lzxy@users.noreply.github.com> Date: Tue, 11 Apr 2023 21:56:13 +0800 Subject: [PATCH 11/39] fix: install `psutils` by default for Windows users --- scripts/install.ps1 | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/scripts/install.ps1 b/scripts/install.ps1 index a431964cf..7b7d10510 100644 --- a/scripts/install.ps1 +++ b/scripts/install.ps1 @@ -12,8 +12,8 @@ $REQUIRED_NVIM_VERSION = [version]'0.8.0' $USE_SSH = $True # package mgr vars -$choco_package_matrix = @{ "gcc" = "mingw"; "git" = "git"; "nvim" = "neovim"; "make" = "make"; "node" = "nodejs"; "pip" = "python3"; "fzf" = "fzf"; "rg" = "ripgrep"; "go" = "go"; "curl" = "curl"; "wget" = "wget"; "tree-sitter" = "tree-sitter"; "ruby" = "ruby"; "sqlite3" = "sqlite"; "rustc" = "rust-ms" } -$scoop_package_matrix = @{ "gcc" = "mingw"; "git" = "git"; "nvim" = "neovim"; "make" = "make"; "node" = "nodejs"; "pip" = "python"; "fzf" = "fzf"; "rg" = "ripgrep"; "go" = "go"; "curl" = "curl"; "wget" = "wget"; "tree-sitter" = "tree-sitter"; "ruby" = "ruby"; "sqlite3" = "sqlite"; "rustc" = "rust" } +$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"; "sqlite3" = "sqlite"; "rustc" = "rust-ms" } +$scoop_package_matrix = @{ "gcc" = "mingw"; "git" = "git"; "nvim" = "neovim"; "make" = "make"; "sudo" = "psutils"; "node" = "nodejs"; "pip" = "python"; "fzf" = "fzf"; "rg" = "ripgrep"; "go" = "go"; "curl" = "curl"; "wget" = "wget"; "tree-sitter" = "tree-sitter"; "ruby" = "ruby"; "sqlite3" = "sqlite"; "rustc" = "rust" } $installer_pkg_matrix = @{ "NodeJS" = "npm"; "Python" = "pip"; "Ruby" = "gem" } # env vars @@ -254,6 +254,7 @@ function fetch_deps { check_and_fetch_exec -PkgName "git" check_and_fetch_exec -PkgName "nvim" check_and_fetch_exec -PkgName "make" + check_and_fetch_exec -PkgName "sudo" check_and_fetch_exec -PkgName "node" check_and_fetch_exec -PkgName "pip" check_and_fetch_exec -PkgName "fzf" From 70dedbaf1c743b55f8abd097c55577ed2008dceb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=86=B7=E9=85=94=E9=96=91=E5=90=9F?= <50296129+Jint-lzxy@users.noreply.github.com> Date: Tue, 11 Apr 2023 22:16:21 +0800 Subject: [PATCH 12/39] revert: bind `SudaWrite` to `` ref: https://github.com/ayamir/nvimdots/pull/641#issuecomment-1503431723 --- lua/keymap/editor.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/keymap/editor.lua b/lua/keymap/editor.lua index 27fb19368..37f56aeab 100644 --- a/lua/keymap/editor.lua +++ b/lua/keymap/editor.lua @@ -86,7 +86,7 @@ local plug_map = { ["i|"] = map_cmd("(TaboutBackMulti)"):with_silent():with_noremap():with_desc("edit: Goto begin of pair"), -- Plugin suda.vim - ["n|"] = map_cu("SudaWrite"):with_silent():with_noremap():with_desc("editn: Save file using sudo"), + ["n|"] = map_cu("SudaWrite"):with_silent():with_noremap():with_desc("editn: Save file using sudo"), } bind.nvim_load_mapping(plug_map) From 00c063d23b7c8ee95f82fda3a379082927fad34b Mon Sep 17 00:00:00 2001 From: CharlesChiuGit Date: Wed, 12 Apr 2023 16:39:16 +0800 Subject: [PATCH 13/39] fix(cmp): nil `vim_item` --- lua/modules/configs/completion/cmp.lua | 6 ++++-- lua/modules/utils/icons.lua | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/lua/modules/configs/completion/cmp.lua b/lua/modules/configs/completion/cmp.lua index d0e02a44f..b47daeb07 100644 --- a/lua/modules/configs/completion/cmp.lua +++ b/lua/modules/configs/completion/cmp.lua @@ -45,9 +45,11 @@ return function() opts = opts or {} return function(entry, vim_item) - vim_item = opts.before and opts.before(entry, vim_item) + if opts.before then + vim_item = opts.before(entry, vim_item) + end - local kind_symbol = opts.symbol_map[vim_item.kind] or icons.kind.Undefinded + local kind_symbol = opts.symbol_map[vim_item.kind] or icons.kind.Undefined local source_symbol = opts.symbol_map[entry.source.name] or icons.cmp.undefined vim_item.menu = " " .. source_symbol .. " |" diff --git a/lua/modules/utils/icons.lua b/lua/modules/utils/icons.lua index bc41811ef..945b4efaa 100644 --- a/lua/modules/utils/icons.lua +++ b/lua/modules/utils/icons.lua @@ -166,7 +166,6 @@ local data = { Copilot = "", Copilot_alt = "", -- Add source-specific icons here - undefined = "", buffer = "", cmp_tabnine = "", codeium = "", @@ -180,6 +179,7 @@ local data = { spell = "暈", tmux = "", treesitter = "", + undefined = "", }, dap = { Breakpoint = "", From 30310e2912fb63e41520b1c41ce6dbe231b8509b Mon Sep 17 00:00:00 2001 From: CharlesChiuGit Date: Wed, 12 Apr 2023 16:39:39 +0800 Subject: [PATCH 14/39] perf(core-mapping): add some useful mapping --- lua/core/mapping.lua | 69 +++++++++++++++++++++++++++----------------- 1 file changed, 43 insertions(+), 26 deletions(-) diff --git a/lua/core/mapping.lua b/lua/core/mapping.lua index 20318007c..cfe752410 100644 --- a/lua/core/mapping.lua +++ b/lua/core/mapping.lua @@ -5,13 +5,15 @@ local map_cmd = bind.map_cmd local core_map = { -- Suckless - ["n|"] = map_cr("normal za"):with_noremap():with_silent():with_desc("editn: Toggle code fold"), - ["n|"] = map_cu("write"):with_noremap():with_silent():with_desc("editn: Save file"), - ["n|Y"] = map_cmd("y$"):with_desc("editn: Yank text to EOL"), - ["n|D"] = map_cmd("d$"):with_desc("editn: Delete text to EOL"), - ["n|n"] = map_cmd("nzzzv"):with_noremap():with_desc("editn: Next search result"), - ["n|N"] = map_cmd("Nzzzv"):with_noremap():with_desc("editn: Prev search result"), - ["n|J"] = map_cmd("mzJ`z"):with_noremap():with_desc("editn: Join next line"), + ["n|"] = map_cr("normal za"):with_noremap():with_silent():with_desc("edit: Toggle code fold"), + ["n|"] = map_cu("write"):with_noremap():with_silent():with_desc("edit: Save file"), + ["n|Y"] = map_cmd("y$"):with_desc("edit: Yank text to EOL"), + ["n|D"] = map_cmd("d$"):with_desc("edit: Delete text to EOL"), + ["n|n"] = map_cmd("nzzzv"):with_noremap():with_desc("edit: Next search result"), + ["n|N"] = map_cmd("Nzzzv"):with_noremap():with_desc("edit: Prev search result"), + ["n|J"] = map_cmd("mzJ`z"):with_noremap():with_desc("edit: Join next line"), + ["n|Q"] = map_cmd(""):with_noremap():with_silent():with_desc("edit: Do nothing when press Q"), + ["n|"] = map_cmd("noh"):with_noremap():with_silent():with_desc("edit: Clear search highlight"), ["n|"] = map_cmd("h"):with_noremap():with_desc("window: Focus left"), ["n|"] = map_cmd("l"):with_noremap():with_desc("window: Focus right"), ["n|"] = map_cmd("j"):with_noremap():with_desc("window: Focus down"), @@ -24,30 +26,45 @@ local core_map = { ["n|"] = map_cr("vertical resize +5"):with_silent():with_desc("window: Resize +5 vertically"), ["n|"] = map_cr("resize -2"):with_silent():with_desc("window: Resize -2 horizontally"), ["n|"] = map_cr("resize +2"):with_silent():with_desc("window: Resize +2 horizontally"), - ["n|"] = map_cmd(":wq"):with_desc("editn: Save file and quit"), - ["n|"] = map_cmd(":q!"):with_desc("editn: Force quit"), - ["n|o"] = map_cr("setlocal spell! spelllang=en_us"):with_desc("editn: Toggle spell check"), + ["n|"] = map_cmd(":wq"):with_desc("edit: Save file and quit"), + ["n|"] = map_cmd(":q!"):with_desc("edit: Force quit"), + ["n|o"] = map_cr("setlocal spell! spelllang=en_us"):with_desc("edit: Toggle spell check"), + ["n|+"] = map_cmd(""):with_noremap():with_silent():with_desc("edit: Increment"), + ["n|-"] = map_cmd(""):with_noremap():with_silent():with_desc("edit: Decrement"), + ["n|"] = map_cmd("ggG"):with_noremap():with_silent():with_desc("edit: Select all"), + ["n|tn"] = map_cmd("tabnew"):with_noremap():with_silent():with_desc("tab: Create a new tab"), + ["n|tk"] = map_cmd("tabnext"):with_noremap():with_silent():with_desc("tab: Move to next tab"), + ["n|tj"] = map_cmd("tabprevious"):with_noremap():with_silent():with_desc("tab: Move to previous tab"), + ["n|to"] = map_cmd("tabonly"):with_noremap():with_silent():with_desc("tab: Only keep current tab"), + ["n|x"] = map_cmd("!chmod +x %"):with_silent():with_desc("file: chmod +x current file"), -- Insert mode - ["i|"] = map_cmd("u"):with_noremap():with_desc("editi: Delete previous block"), - ["i|"] = map_cmd(""):with_noremap():with_desc("editi: Move cursor to left"), - ["i|"] = map_cmd("^i"):with_noremap():with_desc("editi: Move cursor to line start"), - ["i|"] = map_cmd(":w"):with_desc("editi: Save file"), - ["i|"] = map_cmd(":wq"):with_desc("editi: Save file and quit"), + ["i|"] = map_cmd("u"):with_noremap():with_desc("edit: Delete previous block"), + ["i|"] = map_cmd(""):with_noremap():with_desc("edit: Move cursor to left"), + ["i|"] = map_cmd("^i"):with_noremap():with_desc("edit: Move cursor to line start"), + ["i|"] = map_cmd(":w"):with_desc("edit: Save file"), + ["i|"] = map_cmd(":wq"):with_desc("edit: Save file and quit"), -- Command mode - ["c|"] = map_cmd(""):with_noremap():with_desc("editc: Left"), - ["c|"] = map_cmd(""):with_noremap():with_desc("editc: Right"), - ["c|"] = map_cmd(""):with_noremap():with_desc("editc: Home"), - ["c|"] = map_cmd(""):with_noremap():with_desc("editc: End"), - ["c|"] = map_cmd(""):with_noremap():with_desc("editc: Delete"), - ["c|"] = map_cmd(""):with_noremap():with_desc("editc: Backspace"), + ["c|"] = map_cmd(""):with_noremap():with_desc("edit: Left"), + ["c|"] = map_cmd(""):with_noremap():with_desc("edit: Right"), + ["c|"] = map_cmd(""):with_noremap():with_desc("edit: Home"), + ["c|"] = map_cmd(""):with_noremap():with_desc("edit: End"), + ["c|"] = map_cmd(""):with_noremap():with_desc("edit: Delete"), + ["c|"] = map_cmd(""):with_noremap():with_desc("edit: Backspace"), ["c|"] = map_cmd([[=expand("%:p:h") . "/" ]]) :with_noremap() - :with_desc("editc: Complete path of current file"), + :with_desc("edit: Complete path of current file"), -- Visual mode - ["v|J"] = map_cmd(":m '>+1gv=gv"):with_desc("editv: Move this line down"), - ["v|K"] = map_cmd(":m '<-2gv=gv"):with_desc("editv: Move this line up"), - ["v|<"] = map_cmd(""] = map_cmd(">gv"):with_desc("editv: Increase indent"), + ["v|J"] = map_cmd(":m '>+1gv=gv"):with_desc("edit: Move this line down"), + ["v|K"] = map_cmd(":m '<-2gv=gv"):with_desc("edit: Move this line up"), + ["v|<"] = map_cmd(""] = map_cmd(">gv"):with_desc("edit: Increase indent"), } bind.nvim_load_mapping(core_map) + +vim.api.nvim_set_keymap( + "n", + "s", + "%s/\\<\\>//gI", + { noremap = true, silent = true, nowait = true, desc = "edit: Start replacment mode of current word" } +) From aa04de3d808720b9c97d586b0edcdb211115be38 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=86=B7=E9=85=94=E9=96=91=E5=90=9F?= <50296129+Jint-lzxy@users.noreply.github.com> Date: Wed, 12 Apr 2023 20:05:03 +0800 Subject: [PATCH 15/39] fix(nvim-tree): `hide_root_folder` is deprecated --- lua/modules/configs/tool/nvim-tree.lua | 1 - 1 file changed, 1 deletion(-) diff --git a/lua/modules/configs/tool/nvim-tree.lua b/lua/modules/configs/tool/nvim-tree.lua index 810e9cce9..2979c4a78 100644 --- a/lua/modules/configs/tool/nvim-tree.lua +++ b/lua/modules/configs/tool/nvim-tree.lua @@ -26,7 +26,6 @@ return function() number = false, relativenumber = false, signcolumn = "yes", - hide_root_folder = false, float = { enable = false, open_win_config = { From 68fefe763d996ed6c01574ef1ae349708293a214 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=86=B7=E9=85=94=E9=96=91=E5=90=9F?= <50296129+Jint-lzxy@users.noreply.github.com> Date: Wed, 12 Apr 2023 20:28:35 +0800 Subject: [PATCH 16/39] perf: load fidget.nvim after `LspAttach` --- lua/modules/plugins/ui.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/modules/plugins/ui.lua b/lua/modules/plugins/ui.lua index 1957421dd..dc203ef8f 100644 --- a/lua/modules/plugins/ui.lua +++ b/lua/modules/plugins/ui.lua @@ -21,7 +21,7 @@ ui["sainnhe/edge"] = { } ui["j-hui/fidget.nvim"] = { lazy = true, - event = "BufReadPost", + event = "LspAttach", config = require("ui.fidget"), } ui["lewis6991/gitsigns.nvim"] = { From 177cda4677b3b0f7345dadf84d3c52e97fa65e0b Mon Sep 17 00:00:00 2001 From: Charles Chiu Date: Thu, 13 Apr 2023 00:01:19 +0800 Subject: [PATCH 17/39] minor fix 1. remove `` at "n|Q" 2. use visual mode instead of visual-line mode for "n|" --- lua/core/mapping.lua | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lua/core/mapping.lua b/lua/core/mapping.lua index cfe752410..00629f462 100644 --- a/lua/core/mapping.lua +++ b/lua/core/mapping.lua @@ -12,7 +12,6 @@ local core_map = { ["n|n"] = map_cmd("nzzzv"):with_noremap():with_desc("edit: Next search result"), ["n|N"] = map_cmd("Nzzzv"):with_noremap():with_desc("edit: Prev search result"), ["n|J"] = map_cmd("mzJ`z"):with_noremap():with_desc("edit: Join next line"), - ["n|Q"] = map_cmd(""):with_noremap():with_silent():with_desc("edit: Do nothing when press Q"), ["n|"] = map_cmd("noh"):with_noremap():with_silent():with_desc("edit: Clear search highlight"), ["n|"] = map_cmd("h"):with_noremap():with_desc("window: Focus left"), ["n|"] = map_cmd("l"):with_noremap():with_desc("window: Focus right"), @@ -31,7 +30,7 @@ local core_map = { ["n|o"] = map_cr("setlocal spell! spelllang=en_us"):with_desc("edit: Toggle spell check"), ["n|+"] = map_cmd(""):with_noremap():with_silent():with_desc("edit: Increment"), ["n|-"] = map_cmd(""):with_noremap():with_silent():with_desc("edit: Decrement"), - ["n|"] = map_cmd("ggG"):with_noremap():with_silent():with_desc("edit: Select all"), + ["n|"] = map_cmd("gg0vG$"):with_noremap():with_silent():with_desc("edit: Select all"), ["n|tn"] = map_cmd("tabnew"):with_noremap():with_silent():with_desc("tab: Create a new tab"), ["n|tk"] = map_cmd("tabnext"):with_noremap():with_silent():with_desc("tab: Move to next tab"), ["n|tj"] = map_cmd("tabprevious"):with_noremap():with_silent():with_desc("tab: Move to previous tab"), From 47e6f04a71b73d5d4d097cc1f5a7f2a22a6ec612 Mon Sep 17 00:00:00 2001 From: Charles Chiu Date: Thu, 13 Apr 2023 00:05:32 +0800 Subject: [PATCH 18/39] perf: align style --- lua/core/mapping.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/core/mapping.lua b/lua/core/mapping.lua index 00629f462..06af10ec9 100644 --- a/lua/core/mapping.lua +++ b/lua/core/mapping.lua @@ -64,6 +64,6 @@ bind.nvim_load_mapping(core_map) vim.api.nvim_set_keymap( "n", "s", - "%s/\\<\\>//gI", + "%s/\\<\\>//gI", { noremap = true, silent = true, nowait = true, desc = "edit: Start replacment mode of current word" } ) From 12572d16d363a54728471fe23831d8ceb9676679 Mon Sep 17 00:00:00 2001 From: CharlesChiuGit Date: Thu, 13 Apr 2023 16:53:02 +0800 Subject: [PATCH 19/39] perf(0.9): `stabilize.nvim` had been upstream to `0.9` --- lua/modules/plugins/editor.lua | 4 ---- 1 file changed, 4 deletions(-) diff --git a/lua/modules/plugins/editor.lua b/lua/modules/plugins/editor.lua index 0322b8be1..88fe34965 100644 --- a/lua/modules/plugins/editor.lua +++ b/lua/modules/plugins/editor.lua @@ -58,10 +58,6 @@ editor["RRethy/vim-illuminate"] = { event = { "CursorHold", "CursorHoldI" }, config = require("editor.vim-illuminate"), } -editor["luukvbaal/stabilize.nvim"] = { - lazy = true, - event = "BufReadPost", -} editor["romainl/vim-cool"] = { lazy = true, event = { "CursorMoved", "InsertEnter" }, From f9668aed9067316a3c4a2fc78c3a2a0953697ebe Mon Sep 17 00:00:00 2001 From: CharlesChiuGit Date: Thu, 13 Apr 2023 16:53:55 +0800 Subject: [PATCH 20/39] chore(project.nvim): update legacy code --- lua/modules/configs/tool/project.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/modules/configs/tool/project.lua b/lua/modules/configs/tool/project.lua index 281f1a25e..153d023ee 100644 --- a/lua/modules/configs/tool/project.lua +++ b/lua/modules/configs/tool/project.lua @@ -3,7 +3,7 @@ return function() manual_mode = false, detection_methods = { "lsp", "pattern" }, patterns = { ".git", "_darcs", ".hg", ".bzr", ".svn", "Makefile", "package.json" }, - ignore_lsp = { "efm", "copilot" }, + ignore_lsp = { "null-ls", "copilot" }, exclude_dirs = {}, show_hidden = false, silent_chdir = true, From bda4aacf4cbdda19e38f98f66eaf55b5cb95fdd4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=86=B7=E9=85=94=E9=96=91=E5=90=9F?= <50296129+Jint-lzxy@users.noreply.github.com> Date: Thu, 13 Apr 2023 20:11:57 +0800 Subject: [PATCH 21/39] chore(README): update branch info --- README.md | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 3ab8f9e4c..b93c1ddff 100644 --- a/README.md +++ b/README.md @@ -38,14 +38,15 @@ This repo hosts my [NeoVim](https://neovim.io/) configuration for Linux, macOS, and Windows. `init.lua` is the config entry point. -It contains two branches: +Branch info:
-| Branch | Completion Solution | -| :----: | :------------------------: | -| main | config for nvim 0.8 stable | -| 0.7 | config for nvim 0.7 stable | +| Branch | Supported neovim version | +| :----: | :----------------------: | +| main | nvim 0.9 stable | +| 0.8 | nvim 0.8 | +| 0.7 | nvim 0.7 |
From fccf351385c08f7019afd9efd0adc0a9c2ebd2d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=86=B7=E9=85=94=E9=96=91=E5=90=9F?= <50296129+Jint-lzxy@users.noreply.github.com> Date: Fri, 14 Apr 2023 00:07:33 +0800 Subject: [PATCH 22/39] chore(mapping): cleanup (#657) --- lua/core/mapping.lua | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/lua/core/mapping.lua b/lua/core/mapping.lua index 06af10ec9..ca58b0743 100644 --- a/lua/core/mapping.lua +++ b/lua/core/mapping.lua @@ -12,7 +12,7 @@ local core_map = { ["n|n"] = map_cmd("nzzzv"):with_noremap():with_desc("edit: Next search result"), ["n|N"] = map_cmd("Nzzzv"):with_noremap():with_desc("edit: Prev search result"), ["n|J"] = map_cmd("mzJ`z"):with_noremap():with_desc("edit: Join next line"), - ["n|"] = map_cmd("noh"):with_noremap():with_silent():with_desc("edit: Clear search highlight"), + ["n|"] = map_cr("noh"):with_noremap():with_silent():with_desc("edit: Clear search highlight"), ["n|"] = map_cmd("h"):with_noremap():with_desc("window: Focus left"), ["n|"] = map_cmd("l"):with_noremap():with_desc("window: Focus right"), ["n|"] = map_cmd("j"):with_noremap():with_desc("window: Focus down"), @@ -25,17 +25,17 @@ local core_map = { ["n|"] = map_cr("vertical resize +5"):with_silent():with_desc("window: Resize +5 vertically"), ["n|"] = map_cr("resize -2"):with_silent():with_desc("window: Resize -2 horizontally"), ["n|"] = map_cr("resize +2"):with_silent():with_desc("window: Resize +2 horizontally"), - ["n|"] = map_cmd(":wq"):with_desc("edit: Save file and quit"), - ["n|"] = map_cmd(":q!"):with_desc("edit: Force quit"), + ["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|+"] = map_cmd(""):with_noremap():with_silent():with_desc("edit: Increment"), ["n|-"] = map_cmd(""):with_noremap():with_silent():with_desc("edit: Decrement"), ["n|"] = map_cmd("gg0vG$"):with_noremap():with_silent():with_desc("edit: Select all"), - ["n|tn"] = map_cmd("tabnew"):with_noremap():with_silent():with_desc("tab: Create a new tab"), - ["n|tk"] = map_cmd("tabnext"):with_noremap():with_silent():with_desc("tab: Move to next tab"), - ["n|tj"] = map_cmd("tabprevious"):with_noremap():with_silent():with_desc("tab: Move to previous tab"), - ["n|to"] = map_cmd("tabonly"):with_noremap():with_silent():with_desc("tab: Only keep current tab"), - ["n|x"] = map_cmd("!chmod +x %"):with_silent():with_desc("file: chmod +x current file"), + ["x|"] = map_cmd("gg0vG$"):with_noremap():with_silent():with_desc("edit: Select all"), + ["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"), + ["n|to"] = map_cr("tabonly"):with_noremap():with_silent():with_desc("tab: Only keep current tab"), -- Insert mode ["i|"] = map_cmd("u"):with_noremap():with_desc("edit: Delete previous block"), ["i|"] = map_cmd(""):with_noremap():with_desc("edit: Move cursor to left"), @@ -60,10 +60,3 @@ local core_map = { } bind.nvim_load_mapping(core_map) - -vim.api.nvim_set_keymap( - "n", - "s", - "%s/\\<\\>//gI", - { noremap = true, silent = true, nowait = true, desc = "edit: Start replacment mode of current word" } -) From e533b2a836801a2ee18ca46b354c969124e88b08 Mon Sep 17 00:00:00 2001 From: Charles Chiu Date: Tue, 18 Apr 2023 13:25:21 +0800 Subject: [PATCH 23/39] fix(icon): update invalid cmp icon (#665) --- lua/modules/configs/completion/cmp.lua | 2 +- lua/modules/utils/icons.lua | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lua/modules/configs/completion/cmp.lua b/lua/modules/configs/completion/cmp.lua index b47daeb07..b83b1843e 100644 --- a/lua/modules/configs/completion/cmp.lua +++ b/lua/modules/configs/completion/cmp.lua @@ -53,7 +53,7 @@ return function() local source_symbol = opts.symbol_map[entry.source.name] or icons.cmp.undefined vim_item.menu = " " .. source_symbol .. " |" - vim_item.kind = string.format(" ⟬ %s %s ⟭", kind_symbol, vim_item.kind) + vim_item.kind = string.format(" 〔 %s %s 〕", kind_symbol, vim_item.kind) if opts.maxwidth ~= nil then if opts.ellipsis_char == nil then diff --git a/lua/modules/utils/icons.lua b/lua/modules/utils/icons.lua index 945b4efaa..3d5703e67 100644 --- a/lua/modules/utils/icons.lua +++ b/lua/modules/utils/icons.lua @@ -163,13 +163,13 @@ local data = { cmp = { Codeium = "", TabNine = "", - Copilot = "", - Copilot_alt = "", + Copilot = "", -- Add source-specific icons here buffer = "", - cmp_tabnine = "", - codeium = "", + cmp_tabnine = "", + codeium = "", copilot = "", + copilot_alt = "", latex_symbols = "", luasnip = "", nvim_lsp = "", From f0fa437b349087b0adc3ed86e60564bf528721d2 Mon Sep 17 00:00:00 2001 From: Charles Chiu Date: Wed, 19 Apr 2023 12:12:06 +0800 Subject: [PATCH 24/39] chore/lspsaga_move (#667) --- 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 187c93dbb..3ed980d0d 100644 --- a/lua/modules/plugins/completion.lua +++ b/lua/modules/plugins/completion.lua @@ -9,7 +9,7 @@ completion["neovim/nvim-lspconfig"] = { { "williamboman/mason.nvim" }, { "williamboman/mason-lspconfig.nvim" }, { - "glepnir/lspsaga.nvim", + "nvimdev/lspsaga.nvim", config = require("completion.lspsaga"), }, }, From 62417b10a73cd9d60d7253af16da96c0a93db4f5 Mon Sep 17 00:00:00 2001 From: Xie Zejian Date: Wed, 19 Apr 2023 16:42:10 +0800 Subject: [PATCH 25/39] fix: paint word boundary in python (#669) --- lua/modules/configs/ui/paint.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/modules/configs/ui/paint.lua b/lua/modules/configs/ui/paint.lua index 1fda36cb1..434355659 100644 --- a/lua/modules/configs/ui/paint.lua +++ b/lua/modules/configs/ui/paint.lua @@ -12,7 +12,7 @@ return function() }, { filter = { filetype = "python" }, - pattern = "%s*(%w+:)", + pattern = "%s*([_%w]+:)", hl = "Constant", }, }, From ecaba008ae53e66113f0938a0605416de4d3ec83 Mon Sep 17 00:00:00 2001 From: CharlesChiuGit Date: Fri, 21 Apr 2023 10:36:20 +0800 Subject: [PATCH 26/39] fix(bufferline): `show_buffer_default_icon` is now deprecate --- lua/modules/configs/ui/bufferline.lua | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lua/modules/configs/ui/bufferline.lua b/lua/modules/configs/ui/bufferline.lua index 3f6d081d0..96a7bfc83 100644 --- a/lua/modules/configs/ui/bufferline.lua +++ b/lua/modules/configs/ui/bufferline.lua @@ -14,13 +14,19 @@ return function() color_icons = true, show_buffer_icons = true, show_buffer_close_icons = true, - show_buffer_default_icon = true, show_close_icon = true, show_tab_indicators = true, enforce_regular_tabs = true, persist_buffer_sort = true, always_show_bufferline = true, separator_style = "thin", + get_element_icon = function(buf) + return require("nvim-web-devicons").get_icon( + buf.name, + vim.bo.filetype, + { default = true, strict = true } + ) + end, diagnostics = "nvim_lsp", diagnostics_indicator = function(count) return "(" .. count .. ")" From 6c6912bd78fcb2b672503580ceec5bed0c1e6d36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=86=B7=E9=85=94=E9=96=91=E5=90=9F?= <50296129+Jint-lzxy@users.noreply.github.com> Date: Sat, 22 Apr 2023 23:52:03 +0800 Subject: [PATCH 27/39] feat(formatting): notify users for files under disabled dirs --- lua/modules/configs/completion/formatting.lua | 33 ++++++++++++++----- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/lua/modules/configs/completion/formatting.lua b/lua/modules/configs/completion/formatting.lua index 66b7bbd5e..f095ac92e 100644 --- a/lua/modules/configs/completion/formatting.lua +++ b/lua/modules/configs/completion/formatting.lua @@ -15,7 +15,7 @@ vim.api.nvim_create_user_command("FormatterToggleFt", function(opts) vim.notify( string.format("[LSP] Formatter for [%s] has been recorded in list and disabled.", opts.args), vim.log.levels.WARN, - { title = "LSP Formatter Warning!" } + { title = "LSP Formatter Warning" } ) block_list[opts.args] = true else @@ -39,14 +39,17 @@ function M.enable_format_on_save(is_configured) group = "format_on_save", pattern = opts.pattern, callback = function() - require("completion.formatting").format({ timeout_ms = opts.timeout, filter = M.format_filter }) + require("completion.formatting").format({ + timeout_ms = opts.timeout, + filter = M.format_filter, + }) end, }) if not is_configured then vim.notify( "Successfully enabled format-on-save", vim.log.levels.INFO, - { title = "Settings modification success!" } + { title = "Settings modification success" } ) end end @@ -54,7 +57,11 @@ end function M.disable_format_on_save() pcall(vim.api.nvim_del_augroup_by_name, "format_on_save") if format_on_save then - vim.notify("Disabled format-on-save", vim.log.levels.INFO, { title = "Settings modification success!" }) + vim.notify( + "Successfully disabled format-on-save", + vim.log.levels.INFO, + { title = "Settings modification success" } + ) end end @@ -95,6 +102,14 @@ function M.format(opts) local cwd = vim.fn.getcwd() for i = 1, #disabled_workspaces do if cwd.find(cwd, disabled_workspaces[i]) ~= nil then + vim.notify( + string.format( + "[LSP] Formatting support for all files under [%s] has been disabled.", + disabled_workspaces[i] + ), + vim.log.levels.WARN, + { title = "LSP Formatter Warning" } + ) return end end @@ -122,7 +137,7 @@ function M.format(opts) vim.notify( "[LSP] Format request failed, no matching language servers.", vim.log.levels.WARN, - { title = "Formatting Failed!" } + { title = "Formatting Failed" } ) end @@ -136,7 +151,7 @@ function M.format(opts) vim.bo.filetype ), vim.log.levels.WARN, - { title = "LSP Formatter Warning!" } + { title = "LSP Formatter Warning" } ) return end @@ -145,15 +160,15 @@ function M.format(opts) if result and result.result then vim.lsp.util.apply_text_edits(result.result, bufnr, client.offset_encoding) vim.notify( - string.format("[LSP] Format successfully with [%s]!", client.name), + string.format("[LSP] Format successfully with %s!", client.name), vim.log.levels.INFO, - { title = "LSP Format Success!" } + { title = "LSP Format Success" } ) elseif err then vim.notify( string.format("[LSP][%s] %s", client.name, err), vim.log.levels.ERROR, - { title = "LSP Format Error!" } + { title = "LSP Format Error" } ) end end From 75f4dc858a40fd9ffa27a0c37fc066d385188830 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=86=B7=E9=85=94=E9=96=91=E5=90=9F?= <50296129+Jint-lzxy@users.noreply.github.com> Date: Sat, 22 Apr 2023 23:54:51 +0800 Subject: [PATCH 28/39] chore(formatting): rephrase messages --- lua/modules/configs/completion/formatting.lua | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/lua/modules/configs/completion/formatting.lua b/lua/modules/configs/completion/formatting.lua index f095ac92e..42dfe4c3d 100644 --- a/lua/modules/configs/completion/formatting.lua +++ b/lua/modules/configs/completion/formatting.lua @@ -103,10 +103,7 @@ function M.format(opts) for i = 1, #disabled_workspaces do if cwd.find(cwd, disabled_workspaces[i]) ~= nil then vim.notify( - string.format( - "[LSP] Formatting support for all files under [%s] has been disabled.", - disabled_workspaces[i] - ), + string.format("[LSP] Formatting support for all files under [%s] is disabled.", disabled_workspaces[i]), vim.log.levels.WARN, { title = "LSP Formatter Warning" } ) From e2cfef96a600cad56e46ce0c907d478f4fdb9324 Mon Sep 17 00:00:00 2001 From: Charles Chiu Date: Sun, 23 Apr 2023 23:04:09 +0800 Subject: [PATCH 29/39] fix(font-encoding): fix invalid characters on windows, fix #639 (#659) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: 冷酔閑吟 <50296129+Jint-lzxy@users.noreply.github.com> --- lua/core/init.lua | 29 +++++++++++++++++++++++++++++ lua/core/options.lua | 2 +- 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/lua/core/init.lua b/lua/core/init.lua index f63db01b5..80a6824ee 100644 --- a/lua/core/init.lua +++ b/lua/core/init.lua @@ -115,6 +115,34 @@ local clipboard_config = function() end end +local shell_config = function() + if global.is_windows then + if not (vim.fn.executable("pwsh") or vim.fn.executable("powershell")) then + vim.notify( + [[ +Failed to setup terminal config + +PowerShell is either not installed, missing from PATH, or not executable; +cmd.exe will be used instead for `:!` (shell bang) and toggleterm.nvim. + +You're recommended to install PowerShell for better experience.]], + vim.log.levels.WARN, + { title = "[core] Runtime error" } + ) + return + end + + 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") 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, {}) + end +end + local load_core = function() createdir() disable_distribution_plugins() @@ -122,6 +150,7 @@ local load_core = function() neovide_config() clipboard_config() + shell_config() require("core.options") require("core.mapping") diff --git a/lua/core/options.lua b/lua/core/options.lua index 4b968b155..48648e39f 100644 --- a/lua/core/options.lua +++ b/lua/core/options.lua @@ -125,7 +125,7 @@ local function load_options() -- Fix sqlite3 missing-lib issue on Windows if global.is_windows then -- Download the DLLs form https://www.sqlite.org/download.html - vim.g.sqlite_clib_path = global.home .. "/Documents/sqlite-dll-win64-x64-3400100/sqlite3.dll" + vim.g.sqlite_clib_path = global.home .. "/Documents/sqlite-dll-win64-x64-3400200/sqlite3.dll" end end From f2f3c2c60b9768815fc28f47e53d5562b032065a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=86=B7=E9=85=94=E9=96=91=E5=90=9F?= <50296129+Jint-lzxy@users.noreply.github.com> Date: Sun, 23 Apr 2023 23:05:29 +0800 Subject: [PATCH 30/39] pref: unify code style for PowerShell commands --- lua/core/init.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/core/init.lua b/lua/core/init.lua index 80a6824ee..7411191cf 100644 --- a/lua/core/init.lua +++ b/lua/core/init.lua @@ -133,7 +133,7 @@ You're recommended to install PowerShell for better experience.]], end local basecmd = "-NoLogo -MTA -ExecutionPolicy RemoteSigned" - local ctrlcmd = "-Command [Console]::InputEncoding=[Console]::OutputEncoding=[System.Text.Encoding]::UTF8" + local ctrlcmd = "-Command [console]::InputEncoding = [console]::OutputEncoding = [System.Text.Encoding]::UTF8" vim.api.nvim_set_option_value("shell", vim.fn.executable("pwsh") 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", {}) From 4e56030323b12db70cfee724e194a7122606f78a Mon Sep 17 00:00:00 2001 From: Charles Chiu Date: Tue, 25 Apr 2023 10:37:44 +0800 Subject: [PATCH 31/39] perf: better guidance to `Discussions` and `Wiki` (#680) --- .github/ISSUE_TEMPLATE/bug_report.yml | 5 +++-- .github/ISSUE_TEMPLATE/config.yml | 7 +++++++ .github/ISSUE_TEMPLATE/lsp_issue_report.yml | 5 +++-- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml index 5ba7d5db8..385f0152e 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -1,6 +1,6 @@ name: Bug Report description: File a bug report -labels: [bug] +labels: [ bug ] body: - type: markdown attributes: @@ -59,7 +59,8 @@ 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.7 (Legacy) + - 0.8 (Legacy) + - 0.7 (deprecated) validations: required: true - type: dropdown diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml index 0086358db..df53e0c40 100644 --- a/.github/ISSUE_TEMPLATE/config.yml +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -1 +1,8 @@ blank_issues_enabled: true +contact_links: + - name: GitHub Discussions + url: https://github.com/ayamir/nvimdots/discussions + about: When you have questions that are not bug reports or feature requests + - name: GitHub Wiki + url: https://github.com/ayamir/nvimdots/wiki + about: Make sure you have check our documentation first, to be explicite, the `FAQ`. diff --git a/.github/ISSUE_TEMPLATE/lsp_issue_report.yml b/.github/ISSUE_TEMPLATE/lsp_issue_report.yml index 2b51f27dc..00156d24f 100644 --- a/.github/ISSUE_TEMPLATE/lsp_issue_report.yml +++ b/.github/ISSUE_TEMPLATE/lsp_issue_report.yml @@ -1,6 +1,6 @@ name: LSP Issue description: File a bug report related to LSPs -labels: [bug, lsp] +labels: [ bug, lsp ] body: - type: markdown attributes: @@ -59,7 +59,8 @@ 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.7 (Legacy) + - 0.8 (Legacy) + - 0.7 (Deprecated) validations: required: true - type: dropdown From e679eae9713d8a1aab792324cc77f94a4e2f2912 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=86=B7=E9=85=94=E9=96=91=E5=90=9F?= <50296129+Jint-lzxy@users.noreply.github.com> Date: Tue, 25 Apr 2023 19:32:17 +0800 Subject: [PATCH 32/39] pref(ISSUE_TEMPLATE): fix typos and format with prettier --- .github/ISSUE_TEMPLATE/bug_report.yml | 4 ++-- .github/ISSUE_TEMPLATE/config.yml | 8 ++++---- .github/ISSUE_TEMPLATE/lsp_issue_report.yml | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml index 385f0152e..b3051463a 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -1,6 +1,6 @@ name: Bug Report description: File a bug report -labels: [ bug ] +labels: [bug] body: - type: markdown attributes: @@ -60,7 +60,7 @@ body: options: - main (Default/Latest) - 0.8 (Legacy) - - 0.7 (deprecated) + - 0.7 (Deprecated) validations: required: true - type: dropdown diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml index df53e0c40..75ee6b713 100644 --- a/.github/ISSUE_TEMPLATE/config.yml +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -1,8 +1,8 @@ -blank_issues_enabled: true +blank_issues_enabled: false contact_links: - name: GitHub Discussions - url: https://github.com/ayamir/nvimdots/discussions - about: When you have questions that are not bug reports or feature requests + url: https://github.com/ayamir/nvimdots/discussions/new/choose + about: Any issue that does not fall into the above categories shall go here. - name: GitHub Wiki url: https://github.com/ayamir/nvimdots/wiki - about: Make sure you have check our documentation first, to be explicite, the `FAQ`. + about: Make sure you have checked our documentation first. To be explicit, the "Issues" section. diff --git a/.github/ISSUE_TEMPLATE/lsp_issue_report.yml b/.github/ISSUE_TEMPLATE/lsp_issue_report.yml index 00156d24f..6c7db3d5d 100644 --- a/.github/ISSUE_TEMPLATE/lsp_issue_report.yml +++ b/.github/ISSUE_TEMPLATE/lsp_issue_report.yml @@ -1,6 +1,6 @@ name: LSP Issue description: File a bug report related to LSPs -labels: [ bug, lsp ] +labels: [bug, lsp] body: - type: markdown attributes: From 24c9bef9807d13e6dabdcfac8453408b7498911d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=86=B7=E9=85=94=E9=96=91=E5=90=9F?= <50296129+Jint-lzxy@users.noreply.github.com> Date: Tue, 25 Apr 2023 19:42:07 +0800 Subject: [PATCH 33/39] fixup! pref(ISSUE_TEMPLATE): fix typos and format with prettier --- .github/ISSUE_TEMPLATE/config.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml index 75ee6b713..f091d5377 100644 --- a/.github/ISSUE_TEMPLATE/config.yml +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -1,8 +1,8 @@ -blank_issues_enabled: false +blank_issues_enabled: true contact_links: - name: GitHub Discussions url: https://github.com/ayamir/nvimdots/discussions/new/choose - about: Any issue that does not fall into the above categories shall go here. + about: Any issue that does not fall into the above categories shall go here - name: GitHub Wiki url: https://github.com/ayamir/nvimdots/wiki - about: Make sure you have checked our documentation first. To be explicit, the "Issues" section. + about: Make sure you have checked our documentation first. To be explicit, the "Issues" section From a5c8d330dde138eaaec4a18a64dee9c6b5aaa8a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=86=B7=E9=85=94=E9=96=91=E5=90=9F?= <50296129+Jint-lzxy@users.noreply.github.com> Date: Tue, 25 Apr 2023 20:11:25 +0800 Subject: [PATCH 34/39] feat(scripts): abort for nvim v0.7 and its antecedent --- scripts/install.ps1 | 19 +++++++++++++------ scripts/install.sh | 20 ++++++++++++++------ 2 files changed, 27 insertions(+), 12 deletions(-) diff --git a/scripts/install.ps1 b/scripts/install.ps1 index cd124c346..953849c53 100644 --- a/scripts/install.ps1 +++ b/scripts/install.ps1 @@ -59,6 +59,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)"; } + function warn_ext ([Parameter(Mandatory = $True)][ValidateNotNullOrEmpty()] [string]$Msg) { Write-Host " $(_chomp -Str $Msg)" } @@ -313,7 +314,7 @@ function _main { # Check dependencies if (-not (check_in_path -WithName "nvim")) { _abort -Msg "Required executable not found." -Type "NotInstalled" -Info_msg @' -You must install NeoVim before installing this Nvim config. See: +You must install Neovim before installing this Nvim config. See: https://github.com/neovim/neovim/wiki/Installing-Neovim ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ [INFO] "nvim" is either not installed, missing from PATH, or not executable. @@ -361,8 +362,11 @@ You must install Git before installing this Nvim config. See: safe_execute -WithCmd { git clone --progress -b 0.8 "$env:CCLONE_ATTR" 'git@github.com:ayamir/nvimdots.git' "$env:CCDEST_DIR" } } else { warn -Msg "You have outdated Nvim installed (< $REQUIRED_NVIM_VERSION_LEGACY)." - info -Msg "Automatically redirecting you to the latest compatible version..." - safe_execute -WithCmd { git clone --progress -b 0.7 "$env:CCLONE_ATTR" 'git@github.com:ayamir/nvimdots.git' "$env:CCDEST_DIR" } + _abort -Msg "This Neovim distribution is no longer supported." -Type "NotImplemented" -Info_msg @" +You have a legacy Neovim distribution installed. +Please make sure you have nvim v$REQUIRED_NVIM_VERSION_LEGACY installed at the very least. + +"@ } } else { if ((check_nvim_version -RequiredVersionMin $REQUIRED_NVIM_VERSION)) { @@ -373,8 +377,11 @@ You must install Git before installing this Nvim config. See: safe_execute -WithCmd { git clone --progress -b 0.8 "$env:CCLONE_ATTR" 'https://github.com/ayamir/nvimdots.git' "$env:CCDEST_DIR" } } else { warn -Msg "You have outdated Nvim installed (< $REQUIRED_NVIM_VERSION_LEGACY)." - info -Msg "Automatically redirecting you to the latest compatible version..." - safe_execute -WithCmd { git clone --progress -b 0.7 "$env:CCLONE_ATTR" 'https://github.com/ayamir/nvimdots.git' "$env:CCDEST_DIR" } + _abort -Msg "This Neovim distribution is no longer supported." -Type "NotImplemented" -Info_msg @" +You have a legacy Neovim distribution installed. +Please make sure you have nvim v$REQUIRED_NVIM_VERSION_LEGACY installed at the very least. + +"@ } } @@ -389,7 +396,7 @@ You must install Git before installing this Nvim config. See: } } - info -Msg "Spawning neovim and fetching plugins... (You'll be redirected shortly)" + 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 'If lazy.nvim failed to fetch any plugin(s), maunally execute `:Lazy sync` until everything is up-to-date.' diff --git a/scripts/install.sh b/scripts/install.sh index e06fde2b4..0cedade42 100755 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -204,7 +204,7 @@ fi if ! command -v nvim >/dev/null; then abort "$( cat < Date: Tue, 25 Apr 2023 20:52:48 +0800 Subject: [PATCH 35/39] feat(settings): allow customization of `transparent_background` (#687) --- lua/core/settings.lua | 4 ++++ lua/modules/configs/ui/catppuccin.lua | 4 +--- lua/modules/configs/ui/edge.lua | 2 +- lua/modules/configs/ui/nord.lua | 2 +- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/lua/core/settings.lua b/lua/core/settings.lua index 88fa3392e..a1250fd0e 100644 --- a/lua/core/settings.lua +++ b/lua/core/settings.lua @@ -32,6 +32,10 @@ settings["palette_overwrite"] = {} ---@type string settings["colorscheme"] = "catppuccin" +-- Set it to true if your terminal has transparent background. +---@type boolean +settings["transparent_background"] = false + -- Set background color to use here. -- Useful if you would like to use a colorscheme that has a light and dark variant like `edge`. -- Valid values are: `dark`, `light`. diff --git a/lua/modules/configs/ui/catppuccin.lua b/lua/modules/configs/ui/catppuccin.lua index 3895ca023..6cb07aa21 100644 --- a/lua/modules/configs/ui/catppuccin.lua +++ b/lua/modules/configs/ui/catppuccin.lua @@ -1,6 +1,4 @@ return function() - local transparent_background = false -- Set background transparency here! - require("catppuccin").setup({ flavour = "mocha", -- Can be one of: latte, frappe, macchiato, mocha background = { light = "latte", dark = "mocha" }, @@ -11,7 +9,7 @@ return function() shade = "dark", percentage = 0.15, }, - transparent_background = transparent_background, + transparent_background = require("core.settings").transparent_background, show_end_of_buffer = false, -- show the '~' characters after the end of buffers term_colors = true, compile_path = vim.fn.stdpath("cache") .. "/catppuccin", diff --git a/lua/modules/configs/ui/edge.lua b/lua/modules/configs/ui/edge.lua index 216899a8e..6f63356be 100644 --- a/lua/modules/configs/ui/edge.lua +++ b/lua/modules/configs/ui/edge.lua @@ -4,5 +4,5 @@ return function() vim.g.edge_disable_italic_comment = 1 vim.g.edge_show_eob = 1 vim.g.edge_better_performance = 1 - vim.g.edge_transparent_background = 1 + vim.g.edge_transparent_background = require("core.settings").transparent_background and 2 or 0 end diff --git a/lua/modules/configs/ui/nord.lua b/lua/modules/configs/ui/nord.lua index 522d3f7c0..17f535539 100644 --- a/lua/modules/configs/ui/nord.lua +++ b/lua/modules/configs/ui/nord.lua @@ -2,7 +2,7 @@ return function() vim.g.nord_contrast = true vim.g.nord_borders = false vim.g.nord_cursorline_transparent = true - vim.g.nord_disable_background = false + vim.g.nord_disable_background = require("core.settings").transparent_background vim.g.nord_enable_sidebar_background = true vim.g.nord_italic = true end From 6d55f062ad72862588cbdd1aeb54657fd49d6ce0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=86=B7=E9=85=94=E9=96=91=E5=90=9F?= <50296129+Jint-lzxy@users.noreply.github.com> Date: Wed, 26 Apr 2023 11:28:21 +0800 Subject: [PATCH 36/39] fix(bufferline): use defaults for `get_element_icon` (#685) --- lua/modules/configs/ui/bufferline.lua | 7 ------- 1 file changed, 7 deletions(-) diff --git a/lua/modules/configs/ui/bufferline.lua b/lua/modules/configs/ui/bufferline.lua index 96a7bfc83..e0dd7911c 100644 --- a/lua/modules/configs/ui/bufferline.lua +++ b/lua/modules/configs/ui/bufferline.lua @@ -20,13 +20,6 @@ return function() persist_buffer_sort = true, always_show_bufferline = true, separator_style = "thin", - get_element_icon = function(buf) - return require("nvim-web-devicons").get_icon( - buf.name, - vim.bo.filetype, - { default = true, strict = true } - ) - end, diagnostics = "nvim_lsp", diagnostics_indicator = function(count) return "(" .. count .. ")" From e15ac1cabe972e907940b76a23b7eb2c22361aab Mon Sep 17 00:00:00 2001 From: Saafo <46736350+Saafo@users.noreply.github.com> Date: Wed, 26 Apr 2023 20:39:28 +0800 Subject: [PATCH 37/39] feat(auto-session): remember opened buffers (#688) --- lua/core/options.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/core/options.lua b/lua/core/options.lua index 48648e39f..647a25005 100644 --- a/lua/core/options.lua +++ b/lua/core/options.lua @@ -58,7 +58,7 @@ local function load_options() relativenumber = true, ruler = true, scrolloff = 2, - sessionoptions = "curdir,help,tabpages,winsize", + sessionoptions = "buffers,curdir,help,tabpages,winsize", shada = "!,'300,<50,@100,s10,h", shiftround = true, shiftwidth = 4, From f9ca54962b14d4be3d612229107c0bf44e68dc94 Mon Sep 17 00:00:00 2001 From: ayamir Date: Thu, 27 Apr 2023 10:44:46 +0800 Subject: [PATCH 38/39] revert(keymap): remove redundant mappings. --- lua/core/mapping.lua | 4 ---- 1 file changed, 4 deletions(-) diff --git a/lua/core/mapping.lua b/lua/core/mapping.lua index ca58b0743..2103b0f64 100644 --- a/lua/core/mapping.lua +++ b/lua/core/mapping.lua @@ -28,10 +28,6 @@ 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|+"] = map_cmd(""):with_noremap():with_silent():with_desc("edit: Increment"), - ["n|-"] = map_cmd(""):with_noremap():with_silent():with_desc("edit: Decrement"), - ["n|"] = map_cmd("gg0vG$"):with_noremap():with_silent():with_desc("edit: Select all"), - ["x|"] = map_cmd("gg0vG$"):with_noremap():with_silent():with_desc("edit: Select all"), ["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"), From eccd1d8e78f1786a82660731e4c9be9aec805a97 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=86=B7=E9=85=94=E9=96=91=E5=90=9F?= <50296129+Jint-lzxy@users.noreply.github.com> Date: Sun, 30 Apr 2023 22:22:42 +0800 Subject: [PATCH 39/39] fix(catppuccin): properly detect `g:colors_name` (#695) Ref: upstream breaking change [https://github.com/catppuccin/nvim/commit/7a7a6646769e0c0be5d443cf55c04970f90fd230]