mirror of
https://github.com/LunarVim/LunarVim.git
synced 2025-07-19 18:25:22 +02:00
[Feature] Allow users to inspect all settings inside LV (#984)
This commit is contained in:
parent
113f69c447
commit
56f17cebd4
2 changed files with 64 additions and 0 deletions
|
@ -152,6 +152,14 @@ O.lang.python.analysis.use_library_code_types = true
|
|||
-- vim.cmd('source ' .. CONFIG_PATH .. '/lua/lv-user/init.vim')
|
||||
```
|
||||
|
||||
In case you want to see all the settings inside LunarVim, run the following:
|
||||
|
||||
```bash
|
||||
cd ~/.config/nvim
|
||||
nvim --headless +'lua require("lv-utils").generate_settings()' +qa && sort -o lv-settings.lua{,}
|
||||
```
|
||||
and then inspect `~/.config/nvim/lv-settings.lua` file
|
||||
|
||||
## Updating LunarVim
|
||||
|
||||
In order to update you should be aware of three things `Plugins`, `LunarVim` and `Neovim`
|
||||
|
|
|
@ -1,5 +1,61 @@
|
|||
local lv_utils = {}
|
||||
|
||||
-- recursive Print (structure, limit, separator)
|
||||
local function r_inspect_settings(structure, limit, separator)
|
||||
limit = limit or 100 -- default item limit
|
||||
separator = separator or "." -- indent string
|
||||
if limit < 1 then
|
||||
print "ERROR: Item limit reached."
|
||||
return limit - 1
|
||||
end
|
||||
if structure == nil then
|
||||
io.write("-- O", separator:sub(2), " = nil\n")
|
||||
return limit - 1
|
||||
end
|
||||
local ts = type(structure)
|
||||
|
||||
if ts == "table" then
|
||||
for k, v in pairs(structure) do
|
||||
-- replace non alpha keys wih ["key"]
|
||||
if tostring(k):match "[^%a_]" then
|
||||
k = '["' .. tostring(k) .. '"]'
|
||||
end
|
||||
limit = r_inspect_settings(v, limit, separator .. "." .. tostring(k))
|
||||
if limit < 0 then
|
||||
break
|
||||
end
|
||||
end
|
||||
return limit
|
||||
end
|
||||
|
||||
if ts == "string" then
|
||||
-- escape sequences
|
||||
structure = string.format("%q", structure)
|
||||
end
|
||||
separator = separator:gsub("%.%[", "%[")
|
||||
if type(structure) == "function" then
|
||||
-- don't print functions
|
||||
io.write("-- O", separator:sub(2), " = function ()\n")
|
||||
else
|
||||
io.write("O", separator:sub(2), " = ", tostring(structure), "\n")
|
||||
end
|
||||
return limit - 1
|
||||
end
|
||||
|
||||
function lv_utils.generate_settings()
|
||||
-- Opens a file in append mode
|
||||
local file = io.open("lv-settings.lua", "w")
|
||||
|
||||
-- sets the default output file as test.lua
|
||||
io.output(file)
|
||||
|
||||
-- write all `O` related settings to `lv-settings.lua` file
|
||||
r_inspect_settings(O, 10000, ".")
|
||||
|
||||
-- closes the open file
|
||||
io.close(file)
|
||||
end
|
||||
|
||||
function lv_utils.reload_lv_config()
|
||||
vim.cmd "source ~/.config/nvim/lua/keymappings.lua"
|
||||
vim.cmd "source ~/.config/nvim/lv-config.lua"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue