Explorar el Código

Changed all stdpaths to point to nvim config directory

Aleksei Dorokhov hace 2 meses
padre
commit
dcf85fc2bb
Se han modificado 2 ficheros con 27 adiciones y 0 borrados
  1. 3 0
      .gitignore
  2. 24 0
      init.lua

+ 3 - 0
.gitignore

@@ -1,3 +1,6 @@
 lazy-lock.json
 .netrwhist
+cache
+data
+state
 

+ 24 - 0
init.lua

@@ -2,6 +2,30 @@
 vim.g.loaded_netrw = 1
 vim.g.loaded_netrwPlugin = 1
 
+-- override stdpath locations, so that config is fully hermetic
+local orig_stdpath = vim.fn.stdpath
+vim.fn.stdpath = function(value)
+    local config_path = orig_stdpath("config")
+
+    if value == "config" then
+      return config_path
+    end
+
+    if value == "data" then
+        return config_path .. "/data"
+    end
+
+    if value == "cache" then
+      return config_path .. "/cache"
+    end
+
+    if value == "state" then
+      return config_path .. "/state"
+    end
+
+    return orig_stdpath(value)
+end
+
 -- package manager
 local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
 if not (vim.uv or vim.loop).fs_stat(lazypath) then