elixir-ls icon indicating copy to clipboard operation
elixir-ls copied to clipboard

Have elixir_ls ignore files and directories

Open alecStewart1 opened this issue 4 years ago • 4 comments

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?

alecStewart1 avatar Jan 03 '21 00:01 alecStewart1

A PR would be welcome. The watcher is created here https://github.com/elixir-lsp/elixir-ls/blob/9fc218835e2e08ac8157f3c3af4d9c037be7d78f/apps/language_server/lib/language_server/server.ex#L240

lukaszsamson avatar Jan 11 '21 21:01 lukaszsamson

This is an lsp-mode limitation https://github.com/emacs-lsp/lsp-mode/issues/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.

axelson avatar Jan 14 '21 18:01 axelson

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")
        )

peaceful-james avatar Mar 08 '21 10:03 peaceful-james

@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.

howdoicomputer avatar Mar 10 '21 22:03 howdoicomputer

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

arosenb2 avatar Oct 21 '22 20:10 arosenb2

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)))

alexpls avatar Apr 16 '23 07:04 alexpls