Stream: t-compiler/wg-rls-2.0

Topic: Emacs: right syntax for appending to lsp-file-watch-ignored


apiraino (Jul 18 2020 at 14:05, on Zulip):

hi, I'd like to add two more directories to the ignorelist of files watched: tests and bench.

I tried various syntax combinations to append these values to the plist defined in lsp-mode.el but I fail, ex.:
(setq lsp-file-watch-ignored "bench\\/")

gives me this error when LSp starts on that project:
Error processing message (wrong-type-argument listp "bench\\/$")

a little help? :)

Florian Diebold (Jul 18 2020 at 14:33, on Zulip):

probably something like

(add-to-list 'lsp-file-watch-ignored "bench\\/")

but I also assume the regex should rather be something like "[/\\\\]bench$", judging from the other examples

Florian Diebold (Jul 18 2020 at 14:34, on Zulip):

but also, why would you want to ignore tests and bench?

apiraino (Jul 18 2020 at 14:50, on Zulip):

hey thanks! but I get another error
Error (use-package): lsp-mode/:init: Symbol’s value as variable is void: lsp-file-watch-ignored
I wonder if it possible actually to customize it. I feel like this is not yet supported :thinking: it's not even documented

I'm trying to ignore those dirs because they contains a lot of junk related to the project but not to my rust code :)

Florian Diebold (Jul 18 2020 at 14:58, on Zulip):

it's a defcustom, so it's customizable. I guess your code gets called before lsp-mode is loaded; you may need to do it in a different section in the use-package declaration

apiraino (Jul 18 2020 at 15:00, on Zulip):

uhm ok I see. I'll try to figure it out later. thanks again :thumbs_up:

apiraino (Jul 28 2020 at 10:27, on Zulip):

ok @Florian Diebold I think I have sorted this out. I use use-package so I checked again their docs first

Before I had

(use-package lsp-mode
  :init
  (global-set-key (kbd "C-c .") 'lsp-find-definition)
  (global-set-key (kbd "C-c ,") 'pop-tag-mark)
  ... many (setq) ...
  (add-to-list ....)

  (add-hook ....)

  :hook ((rust-mode . lsp))
  :commands lsp)
apiraino (Jul 28 2020 at 10:27, on Zulip):

Then I took you hint and moved the add-to-list statement into the :config section

(use-package lsp-mode
  :init
  (global-set-key (kbd "C-c .") 'lsp-find-definition)
  (global-set-key (kbd "C-c ,") 'pop-tag-mark)
  ... many (setq) ...

  : config
  (add-to-list ....)

  (add-hook ....)

  :hook ((rust-mode . lsp))
  :commands lsp)
apiraino (Jul 28 2020 at 10:28, on Zulip):

seems that fixed, the warning does not show up anymore. But I'm not sure I did the right thing :)

apiraino (Jul 28 2020 at 10:32, on Zulip):

makes sense the above?

Florian Diebold (Jul 28 2020 at 10:36, on Zulip):

that's what I was imagining :+1:

Last update: Sep 27 2020 at 14:00UTC