Fork me on GitHub
#lsp
<
2023-11-27
>
borkdude16:11:31

has anyone else noticed that linting only gets applied post saving a file? I have this behavior since a day or so

ericdallo16:11:23

I can't repro that, you mean that you updated lsp-mode or some package?

borkdude16:11:03

yeah, I guess so but I don't know which one 😢

ericdallo16:11:29

I can try to update lsp-mode and check

ericdallo16:11:03

updated lsp-mode and it's still working for me

Ed10:11:04

If you copied and pasted the settings that I pasted you the other day, you may have (setq flycheck-check-syntax-automatically '(save mode-enabled))? I think this makes flymake only actually run the linter when the file is saved?

Ed10:11:51

that was terribly worded ... that's what I get for trying to type on slack during a meeting ... https://clojurians.slack.com/archives/C099W16KZ/p1700920735589559?thread_ts=1700910274.477479&amp;cid=C099W16KZ ... that snippet sets flycheck to only check syntax on save, and I think that's how lsp-mode works? Does that make more sense?

borkdude10:11:58

@U0P0TMEFJ Ah so that was what was going on! I already wondered in #CPABC1H61 what got me into this new behavior! thanks!

borkdude10:11:17

undid this now

👍 1
borkdude12:11:04

@U0P0TMEFJ Do you know what linter is used in this lsp server and how to configure it? I assumed it was eslint, but no matter how I configure things it doesn't work

Ed12:11:49

in the js/ts lsp server?

Ed12:11:07

I think I'm running eslint

Ed12:11:37

what do you get when you run flycheck-verifiy-setup?

Ed12:11:04

Syntax checkers for buffer index.ts<auth-service/src> in typescript-mode:

First checker to run:

  lsp (explicitly selected)
    - may enable: yes
    - may run:    t

Checkers that could run if selected:

  javascript-eslint  select
    - may enable:  yes
    - executable:  Found at /var/home/ed/bin/npx-eslint
    - config file: found

  typescript-tslint  select
    - may enable:         yes
    - executable:         Found at /var/home/ed/bin/npx-tslint
    - configuration file: Not found

borkdude12:11:19

Syntax checkers for buffer core.js in js2-mode:

First checker to run:

  lsp (explicitly selected)
    - may enable: yes
    - may run:    t

Checkers that are compatible with this mode, but will not run until properly configured:

  javascript-eslint (automatically disabled) reset
    - may enable:  no
    - executable:  Not found
    - config file: missing or incorrect

  javascript-jshint (automatically disabled) reset
    - may enable:         no
    - executable:         Not found
    - configuration file: Not found

  javascript-standard (automatically disabled) reset
    - may enable: no
    - executable: Not found

Flycheck Mode is enabled.  Use C-u C-c ! x to enable disabled checkers.

--------------------

Flycheck version: 33snapshot (package: 20230813.620)
Emacs version:    29.1
System:           aarch64-apple-darwin21.6.0
Window system:    mac

borkdude12:11:39

I am trying to suppress this one:

borkdude12:11:46

but no luck so far

borkdude12:11:45

perhaps this is some typescript thing

ericdallo12:11:03

I didn't know about this flycheck feature, interesting

borkdude12:11:06

I have no idea where this warning is coming from

Ed12:11:53

you can run flycheck-compile and it will ask for a linter to run

borkdude12:11:08

o ffff me:

// deno-lint-ignore require-yield
      

borkdude12:11:13

what is deno-lint

Ed12:11:11

dunno ... but I've heard of deno ... https://deno.com/ ... so something to do with that????

borkdude12:11:25

I not using deno...

borkdude12:11:38

I just installed whatever lsp server it asked me to, perhaps it's just that

borkdude12:11:48

how can I check this @UKFSJSM38 😆

ericdallo12:11:13

maybe lsp-describe-session

borkdude12:11:30

yeah it's deno-ls

ericdallo12:11:44

there is lsp-uninstall-server and lsp-install-server

ericdallo12:11:53

(in case you installed via emacs lsp-mode)

Ed12:11:00

eslint + ts-ls ... they're written in my modeline

borkdude12:11:48

hmm I don't remember installing this server and it doesn't appear with lsp-uninstall-server

ericdallo12:11:27

try list-process and check if you can find the path to that

borkdude12:11:52

ah it just runs deno ls maybe as a fallback?

borkdude12:11:36

I had deno installed. Anyway I can live with this

Ed12:11:35

so it turns out that I have some things in my custom.el

'(flycheck-javascript-eslint-executable "~/bin/npx-eslint")
and
'(flycheck-typescript-tslint-executable "~/bin/npx-tslint")
that point at shell scripts that load the npm env from things like .nvmrc files and run npx inside the project - so I don't have to rely on switching node versions for different projects and so on

borkdude12:11:39

npm i -g typescript-language-server typescript
switches it to ts-ls automatically

Ed12:11:24

cool ... and maybe I've done that in the past too? ... apologies for leading you astray

borkdude12:11:05

no worries!

Ed12:11:35

but I tend to try and avoid installing things globally - I'm a contractor and have to work on lots of different people's code bases - so I spin up containers with podman for each client which lets me have many different dev envs on the same laptop (I use fedora silverblue which makes the whole thing a bit more straight forward 😉 )

borkdude12:11:16

yeah I totally get that

borkdude12:11:40

I don't know how to enable eslint via lsp

borkdude12:11:03

here on this page it says: https://emacs-lsp.github.io/lsp-mode/page/lsp-eslint/ lsp-eslint-enable but I don't get this command...

borkdude12:11:09

maybe a separate package to install?

Ed12:11:49

I don't have any eslint packages installed

ericdallo12:11:30

AFAICS there is a server to be installed via lsp-install-server eslint

ericdallo13:11:13

I don't use those server installations via lsp-mode as well (especially because I'm a nix user), but a nice idea would be to follow the nix approach and have a way to declare in your config the servers you want installed and lsp-mode just install/uninstall it automatically or so, then you will have a way to control what you want installed and what not in a declarative way (like nix)

Ed13:11:22

yeah ... I've been looking at this https://www.jetpack.io/devbox/ ... it looks like it does what silverblue's toolbox does, but with nix? ... not got around to trying it yet though 😉

ericdallo13:11:37

interesting, looks like a wrapper for nix in a more intuitive way perhaps

Ed13:11:34

I spin up an container for each contract I'm working on ... but that includes emacs every time - so if I'm working on 2 different things I have 2 emacs servers running (and need to specify a socket for them to communicate on) ... but they share my emacs config dir - so sometimes I've run 2 different emacs versions with the same ~/.emacs.d/ and come across compilation problems where packages work in one but not the other ... it happens rarely but it's a pain when it does happen

Ed13:11:14

I use this to isolate things atm https://docs.fedoraproject.org/en-US/fedora-silverblue/toolbox/ ... the nix approach that the devbox thing uses seems like it could be nicer

borkdude13:11:33

somehow I still don't get linting from eslint...

borkdude13:11:50

and on the command line it only complains about something which is valid:

const x = 10;
const is a reserved word, yah duh

borkdude13:11:37

ah now it works after some init ceremony