emacs-lsp / lsp-mode

Emacs client/library for the Language Server Protocol
https://emacs-lsp.github.io/lsp-mode
GNU General Public License v3.0
4.8k stars 892 forks source link

Unable to add lsp-file-watch-ignored-directories #3439

Open windrg opened 2 years ago

windrg commented 2 years ago

Thank you for the bug report

Bug description

I've added few folder to the list lsp-file-watch-ignored-directories

  (with-eval-after-load 'lsp-mode
    (add-to-list 'lsp-file-watch-ignored-directories "[/\\\\]\\.repo\\'")
    (add-to-list 'lsp-file-watch-ignored-directories "[/\\\\]\\.ccls-cache\\'")
    (add-to-list 'lsp-file-watch-ignored-directories "[/\\\\]\\.clangd\\'")
    (add-to-list 'lsp-file-watch-ignored-directories "[/\\\\]\\__pycache__\\'")
    )

and I've got

======================================================================
1 -> (lsp--string-match-any ("[/\\\\]\\__pycache__\\'" "[/\\\\]\\.clangd\\'" "[/\\\\]\\.repo\\'" "[/\\\\]\\.git\\'" "[/\\\\]\\.github\\'" "[/\\\\]\\.circleci\\'" "[/\\\\]\\.hg\\'" "[/\\\\]\\.bzr\\'" "[/\\\\]_darcs\\'" "[/\\\\]\\.svn\\'" "[/\\\\]_FOSSIL_\\'" "[/\\\\]\\.idea\\'" "[/\\\\]\\.ensime_cache\\'" "[/\\\\]\\.eunit\\'" "[/\\\\]node_modules" "[/\\\\]\\.yarn\\'" "[/\\\\]\\.fslckout\\'" "[/\\\\]\\.tox\\'" "[/\\\\]dist\\'" "[/\\\\]dist-newstyle\\'" "[/\\\\]\\.stack-work\\'" "[/\\\\]\\.bloop\\'" "[/\\\\]\\.metals\\'" "[/\\\\]target\\'" "[/\\\\]\\.ccls-cache\\'" "[/\\\\]\\.vscode\\'" "[/\\\\]\\.venv\\'" "[/\\\\]\\.mypy_cache\\'" "[/\\\\]\\.deps\\'" "[/\\\\]build-aux\\'" "[/\\\\]autom4te.cache\\'" "[/\\\\]\\.reference\\'" "[/\\\\]\\.lsp\\'" "[/\\\\]\\.clj-kondo\\'" "[/\\\\]\\.shadow-cljs\\'" "[/\\\\]\\.babel_cache\\'" "[/\\\\]\\.cpcache\\'" "[/\\\\]\\checkouts\\'" "[/\\\\]\\.m2\\'" "[/\\\\]bin/Debug\\'" "[/\\\\]obj\\'" "[/\\\\]_opam\\'" "[/\\\\]_build\\'" "[/\\\\]\\.elixir_ls\\'" "[/\\\\]\\.direnv\\'") "/home/cysh/ws/src/myproject/.ccls-cache")
1 <- lsp--string-match-any: !non-local\ exit!

Steps to reproduce

add this codes and open a project


 (with-eval-after-load 'lsp-mode
    (add-to-list 'lsp-file-watch-ignored-directories "[/\\\\]\\.repo\\'")
    (add-to-list 'lsp-file-watch-ignored-directories "[/\\\\]\\.ccls-cache\\'")
    (add-to-list 'lsp-file-watch-ignored-directories "[/\\\\]\\.clangd\\'")
    (add-to-list 'lsp-file-watch-ignored-directories "[/\\\\]\\__pycache__\\'")
    )

Expected behavior

No error

Which Language Server did you use?

ccls

OS

Linux

Error callstack

No response

Anything else?

No response

yyoncho commented 2 years ago

This is failing due to with "Invalid regular expression"

windrg commented 2 years ago

Can you tell me which part is wrong in those expression, please?

mattsawyer77 commented 1 year ago

@windrg this issue had been a showstopper for me, until I figured out the underscore character was causing an issue, at least in this form of regex. I don't fully grok the regular expression patterns typically used in this list, but does replacing

"[/\\\\]\\__pycache__\\'"

with

"[/\\\\]__pycache__"

work for you?

truthdoug commented 11 months ago

I'm also having this problem. There's a whole project that I'd like to ignore. I load lsp this way:

(use-package lsp-pyright
  :ensure t
  :hook ((python-mode python-ts-mode) . (lambda ()
                                          (require 'lsp-pyright)
                                          (add-to-list 'lsp-file-watch-ignored-directories
                                                       "[/\\\\]\\ignoredprojectname\\'")
                                          (lsp))))  ; or lsp-deferred

There are a couple issues/questions I have:

  1. Why isn't my ignored project being ignored? Is there an obvious problem with my syntax?
  2. Can somebody explain the regex used here (and other examples)? What do all the slashes signify?
  3. The ignored project is not a python project and none of its files would be using python-mode or python-ts-mode. Why is lsp-file-watch looking at it in the first place?
truthdoug commented 10 months ago

Following up on my last comment. I tried putting the modification of lsp-file-watch-ignored-directories following a :config keyword and it didn't make a difference. I was still prompted if I wanted to watch the many files in this project:

(use-package lsp-pyright
  :config
  (add-to-list 'lsp-file-watch-ignored-directories "[/\\\\]\\ignoredprojectname\\'")
  :ensure t
  :hook ((python-mode python-ts-mode) . (lambda ()
                                          (require 'lsp-pyright)
                                          (lsp))))  ; or lsp-deferred