Skip to content

Conversation

haberdashPI
Copy link
Owner

@haberdashPI haberdashPI commented Aug 29, 2024

This is a bit of a hodge-podge of updates.

Changes:

  • Offer to install required extensions when loading keybindings
  • Allow user to specify "user bindings" in a custom file, as an extension of the activated preset bindings.
  • Removes a few bindings from larkin.toml that are very specific to my personal setup and add them to my own user binding file. They probably didn't work anyways and/or weren't relevant for anyone but frequent users of Julia.

Coverage:

  • Include more comprehensive coverage of keybinding configuration actions

Bug Fixes:

  • there were issues with ensuring that master key configured bindings correctly detected that bare keys (no modifiers) should not be responded to in e.g. text boxes
  • visual and palette display of bindings did not always properly update when activating new bindings

Here are the bindings that exist in my own personal masterkeys.toml that I add to my config using the new command Master Key: Activate User Keybindings. These bindings were previously included as part of the Larkin preset.

#- Cell Movement (provides file specific overrides to existing bindings)

[[bind]]
path = "edit.motion"
key = "g c"
name = "cell →"
description = "next notebook cell"
combinedName = "cell →/←"
combinedDescription = "next/prev notebook cell"
combinedKey = "c/shift+c"
when = "editorLangId == 'markdown' || editorLangId == 'quarto'"
command = "runCommands"
args.commands = ["terminal-polyglot.next-fence-select", "selection-utilities.revealActive"]
hideInDocs = true

[[bind]]
path = "edit.motion"
key = "g shift+c"
name = "cell ←"
combinedName = "cell →/←"
description = "previous jupyter notebook cell"
when = "editorLangId == 'markdown' || editorLangId == 'quarto'"
command = "runCommands"
args.commands = ["terminal-polyglot.prev-fence-select", "selection-utilities.revealActive"]
hideInDocs = true

# ## Terminal-related Commands

[[bind]]
path = "edit.motion.match.cell"
name = "in cell"
description = "select text within a cell (ala jupyter)"
key = "m c"
when = "editorLangId == 'markdown' || editorLangId == 'quarto'"
command = "runCommands"
args.commands = ["terminal-polyglot.select-fence", "selection-utilities.revealActive"]

[[bind]]
path = "edit.action"
name = "to repl"
description = """
send text to a terminal (usually containing a REPL); use language
specific extensions when available and put the pasted code into a block (when defined)."
"""
key = "["
when = "editorLangId == 'julia' && !editorHasSelection && count >= 1"
command = "runCommands"
args.commands = [
      { defined = "selectLinesDown" },
      "expandLineSelection", "selection-utilities.trimSelectionWhitespace",
      "language-julia.executeCodeBlockOrSelectionAndMove",
      "cursorUndo"
]

[[bind]]
path = "edit.action"
key = "["
when = "editorLangId == 'julia' && !editorHasSelection && !count"
command = "runCommands"
args.commands = [
      "expandLineSelection", "selection-utilities.trimSelectionWhitespace",
      "language-julia.executeCodeBlockOrSelectionAndMove",
      "cursorUndo"
]

[[bind]]
path = "edit.action"
key = "enter"
when = "editorLangId == 'julia' && editorHasSelection"
command = "runCommands"
args.commands = ["selection-utilities.trimSelectionWhitespace",
        "language-julia.executeCodeBlockOrSelectionAndMove",
        "cursorUndo"]

[[bind]]
path = "edit.action"
key = "enter"
when = "editorLangId != 'julia' && !(master-key.firstSelectionOrWord =~ /\\n/)"
command = "runCommands"
args.commands = ["terminal-polyglot.send-text",
        "selection-utilities.shrinkToActive"]

[[bind]]
path = "edit.action"
name = "repl"
key = "enter"
when = "editorLangId != 'julia' && master-key.firstSelectionOrWord =~ /\\n/"
command = "runCommands"
args.commands = ["terminal-polyglot.send-block-text",
      "selection-utilities.shrinkToActive"]

[[bind]]
path = "edit.action"
key = "shift+enter"
name = "to repl (v2)"
combinedName = "to repl v2 (v3)"
description = """
send text to a terminal (usually containing a REPL), placing in a block when defined.
"""
combinedDescription = """
send text to a terminal (usually containing a REPL); v2 places the code in a block when defined (v3 does not).
"""
combinedKey = "tab / shift+enter"
command = "runCommands"
args.commands = ["terminal-polyglot.send-block-text", "selection-utilities.shrinkToActive"]

[[bind]]
path = "edit.action"
key = "tab enter"
name = "to repl (v3)"
combinedName = "to repl v2 (v3)"
description = """
send text to a terminal (usually containing a REPL)
"""
command = "runCommands"
args.commands = ["terminal-polyglot.send-text", "selection-utilities.shrinkToActive"]

[[bind]]
path = "edit.action"
name = "open terminal"
key = "]"
when = "master-key.count"
command = "terminal-polyglot.open-terminal-N"
computedArgs.index = "count"
args.focus = false

[[bind]]
path = "edit.action"
name = "open terminal"
key = "]"
when = "!master-key.count"
command = "terminal-polyglot.open-terminal"
computedArgs.index = "count"
args.focus = false

[[bind]]
path = "edit.action"
name = "run in terminal"
key = "tab shift+r"
command = "terminal-polyglot.run"
args.focus = false

[[bind]]
path = "edit.action.do"
name = "activate"
combinedName = "activate / activate tests"
combinedDescription = "Activate the julia project / julia tests associated with the current file in the active REPL"
combinedKey = "a/t"
description = "Activate the julia project associated with the current file in the active REPL"
key = "space a"
when = "editorLangId == 'julia'"
command = "terminal-polyglot.send-command"
args.cmd = "activate_from(\"%file%\")"

[[bind]]
path = "edit.action.do"
name = "activate tests"
description = "Activate the julia project test environment associated with the current file in the active REPL"
key = "space t"
combinedName = "activate / activate tests"
when = "editorLangId == 'julia'"
command = "terminal-polyglot.send-command"
args.cmd = "\nbegin; activate_from(\"%file%\"); using TestEnv; TestEnv.activate(); end"

@haberdashPI haberdashPI marked this pull request as ready for review September 1, 2024 14:45
@codecov
Copy link

codecov bot commented Sep 3, 2024

Codecov Report

Attention: Patch coverage is 61.71875% with 49 lines in your changes missing coverage. Please review.

Project coverage is 76.28%. Comparing base (e03110f) to head (6add52d).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
src/web/keybindings/index.ts 52.83% 20 Missing and 5 partials ⚠️
src/web/keybindings/config.ts 66.66% 14 Missing and 5 partials ⚠️
src/web/keybindings/processing.ts 33.33% 1 Missing and 1 partial ⚠️
src/web/utils.ts 50.00% 1 Missing and 1 partial ⚠️
src/web/extension.ts 80.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #13      +/-   ##
==========================================
+ Coverage   74.72%   76.28%   +1.56%     
==========================================
  Files          24       24              
  Lines        2263     2315      +52     
  Branches      449      465      +16     
==========================================
+ Hits         1691     1766      +75     
+ Misses        402      371      -31     
- Partials      170      178       +8     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@haberdashPI haberdashPI changed the title User Bindings Keybinding Configuration Improvements Sep 7, 2024
@haberdashPI haberdashPI merged commit f64e88e into main Sep 7, 2024
1 check passed
haberdashPI added a commit that referenced this pull request Sep 10, 2024
This is a series of small, mostly cosmetic updates prior to the 0.3.0
release which will be the first release published to the VSCode/VSCodium
'stores'.

Updates:

- Many improvements to the README
- A shiny logo
- Rename `Remove Keybindings` to `Deactivate Keybindings` to match
`Activate Keybindings`
- Activating user bindings has a default file equal to the currently
active file
- Created an `Install Active Keybinding Extensions` command that lets
users install extensions after activating keybindings without having to
reactivate them.

FYI: @bhainesva: I have reverted your change to the `shift+r` command
form #15 as I have found that in general it is more useful to have it
not expand lines in my daily work. If you desire the behavior as it was
previously documented you can always press `shift+x shift+r`, or
override the default binding with a user binding, as made possible by
#13
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