Skip to content

Commit 0a88ec8

Browse files
authored
Merge pull request #18 from clojure-vim/confi-open
Open new and/or alternate file config
2 parents 88c74a1 + 95efc1a commit 0a88ec8

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

rplugin/python3/acid/commands/alternate_file.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ def prepare_payload(self):
4040
path = current_file(self.nvim)
4141
root_path = current_path(self.nvim)
4242
rel_path = os.path.relpath(path, start=root_path).split('/')
43+
open_with = nvim.vars.get(
44+
'acid_open_alternate_file_with',
45+
nvim.vars.get('acid_open_new_file_with', 'edit')
46+
)
4347

4448
if rel_path[0] in src:
4549
log_debug("Current file is a 'src', changing to 'test'")
@@ -57,7 +61,7 @@ def prepare_payload(self):
5761
)
5862

5963
if os.path.exists(alt_path):
60-
self.nvim.command('edit {}'.format(alt_path))
64+
self.nvim.command('silent {} {}'.format(open_with, alt_path))
6165
else:
6266
ns = path_to_ns(alt_path, test | src)
6367
self.nvim.command('AcidNewFile {}'.format(ns))

rplugin/python3/acid/commands/new.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,13 @@ def prompt_default(nvim):
2323
def prepare_payload(self, ns):
2424
fname = "{}.clj".format(ns_to_path(ns))
2525
base = 'test' if ns.endswith('-test') else 'src'
26+
open_with = nvim.vars.get('acid_open_new_file_with', 'edit')
2627
path = os.path.join(current_path(self.nvim), base, fname)
2728

2829
with open(path, 'w') as fpath:
2930
fpath.write('(ns {})'.format(ns))
3031

31-
self.nvim.command('silent edit {}'.format(path))
32+
self.nvim.command('silent {} {}'.format(open_with, path))
3233

3334
# Does not interact with nrepl
3435
return None

0 commit comments

Comments
 (0)