fix(pack): consistently use "revision" instead of "state"

Problem: In some areas plugin's revision is named "state". This might be
  confusing for the users.

Solution: Consistently use "revision" to indicate "plugin's state on
  disk".
This commit is contained in:
Evgeni Chasnovski
2025-11-06 19:53:01 +02:00
parent f3f5095630
commit ee3239fcb6
5 changed files with 36 additions and 36 deletions

View File

@@ -273,7 +273,7 @@ Basic install and management:
Switch plugin's version: Switch plugin's version:
• Update 'init.lua' for plugin to have desired `version`. Let's say, plugin • Update 'init.lua' for plugin to have desired `version`. Let's say, plugin
named 'plugin1' has changed to `vim.version.range('*')`. named 'plugin1' has changed to `vim.version.range('*')`.
• |:restart|. The plugin's actual state on disk is not yet changed. Only • |:restart|. The plugin's actual revision on disk is not yet changed. Only
plugin's `version` in |vim.pack-lockfile| is updated. plugin's `version` in |vim.pack-lockfile| is updated.
• Execute `vim.pack.update({ 'plugin1' })`. • Execute `vim.pack.update({ 'plugin1' })`.
• Review changes and either confirm or discard them. If discarded, revert any • Review changes and either confirm or discard them. If discarded, revert any
@@ -356,7 +356,7 @@ add({specs}, {opts}) *vim.pack.add()*
|vim.pack-directory|: |vim.pack-directory|:
• If exists, do nothing in this step. • If exists, do nothing in this step.
• If doesn't exist, install it by downloading from `src` into `name` • If doesn't exist, install it by downloading from `src` into `name`
subdirectory (via `git clone`) and update state to match `version` subdirectory (via `git clone`) and update revision to follow `version`
(via `git checkout`). (via `git checkout`).
• For each plugin execute |:packadd| (or customizable `load` function) • For each plugin execute |:packadd| (or customizable `load` function)
making it reachable by Nvim. making it reachable by Nvim.
@@ -365,7 +365,7 @@ add({specs}, {opts}) *vim.pack.add()*
• Installation is done in parallel, but waits for all to finish before • Installation is done in parallel, but waits for all to finish before
continuing next code execution. continuing next code execution.
• If plugin is already present on disk, there are no checks about its • If plugin is already present on disk, there are no checks about its
present state. The specified `version` can be not the one actually current revision. The specified `version` can be not the one actually
present on disk. Execute |vim.pack.update()| to synchronize. present on disk. Execute |vim.pack.update()| to synchronize.
• Adding plugin second and more times during single session does nothing: • Adding plugin second and more times during single session does nothing:
only the data from the first adding is registered. only the data from the first adding is registered.
@@ -416,7 +416,7 @@ get({names}, {opts}) *vim.pack.get()*
update({names}, {opts}) *vim.pack.update()* update({names}, {opts}) *vim.pack.update()*
Update plugins Update plugins
• Download new changes from source. • Download new changes from source.
• Infer update info (current/target state, changelog, etc.). • Infer update info (current/target revisions, changelog, etc.).
• Depending on `force`: • Depending on `force`:
• If `false`, show confirmation buffer. It lists data about all set to • If `false`, show confirmation buffer. It lists data about all set to
update plugins. Pending changes starting with `>` will be applied update plugins. Pending changes starting with `>` will be applied

View File

@@ -18,7 +18,7 @@ local cur_header_hl_group = nil
local lines = vim.api.nvim_buf_get_lines(0, 0, -1, false) local lines = vim.api.nvim_buf_get_lines(0, 0, -1, false)
for i, l in ipairs(lines) do for i, l in ipairs(lines) do
local cur_group = l:match('^# (%S+)') local cur_group = l:match('^# (%S+)')
local cur_info = l:match('^Path: +') or l:match('^Source: +') or l:match('^State[^:]*: +') local cur_info = l:match('^Path: +') or l:match('^Source: +') or l:match('^Revision[^:]*: +')
if cur_group ~= nil then if cur_group ~= nil then
--- @cast cur_group string --- @cast cur_group string
-- Header 1 -- Header 1
@@ -32,7 +32,7 @@ for i, l in ipairs(lines) do
local end_col = l:match('(). +%b()$') or l:len() local end_col = l:match('(). +%b()$') or l:len()
hi_range(i, cur_info:len(), end_col, 'DiagnosticInfo') hi_range(i, cur_info:len(), end_col, 'DiagnosticInfo')
-- Plugin state after update -- Plugin version after update
local col = l:match('() %b()$') local col = l:match('() %b()$')
if col then if col then
hi_range(i, col, l:len(), 'DiagnosticHint') hi_range(i, col, l:len(), 'DiagnosticHint')

