Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Append g:zig_std_dir to &path #81

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

dweiller
Copy link

The current behaviour of the path option setting seems unintuitive to me: it ignores the global value of the path option, so any globally desired value of path (like the current directory/file) must be copied into the local local value in order files to be found anywhere outside the standard library. In particular this makes the default behaviour (i.e. if the user does not explicitly set a local value for path before the ftplugin is sourced) to not resolve files relative to the current file or directory (the default (global) value of path does this). This change uses &path instead of &l:path to fix this, making the default behaviour work as (I think should be) expected.

In addition, this change appends rather than prepends the standard library path - if a zig file does @import("builtin.zig") and there is a file builtin.zig in the same directory, then the file being imported is (barring some extreme use of main-pkg-path) that one, not the one in the standard library, so appending will make gf resolve it correctly with the default path option.

Using the local value of path means that if the user has not set a local
value for path, the value of 'path' will just be 'g:zig_std_dir'. By
using '&path' the current value of 'path' is used (i.e. if no local
value is set the global one is used). For example, this means that if
'path' is at its default value of '.,/usr/include/,,' (which is not
local) before loading the ftplugin, before this change the default value
of path would be completely replaced, making gf not find files files
relative to the current file or directtory. With this change, gf will
find imported files relative to the current file and directory by
default.

Appending 'g:zig_std_dir' rather than prepending means that zig files
with the same name as ones in the standard library should be resolved to
the one the project one is working on rather than the one in the
standard library.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant