Debian Codegraph @

CONTRIBUTING.md

raw
1 # Contributing
2
3 Code contributions are always welcome in `lf`.
4
5 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:
6
7 - Whether it can be implemented entirely in user configuration instead
8 - The complexity added by supporting it
9 - The number of users interested in it
10
11 If your feature can be implemented as a configuration option, **please add it to the [wiki](https://github.com/gokcehan/lf/wiki)**.
12
13 For bug fixes, you can simply send a pull request.
14
15 ## Code conventions
16
17 In addition to `gofmt` and friends (e.g. [go vet](https://pkg.go.dev/cmd/vet), [staticcheck](https://staticcheck.dev/), [golangci-lint](https://golangci-lint.run/)), we have a few conventions:
18
19 - Global variables are best avoided except when they are not.
20 Global variable names are prefixed with `g` as in `gFooBar`.
21 Exceptions are variables that store values of environment variables, which are prefixed with `env` as in `envFooBar`, and regular expressions, which are prefixed with `re` as in `reFooBar` when they are global.
22 - Type and function names are lowercase as in `fooBar` since we don't use exporting.
23 - For filename variables, `name`, `fname`, or `filename` should refer to the base name of the file as in `baz.txt`, and `path`, `fpath`, or `filepath` should refer to the full path of the file as in `/foo/bar/baz.txt`.
24 - Run `go fmt` to ensure that files are formatted correctly.
25 - Consider using [conventional](https://www.conventionalcommits.org/) commit messages.
26
27 Use the surrounding code as reference when in doubt as usual.
28
29 ## Adding a new option
30
31 Adding a new option usually requires the following steps:
32
33 - Add option name/type to `gOpts` struct in `opts.go`
34 - Add default option value to `init` function in `opts.go`
35 - Add option evaluation logic to `setExpr.eval` in `eval.go`
36 - Implement the option somewhere in the code
37 - Add option name and its default value to `Quick Reference` and `Settings` sections in `doc.md`
38 - Run `gen/doc.sh` to update the documentation (optional as it requires `docker`/`podman`, but appreciated)
39 - Commit your changes and send a pull request
40
41 Options should be defined in alphabetical order, but note that boolean options are defined first in `eval.go` as they require special handling.
42
43 ## Adding a new builtin command
44
45 Adding a new command usually requires the following steps:
46
47 - Add default key if any to `init` function in `opts.go`
48 - Add command evaluation logic to `callExpr.eval` in `eval.go`
49 - Implement the command somewhere in the code
50 - Add command name to `gCmdWords` in `complete.go` for tab completion
51 - Add command name to `Quick Reference` and `Commands` sections in `doc.md`
52 - Run `gen/doc.sh` to update the documentation (optional as it requires `docker`/`podman`, but appreciated)
53 - Commit your changes and send a pull request
54
55 Commands should be defined in alphabetical order, but note that commands are first organized roughly into the following sections in `eval.go` for clarity:
56
57 - Navigation
58 - Selection
59 - File-related operations
60 - Shell commands
61 - Finding and searching
62 - Filtering
63 - Marks
64 - Tags
65 - Echoing
66 - Miscellaneous commands
67 - Visual mode
68 - Command-line mode commands
69 - Hook commands
70
71 ## Platform specific code
72
73 There are two files named `os.go` and `os_windows.go` for Unix and Windows specific code respectively.
74 If you add something to either of these files but not the other, you will probably break the build for the other platform.
75 If your addition works the same on both platforms, your addition probably belongs to `main.go` instead.
76
77 There are also different variants of the `df` functionality provided by `df_openbsd.go`, `df_statfs.go`, `df_statvfs.go` and `df_windows.go`.
78 Where applicable, ensure that any changes you make are reflected across all of these files for consistency.