Skip to content
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

Presence of .merlin.skip-if-not-cwd skips config in dir #1870

Open
wants to merge 45 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
9be57bf
Prepare for release 4.15-414
voodoos May 31, 2024
89e00d2
[B] Merge pull request #1758 from xvw/tunneling-merlin-lsp-p1-split-p…
voodoos Jun 10, 2024
060404c
[B] Merge pull request #1778 from voodoos/find-command-opt
voodoos Jun 10, 2024
d129d7e
Prepare for release v4.16-414
voodoos Jun 10, 2024
5a98d88
Remove duplicate entry in changelog
voodoos Jun 10, 2024
16a1274
Merge pull request #1782 from voodoos/backports-414
voodoos Jun 10, 2024
a903759
Backport changes from issue #1798
bschommer Sep 11, 2024
10d3659
Backported Changes entry.
bschommer Sep 11, 2024
86c2a26
Merge pull request #1818 from bschommer/backport-1798
voodoos Sep 12, 2024
c3b78f8
[B] SOURCE_ROOT, UNIT_NAME and WRAPPING_PREFIX
voodoos Sep 25, 2024
570cd57
[B] #1795: Fix #1794: Add `-unboxed-types` and `-no-unboxed-types` to…
voodoos Sep 25, 2024
9d76cd6
[B] #1804 vim: remove references to MerlinPhrase
voodoos Sep 25, 2024
9ac5dea
[B] #1806 Ignore new Menhir deprecations
voodoos Sep 25, 2024
7eed27a
[B] #1800 Refinement in the presence of optional arguments
voodoos Sep 25, 2024
b8d97d5
[B] #1807 Check always that default args are option
voodoos Sep 25, 2024
f9901b1
[B] #1803 Fix ignorance of STDLIB in .merlin
voodoos Sep 25, 2024
cfa3683
[B] #1745 Expand PPX nodes
voodoos Sep 25, 2024
c4efe5c
[B] #1810 Produce a better error message when a flag spec appears mul…
voodoos Sep 25, 2024
a2105f4
[B] #1812 Inlay hint upstreaming
voodoos Sep 25, 2024
797e2a9
[B] #1814 Some UI improvement for `emacs/merlin-search`
voodoos Sep 25, 2024
55182d3
[B] #1811 Exposes some helper for reducing direct typedtree usage in Lsp
voodoos Sep 25, 2024
cdda0ec
[B] #1720 Signature Help
voodoos Sep 25, 2024
e438ad6
Compat with new occurrences api
voodoos Sep 25, 2024
5d5a94f
Setup codebase formatting and fix a few comments.
voodoos Sep 25, 2024
9f8a3c8
Format the codebase
voodoos Sep 25, 2024
f5f686e
Add commit to ignored revs
voodoos Sep 25, 2024
cb0da02
[B] #1828 Search by type feature, a kind of sherlodoc in Merlin
voodoos Sep 25, 2024
eaa241d
Promote fixed test after Dune upgrade
voodoos Sep 25, 2024
bbc283a
Silence ld warnings in tests
voodoos Sep 25, 2024
78d96ee
Enable github CI
voodoos Sep 25, 2024
59a67b4
[B] #1839 Fix ignorance of SOURCE_ROOT directive
voodoos Sep 25, 2024
16e46ba
Make deps explicit
patrick-nicodemus Sep 25, 2024
e7ed700
[B] #1841 Document missing commands in PROTOCOL.md
voodoos Sep 26, 2024
611e0ec
Prepare changelog for release 4.17-414
voodoos Sep 26, 2024
1d0b5a9
[B] Promote sherlodoc parser to sources
voodoos Sep 27, 2024
b17f7d1
Update changelog for release 4.17.1
voodoos Sep 27, 2024
44c1124
Update opam deps
voodoos Sep 27, 2024
3e61631
[B] #1854 Fix `EXCLUDE_QUERY_DIR` for cmt files
voodoos Nov 26, 2024
f6ea671
[B] #1856 Fix 1852 packaging issues
voodoos Nov 26, 2024
614add9
[B] #1858 from xvw/fix-1113 Fix #1113
voodoos Nov 26, 2024
758f839
[B] #1864 Fix type enclosing deduplication
voodoos Nov 26, 2024
162aa66
Prepare release 4.18-414
voodoos Nov 26, 2024
ee816ec
Remove strict dependency on dot-merlin-reader
voodoos Nov 26, 2024
2b9cd21
Merge pull request #1866 from voodoos/414-4.18-backports
voodoos Nov 26, 2024
e09ade6
Presence of .merlin.skip-if-not-cwd skips config in dir
jonahbeckford Dec 1, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Presence of .merlin.skip-if-not-cwd skips config in dir
jonahbeckford committed Dec 21, 2024
commit e09ade6d40dfb7f5c566bc3366057b27f05ca628
41 changes: 27 additions & 14 deletions src/kernel/mconfig_dot.ml
Original file line number Diff line number Diff line change
@@ -404,25 +404,38 @@ let find_project_context start_dir =
then Some dir
else None
in
let cwd = Sys.getcwd () in
let cwd = Misc.canonicalize_filename ~cwd cwd in

let rec loop workdir dir =
try
Some
(List.find_map [ ".merlin"; "dune-project"; "dune-workspace" ]
~f:(fun f ->
let fname = Filename.concat dir f in
if Sys.file_exists fname && not (Sys.is_directory fname) then
(* When starting [dot-merlin-reader] from [dir]
(List.find_map [
".merlin.skip-if-not-cwd";
".merlin"; "dune-project"; "dune-workspace"
]
~f:(fun f ->
let fname = Filename.concat dir f in
if Sys.file_exists fname && not (Sys.is_directory fname)
then (
(* Special case:
1. exists .merlin.skip-if-not-cwd
2. not cwd (aka. `cwd <> dir`) *)
if f = ".merlin.skip-if-not-cwd" then (
if cwd <> Misc.canonicalize_filename ~cwd dir then
raise Not_found
else None)
else
(* When starting [dot-merlin-reader] from [dir]
the workdir is always [dir] *)
let workdir = if f = ".merlin" then None else workdir in
let workdir = Option.value ~default:dir workdir in
Some
( { workdir;
process_dir = dir;
configurator = Option.get (Configurator.of_string_opt f)
},
fname )
else None))
let workdir = if f = ".merlin" then None else workdir in
let workdir = Option.value ~default:dir workdir in
Some ({
workdir;
process_dir = dir;
configurator = Option.get (Configurator.of_string_opt f)
}, fname))
else None))
with Not_found ->
let parent = Filename.dirname dir in
if parent <> dir then
10 changes: 9 additions & 1 deletion src/kernel/mconfig_dot.mli
Original file line number Diff line number Diff line change
@@ -80,6 +80,14 @@ val get_config : context -> string -> config * string list
- dune-project
- dune-workspace

They are detected in that order. [dune] and [jbuild] file do not need to be taken into account because any project using a recent version of dune should have a dune-project file which is even auto-generated when it is missing. And only recent versions of dune will stop writing .merlin files.
They are detected in that order. [dune] and [jbuild] file do not need to
be taken into account because any project using a recent version of dune
should have a dune-project file which is even auto-generated when it is
missing. And only recent versions of dune will stop writing .merlin files.

The presence of the file [".merlin.skip-if-not-cwd"] in a directory means
that the three (3) project configuration files are {b not} checked if the
directory containing [".merlin.skip-if-not-cwd"] is not the current
working directory.
*)
val find_project_context : string -> (context * string) option