[nvim] Iterate through the entries in each vim.opt table and create directories that should exist
This commit is contained in:
		
							parent
							
								
									6f6129f071
								
							
						
					
					
						commit
						4a0fa054d8
					
				
					 1 changed files with 7 additions and 8 deletions
				
			
		| 
						 | 
					@ -12,7 +12,7 @@ require 'colors'
 | 
				
			||||||
require 'keys'
 | 
					require 'keys'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function ensureMetadataDirectoriesExist()
 | 
					function ensureMetadataDirectoriesExist()
 | 
				
			||||||
    local options = {
 | 
					    local paths = {
 | 
				
			||||||
        vim.opt.backupdir:get(),
 | 
					        vim.opt.backupdir:get(),
 | 
				
			||||||
        vim.opt.directory:get(),
 | 
					        vim.opt.directory:get(),
 | 
				
			||||||
        vim.opt.undodir:get(),
 | 
					        vim.opt.undodir:get(),
 | 
				
			||||||
| 
						 | 
					@ -22,9 +22,9 @@ function ensureMetadataDirectoriesExist()
 | 
				
			||||||
        os.execute("mkdir", "-p", path)
 | 
					        os.execute("mkdir", "-p", path)
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    for _, opt in ipairs(options) do
 | 
					    for _, opt in ipairs(paths) do
 | 
				
			||||||
        for _, path in ipairs(opt) do
 | 
					        for _, value in ipairs(opt) do
 | 
				
			||||||
            if string.find(path, "//$") then
 | 
					            if string.find(value, "//$") then
 | 
				
			||||||
                makeDirectory(path)
 | 
					                makeDirectory(path)
 | 
				
			||||||
            end
 | 
					            end
 | 
				
			||||||
        end
 | 
					        end
 | 
				
			||||||
| 
						 | 
					@ -32,10 +32,9 @@ function ensureMetadataDirectoriesExist()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    -- The shadafile option is a single option but get() returns a table, so
 | 
					    -- The shadafile option is a single option but get() returns a table, so
 | 
				
			||||||
    -- iterate it just to be safe.
 | 
					    -- iterate it just to be safe.
 | 
				
			||||||
    local shadaFile = vim.opt.shadafile:get()
 | 
					    for _, opt in ipairs(vim.opt.shadafile:get()) do
 | 
				
			||||||
    for _, path in ipairs(shadaFile) do
 | 
					        local shadaDirectory = vim.fs.dirname(opt)
 | 
				
			||||||
        local shadaFileDirectory = vim.fs.dirname(path)
 | 
					        makeDirectory(shadaDirectory)
 | 
				
			||||||
        makeDirectory(shadaFileDirectory)
 | 
					 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue