Skip to content

Commit e96968b

Browse files
authored
`lsp-file-watch-ignored': use proper regexes (#2208)
* `lsp-file-watch-ignored': use proper regexes Emacs regexes specify the end of string using \', not $ as was used in that variable (the latter matching *either* the end of the line or the string, which could cause issues with files that have newlines in them (Linux allows this)). Fix that by using \' for the end of string character instead. Also properly handle node_modules. It is not necessarily always at the root of the project, as is the case with .pyi files needed by pyright, which are in a node_modules folder somewhere in the user's home directory. This causes annoyances after Emacs-restarts, with `lsp' prompting the user to watch 11+k immutable files. Fix that by removing the `eos' matcher and matching a slash after "node_modules". * Don't watch node_modules at project root After the previous commit, node_modules would only be watched in the middle of a path, due to the slash at the end, which is possibly not sent by language servers. Now, don't require a trailing slash when ignoring node_modules. Files like node_modules<foobar> would still not get watched though, but that shouldn't cause issues. Also, in `lsp' auto-loading, remove the `featurep' check around `require', since that is done by the former anyway. * Revert the unless (featurep) check It is unrelated to this PR, so remove it. Whether to change that should be left to further discussion.
1 parent 0fda1e2 commit e96968b

File tree

1 file changed

+27
-26
lines changed

1 file changed

+27
-26
lines changed

lsp-mode.el

Lines changed: 27 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -480,32 +480,32 @@ the server has requested that."
480480
;;;###autoload(put 'lsp-enable-file-watchers 'safe-local-variable #'booleanp)
481481

482482
(defcustom lsp-file-watch-ignored '(; SCM tools
483-
"[/\\\\]\\.git$"
484-
"[/\\\\]\\.hg$"
485-
"[/\\\\]\\.bzr$"
486-
"[/\\\\]_darcs$"
487-
"[/\\\\]\\.svn$"
488-
"[/\\\\]_FOSSIL_$"
483+
"[/\\\\]\\.git\\'"
484+
"[/\\\\]\\.hg\\'"
485+
"[/\\\\]\\.bzr\\'"
486+
"[/\\\\]_darcs\\'"
487+
"[/\\\\]\\.svn\\'"
488+
"[/\\\\]_FOSSIL_\\'"
489489
;; 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$"
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\\'"
504504
;; Autotools output
505-
"[/\\\\]\\.deps$"
506-
"[/\\\\]build-aux$"
507-
"[/\\\\]autom4te.cache$"
508-
"[/\\\\]\\.reference$")
505+
"[/\\\\]\\.deps\\'"
506+
"[/\\\\]build-aux\\'"
507+
"[/\\\\]autom4te.cache\\'"
508+
"[/\\\\]\\.reference\\'")
509509
"List of regexps matching directory paths which won't be monitored when creating file watches."
510510
:group 'lsp-mode
511511
:type '(repeat string)
@@ -7678,13 +7678,14 @@ When ARG is t the lsp mode will start new language server even if
76787678
there is language server which can handle current language. When
76797679
ARG is nil current file will be opened in multi folder language
76807680
server if there is such. When `lsp' is called with prefix
7681-
argument ask the user to select which language server to start. "
7681+
argument ask the user to select which language server to start."
76827682
(interactive "P")
76837683

76847684
(when (and lsp-auto-configure (not lsp--client-packages-required))
76857685
(seq-do (lambda (package)
76867686
;; loading client is slow and `lsp' can be called repeatedly
7687-
(unless (featurep package) (require package nil t)))
7687+
(unless (featurep package)
7688+
(require package nil t)))
76887689
lsp-client-packages)
76897690
(setq lsp--client-packages-required t))
76907691

0 commit comments

Comments
 (0)