1
1
mirror of https://github.com/qvacua/vimr.git synced 2024-11-24 03:25:03 +03:00

Merge branch 'develop' into update-neovim

This commit is contained in:
Tae Won Ha 2022-03-16 21:48:20 +01:00
commit 048f0ae4a2
No known key found for this signature in database
GPG Key ID: E40743465B5B8B44
16 changed files with 103 additions and 23 deletions

View File

@ -90,7 +90,7 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 1200;
LastUpgradeCheck = 1320;
LastUpgradeCheck = 1330;
TargetAttributes = {
4B7FBFF724EC936C002D12A1 = {
CreatedOnToolsVersion = 12.0;

View File

@ -69,7 +69,7 @@ then continuously invoke the `build_nvimserver_for_local_dev` script.
`build_release.sh` script later.
* Tag with the name
- Snapshot: `snapshot/yyyymmdd.HHMMSS`
- Release: `vX.Y.Z`
- Release: `vX.Y.Z-yyyymmdd.HHMMSS`
* Push, create a release and add release notes.
* Build, package and upload via
```bash

View File

@ -311,7 +311,7 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 1200;
LastUpgradeCheck = 1320;
LastUpgradeCheck = 1330;
ORGANIZATIONNAME = "Tae Won Ha";
TargetAttributes = {
4B0225EF224AAE260052362B = {

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1320"
LastUpgradeVersion = "1330"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"

View File

@ -107,7 +107,7 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 1020;
LastUpgradeCheck = 1320;
LastUpgradeCheck = 1330;
ORGANIZATIONNAME = "Tae Won Ha";
TargetAttributes = {
4B02265B224AB1490052362B = {

View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<Workspace
version = "1.0">
<FileRef
location = "self:">
</FileRef>
</Workspace>

View File

@ -98,7 +98,7 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 1220;
LastUpgradeCheck = 1320;
LastUpgradeCheck = 1330;
TargetAttributes = {
4BEBD4B5256A76BB002218F8 = {
CreatedOnToolsVersion = 12.2;

View File

@ -823,7 +823,7 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0830;
LastUpgradeCheck = 1320;
LastUpgradeCheck = 1330;
ORGANIZATIONNAME = "Tae Won Ha";
TargetAttributes = {
4BEBA5041CFF374B00673FDF = {

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1320"
LastUpgradeVersion = "1330"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1320"
LastUpgradeVersion = "1330"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"

View File

@ -213,7 +213,12 @@ extension AppDelegate {
urls: urls, cwd: FileUtils.userHomeUrl, cliPipePath: nil, nvimArgs: nil, envDict: nil,
line: nil
)
self.emit(.newMainWindow(config: config))
switch self.context.state.openFilesFromApplicationsAction {
case .inCurrentWindow:
self.emit(.openInKeyWindow(config: config))
default:
self.emit(.newMainWindow(config: config))
}
sender.reply(toOpenOrPrint: .success)
}

View File

@ -12,6 +12,7 @@ class GeneralPref: PrefPane, UiComponent, NSTextFieldDelegate {
enum Action {
case setOpenOnLaunch(Bool)
case setOpenFilesFromApplications(AppState.OpenFilesFromApplicationsAction)
case setAfterLastWindowAction(AppState.AfterLastWindowAction)
case setActivateAsciiImInNormalModeAction(Bool)
case setOpenOnReactivation(Bool)
@ -33,6 +34,9 @@ class GeneralPref: PrefPane, UiComponent, NSTextFieldDelegate {
self.openOnReactivationCheckbox.boolState = state.openNewMainWindowOnReactivation
self.defaultUsesVcsIgnoresCheckbox.boolState = state.openQuickly.defaultUsesVcsIgnores
self.openFilesFromApplicationsAction = state.openFilesFromApplicationsAction
self.openFilesFromApplicationsPopup.selectItem(at: AppState.OpenFilesFromApplicationsAction.allCases.firstIndex(of: state.openFilesFromApplicationsAction) ?? 0)
self.lastWindowAction = state.afterLastWindowAction
self.afterLastWindowPopup
.selectItem(at: indexToAfterLastWindowAction.firstIndex(of: state.afterLastWindowAction) ?? 0)
@ -48,6 +52,13 @@ class GeneralPref: PrefPane, UiComponent, NSTextFieldDelegate {
self.openOnReactivationCheckbox.boolState = state.openNewMainWindowOnReactivation
}
if self.openFilesFromApplicationsAction != state.openFilesFromApplicationsAction {
self.openFilesFromApplicationsPopup.selectItem(
at: AppState.OpenFilesFromApplicationsAction.allCases.firstIndex(of: state.openFilesFromApplicationsAction) ?? 0
)
self.openFilesFromApplicationsAction = state.openFilesFromApplicationsAction
}
if self.lastWindowAction != state.afterLastWindowAction {
self.afterLastWindowPopup.selectItem(
at: indexToAfterLastWindowAction.firstIndex(of: state.afterLastWindowAction) ?? 0
@ -61,6 +72,7 @@ class GeneralPref: PrefPane, UiComponent, NSTextFieldDelegate {
private let emit: (Action) -> Void
private let disposeBag = DisposeBag()
private var openFilesFromApplicationsAction = AppState.OpenFilesFromApplicationsAction.inNewWindow
private var lastWindowAction = AppState.AfterLastWindowAction.doNothing
private let activateAsciiImInNormalModeCheckbox = NSButton(forAutoLayout: ())
@ -68,6 +80,7 @@ class GeneralPref: PrefPane, UiComponent, NSTextFieldDelegate {
private let openOnReactivationCheckbox = NSButton(forAutoLayout: ())
private let defaultUsesVcsIgnoresCheckbox = NSButton(forAutoLayout: ())
private let openFilesFromApplicationsPopup = NSPopUpButton(forAutoLayout: ())
private let afterLastWindowPopup = NSPopUpButton(forAutoLayout: ())
@available(*, unavailable)
@ -96,6 +109,20 @@ class GeneralPref: PrefPane, UiComponent, NSTextFieldDelegate {
let whenLaunching = self.openWhenLaunchingCheckbox
let onReactivation = self.openOnReactivationCheckbox
let openFilesFromApplicationsTitle = self.titleTextField(title: "Open files from applications:")
openFilesFromApplicationsPopup.target = self
openFilesFromApplicationsPopup.action = #selector(GeneralPref.afterOpenFilesFromApplicationsAction)
openFilesFromApplicationsPopup.addItems(withTitles: [
"In a New Window",
"In the Current Window",
])
let openFilesFromApplicationsInfo =
self.infoTextField(markdown: #"""
This applies to files opened from the Finder \
(e.g. by double-clicking on a file or by dragging a file onto the VimR dock icon) \
or from external programs such as Xcode.
"""#)
let afterLastWindowTitle = self.titleTextField(title: "After Last Window Closes:")
let lastWindow = self.afterLastWindowPopup
lastWindow.target = self
@ -156,6 +183,10 @@ class GeneralPref: PrefPane, UiComponent, NSTextFieldDelegate {
self.addSubview(ignoreListTitle)
self.addSubview(ignoreInfo)
self.addSubview(openFilesFromApplicationsTitle)
self.addSubview(openFilesFromApplicationsPopup)
self.addSubview(openFilesFromApplicationsInfo)
self.addSubview(afterLastWindowTitle)
self.addSubview(lastWindow)
@ -191,9 +222,18 @@ class GeneralPref: PrefPane, UiComponent, NSTextFieldDelegate {
relation: .greaterThanOrEqual
)
openFilesFromApplicationsTitle.autoAlignAxis(.baseline, toSameAxisOf: openFilesFromApplicationsPopup)
openFilesFromApplicationsTitle.autoPinEdge(.right, to: .right, of: openUntitledWindowTitle)
openFilesFromApplicationsTitle.autoPinEdge(toSuperviewEdge: .left, withInset: 18, relation: .greaterThanOrEqual)
openFilesFromApplicationsPopup.autoPinEdge(.top, to: .bottom, of: onReactivation, withOffset: 18)
openFilesFromApplicationsPopup.autoPinEdge(.left, to: .right, of: openFilesFromApplicationsTitle, withOffset: 5)
openFilesFromApplicationsInfo.autoPinEdge(.top, to: .bottom, of: openFilesFromApplicationsPopup, withOffset: 5)
openFilesFromApplicationsInfo.autoPinEdge(toSuperviewEdge: .right, withInset: 18)
openFilesFromApplicationsInfo.autoPinEdge(.left, to: .left, of: openFilesFromApplicationsPopup)
afterLastWindowTitle.autoAlignAxis(.baseline, toSameAxisOf: lastWindow)
afterLastWindowTitle.autoPinEdge(toSuperviewEdge: .left, withInset: 18)
lastWindow.autoPinEdge(.top, to: .bottom, of: onReactivation, withOffset: 18)
lastWindow.autoPinEdge(.top, to: .bottom, of: openFilesFromApplicationsInfo, withOffset: 18)
lastWindow.autoPinEdge(.left, to: .right, of: afterLastWindowTitle, withOffset: 5)
activateAsciiImTitle.autoAlignAxis(.baseline, toSameAxisOf: asciiIm, withOffset: 0)
@ -290,6 +330,16 @@ extension GeneralPref {
self.emit(.setOpenOnReactivation(self.openOnReactivationCheckbox.boolState))
}
@objc func afterOpenFilesFromApplicationsAction(_ sender: NSPopUpButton) {
let index = sender.indexOfSelectedItem
guard AppState.OpenFilesFromApplicationsAction.allCases.indices.contains(index) else {
return
}
self.openFilesFromApplicationsAction = AppState.OpenFilesFromApplicationsAction.allCases[index]
self.emit(.setOpenFilesFromApplications(self.openFilesFromApplicationsAction))
}
@objc func afterLastWindowAction(_ sender: NSPopUpButton) {
let index = sender.indexOfSelectedItem

View File

@ -16,6 +16,9 @@ class GeneralPrefReducer: ReducerType {
case let .setOpenOnLaunch(value):
state.openNewMainWindowOnLaunch = value
case let .setOpenFilesFromApplications(action):
state.openFilesFromApplicationsAction = action
case let .setAfterLastWindowAction(action):
state.afterLastWindowAction = action

View File

@ -10,6 +10,10 @@ import RxSwift
import Workspace
struct AppState: Codable {
enum OpenFilesFromApplicationsAction: String, Codable, CaseIterable {
case inNewWindow
case inCurrentWindow
}
enum AfterLastWindowAction: String, Codable {
case doNothing = "do-nothing"
case hide
@ -21,6 +25,7 @@ struct AppState: Codable {
enum CodingKeys: String, CodingKey {
case openNewMainWindowOnLaunch = "open-new-window-when-launching"
case openNewMainWindowOnReactivation = "open-new-window-on-reactivation"
case openFilesFromApplicationsAction = "open-files-from-applications-action"
case afterLastWindowAction = "after-last-window-action"
case activateAsciiImInNormalMode = "activate-ascii-im-in-normal-mode"
case useSnapshotUpdate = "use-snapshot-update-channel"
@ -32,6 +37,7 @@ struct AppState: Codable {
var openNewMainWindowOnLaunch = true
var openNewMainWindowOnReactivation = true
var openFilesFromApplicationsAction = OpenFilesFromApplicationsAction.inNewWindow
var afterLastWindowAction = AfterLastWindowAction.doNothing
var activateAsciiImInNormalMode = true
@ -64,6 +70,10 @@ struct AppState: Codable {
forKey: .openNewMainWindowOnReactivation,
default: AppState.default.openNewMainWindowOnReactivation
)
self.openFilesFromApplicationsAction = try container.decode(
forKey: .openFilesFromApplicationsAction,
default: .inNewWindow
)
self.afterLastWindowAction = try container.decode(
forKey: .afterLastWindowAction,
default: .doNothing

View File

@ -1,13 +1,16 @@
#!/usr/bin/env python3
import tempfile
import urllib.parse
import subprocess
import argparse
import os
import uuid
import json
from enum import Enum
class Action:
class Action(Enum):
ACTIVATE = "activate"
OPEN = "open"
NEW_WINDOW = "open-in-new-window"
@ -15,7 +18,7 @@ class Action:
NVIM = "nvim"
class QueryParamKey:
class QueryParamKey(Enum):
PIPE_PATH = "pipe-path"
ENV_PATH = "env-path"
CWD = "cwd"
@ -36,10 +39,10 @@ def call_open(action, query_params, args):
if args.wait:
query_params[QueryParamKey.WAIT] = "true"
url = "vimr://{0}?{1}".format(action, urllib.parse.urlencode(query_params, True).replace('+', '%20'))
url = f"vimr://{action}?{urllib.parse.urlencode(query_params, True).replace('+', '%20')}"
if args.dry_run:
print("/usr/bin/open {0}".format(url))
print(f"/usr/bin/open {url}")
else:
subprocess.call(["/usr/bin/open", url])
@ -72,17 +75,19 @@ def vimr(action, args, query_params):
def main(args):
temp_dir_path = tempfile.gettempdir()
uuid_str = str(uuid.uuid4())
pipe_path = "/tmp/com_qvacua_vimr_cli_pipe_{0}".format(uuid_str)
pipe_path = f"/{temp_dir_path}/com_qvacua_vimr_cli_pipe_{uuid_str}"
if os.path.exists(pipe_path):
os.remove(pipe_path)
try:
os.mkfifo(pipe_path, 0o600)
except OSError as error:
print("ERROR: {0}\n"
"{1} could not be mkfifo'ed.\n"
"Please go to https://github.com/qvacua/vimr and create an issue.".format(error, pipe_path))
print(f"ERROR: {error}\n"
f"{pipe_path} could not be mkfifo'ed.\n"
f"Please go to https://github.com/qvacua/vimr and create an issue.")
raise
query_params = {
@ -93,7 +98,7 @@ def main(args):
query_params[QueryParamKey.LINE] = args.line
if args.cur_env:
env_file = "/tmp/com_qvacua_vimr_env_{0}".format(uuid_str)
env_file = f"/{temp_dir_path}/com_qvacua_vimr_env_{uuid_str}"
with open(env_file, "w") as f:
f.write(json.dumps({k: v for (k, v) in os.environ.items()}))
os.chmod(env_file, 0o600)

View File

@ -6,7 +6,7 @@ marketing_version=${marketing_version:-""}
main() {
if [[ "${is_snapshot}" == false && -z "${marketing_version}" ]]; then
echo "When no snapshot, you have to set 'marketing_version', eg 0.38.1"
echo "When no snapshot, you have to set 'marketing_version', eg v0.38.1"
if [[ "${marketing_version}" =~ ^v.* ]]; then
echo "### marketing_version must not begin with v!"
@ -38,9 +38,9 @@ main() {
local tag
if [[ "${is_snapshot}" == true ]]; then
tag="tag=snapshot/${bundle_version}"
tag="snapshot/${bundle_version}"
else
tag="tag=v${marketing_version}"
tag="v${marketing_version}-${bundle_version}"
fi
echo "bundle_version=${bundle_version} marketing_version=${marketing_version} tag=${tag}"
}