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

Have elixir_ls ignore files and directories #448

Closed
alecStewart1 opened this issue Jan 3, 2021 · 6 comments
Closed

Have elixir_ls ignore files and directories #448

alecStewart1 opened this issue Jan 3, 2021 · 6 comments
Labels
help wanted Extra attention is needed

Comments

@alecStewart1
Copy link

alecStewart1 commented Jan 3, 2021

Environment

  • elixir --version;
Erlang/OTP 23 [erts-11.1.4] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [hipe]

Elixir 1.11.0 (compiled with Erlang/OTP 23)
  • OS:

    Artix Linux.

    uname -a:

Linux my-artix 5.9.14-artix1-1 #1 SMP PREEMPT Sat, 12 Dec 2020 22:57:38 +0000 x86_64 GNU/Linux
  • Editor:

    Emacs 27.1

  • Editor Plugin

    lsp-mode

Hello!

Thank you for everyone who created and contributes to elixir_ls.

If there's one thing I can ask for with elixir_ls is for the ability to specify files and directories for elixir_ls no to look at or in.

Using Emacs and starting a Phoenix project, Emacs's lsp-mode will tell me

There are 3477 files in folder /home/my_user/Projects/Elixir/my_phoenix_app so watching the repo may slow Emacs down.
Do you want to watch all files in /home/my_user/Projects/Elixir/my_phoenix_app? (y or no) 

I imagine that's deps, and/or _build. Is it possible to have elixir_ls ignore those directories?

@lukaszsamson
Copy link
Collaborator

A PR would be welcome. The watcher is created here

watchers = for ext <- @watched_extensions, do: %{"globPattern" => "**/*." <> ext}

@lukaszsamson lukaszsamson added the help wanted Extra attention is needed label Jan 11, 2021
@axelson
Copy link
Member

axelson commented Jan 14, 2021

This is an lsp-mode limitation emacs-lsp/lsp-mode#713 I'm not sure that we can do anything to override that on the ElixirLS side. I did just start trying out a snippet that you could use in your emacs configuration:

;; Elixir: Ignore some common directories that don't need to be watched
(after! lsp-mode
  (dolist (match
           '("[/\\\\].direnv$"
             "[/\\\\]node_modules$"
             "[/\\\\]deps"
             "[/\\\\]build"
             "[/\\\\]_build"))
    (add-to-list 'lsp-file-watch-ignored match)))

But I'm not sure how well that is working so far.

@peaceful-james
Copy link

This is an lsp-mode limitation emacs-lsp/lsp-mode#713 I'm not sure that we can do anything to override that on the ElixirLS side. I did just start trying out a snippet that you could use in your emacs configuration:

;; Elixir: Ignore some common directories that don't need to be watched
(after! lsp-mode
  (dolist (match
           '("[/\\\\].direnv$"
             "[/\\\\]node_modules$"
             "[/\\\\]deps"
             "[/\\\\]build"
             "[/\\\\]_build"))
    (add-to-list 'lsp-file-watch-ignored match)))

But I'm not sure how well that is working so far.

I have tried using this and it doesn't work for me. I find I have to set the variable explicitly in the user-config section of my .spacemacs file, like this:

  (setq lsp-file-watch-ignored
        '(".idea" ".ensime_cache" ".eunit" "node_modules"
          ".git" ".hg" ".fslckout" "_FOSSIL_"
          ".bzr" "_darcs" ".tox" ".svn" ".stack-work"
          "build" "_build" "deps" "postgres-data")
        )

@howdoicomputer
Copy link

@peaceful-james Probably because after! is a macro that is built into Doom Emacs. https://github.com/hlissner/doom-emacs/blob/b681a2e1b4d7884e5836c471f364bb4cbcd39978/core/core-lib.el#L333

His block worked for me.

@arosenb2
Copy link

It might be useful to use a project's gitignore file as a starting point for what to ignore

@alexpls
Copy link

alexpls commented Apr 16, 2023

A bunch of these directories are now ignored by default.

In my case, adding the following to my config.el (Doom) was enough to get rid of the warning:

; Elixir: Ignore files which don't need to be watched
; https://emacs-lsp.github.io/lsp-mode/page/file-watchers/
(after! lsp-mode
  (dolist (match
           '("[/\\\\]_build\\'"
             "[/\\\\]deps\\'"))
    (add-to-list 'lsp-file-watch-ignored-directories match)))

@lukaszsamson lukaszsamson closed this as not planned Won't fix, can't repro, duplicate, stale Jun 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

7 participants