1
0
Fork 0
mirror of https://github.com/nix-community/nixvim.git synced 2025-11-09 12:06:05 +01:00

treewide(docs): use literalLua instead of __raw in option examples

This commit is contained in:
Axel Karjalainen 2025-10-04 22:38:00 +03:00 committed by Gaétan Lepage
parent 5aae2b9fcd
commit 5ddfbdf1c2
23 changed files with 54 additions and 57 deletions

View file

@ -18,7 +18,7 @@ lib.nixvim.plugins.mkNeovimPlugin {
Enables/disables auto creating, saving and restoring. Enables/disables auto creating, saving and restoring.
''; '';
root_dir = defaultNullOpts.mkStr { __raw = "vim.fn.stdpath 'data' .. '/sessions/'"; } '' root_dir = defaultNullOpts.mkStr (lib.nixvim.literalLua "vim.fn.stdpath 'data' .. '/sessions/'") ''
Root directory for session files. Root directory for session files.
Can be either a string or lua code (using `{__raw = 'foo';}`). Can be either a string or lua code (using `{__raw = 'foo';}`).
''; '';
@ -89,7 +89,7 @@ lib.nixvim.plugins.mkNeovimPlugin {
''; '';
session_control = { session_control = {
control_dir = defaultNullOpts.mkStr { __raw = "vim.fn.stdpath 'data' .. '/auto_session/'"; } '' control_dir = defaultNullOpts.mkStr (lib.nixvim.literalLua "vim.fn.stdpath 'data' .. '/auto_session/'") ''
Auto session control dir, for control files, like alternating between two sessions Auto session control dir, for control files, like alternating between two sessions
with session-lens. with session-lens.
''; '';

View file

@ -12,12 +12,12 @@ lib.nixvim.plugins.mkNeovimPlugin {
settingsOptions = { settingsOptions = {
bucket = { bucket = {
hostname = defaultNullOpts.mkStr { __raw = "vim.uv.os_gethostname()"; } '' hostname = defaultNullOpts.mkStr (lib.nixvim.literalLua "vim.uv.os_gethostname()") ''
The hostname to be presented to the ActivityWatch server. The hostname to be presented to the ActivityWatch server.
Defaults to the hostname of the computer. Defaults to the hostname of the computer.
''; '';
name = defaultNullOpts.mkStr { __raw = "'aw-watcher-neovim_' .. bucket.hostname'"; } '' name = defaultNullOpts.mkStr (lib.nixvim.literalLua "'aw-watcher-neovim_' .. bucket.hostname'") ''
The name of the bucket in the ActivityWatch server. The name of the bucket in the ActivityWatch server.
''; '';
}; };

View file

@ -55,9 +55,7 @@ lib.nixvim.plugins.mkNeovimPlugin {
types.rawLua types.rawLua
]) "img" "Directory that will be inserted into text/buffer."; ]) "img" "Directory that will be inserted into text/buffer.";
img_name = defaultNullOpts.mkStr { img_name = defaultNullOpts.mkStr (lib.nixvim.literalLua "function() return os.date('%Y-%m-%d-%H-%M-%S') end") "Image's name.";
__raw = "function() return os.date('%Y-%m-%d-%H-%M-%S') end";
} "Image's name.";
img_handler = defaultNullOpts.mkLuaFn "function(img) end" '' img_handler = defaultNullOpts.mkLuaFn "function(img) end" ''
Function that will handle image after pasted. Function that will handle image after pasted.

View file

@ -89,7 +89,7 @@ lib.nixvim.plugins.mkNeovimPlugin {
Default context to use, `"buffers"`, `"buffer"` or `null` (can be specified manually in prompt via @). Default context to use, `"buffers"`, `"buffer"` or `null` (can be specified manually in prompt via @).
''; '';
history_path = defaultNullOpts.mkStr (lib.nixvim.mkRaw "vim.fn.stdpath('data') .. '/copilotchat_history'") '' history_path = defaultNullOpts.mkStr (lib.nixvim.literalLua "vim.fn.stdpath('data') .. '/copilotchat_history'") ''
Default path to stored history. Default path to stored history.
''; '';

View file

@ -23,7 +23,7 @@ lib.nixvim.plugins.mkNeovimPlugin {
]; ];
settingsOptions = { settingsOptions = {
glow_path = defaultNullOpts.mkStr (lib.nixvim.mkRaw "vim.fn.exepath('glow')") '' glow_path = defaultNullOpts.mkStr (lib.nixvim.literalLua "vim.fn.exepath('glow')") ''
Path to `glow` binary. Path to `glow` binary.
If null or `""`, `glow` in your `$PATH` with be used if available. If null or `""`, `glow` in your `$PATH` with be used if available.

View file

@ -20,9 +20,7 @@ in
''; '';
}; };
root_dir = root_dir = defaultNullOpts.mkStr (lib.nixvim.literalLua "require('jdtls.setup').find_root({'.git', 'mvnw', 'gradlew'})") ''
defaultNullOpts.mkStr { __raw = "require('jdtls.setup').find_root({'.git', 'mvnw', 'gradlew'})"; }
''
Function to identify the root directory from which to run the language server. Function to identify the root directory from which to run the language server.
''; '';

View file

@ -53,7 +53,7 @@ mkVimPlugin {
The highlight group to be used for highlighting cells. The highlight group to be used for highlighting cells.
''; '';
save_path = helpers.defaultNullOpts.mkStr { __raw = "vim.fn.stdpath('data') .. '/magma'"; } '' save_path = helpers.defaultNullOpts.mkStr (lib.nixvim.literalLua "vim.fn.stdpath('data') .. '/magma'") ''
Where to save/load with `:MagmaSave` and `:MagmaLoad` (with no parameters). Where to save/load with `:MagmaSave` and `:MagmaLoad` (with no parameters).
The generated file is placed in this directory, with the filename itself being the The generated file is placed in this directory, with the filename itself being the
buffer's name, with `%` replaced by `%%` and `/` replaced by `%`, and postfixed with the buffer's name, with `%` replaced by `%%` and `/` replaced by `%`, and postfixed with the

View file

@ -42,9 +42,7 @@ lib.nixvim.plugins.mkNeovimPlugin {
[README](https://github.com/AckslD/nvim-neoclip.lua#custom-actions). [README](https://github.com/AckslD/nvim-neoclip.lua#custom-actions).
''; '';
db_path = db_path = helpers.defaultNullOpts.mkStr (lib.nixvim.literalLua "vim.fn.stdpath('data') .. '/databases/neoclip.sqlite3'") ''
helpers.defaultNullOpts.mkStr { __raw = "vim.fn.stdpath('data') .. '/databases/neoclip.sqlite3'"; }
''
The path to the sqlite database to store history if `enable_persistent_history=true`. The path to the sqlite database to store history if `enable_persistent_history=true`.
Defaults to `$XDG_DATA_HOME/nvim/databases/neoclip.sqlite3`. Defaults to `$XDG_DATA_HOME/nvim/databases/neoclip.sqlite3`.
''; '';

View file

@ -103,7 +103,7 @@ in
method, described in [BUILTIN_CONFIG](https://github.com/nvimtools/none-ls.nvim/blob/main/doc/BUILTIN_CONFIG.md). method, described in [BUILTIN_CONFIG](https://github.com/nvimtools/none-ls.nvim/blob/main/doc/BUILTIN_CONFIG.md).
''; '';
fallback_severity = defaultNullOpts.mkUnsignedInt { __raw = "vim.diagnostic.severity.ERROR"; } '' fallback_severity = defaultNullOpts.mkUnsignedInt (lib.nixvim.literalLua "vim.diagnostic.severity.ERROR") ''
Defines the severity used when a diagnostic source does not explicitly define a severity. Defines the severity used when a diagnostic source does not explicitly define a severity.
See `:help diagnostic-severity` for available values. See `:help diagnostic-severity` for available values.
''; '';

View file

@ -41,7 +41,8 @@ lib.nixvim.plugins.mkNeovimPlugin {
''; '';
search_paths = search_paths =
defaultNullOpts.mkListOf types.str [ { __raw = "vim.fn.stdpath('config') .. '/snippets'"; } ] defaultNullOpts.mkListOf types.str
(lib.nixvim.literalLua "{ vim.fn.stdpath('config') .. '/snippets' }")
'' ''
Paths to search for snippets. Paths to search for snippets.
''; '';

View file

@ -70,9 +70,7 @@ lib.nixvim.plugins.mkNeovimPlugin {
What scope to change the directory. What scope to change the directory.
''; '';
data_path = defaultNullOpts.mkStr { data_path = defaultNullOpts.mkStr (lib.nixvim.literalLua "vim.fn.stdpath('data')") "Path where project.nvim will store the project history for use in telescope.";
__raw = "vim.fn.stdpath('data')";
} "Path where project.nvim will store the project history for use in telescope.";
}; };
settingsExample = { settingsExample = {

View file

@ -87,7 +87,7 @@ lib.nixvim.plugins.mkNeovimPlugin {
Encode URL before making request. Encode URL before making request.
''; '';
user_agent = defaultNullOpts.mkStr (lib.nixvim.mkRaw ''"rest.nvim v" .. require("rest-nvim.api").VERSION'') '' user_agent = defaultNullOpts.mkStr (lib.nixvim.literalLua ''"rest.nvim v" .. require("rest-nvim.api").VERSION'') ''
Set `User-Agent` header when it is empty. Set `User-Agent` header when it is empty.
''; '';
@ -135,7 +135,7 @@ lib.nixvim.plugins.mkNeovimPlugin {
Whether to enable cookies support or not. Whether to enable cookies support or not.
''; '';
path = defaultNullOpts.mkStr (lib.nixvim.mkRaw ''vim.fs.joinpath(vim.fn.stdpath("data") --[[@as string]], "rest-nvim.cookies")'') '' path = defaultNullOpts.mkStr (lib.nixvim.literalLua ''vim.fs.joinpath(vim.fn.stdpath("data") --[[@as string]], "rest-nvim.cookies")'') ''
Environment variables file pattern for `telescope.nvim`. Environment variables file pattern for `telescope.nvim`.
''; '';
}; };

View file

@ -273,7 +273,7 @@ with lib;
Disabling it may improve rust-analyzer's startup time. Disabling it may improve rust-analyzer's startup time.
''; '';
logfile = helpers.defaultNullOpts.mkStr { __raw = "vim.fn.tempname() .. '-rust-analyzer.log'"; } '' logfile = helpers.defaultNullOpts.mkStr (lib.nixvim.literalLua "vim.fn.tempname() .. '-rust-analyzer.log'") ''
The path to the rust-analyzer log file. The path to the rust-analyzer log file.
''; '';

View file

@ -20,7 +20,7 @@ lib.nixvim.plugins.mkNeovimPlugin {
Whether to show notification when big file detected. Whether to show notification when big file detected.
''; '';
size = defaultNullOpts.mkNum { __raw = "1.5 * 1024 * 1024"; } '' size = defaultNullOpts.mkNum (lib.nixvim.literalLua "1.5 * 1024 * 1024") ''
The size at which a file is considered big. The size at which a file is considered big.
''; '';

View file

@ -82,7 +82,7 @@ lib.nixvim.plugins.mkNeovimPlugin {
] "Display modes used in `live_mode`."; ] "Display modes used in `live_mode`.";
display_options = { display_options = {
terminal_scrollback = helpers.defaultNullOpts.mkUnsignedInt { __raw = "vim.o.scrollback"; } '' terminal_scrollback = helpers.defaultNullOpts.mkUnsignedInt (lib.nixvim.literalLua "vim.o.scrollback") ''
Change terminal display scrollback lines. Change terminal display scrollback lines.
''; '';

View file

@ -15,12 +15,12 @@ mkExtension {
Custom theme, will use your global theme by default. Custom theme, will use your global theme by default.
''; '';
path = defaultNullOpts.mkStr { __raw = "vim.loop.cwd()"; } '' path = defaultNullOpts.mkStr (lib.nixvim.literalLua "vim.loop.cwd()") ''
Directory to browse files from. Directory to browse files from.
`vim.fn.expanded` automatically. `vim.fn.expanded` automatically.
''; '';
cwd = defaultNullOpts.mkStr { __raw = "vim.loop.cwd()"; } '' cwd = defaultNullOpts.mkStr (lib.nixvim.literalLua "vim.loop.cwd()") ''
Directory to browse folders from. Directory to browse folders from.
`vim.fn.expanded` automatically. `vim.fn.expanded` automatically.
''; '';

View file

@ -13,7 +13,7 @@ mkExtension {
If true, it removes stale entries count over than `db_validate_threshold`. If true, it removes stale entries count over than `db_validate_threshold`.
''; '';
db_root = defaultNullOpts.mkStr { __raw = "vim.fn.stdpath 'data'"; } '' db_root = defaultNullOpts.mkStr (lib.nixvim.literalLua "vim.fn.stdpath 'data'") ''
Path to parent directory of custom database location. Path to parent directory of custom database location.
Defaults to `$XDG_DATA_HOME/nvim` if unset. Defaults to `$XDG_DATA_HOME/nvim` if unset.
''; '';

View file

@ -141,7 +141,7 @@ lib.nixvim.plugins.mkNeovimPlugin {
Close the terminal window when the process exits. Close the terminal window when the process exits.
''; '';
shell = helpers.defaultNullOpts.mkStr { __raw = "vim.o.shell"; } '' shell = helpers.defaultNullOpts.mkStr (lib.nixvim.literalLua "vim.o.shell") ''
Change the default shell. Change the default shell.
''; '';

View file

@ -2,7 +2,7 @@
with lib; with lib;
let let
inherit (lib) types; inherit (lib) types;
inherit (lib.nixvim) defaultNullOpts mkRaw; inherit (lib.nixvim) defaultNullOpts;
specExamples = [ specExamples = [
# Basic group with custom icon # Basic group with custom icon
@ -85,7 +85,7 @@ lib.nixvim.plugins.mkNeovimPlugin {
] "Preset style for WhichKey. Set to false to disable."; ] "Preset style for WhichKey. Set to false to disable.";
delay = defaultNullOpts.mkInt' { delay = defaultNullOpts.mkInt' {
pluginDefault.__raw = '' pluginDefault = lib.nixvim.literalLua ''
function(ctx) function(ctx)
return ctx.plugin and 0 or 200 return ctx.plugin and 0 or 200
end end
@ -94,7 +94,7 @@ lib.nixvim.plugins.mkNeovimPlugin {
}; };
filter = defaultNullOpts.mkLuaFn' { filter = defaultNullOpts.mkLuaFn' {
pluginDefault.__raw = '' pluginDefault = lib.nixvim.literalLua ''
function(mapping) function(mapping)
return true return true
end end
@ -126,7 +126,7 @@ lib.nixvim.plugins.mkNeovimPlugin {
] "Manually setup triggers"; ] "Manually setup triggers";
defer = defaultNullOpts.mkLuaFn' { defer = defaultNullOpts.mkLuaFn' {
pluginDefault.__raw = '' pluginDefault = lib.nixvim.literalLua ''
function(ctx) function(ctx)
return ctx.mode == "V" or ctx.mode == "<C-V> return ctx.mode == "V" or ctx.mode == "<C-V>
end''; end'';
@ -230,11 +230,14 @@ lib.nixvim.plugins.mkNeovimPlugin {
expand = defaultNullOpts.mkInt 0 "Expand groups when <= n mappings."; expand = defaultNullOpts.mkInt 0 "Expand groups when <= n mappings.";
replace = { replace = {
key = defaultNullOpts.mkListOf (types.either types.strLuaFn (with types; listOf str)) (mkRaw '' key =
defaultNullOpts.mkListOf (types.either types.strLuaFn (with types; listOf str))
(lib.nixvim.literalLua ''
function(key) function(key)
return require("which-key.view").format(key) return require("which-key.view").format(key)
end end
'') "Lua functions or list of strings to replace key left side key name with."; '')
"Lua functions or list of strings to replace key left side key name with.";
desc = defaultNullOpts.mkListOf (with types; listOf str) [ desc = defaultNullOpts.mkListOf (with types; listOf str) [
[ [
"<Plug>%(?(.*)%)?" "<Plug>%(?(.*)%)?"

View file

@ -53,7 +53,7 @@ lib.nixvim.plugins.mkNeovimPlugin {
enable_mouse_support = defaultNullOpts.mkBool false "Enables mouse support."; enable_mouse_support = defaultNullOpts.mkBool false "Enables mouse support.";
open_file_function = defaultNullOpts.mkLuaFn' { open_file_function = defaultNullOpts.mkLuaFn' {
pluginDefault.__raw = '' pluginDefault = lib.nixvim.literalLua ''
function(chosen_file) function(chosen_file)
vim.cmd(string.format("edit %s", vim.fn.fnameescape(chosen_file))) vim.cmd(string.format("edit %s", vim.fn.fnameescape(chosen_file)))
end end
@ -99,7 +99,7 @@ lib.nixvim.plugins.mkNeovimPlugin {
hooks = { hooks = {
yazi_opened = defaultNullOpts.mkLuaFn' { yazi_opened = defaultNullOpts.mkLuaFn' {
pluginDefault.__raw = '' pluginDefault = lib.nixvim.literalLua ''
function(preselected_path, yazi_buffer_id, config) function(preselected_path, yazi_buffer_id, config)
end end
''; '';
@ -110,7 +110,7 @@ lib.nixvim.plugins.mkNeovimPlugin {
}; };
yazi_closed_successfully = defaultNullOpts.mkLuaFn' { yazi_closed_successfully = defaultNullOpts.mkLuaFn' {
pluginDefault.__raw = '' pluginDefault = lib.nixvim.literalLua ''
function(chosen_file, config, state) function(chosen_file, config, state)
end end
''; '';
@ -118,7 +118,7 @@ lib.nixvim.plugins.mkNeovimPlugin {
}; };
yazi_opened_multiple_files = defaultNullOpts.mkLuaFn' { yazi_opened_multiple_files = defaultNullOpts.mkLuaFn' {
pluginDefault.__raw = '' pluginDefault = lib.nixvim.literalLua ''
function(chosen_files) function(chosen_files)
vim.cmd("args" .. table.concat(chosen_files, " ")) vim.cmd("args" .. table.concat(chosen_files, " "))
end end

View file

@ -3,7 +3,12 @@
... ...
}: }:
let let
inherit (lib.nixvim) defaultNullOpts mkNullOrOption mkNullOrStrLuaFnOr; inherit (lib.nixvim)
defaultNullOpts
mkNullOrOption
mkNullOrStrLuaFnOr
literalLua
;
inherit (lib) types; inherit (lib) types;
in in
lib.nixvim.plugins.mkNeovimPlugin { lib.nixvim.plugins.mkNeovimPlugin {
@ -23,9 +28,7 @@ lib.nixvim.plugins.mkNeovimPlugin {
]; ];
in in
{ {
compile_path = defaultNullOpts.mkStr { compile_path = defaultNullOpts.mkStr (literalLua "vim.fn.stdpath 'cache' .. '/catppuccin'") "Set the compile cache directory.";
__raw = "vim.fn.stdpath 'cache' .. '/catppuccin'";
} "Set the compile cache directory.";
flavour = mkNullOrOption (types.enum (flavours ++ [ "auto" ])) '' flavour = mkNullOrOption (types.enum (flavours ++ [ "auto" ])) ''
Theme flavour. Theme flavour.

View file

@ -3,7 +3,7 @@
... ...
}: }:
let let
inherit (lib.nixvim) defaultNullOpts mkNullOrOption; inherit (lib.nixvim) defaultNullOpts mkNullOrOption literalLua;
inherit (lib) types; inherit (lib) types;
in in
lib.nixvim.plugins.mkNeovimPlugin { lib.nixvim.plugins.mkNeovimPlugin {
@ -34,7 +34,7 @@ lib.nixvim.plugins.mkNeovimPlugin {
settingsOptions = { settingsOptions = {
options = { options = {
compile_path = defaultNullOpts.mkStr { __raw = "vim.fn.stdpath('cache') .. '/nightfox'"; } '' compile_path = defaultNullOpts.mkStr (literalLua "vim.fn.stdpath('cache') .. '/nightfox'") ''
The output directory path where the compiled results will be written to. The output directory path where the compiled results will be written to.
''; '';

View file

@ -98,9 +98,7 @@ lib.nixvim.plugins.mkNeovimPlugin {
Whether to enable caching. Whether to enable caching.
''; '';
cache_dir = defaultNullOpts.mkStr { cache_dir = defaultNullOpts.mkStr (lib.nixvim.literalLua "vim.fn.stdpath('cache') .. '/palette'") "Cache directory.";
__raw = "vim.fn.stdpath('cache') .. '/palette'";
} "Cache directory.";
}; };
settingsExample = { }; settingsExample = { };