View File

@@ -70,7 +70,7 @@
---Switch plugin's version: ---Switch plugin's version:
---- Update 'init.lua' for plugin to have desired `version`. Let's say, plugin ---- Update 'init.lua' for plugin to have desired `version`. Let's say, plugin
---named 'plugin1' has changed to `vim.version.range('*')`. ---named 'plugin1' has changed to `vim.version.range('*')`.
---- |:restart|. The plugin's actual state on disk is not yet changed. ---- |:restart|. The plugin's actual revision on disk is not yet changed.
--- Only plugin's `version` in |vim.pack-lockfile| is updated. --- Only plugin's `version` in |vim.pack-lockfile| is updated.
---- Execute `vim.pack.update({ 'plugin1' })`. ---- Execute `vim.pack.update({ 'plugin1' })`.
---- Review changes and either confirm or discard them. If discarded, revert ---- Review changes and either confirm or discard them. If discarded, revert
@@ -602,7 +602,7 @@ end
--- @async --- @async
--- @param p vim.pack.Plug --- @param p vim.pack.Plug
local function infer_states(p) local function infer_revisions(p)
p.info.sha_head = p.info.sha_head or git_get_hash('HEAD', p.path) p.info.sha_head = p.info.sha_head or git_get_hash('HEAD', p.path)
resolve_version(p) resolve_version(p)
@@ -616,7 +616,7 @@ end
--- @param p vim.pack.Plug --- @param p vim.pack.Plug
--- @param timestamp string --- @param timestamp string
local function checkout(p, timestamp) local function checkout(p, timestamp)
infer_states(p) infer_revisions(p)
local msg = ('vim.pack: %s Stash before checkout'):format(timestamp) local msg = ('vim.pack: %s Stash before checkout'):format(timestamp)
git_cmd({ 'stash', '--quiet', '--message', msg }, p.path) git_cmd({ 'stash', '--quiet', '--message', msg }, p.path)
@@ -668,7 +668,7 @@ end
--- @param p vim.pack.Plug --- @param p vim.pack.Plug
local function infer_update_details(p) local function infer_update_details(p)
p.info.update_details = '' p.info.update_details = ''
infer_states(p) infer_revisions(p)
local sha_head = assert(p.info.sha_head) local sha_head = assert(p.info.sha_head)
local sha_target = assert(p.info.sha_target) local sha_target = assert(p.info.sha_target)
@@ -756,14 +756,14 @@ end
--- - For each specification check that plugin exists on disk in |vim.pack-directory|: --- - For each specification check that plugin exists on disk in |vim.pack-directory|:
--- - If exists, do nothing in this step. --- - If exists, do nothing in this step.
--- - If doesn't exist, install it by downloading from `src` into `name` --- - If doesn't exist, install it by downloading from `src` into `name`
--- subdirectory (via `git clone`) and update state to match `version` (via `git checkout`). --- subdirectory (via `git clone`) and update revision to follow `version` (via `git checkout`).
--- - For each plugin execute |:packadd| (or customizable `load` function) making --- - For each plugin execute |:packadd| (or customizable `load` function) making
--- it reachable by Nvim. --- it reachable by Nvim.
--- ---
--- Notes: --- Notes:
--- - Installation is done in parallel, but waits for all to finish before --- - Installation is done in parallel, but waits for all to finish before
--- continuing next code execution. --- continuing next code execution.
--- - If plugin is already present on disk, there are no checks about its present state. --- - If plugin is already present on disk, there are no checks about its current revision.
--- The specified `version` can be not the one actually present on disk. --- The specified `version` can be not the one actually present on disk.
--- Execute |vim.pack.update()| to synchronize. --- Execute |vim.pack.update()| to synchronize.
--- - Adding plugin second and more times during single session does nothing: --- - Adding plugin second and more times during single session does nothing:
@@ -850,9 +850,9 @@ local function compute_feedback_lines_single(p)
if p.info.sha_head == p.info.sha_target then if p.info.sha_head == p.info.sha_target then
parts[#parts + 1] = table.concat({ parts[#parts + 1] = table.concat({
'Path: ' .. p.path, 'Path: ' .. p.path,
'Source: ' .. p.spec.src, 'Source: ' .. p.spec.src,
'State: ' .. p.info.sha_target .. version_suffix, 'Revision: ' .. p.info.sha_target .. version_suffix,
}, '\n') }, '\n')
if p.info.update_details ~= '' then if p.info.update_details ~= '' then
@@ -861,10 +861,10 @@ local function compute_feedback_lines_single(p)
end end
else else
parts[#parts + 1] = table.concat({ parts[#parts + 1] = table.concat({
'Path: ' .. p.path, 'Path: ' .. p.path,
'Source: ' .. p.spec.src, 'Source: ' .. p.spec.src,
'State before: ' .. p.info.sha_head, 'Revision before: ' .. p.info.sha_head,
'State after: ' .. p.info.sha_target .. version_suffix, 'Revision after: ' .. p.info.sha_target .. version_suffix,
'', '',
'Pending updates:', 'Pending updates:',
p.info.update_details, p.info.update_details,
@@ -996,7 +996,7 @@ end
--- Update plugins --- Update plugins
--- ---
--- - Download new changes from source. --- - Download new changes from source.
--- - Infer update info (current/target state, changelog, etc.). --- - Infer update info (current/target revisions, changelog, etc.).
--- - Depending on `force`: --- - Depending on `force`:
--- - If `false`, show confirmation buffer. It lists data about all set to --- - If `false`, show confirmation buffer. It lists data about all set to
--- update plugins. Pending changes starting with `>` will be applied while --- update plugins. Pending changes starting with `>` will be applied while

View File

@@ -194,7 +194,7 @@ methods['textDocument/hover'] = function(params, callback)
local lines = vim.api.nvim_buf_get_lines(bufnr, 0, -1, false) local lines = vim.api.nvim_buf_get_lines(bufnr, 0, -1, false)
local lnum = params.position.line + 1 local lnum = params.position.line + 1
local commit = lines[lnum]:match('^[<>] (%x+) │') or lines[lnum]:match('^State.*:%s+(%x+)') local commit = lines[lnum]:match('^[<>] (%x+) │') or lines[lnum]:match('^Revision.*:%s+(%x+)')
local tag = lines[lnum]:match('^• (.+)$') local tag = lines[lnum]:match('^• (.+)$')
if commit == nil and tag == nil then if commit == nil and tag == nil then
return return

View File

@@ -1055,10 +1055,10 @@ describe('vim.pack', function()
'{101:# Update ───────────────────────────────────────────────────────────────────────} |', '{101:# Update ───────────────────────────────────────────────────────────────────────} |',
' |', ' |',
'{101:## fetch} |', '{101:## fetch} |',
'Path: {103:FETCH_PATH} |', 'Path: {103:FETCH_PATH} |',
'Source: {103:FETCH_SRC} |', 'Source: {103:FETCH_SRC} |',
('State before: {103:%s} |'):format(hashes.fetch_head), ('Revision before: {103:%s} |'):format(hashes.fetch_head),
('State after: {103:%s} {102:(main)} |'):format(hashes.fetch_new), ('Revision after: {103:%s} {102:(main)} |'):format(hashes.fetch_new),
' |', ' |',
'Pending updates: |', 'Pending updates: |',
('{19:< %s │ Commit from `main` to be removed} |'):format( ('{19:< %s │ Commit from `main` to be removed} |'):format(
@@ -1074,9 +1074,9 @@ describe('vim.pack', function()
'{102:# Same ─────────────────────────────────────────────────────────────────────────} |', '{102:# Same ─────────────────────────────────────────────────────────────────────────} |',
' |', ' |',
'{102:## semver} |', '{102:## semver} |',
'Path: {103:SEMVER_PATH} |', 'Path: {103:SEMVER_PATH} |',
'Source: {103:SEMVER_SRC} |', 'Source: {103:SEMVER_SRC} |',
('State: {103:%s} {102:(v0.3.0)} |'):format( ('Revision: {103:%s} {102:(v0.3.0)} |'):format(
hashes.semver_head hashes.semver_head
), ),
' |', ' |',
@@ -1119,10 +1119,10 @@ describe('vim.pack', function()
# Update ─────────────────────────────────────────────────────────────────────── # Update ───────────────────────────────────────────────────────────────────────
## fetch ## fetch
Path: %s Path: %s
Source: %s Source: %s
State before: %s Revision before: %s
State after: %s (main) Revision after: %s (main)
Pending updates: Pending updates:
< %s │ Commit from `main` to be removed < %s │ Commit from `main` to be removed
@@ -1470,10 +1470,10 @@ describe('vim.pack', function()
# Update ─────────────────────────────────────────────────────────────────────── # Update ───────────────────────────────────────────────────────────────────────
## fetch ## fetch
Path: %s Path: %s
Source: %s Source: %s
State before: %s Revision before: %s
State after: %s (main) Revision after: %s (main)
Pending updates: Pending updates:
< %s │ Commit from `main` to be removed < %s │ Commit from `main` to be removed