@@ -479,46 +479,72 @@ the server has requested that."
479479 :package-version '(lsp-mode . "6.1"))
480480;;;###autoload(put 'lsp-enable-file-watchers 'safe-local-variable #'booleanp)
481481
482- (defcustom lsp-file-watch-ignored '(; SCM tools
483- "[/\\\\]\\.git\\'"
484- "[/\\\\]\\.hg\\'"
485- "[/\\\\]\\.bzr\\'"
486- "[/\\\\]_darcs\\'"
487- "[/\\\\]\\.svn\\'"
488- "[/\\\\]_FOSSIL_\\'"
489- ;; IDE or build tools
490- "[/\\\\]\\.idea\\'"
491- "[/\\\\]\\.ensime_cache\\'"
492- "[/\\\\]\\.eunit\\'"
493- "[/\\\\]node_modules"
494- "[/\\\\]\\.fslckout\\'"
495- "[/\\\\]\\.tox\\'"
496- "[/\\\\]dist\\'"
497- "[/\\\\]dist-newstyle\\'"
498- "[/\\\\]\\.stack-work\\'"
499- "[/\\\\]\\.bloop\\'"
500- "[/\\\\]\\.metals\\'"
501- "[/\\\\]target\\'"
502- "[/\\\\]\\.ccls-cache\\'"
503- "[/\\\\]\\.vscode\\'"
504- ;; Autotools output
505- "[/\\\\]\\.deps\\'"
506- "[/\\\\]build-aux\\'"
507- "[/\\\\]autom4te.cache\\'"
508- "[/\\\\]\\.reference\\'"
509- ;; .Net Core build-output
510- "[/\\\\]bin/Debug\\'"
511- "[/\\\\]obj\\'")
482+ (define-obsolete-variable-alias 'lsp-file-watch-ignored 'lsp-file-watch-ignored-directories "7.1.0")
483+
484+ (defcustom lsp-file-watch-ignored-directories
485+ '(; SCM tools
486+ "[/\\\\]\\.git\\'"
487+ "[/\\\\]\\.hg\\'"
488+ "[/\\\\]\\.bzr\\'"
489+ "[/\\\\]_darcs\\'"
490+ "[/\\\\]\\.svn\\'"
491+ "[/\\\\]_FOSSIL_\\'"
492+ ;; IDE or build tools
493+ "[/\\\\]\\.idea\\'"
494+ "[/\\\\]\\.ensime_cache\\'"
495+ "[/\\\\]\\.eunit\\'"
496+ "[/\\\\]node_modules"
497+ "[/\\\\]\\.fslckout\\'"
498+ "[/\\\\]\\.tox\\'"
499+ "[/\\\\]dist\\'"
500+ "[/\\\\]dist-newstyle\\'"
501+ "[/\\\\]\\.stack-work\\'"
502+ "[/\\\\]\\.bloop\\'"
503+ "[/\\\\]\\.metals\\'"
504+ "[/\\\\]target\\'"
505+ "[/\\\\]\\.ccls-cache\\'"
506+ "[/\\\\]\\.vscode\\'"
507+ ;; Autotools output
508+ "[/\\\\]\\.deps\\'"
509+ "[/\\\\]build-aux\\'"
510+ "[/\\\\]autom4te.cache\\'"
511+ "[/\\\\]\\.reference\\'"
512+ ;; .Net Core build-output
513+ "[/\\\\]bin/Debug\\'"
514+ "[/\\\\]obj\\'")
512515 "List of regexps matching directory paths which won't be monitored when creating file watches."
513516 :group 'lsp-mode
514517 :type '(repeat string)
515- :package-version '(lsp-mode . "6.1"))
516-
517- (defun lsp-file-watch-ignored ()
518- lsp-file-watch-ignored)
518+ :package-version '(lsp-mode . "7.1.0"))
519+
520+ (define-obsolete-function-alias 'lsp-file-watch-ignored 'lsp-file-watch-ignored-directories "7.0.1")
521+
522+ (defun lsp-file-watch-ignored-directories ()
523+ lsp-file-watch-ignored-directories)
524+
525+ ;; Allow lsp-file-watch-ignored-directories as a file or directory-local variable
526+ (put 'lsp-file-watch-ignored-directories 'safe-local-variable 'lsp--string-listp)
527+
528+ (defcustom lsp-file-watch-ignored-files
529+ '(
530+ ;; lockfiles
531+ "[/\\\\]\\.#[^/\\\\]+\\'"
532+ ;; backup files
533+ "[/\\\\][^/\\\\]+~\\'" )
534+ "List of regexps matching files for which change events will
535+ not be sent to the server.
536+
537+ This setting has no impact on whether a file-watch is created for
538+ a directory; it merely prevents notifications pertaining to
539+ matched files from being sent to the server. To prevent a
540+ file-watch from being created for a directory, customize
541+ `lsp-file-watch-ignored-directories'"
542+ :group 'lsp-mode
543+ :type '(repeat string)
544+ :package-version '(lsp-mode . "7.1.0"))
519545
520- ;; Allow lsp-file-watch-ignored as a file or directory-local variable
521- (put 'lsp-file-watch-ignored 'safe-local-variable 'lsp--string-listp)
546+ ;; Allow lsp-file-watch-ignored-files as a file or directory-local variable
547+ (put 'lsp-file-watch-ignored-files 'safe-local-variable 'lsp--string-listp)
522548
523549(defcustom lsp-after-uninitialized-functions nil
524550 "List of functions to be called after a Language Server has been uninitialized."
@@ -1743,7 +1769,7 @@ This set of allowed chars is enough for hexifying local file paths.")
17431769 (cond
17441770 ((and (file-directory-p file-name)
17451771 (equal 'created event-type)
1746- (not (lsp--string-match-any (lsp-file-watch-ignored) file-name)))
1772+ (not (lsp--string-match-any (lsp-file-watch-ignored-directories ) file-name)))
17471773
17481774 (lsp-watch-root-folder (file-truename file-name) callback watch)
17491775
@@ -1754,11 +1780,12 @@ This set of allowed chars is enough for hexifying local file paths.")
17541780 (unless (file-directory-p f)
17551781 (funcall callback (list nil 'created f)))))))
17561782 ((and (not (file-directory-p file-name))
1783+ (not (lsp--string-match-any lsp-file-watch-ignored-files file-name))
17571784 (memq event-type '(created deleted changed)))
17581785 (funcall callback event)))))
17591786
17601787(defun lsp--directory-files-recursively (dir regexp &optional include-directories)
1761- "Copy of `directory-files-recursively' but it skips `lsp-file-watch-ignored'."
1788+ "Copy of `directory-files-recursively' but it skips `lsp-file-watch-ignored-directories '."
17621789 (let* ((result nil)
17631790 (files nil)
17641791 (dir (directory-file-name dir))
@@ -1769,7 +1796,7 @@ This set of allowed chars is enough for hexifying local file paths.")
17691796 'string<))
17701797 (unless (member file '("./" "../"))
17711798 (if (and (directory-name-p file)
1772- (not (lsp--string-match-any (lsp-file-watch-ignored) (f-join dir (f-filename file)))))
1799+ (not (lsp--string-match-any (lsp-file-watch-ignored-directories ) (f-join dir (f-filename file)))))
17731800 (let* ((leaf (substring file 0 (1- (length file))))
17741801 (full-file (f-join dir leaf)))
17751802 ;; Don't follow symlinks to other directories.
@@ -1838,7 +1865,7 @@ already have been created."
18381865 (file-truename f)
18391866 f)
18401867 (lsp-watch-descriptors watch)))
1841- (not (lsp--string-match-any (lsp-file-watch-ignored) f))
1868+ (not (lsp--string-match-any (lsp-file-watch-ignored-directories ) f))
18421869 (not (-contains? '("." "..") (f-filename f)))))
18431870 (directory-files dir t))))
18441871 (error (lsp-log "Failed to create a watch for %s: message" (error-message-string err)))
0 commit comments