-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New editor config #2523
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
New editor config #2523
Conversation
Uffizzi Preview |
4562345
to
70b95c2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work :) I left some comments
or | ||
If for some reason you are not happy with the default commands from a preset, or | ||
there simply is no preset for your editor, you can customize the commands by | ||
setting the `edit`, `editAtLine`, and `editAtLineAndWait` options, e.g.: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd also mention that they can go and update the getPreset
function if they want to add a preset to lazygit for all others to use.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added in 7cd3fb9
pkg/config/editor_presets.go
Outdated
} | ||
|
||
editorToPreset := map[string]string{ | ||
"vim": "vim", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should also add nvim
and vi
as those were previously covered in GetEditCmdStr
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
||
// Whether the given edit commands use the terminal. Used to decide whether | ||
// lazygit needs to suspend to the background before calling the editor. | ||
// Pointer to bool so that we can distinguish unset (nil) from false. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
makes sense
pkg/config/user_config.go
Outdated
EditInTerminal *bool `yaml:"editInTerminal,omitempty"` | ||
|
||
// A built-in preset that sets all of the above settings. Supported presets | ||
// are "vim", "emacs", "nano", "vscode", "sublime", "bbedit", "xcode". |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wouldn't enumerate the presets here given they'll change over time and it'll be one more place we need to keep in sync. I'd instead reference the place where the presets are defined
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense, see ed17d96.
@@ -570,7 +608,7 @@ func GetDefaultConfig() *UserConfig { | |||
BulkMenu: "b", | |||
}, | |||
}, | |||
OS: GetPlatformDefaultConfig(), | |||
OS: OSConfig{}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For posterity I'll just state that (if I understand correctly) we're not using the default here because it prevents us from knowing whether a user has explicitly set one of the configs or not.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Exactly, that's how I tried to explain it in the commit message. 😉
pkg/gui/layout.go
Outdated
@@ -222,6 +222,9 @@ func (gui *Gui) onInitialViewsCreation() error { | |||
if storedPopupVersion < StartupPopupVersion { | |||
popupTasks = append(popupTasks, gui.showIntroPopupMessage) | |||
} | |||
if deprecatedEditConfigPopup := gui.makeDeprecatedEditConfigPopup(); deprecatedEditConfigPopup != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should only show this popup once: it would be annoying to get the popup every time you open lazygit until you've resolved the issue. We could add a new field to our AppState to support this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I disagree pretty strongly here. If we warn only once, people will ignore it the one time they see it, and then likely forget about it. They will then be very annoyed after a year when we remove the old configs and break their lazygit. I think this is not much better than not warning at all. That's exactly what I meant when we discussed the different options on Discord.
I could imagine throttling the warning to once a day, or maybe once a week, but I'm not sure it's worth the extra logic.
Cc @mark2185 who also had a strong opinion on Discord.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about an alternative approach: rather than show a popup, we print a deprecation notice after the gui closes, so the message appears in the user's terminal. This means we'll still be able to nag the user, but it won't actually interfere with their flow (many people such as myself will start a new lazygit session frequently and having the popup there will be very annoying).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would personally like the popup at startup better, as I'm afraid the terminal output is too easy to miss (especially when there's a lot of terminal output already, e.g. from multiple "commit with editor" commands).
But I'd be fine with it if you prefer it; see 2e4ce16.
@stefanhaller fantastic work! Sorry it took me so long to get around to re-reviewing, but this is good to merge. Feel free to clean up your commits and I'll hit the button |
These files were renamed from os_windows_test.go to os_test_windows.go (etc.) in 95b2e95. Since then, the tests have no longer run, since go only looks for tests in files ending with "test.go". It isn't important that the file name ends with "_windows.go", since there are already build constrains in the files themselves.
Now that the tests run again, it turns out that they actually fail, so fix them.
The "open" command is supposed to behave in the same way as double-clicking a file in the Finder/Explorer. The concept of jumping to a specific line in the file doesn't make sense for this; use "edit" instead.
Instead, query the platform defaults only if the config is empty. This will be necessary later to distinguish an empty config from a default config, so that we can give deprecation warnings.
We do this for consistency with the edit settings. The old names are kept as a fallback for now.
We print this to the terminal after lazygit quits rather than showing it in a panel at startup, so as to not annoy people too much. Hopefully it will still be prominent enough this way.
2e4ce16
to
046b0d9
Compare
Done. Thanks! |
This implements the new editor configuration as discussed on Discord:
EditCommand
andEditCommandTemplate
were replaced byEdit
,EditAtLine
, andEditAndLineAndWait
.In addition, there's a new
EditInTerminal
boolean to say whether lazygit should suspend to background before calling the editor.Also, there's a new
EditPreset
config that can set all four of the above settings at once.Finally,
OpenCommand
andOpenLinkCommand
were renamed toOpen
andOpenLink
, respectively, for consistency with the others.go run scripts/cheatsheet/main.go generate
)docs/Config.md
) have been updated if necessary