Code contributions are always welcome in lf.
If you are going to introduce a new feature, it is best to open an issue first for discussion. You should also consider the following:
- Whether it can be implemented entirely in user configuration instead
- The complexity added by supporting it
- The number of users interested in it
If your feature can be implemented as a configuration option, please add it to the wiki.
For bug fixes, you can simply send a pull request.
In addition to gofmt and friends (e.g. go vet, staticcheck, golangci-lint), we have a few conventions:
- Global variables are best avoided except when they are not.
Global variable names are prefixed with
gas ingFooBar. Exceptions are variables that store values of environment variables, which are prefixed withenvas inenvFooBar, and regular expressions, which are prefixed withreas inreFooBarwhen they are global. - Type and function names are lowercase as in
fooBarsince we don't use exporting. - For filename variables,
name,fname, orfilenameshould refer to the base name of the file as inbaz.txt, andpath,fpath, orfilepathshould refer to the full path of the file as in/foo/bar/baz.txt. - Run
go fmtto ensure that files are formatted correctly. - Consider using conventional commit messages.
Use the surrounding code as reference when in doubt as usual.
Adding a new option usually requires the following steps:
- Add option name/type to
gOptsstruct inopts.go - Add default option value to
initfunction inopts.go - Add option evaluation logic to
setExpr.evalineval.go - Implement the option somewhere in the code
- Add option name and its default value to
Quick ReferenceandSettingssections indoc.md - Run
gen/doc.shto update the documentation (optional as it requiresdocker/podman, but appreciated) - Commit your changes and send a pull request
Options should be defined in alphabetical order, but note that boolean options are defined first in eval.go as they require special handling.
Adding a new command usually requires the following steps:
- Add default key if any to
initfunction inopts.go - Add command evaluation logic to
callExpr.evalineval.go - Implement the command somewhere in the code
- Add command name to
gCmdWordsincomplete.gofor tab completion - Add command name to
Quick ReferenceandCommandssections indoc.md - Run
gen/doc.shto update the documentation (optional as it requiresdocker/podman, but appreciated) - Commit your changes and send a pull request
Commands should be defined in alphabetical order, but note that commands are first organized roughly into the following sections in eval.go for clarity:
- Navigation
- Selection
- File-related operations
- Shell commands
- Finding and searching
- Filtering
- Marks
- Tags
- Echoing
- Miscellaneous commands
- Visual mode
- Command-line mode commands
- Hook commands
There are two files named os.go and os_windows.go for Unix and Windows specific code respectively.
If you add something to either of these files but not the other, you will probably break the build for the other platform.
If your addition works the same on both platforms, your addition probably belongs to main.go instead.
There are also different variants of the df functionality provided by df_openbsd.go, df_statfs.go, df_statvfs.go and df_windows.go.
Where applicable, ensure that any changes you make are reflected across all of these files for consistency.