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

Missing support for opening single files outside mix project #307

Closed
4 of 6 tasks
lukaszsamson opened this issue Jun 26, 2020 · 10 comments
Closed
4 of 6 tasks

Missing support for opening single files outside mix project #307

lukaszsamson opened this issue Jun 26, 2020 · 10 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@lukaszsamson
Copy link
Collaborator

lukaszsamson commented Jun 26, 2020

https://elixirforum.com/t/vscode-autocomplete-doesnt-work-for-mix-created-projects/32624/13?u=lukaszsamson

I'm not shure we should support it. If not then it needs to be addressed in the readme

Edit:
Due to numerous request and upcoming better support for .exs scripts in elixir 1.12 I think we should support it.
Here's the short list of issues that need to be taken care of:

@axelson
Copy link
Member

axelson commented Jun 26, 2020

Yeah, I agree. I think we'd just want to add a note to the README for now. It would probably be a considerable undertaking and impact many portions of the project.

@javobalazs
Copy link

There's an (arguably minor but legitimate) case for a mode where some elixir-ls functions work outside a project, without the "No Mixfile found" warning.
I've got a "howtos" project, basically snippets, templates, and howto READMEs for very diverse things. Eg. I have a GenServer "template" with the usual stuff I usually use, together with an application.ex. ElixirLS comes handy for these files with syntax highlighting, code formatting, and whatever works in this mode. I don't want a separate project for each (Elixir) template, these are really nothing more than bigger snippets.
The config option to disable the message, as suggested in the merged issue #435 may be the simplest solution. Note too that this use case is not related to the .exs cases where the warning usually turns up.

@thbar
Copy link

thbar commented Sep 9, 2021

Mix.install/2 scripts are getting traction (e.g. https://github.com/wojtekmach/mix_install_examples), making this more relevant.

@axelson
Copy link
Member

axelson commented Dec 5, 2021

@lukaszsamson what do you think about marking this as fixed and extracting "investigate compiling & loading .exs file for better completions and diagnostic messages" and "investigate building and loading deps via Mix.install" to separate issues? I think those are different than supporting single files. Although I suppose in that case we should remove the "No Mixfile found" warning as @javobalazs mentions.

@lukaszsamson
Copy link
Collaborator Author

@axelson I extracted the issues and updated this one.

Although I suppose in that case we should remove the "No Mixfile found" warning as @javobalazs mentions.

The warning is already removed

@ZelphirKaltstahl
Copy link

I may be misunderstanding the result of this issue.

I created some exs files manually and wrote Elixir code in them. I've apparently set up elixir-ls successfully for Emacs:

[eglot] Connected! Server `ElixirLS' now managing `(elixir-mode)' buffers in project `advent-of-code-2022'.

When I open an exs file, I still see the error:

[eglot] Server reports (type=3): No mixfile found in project. To use a subdirectory, set `elixirLS.projectDir` in your settings

Why do I need a mixfile for code that is in a single file and not using any mix functionality? Is this not the issue discussed here? Should I open a new issue?

@lukaszsamson
Copy link
Collaborator Author

You are not opening a single file. You are opening a directory that is not a mix project hence you get the warning. Nothing is wrong here.

@ZelphirKaltstahl
Copy link

I am not sure I understand.

In detail I do:

  1. I do C-x C-f.
  2. tab-complete myself through the directories until the full filename is there
  3. press the return key
  4. Emacs open an exs file

How am I not opening a single file?

Good to know that it is just a warning though.

However, I do apparently see some linting from the language server, when I introduce syntax errors. Emacs does underline things and put red exclamation marks in the gutter. So the language server must be doing something and Emacs communicating with it. I still need to figure out completions though.

I guess all is as it should be then?

@lukaszsamson
Copy link
Collaborator Author

I guess all is as it should be then?

Yes. You open a directory with exs files that is not a mix project. Some mix projects have unusual directory layout and require special configuration. This warning is an attempts to discover such cases. Since you don't have a mix project you can disregard it.

Technically, what a language server considers one file is what it gets passed in initialize request rootUri. It it's a directory, then you open a directory. It it's a file then you open a single file.

@ZelphirKaltstahl
Copy link

OK thank you for confirming! Sorry for the confusion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

5 participants