summaryrefslogtreecommitdiffstatshomepage
path: root/src/nvim/os/stdpaths.c
AgeCommit message (Collapse)AuthorFiles
2026-04-24fix(path): normalize path slashes on Windows #37729tao1
Problem: On Windows, path separators may become inconsistent for various reasons, which makes normalization quite painful. Solution: Normalize paths to `/` at the entry boundaries and always use it internally, converting back only in rare cases where `\` is really needed (e.g. cmd.exe/bat scripts?). This is the first commit in a series of incremental steps. Note: * some funcs won't respect shellslash. e.g. `expand/fnamemodify` * some funcs still respect shellslash, but will be updated in a follow PR. e.g. `ex_pwd/f_chdir/f_getcwd` * uv's built-in funcs always return `\`. e.g. `uv.cwd/uv.exepath` Co-authored-by: Justin M. Keyes <justinkz@gmail.com>
2026-04-14build: update clang v21, fix warningsdundargoc1
- `src/nvim/ex_cmds_defs.h`: use "U" instead of "u" per `readability-uppercase-literal-suffix`
2025-08-14refactor(build): remove INCLUDE_GENERATED_DECLARATIONS guardsbfredl1
These are not needed after #35129 but making uncrustify still play nice with them was a bit tricky. Unfortunately `uncrustify --update-config-with-doc` breaks strings with backslashes. This issue has been reported upstream, and in the meanwhile auto-update on every single run has been disabled.
2025-04-16fix(env.c): drop envmap, free os_getenv() result #32683Judit Novak1
Problem: vim.uv.os_setenv gets "stuck" per-key. #32550 Caused by the internal `envmap` cache. #7920 :echo $FOO <-- prints nothing :lua vim.uv.os_setenv("FOO", "bar") :echo $FOO <-- prints bar (as expected) :lua vim.uv.os_setenv("FOO", "fizz") :echo $FOO <-- prints bar, still (not expected. Should be "fizz") :lua vim.uv.os_unsetenv("FOO") :echo $FOO <-- prints bar, still (not expected. Should be nothing) :lua vim.uv.os_setenv("FOO", "buzz") :echo $FOO <-- prints bar, still (not expected. Should be "buzz") Solution: - Remove the `envmap` cache. - Callers to `os_getenv` must free the result. - Update all call-sites. - Introduce `os_getenv_noalloc`. - Extend `os_env_exists()` the `nonempty` parameter.
2024-09-08fix(startup): server fails if $NVIM_APPNAME is relative dir #30310Justin M. Keyes1
Problem: If $NVIM_APPNAME is a relative dir path, Nvim fails to start its primary/default server, and `v:servername` is empty. Root cause is d34c64e342dfba9248d1055e702d02620a1b31a8, but this wasn't noticed until 96128a5076b7 started reporting the error more loudly. Solution: - `server_address_new`: replace slashes "/" in the appname before using it as a servername. - `vim_mktempdir`: always prefer the system-wide top-level "nvim.user/" directory. That isn't intended to be specific to NVIM_APPNAME; rather, each *subdirectory* ("nvim.user/xxx") is owned by each Nvim instance. Nvim "apps" can be identified by the server socket(s) stored in those per-Nvim subdirs. fix #30256
2024-06-04fixup: apply the change on more filesJames Tirta Halim1
2024-04-20refactor: add xmemcpyz() and use it in place of some xstrlcpy() (#28422)zeertzjq1
Problem: Using xstrlcpy() when the exact length of the string to be copied is known is not ideal because it requires adding 1 to the length and an unnecessary strlen(). Solution: Add xmemcpyz() and use it in place of such xstrlcpy() calls.
2024-04-03fix(stdpath): remove duplicate directories (#26653)Raphael1
2023-11-30build: don't define FUNC_ATTR_* as empty in headers (#26317)zeertzjq1
FUNC_ATTR_* should only be used in .c files with generated headers. Defining FUNC_ATTR_* as empty in headers causes misuses of them to be silently ignored. Instead don't define them by default, and only define them as empty after a .c file has included its generated header.
2023-11-28refactor: fix headers with IWYUdundargoc1
2023-11-27build(IWYU): fix includes for func_attr.hdundargoc1
2023-11-12build: remove PVSdundargoc1
We already have an extensive suite of static analysis tools we use, which causes a fair bit of redundancy as we get duplicate warnings. PVS is also prone to give false warnings which creates a lot of work to identify and disable.
2023-11-10refactor: change some xstrndup() and xstrnsave() to xmemdupz() (#25959)zeertzjq1
When the given length is exactly the number of bytes to copy, xmemdupz() makes the intention clearer.
2023-09-30build(iwyu): add a few more _defs.h mappings (#25435)zeertzjq1
2023-09-27feat: NVIM_APPNAME supports relative paths #25233Rory Nesbitt1
Problem: NVIM_APPNAME does not allow path separators in the name, so relative paths can't be used: NVIM_APPNAME="neovim-configs/first-config" nvim NVIM_APPNAME="neovim-configs/second-config" nvim Solution: Let NVIM_APPNAME be a relative path. Absolute paths are not supported. fix #23056 fix #24966
2023-05-28fix(NVIM_APPNAME): show error message if $NVIM_APPNAME is invalidGhjuvan Lacambre1
Closes https://github.com/neovim/neovim/issues/23056.
2023-05-16refactor: use xstrl{cpy,cat} on IObuff (#23648)ii141
Replace usage of STR{CPY,CAT} with xstrl{cpy,cat} when using on IObuff Co-authored-by: ii14 <ii14@users.noreply.github.com>
2023-02-16feat: $NVIM_APPNAME #22128Ghjuvan Lacambre1
This commit implements the ability to control all of the XDG paths Neovim should use. This is done by setting an environment variable named NVIM_APPNAME. For example, setting $NVIM_APPNAME makes Neovim look for its configuration directory in $XDG_CONFIG_HOME/$NVIM_APPNAME instead of $XDG_CONFIG_HOME/nvim. If NVIM_APPNAME is not set or is an empty string, "nvim" will be used as default. The usecase for this feature is to enable an easy way to switch from configuration to configuration. One might argue that the various $XDG environment variables can already be used for this usecase. However, setting $XDG environment variables also affects tools spawned by Neovim. For example, while setting $XDG_CONFIG_HOME will enable Neovim to use a different configuration directory, it will also prevent Git from finding its "default" configuration. Closes https://github.com/neovim/neovim/issues/21691
2023-01-18refactor: replace char_u with char 24 (#21823)dundargoc1
refactor: replace char_u with char Work on https://github.com/neovim/neovim/issues/459
2022-11-15build: allow IWYU to fix includes for all .c filesdundargoc1
Allow Include What You Use to remove unnecessary includes and only include what is necessary. This helps with reducing compilation times and makes it easier to visualise which dependencies are actually required. Work on https://github.com/neovim/neovim/issues/549, but doesn't close it since this only works fully for .c files and not headers.
2022-11-06fix(stdpath): default to /tmp if stdpath('run') cannot be created #20952zeertzjq1
Fix #20949
2022-09-18vim-patch:8.1.0941: macros for MS-Windows are inconsistent (#20215)dundargoc1
Problem: Macros for MS-Windows are inconsistent, using "32", "3264 and others. Solution: Use MSWIN for all MS-Windows builds. Use FEAT_GUI_MSWIN for the GUI build. (Hirohito Higashi, closes vim/vim#3932) https://github.com/vim/vim/commit/4f97475d326c2773a78561fb874e4f23c25cbcd9
2022-07-17fix(windows):exepath, stdpath return wrong slashes #19111Enan Ajmain1
exepath and stdpath should respect shellslash and return path with proper file separator. Closes #13787
2022-06-30feat: stdpath('run'), /tmp/nvim.user/ #18993Justin M. Keyes1
Problem: - Since c57f6b28d71d #8519, sockets are created in ~/.local/… but XDG spec says: "XDG_RUNTIME_DIR: Must be on the local filesystem", which implies that XDG_STATE_DIR is potentially non-local. - Not easy to inspect Nvim-created temp files (for debugging etc). Solution: - Store sockets in stdpath('run') ($XDG_RUNTIME_DIR). - Establish "/tmp/nvim.user/" as the tempdir root shared by all Nvims. - Make ok() actually useful. - Introduce assert_nolog(). closes #3517 closes #17093
2022-05-16refactor: replace char_u variables and functions with charDundar Goc1
Work on https://github.com/neovim/neovim/issues/459
2022-05-12fix(windows): stdpath("state") => "nvim-data" #18546dundargoc1
This was missed in https://github.com/neovim/neovim/pull/15583
2022-05-12feat(defaults): session data in $XDG_STATE_HOME #15583Ivan1
See: https://gitlab.freedesktop.org/xdg/xdg-specs/-/commit/4f2884e16db35f2962d9b64312917c81be5cb54b - Move session persistent data to $XDG_STATE_HOME Change 'directory', 'backupdir', 'undodir', 'viewdir' and 'shadafile' default location to $XDG_STATE_HOME/nvim. - Move logs to $XDG_STATE_HOME, too. - Add stdpath('log') support. Fixes: #14805
2021-11-19refactor: saner options for uncrustify (#16204)dundargoc1
* sp_enum_after_assign = force * sp_brace_typedef = force * nl_do_brace = remove * sp_do_brace_open = force * sp_brace_close_while = force * sp_before_semi = remove * sp_before_semi_for = remove * sp_before_semi_for_empty = remove * sp_between_semi_for_empty = remove * sp_after_semi_for_empty = remove * sp_before_square = remove * sp_before_squares = remove * sp_inside_square = remove * sp_inside_fparens = remove * sp_inside_fparen = remove * sp_inside_tparen = remove * sp_after_tparen_close = remove * sp_return_paren = force * pos_bool = lead * sp_pp_concat = remove * sp_pp_stringify = remove * fixup: disable formatting for the INIT section
2021-09-14refactor: format files with uncrustify #15663dundargoc1
2021-01-13logging: move to XDG_CACHE_HOME (#13739)Michael Lingelbach1
while there is some controversy, stdpath('cache') looks like a better fit for logs than stdpath('data'): you can remove logs without preventing nvim to work which fits the XDG_CACHE_HOME definition of `user specific non-essential data files`.
2019-09-06stdpaths_get_xdg_var: consider empty env vars #10953Daniel Hahler1
Without this "sysinit uses VIM if XDG_CONFIG_DIRS unset" fails with an existing `/etc/xdg/nvim/sysinit.vim` file, because `XDG_CONFIG_DIRS=` is not considered, but the default ("/etc/xdg") used then.
2019-04-28win/defaults: Use "…/nvim-data/site" in 'runtimepath'Justin M. Keyes1
On Windows we store non-config data in "$XDG_DATA_HOME/nvim-data". But the "…/site" items in 'runtimepath' did not correctly point to that location, they used "…/nvim/site". Fix the init logic to use "…/nvim-data/site". closes #9910
2018-05-18do not pass NULL to os_getenvJustin M. Keyes1
closes #8393
2018-03-29eval: Add stdpath() method (#5297)Christian Höltje1
Adds the :stdpath method for fetching XDG standard directories. Fixes #5297
2017-04-19*: Add comment to all C filesZyX1
2017-01-08XDG: Windows: resolve $LOCALAPPDATA, $TEMP (#5278)Rui Abreu Ferreira1
After #4964 environment variables in the XDG "fallback" table are no longer expanded. Fallback to correctly expanded $LOCALAPPDATA, $TEMP. If that fails (unlikely), fallback to hard-coded paths (e.g. ~/AppData/Local). Closes #5255
2016-07-10option: Also escape commas in options other then &runtimepathZyX1
2016-03-04Lint: fix line length >80Marco Hinz1
Introduced here: https://github.com/neovim/neovim/commit/4bfac00aa389487c4f11d34e7a3e96e4a1116800#diff-2bf87eef9f7b99dcea4b0c55beee2d63R78
2016-03-03Windows: XDG: Update default paths. #4403Rui Abreu Ferreira1
The previous defaults were including the nvim suffix, causing it to apear twice in the final paths. kXDGDataHome and kXDGConfigHome are now set as %LOCALAPPDATA%, kXDGCacheHome is set as $TEMP. In Windows there is no distinction between configuration and data storage, but we don't want to place all files under the same path. get_xdg_home() now appends a different path suffix for kXDGDataHome. - Configuration files are saved under %LOCALAPPDATA%\nvim - Data files are saved under %LOCALAPPDATA%\nvim-data
2015-10-29stdpaths: Document that stdpaths_*_subpath is not returning NULLZyX1
2015-10-29stdpaths: Use NULL in place of empty stringsZyX1
2015-10-23stdpaths: Remove outdated commentZyX1
2015-10-23stdpaths: Add Windows-specific directoriesZyX1
2015-10-23stdpaths: Add missing includeZyX1
2015-10-23stdpaths: Remove Apple defaults, use \*nix ones insteadZyX1
2015-10-23option: Add `//` to the end of default `&directory`ZyX1
2015-10-23stdpaths: Add documentationZyX1
2015-10-23stdpaths: Do NOT create data directoriesZyX1
This is none of option.c business to create *possibly unneeded* **default** directories **before** user specified where he actually wants to place the files.
2015-10-23stdpaths: Give proper error message in case directory creation failedZyX1
2015-10-23stdpaths,main: Remove all remaining memory leaksZyX1