diff --git a/.github/workflows/lint_code.yml b/.github/workflows/lint_code.yml index f5ed67ddc..9e88fa59e 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 _command_panel _flash_esc_or_noh _debugging --max-line-length 150 --no-config + args: . --std luajit --globals vim _toggle_lazygit _buf_vtext _command_panel _flash_esc_or_noh _debugging --max-line-length 150 --no-config diff --git a/README.md b/README.md index 8c0e05eef..894b7bfa0 100644 --- a/README.md +++ b/README.md @@ -44,8 +44,8 @@ Branch info: | Branch | Supported neovim version | | :----: | :----------------------: | -| 0.10 | nvim 0.10 nightly | | main | nvim 0.9 stable | +| 0.10 | nvim 0.10 nightly | | 0.8 | nvim 0.8 | | 0.7 | nvim 0.7 | diff --git a/lua/keymap/helpers.lua b/lua/keymap/helpers.lua index 94dbf54b9..68276e2eb 100644 --- a/lua/keymap/helpers.lua +++ b/lua/keymap/helpers.lua @@ -39,6 +39,7 @@ _G._toggle_lazygit = function() 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() diff --git a/lua/keymap/tool.lua b/lua/keymap/tool.lua index d95d8c63e..9ec29a30d 100644 --- a/lua/keymap/tool.lua +++ b/lua/keymap/tool.lua @@ -133,7 +133,7 @@ local plug_map = { ["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() }) -- luacheck: ignore + require("telescope.builtin").grep_string({ search = _buf_vtext() }) end) :with_noremap() :with_silent() diff --git a/lua/modules/configs/tool/dap/clients/python.lua b/lua/modules/configs/tool/dap/clients/python.lua index 86c8e1541..3ff35e501 100644 --- a/lua/modules/configs/tool/dap/clients/python.lua +++ b/lua/modules/configs/tool/dap/clients/python.lua @@ -2,15 +2,9 @@ -- https://github.com/microsoft/debugpy/wiki/Debug-configuration-settings return function() local dap = require("dap") - local is_windows = require("core.global").is_windows - local data_dir = require("core.global").data_dir - local python = is_windows and data_dir .. "../mason/packages/debugpy/venv/Scripts/pythonw.exe" - or data_dir .. "../mason/packages/debugpy/venv/bin/python" local utils = require("modules.utils.dap") - - local function is_empty(s) - return s == nil or s == "" - end + local is_windows = require("core.global").is_windows + local debugpy_root = require("mason-registry").get_package("debugpy"):get_install_path() dap.adapters.python = function(callback, config) if config.request == "attach" then @@ -25,7 +19,8 @@ return function() else callback({ type = "executable", - command = python, + command = is_windows and debugpy_root .. "/venv/Scripts/pythonw.exe" + or debugpy_root .. "/venv/bin/python", args = { "-m", "debugpy.adapter" }, options = { source_filetype = "python" }, }) @@ -41,9 +36,9 @@ return function() console = "integratedTerminal", program = utils.input_file_path(), pythonPath = function() - if not is_empty(vim.env.CONDA_PREFIX) then - return is_windows and vim.env.CONDA_PREFIX .. "/Scripts/pythonw.exe" - or vim.env.CONDA_PREFIX .. "/bin/python" + local venv = vim.env.CONDA_PREFIX + if venv then + return is_windows and venv .. "/Scripts/pythonw.exe" or venv .. "/bin/python" else return is_windows and "pythonw.exe" or "python3" end @@ -58,25 +53,18 @@ return function() console = "integratedTerminal", program = utils.input_file_path(), pythonPath = function() + -- Prefer the venv that is defined by the designated environment variable. local cwd, venv = vim.fn.getcwd(), os.getenv("VIRTUAL_ENV") - if - venv - and ( - vim.fn.executable(venv .. "/bin/python") == 1 - or vim.fn.executable(venv .. "/Scripts/pythonw.exe") == 1 - ) - then - return is_windows and venv .. "/Scripts/pythonw.exe" or venv .. "/bin/python" - elseif - (vim.fn.executable(cwd .. "/venv/bin/python") == 1) - or (vim.fn.executable(cwd .. "/venv/Scripts/pythonw.exe") == 1) - then - return is_windows and cwd .. "/venv/Scripts/pythonw.exe" or cwd .. "/venv/bin/python" - elseif - (vim.fn.executable(cwd .. "/.venv/bin/python") == 1) - or (vim.fn.executable(cwd .. "/.venv/Scripts/pythonw.exe") == 1) - then - return is_windows and cwd .. "/.venv/Scripts/pythonw.exe" or cwd .. "/.venv/bin/python" + local python = venv and (is_windows and venv .. "/Scripts/pythonw.exe" or venv .. "/bin/python") or "" + if vim.fn.executable(python) == 1 then + return python + end + + -- Otherwise, fall back to check if there are any local venvs available. + venv = vim.fn.isdirectory(cwd .. "/venv") == 1 and cwd .. "/venv" or cwd .. "/.venv" + python = is_windows and venv .. "/Scripts/pythonw.exe" or venv .. "/bin/python" + if vim.fn.executable(python) == 1 then + return python else return is_windows and "pythonw.exe" or "python3" end diff --git a/lua/modules/configs/tool/telescope.lua b/lua/modules/configs/tool/telescope.lua index 79aa263b1..d8fdddd44 100644 --- a/lua/modules/configs/tool/telescope.lua +++ b/lua/modules/configs/tool/telescope.lua @@ -58,7 +58,6 @@ return function() case_mode = "smart_case", }, frecency = { - use_sqlite = false, show_scores = true, show_unindexed = true, ignore_patterns = { "*.git/*", "*/tmp/*" }, diff --git a/scripts/install.ps1 b/scripts/install.ps1 index d5f275683..4d725c6e4 100644 --- a/scripts/install.ps1 +++ b/scripts/install.ps1 @@ -8,7 +8,6 @@ Set-StrictMode -Version 3.0 $ErrorActionPreference = "Stop" # Exit when command fails # global-scope vars -$REQUIRED_NVIM_VERSION_NIGHTLY = [version]'0.10' $REQUIRED_NVIM_VERSION = [version]'0.9.0' $REQUIRED_NVIM_VERSION_LEGACY = [version]'0.8.0' $USE_SSH = $True @@ -21,7 +20,6 @@ $installer_pkg_matrix = @{ "NodeJS" = "npm"; "Python" = "pip"; "Ruby" = "gem" } # env vars $env:XDG_CONFIG_HOME ??= $env:LOCALAPPDATA $env:CCPACK_MGR ??= 'unknown' -$env:CCLONE_BRANCH_NIGHTLY ??= '0.10' $env:CCLONE_BRANCH ??= 'main' $env:CCLONE_BRANCH_LEGACY ??= '0.8' $env:CCLONE_ATTR ??= 'undef' @@ -285,15 +283,13 @@ function check_nvim_version ([Parameter(Mandatory = $True)][ValidateNotNullOrEmp return ($nvim_version -ge $RequiredVersionMin) } -function clone_by_https_or_ssh ([Parameter(Mandatory = $True)][ValidateNotNullOrEmpty()] [string]$CloneUrl) { - if ((check_nvim_version -RequiredVersionMin $REQUIRED_NVIM_VERSION_NIGHTLY)) { - safe_execute -WithCmd { git clone --progress -b "$env:CCLONE_BRANCH_NIGHTLY" "$env:CCLONE_ATTR" $CloneUrl "$env:CCDEST_DIR" } - } elseif ((check_nvim_version -RequiredVersionMin $REQUIRED_NVIM_VERSION)) { - safe_execute -WithCmd { git clone --progress -b "$env:CCLONE_BRANCH" "$env:CCLONE_ATTR" $CloneUrl "$env:CCDEST_DIR" } +function clone_repo ([Parameter(Mandatory = $True)][ValidateNotNullOrEmpty()] [string]$WithURL) { + if ((check_nvim_version -RequiredVersionMin $REQUIRED_NVIM_VERSION)) { + safe_execute -WithCmd { git clone --progress -b "$env:CCLONE_BRANCH" "$env:CCLONE_ATTR" $WithURL "$env:CCDEST_DIR" } } 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 the latest compatible version..." - safe_execute -WithCmd { git clone --progress -b "$env:CCLONE_BRANCH_LEGACY" "$env:CCLONE_ATTR" $CloneUrl "$env:CCDEST_DIR" } + 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 @" @@ -375,9 +371,9 @@ You must install Git before installing this Nvim config. See: info -Msg "Fetching in progress..." if ($USE_SSH) { - clone_by_https_or_ssh 'git@github.com:ayamir/nvimdots.git' + clone_repo -WithURL 'git@github.com:ayamir/nvimdots.git' } else { - clone_by_https_or_ssh 'https://github.com/ayamir/nvimdots.git' + clone_repo -WithURL 'https://github.com/ayamir/nvimdots.git' } safe_execute -WithCmd { Set-Location -Path "$env:CCDEST_DIR" } diff --git a/scripts/install.sh b/scripts/install.sh index 3a6f3304e..6796f1a0f 100755 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -10,7 +10,6 @@ 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_NIGHTLY=0.10 REQUIRED_NVIM_VERSION=0.9.0 REQUIRED_NVIM_VERSION_LEGACY=0.8.0 USE_SSH=1 @@ -170,10 +169,8 @@ check_nvim_version() { fi } -clone_by_https_or_ssh() { - if check_nvim_version "${REQUIRED_NVIM_VERSION_NIGHTLY}"; then - execute "git" "clone" "-b" "0.10" "${CLONE_ATTR[@]}" "$1" "${DEST_DIR}" - elif check_nvim_version "${REQUIRED_NVIM_VERSION}"; then +clone_repo() { + if check_nvim_version "${REQUIRED_NVIM_VERSION}"; then execute "git" "clone" "-b" "main" "${CLONE_ATTR[@]}" "$1" "${DEST_DIR}" elif check_nvim_version "${REQUIRED_NVIM_VERSION_LEGACY}"; then warn "You have outdated Nvim installed (< ${REQUIRED_NVIM_VERSION})." @@ -273,9 +270,9 @@ fi info "Fetching in progress..." if [[ "${USE_SSH}" -eq "1" ]]; then - clone_by_https_or_ssh "git@github.com:ayamir/nvimdots.git" + clone_repo "git@github.com:ayamir/nvimdots.git" else - clone_by_https_or_ssh "https://github.com/ayamir/nvimdots.git" + clone_repo "https://github.com/ayamir/nvimdots.git" fi cd "${DEST_DIR}" || return diff --git a/tutor/dots.tutor b/tutor/dots.tutor index 80fb5a860..7def1078d 100644 --- a/tutor/dots.tutor +++ b/tutor/dots.tutor @@ -1,43 +1,47 @@ -# Welcome to the nvimdots tutor +# Welcome to the nvimdots Tutor -Nvimdots is a neovim config suite that is designed for extensibility, -performance, and ease of use. It provides the ability to work with textfile, -yet feels like you are working within an IDE environment. -This tutor will walk through how one can utilize this configuration suite to -use Neovim as a powerful code editor. +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. -As a modern neovim config, it provides all of the features you need, code -completion, snippet run, tree-sitter, DAP, fuzzy find, and more. It comes -with state-of-the-art (SOTA) neovim plugins from the community to provide the -best user experience. +This tutor will walk you through how to utilize our configuration to use neovim as a +powerful code editor. + +As a modern neovim config, it provides all the features you need: code completion, +(partial) code testing, tree-sitter, DAP, fuzzy find, and more. It comes with state- +of-the-art (SOTA) neovim plugins from the community to provide the best user +experience. The default []() key is ``{normal}. -The approximate time required to complete the tutor is 5 minutes, depending -upon how much time is spent with experimentation. +The approximate time required to complete the tutorial is 5 minutes, although the +exact duration may vary depending on the amount of time spent experimenting. -# Lesson 1.1: EXPLANATION OF UI +# Lesson 1.1: EXPLANATION OF THE UI -The opened buffers are showed at the top, you can use ``{normal} and ``{normal} to -switch between them. Also, ``{normal}(n meaning No) can be used to switch to the -target buffer directly. +The opened buffers are shown at the top; you can use ``{normal} and ``{normal} to switch +between them. Also, ``{normal} (with `n`{normal} being any number between 1-9) can be used to +switch to the desired buffer directly. -Note: For macOS, you need to remap your `