mirror of
https://github.com/neovim/neovim.git
synced 2026-03-31 04:42:03 +00:00
feat(defaults): exclude temp dirs from 'shada' oldfiles #37631
Problem: Temporary files from /tmp/ and /private/ paths clutter :oldfiles list. Additionally, the documented Windows default (rA:,rB:) was never applied due to a missing platform condition. Solution: Drop platform-specific shada differences and default to excluding /tmp/ and /private/ paths.
This commit is contained in:
@@ -187,6 +187,7 @@ DEFAULTS
|
||||
Unset 'exrc' to stop further search.
|
||||
• Mappings:
|
||||
• |grt| in Normal mode maps to |vim.lsp.buf.type_definition()|
|
||||
• 'shada' default now excludes "/tmp/" and "/private/" paths to reduce clutter in |:oldfiles|.
|
||||
|
||||
DIAGNOSTICS
|
||||
|
||||
|
||||
@@ -5356,9 +5356,7 @@ A jump table for the options with a short description can be found at |Q_op|.
|
||||
the session.
|
||||
|
||||
*'shada'* *'sd'* *E526* *E527* *E528*
|
||||
'shada' 'sd' string (default for
|
||||
Win32: !,'100,<50,s10,h,rA:,rB:
|
||||
others: !,'100,<50,s10,h)
|
||||
'shada' 'sd' string (default "!,'100,<50,s10,h,r/tmp/,r/private/")
|
||||
global
|
||||
When non-empty, the shada file is read upon startup and written
|
||||
when exiting Vim (see |shada-file|). The string should be a comma-
|
||||
|
||||
2
runtime/lua/vim/_meta/options.lua
generated
2
runtime/lua/vim/_meta/options.lua
generated
@@ -5756,7 +5756,7 @@ vim.go.ssop = vim.go.sessionoptions
|
||||
--- security reasons.
|
||||
---
|
||||
--- @type string
|
||||
vim.o.shada = "!,'100,<50,s10,h"
|
||||
vim.o.shada = "!,'100,<50,s10,h,r/tmp/,r/private/"
|
||||
vim.o.sd = vim.o.shada
|
||||
vim.go.shada = vim.o.shada
|
||||
vim.go.sd = vim.go.shada
|
||||
|
||||
@@ -7447,12 +7447,7 @@ local options = {
|
||||
abbreviation = 'sd',
|
||||
alias = { 'vi', 'viminfo' },
|
||||
cb = 'did_set_shada',
|
||||
defaults = {
|
||||
if_true = "!,'100,<50,s10,h",
|
||||
doc = [[for
|
||||
Win32: !,'100,<50,s10,h,rA:,rB:
|
||||
others: !,'100,<50,s10,h]],
|
||||
},
|
||||
defaults = "!,'100,<50,s10,h,r/tmp/,r/private/",
|
||||
deny_duplicates = true,
|
||||
desc = [=[
|
||||
When non-empty, the shada file is read upon startup and written
|
||||
|
||||
@@ -18,7 +18,7 @@ local function _clear()
|
||||
'-i',
|
||||
shada_file, -- Need shada for these tests.
|
||||
'--cmd',
|
||||
'set noswapfile undodir=. directory=. viewdir=. backupdir=. belloff= noshowcmd noruler',
|
||||
"set noswapfile undodir=. directory=. viewdir=. backupdir=. belloff= noshowcmd noruler shada=!,'100,<50,s10,h",
|
||||
},
|
||||
args_rm = { '-i', '--cmd' },
|
||||
}
|
||||
|
||||
@@ -195,7 +195,7 @@ describe('startup defaults', function()
|
||||
os.remove('Xtest-foo')
|
||||
end)
|
||||
|
||||
clear { args = {}, args_rm = { '-i' }, env = env }
|
||||
clear { args = {}, args_rm = { '-i', '--cmd' }, env = env }
|
||||
-- Default 'shadafile' is empty.
|
||||
-- This means use the default location. :help shada-file-name
|
||||
eq('', api.nvim_get_option_value('shadafile', {}))
|
||||
@@ -203,16 +203,18 @@ describe('startup defaults', function()
|
||||
-- Handles viminfo/viminfofile as alias for shada/shadafile.
|
||||
eq('\n shadafile=', eval('execute("set shadafile?")'))
|
||||
eq('\n shadafile=', eval('execute("set viminfofile?")'))
|
||||
eq("\n shada=!,'100,<50,s10,h", eval('execute("set shada?")'))
|
||||
eq("\n shada=!,'100,<50,s10,h", eval('execute("set viminfo?")'))
|
||||
eq("\n shada=!,'100,<50,s10,h,r/tmp/,r/private/", eval('execute("set shada?")'))
|
||||
eq("\n shada=!,'100,<50,s10,h,r/tmp/,r/private/", eval('execute("set viminfo?")'))
|
||||
|
||||
-- Remove /tmp/ exclusion so test works when run in temp directories.
|
||||
command("set shada=!,'100,<50,s10,h")
|
||||
-- Check that shada data (such as v:oldfiles) is saved/restored.
|
||||
command('edit Xtest-foo')
|
||||
command('write')
|
||||
local f = eval('fnamemodify(@%,":p")')
|
||||
assert(string.len(f) > 3)
|
||||
expect_exit(command, 'qall')
|
||||
clear { args = {}, args_rm = { '-i' }, env = env }
|
||||
clear { args = {}, args_rm = { '-i', '--cmd' }, env = env }
|
||||
eq({ f }, eval('v:oldfiles'))
|
||||
end)
|
||||
|
||||
|
||||
@@ -241,8 +241,8 @@ describe('ShaDa support code', function()
|
||||
eq("'10", api.nvim_get_option_value('viminfo', {}))
|
||||
eq("'10", api.nvim_get_option_value('shada', {}))
|
||||
nvim_command('set all&')
|
||||
eq("!,'100,<50,s10,h", api.nvim_get_option_value('viminfo', {}))
|
||||
eq("!,'100,<50,s10,h", api.nvim_get_option_value('shada', {}))
|
||||
eq("!,'100,<50,s10,h,r/tmp/,r/private/", api.nvim_get_option_value('viminfo', {}))
|
||||
eq("!,'100,<50,s10,h,r/tmp/,r/private/", api.nvim_get_option_value('shada', {}))
|
||||
end)
|
||||
|
||||
it('is able to set &shada after &viminfo using :set', function()
|
||||
|
||||
@@ -26,7 +26,7 @@ M.nvim_prog = (os.getenv('NVIM_PRG') or t.paths.test_build_dir .. '/bin/nvim')
|
||||
M.nvim_set = (
|
||||
'set shortmess+=IS background=light noswapfile noautoindent startofline'
|
||||
.. ' laststatus=1 undodir=. directory=. viewdir=. backupdir=.'
|
||||
.. ' belloff= wildoptions-=pum joinspaces noshowcmd noruler nomore redrawdebug=invalid'
|
||||
.. " belloff= wildoptions-=pum joinspaces noshowcmd noruler nomore redrawdebug=invalid shada=!,'100,<50,s10,h"
|
||||
.. [[ statusline=%<%f\ %{%nvim_eval_statusline('%h%w%m%r',\ {'maxwidth':\ 30}).width\ >\ 0\ ?\ '%h%w%m%r\ '\ :\ ''%}%=%{%\ &showcmdloc\ ==\ 'statusline'\ ?\ '%-10.S\ '\ :\ ''\ %}%{%\ exists('b:keymap_name')\ ?\ '<'..b:keymap_name..'>\ '\ :\ ''\ %}%{%\ &ruler\ ?\ (\ &rulerformat\ ==\ ''\ ?\ '%-14.(%l,%c%V%)\ %P'\ :\ &rulerformat\ )\ :\ ''\ %}]]
|
||||
)
|
||||
M.nvim_argv = {
|
||||
|
||||
Reference in New Issue
Block a user