lsp-mode icon indicating copy to clipboard operation
lsp-mode copied to clipboard

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

Open windrg opened this issue 2 years ago • 5 comments

Thank you for the bug report

  • [X] I am using the latest version of lsp-mode related packages.
  • [X] I checked FAQ and Troubleshooting sections
  • [ ] You may also try reproduce the issue using clean environment using the following command: M-x lsp-start-plain

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

windrg avatar Mar 30 '22 14:03 windrg

This is failing due to with "Invalid regular expression"

yyoncho avatar Mar 30 '22 14:03 yyoncho

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

windrg avatar Apr 01 '22 01:04 windrg

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

mattsawyer77 avatar Jan 23 '23 18:01 mattsawyer77

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 avatar Dec 13 '23 15:12 truthdoug

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

truthdoug avatar Jan 18 '24 20:01 truthdoug