ale
ale copied to clipboard
Dart Language Server Not Found
A language server now ships with Dart. The problem is determining the correct path...
Find the right path for the Language Server
I'm using snap
on Manjaro. I found the correct directory for the SDK by running snap run --shell flutter
and echo $SNAP_USER_COMMON
. Based on these instructions.
Snap puts the flutter SDK at: ~/snap/flutter/common/flutter/bin/cache/dart-sdk/
. Meanwhile which flutter
returns /var/lib/snapd/snap/bin/flutter
. Snap's structure is pretty convoluted for our purposes.
Current Workaround
Based on this, I created a script called dart_language_server
on my path with the following contents:
#!/bin/sh
dart ~/snap/flutter/common/flutter/bin/cache/dart-sdk/bin/snapshots/analysis_server.dart.snapshot --lsp
And chmod 755 dart_language_server
.
This allows ALE to find the command without any further modification.
Preferred Alternative: Setting via Vim Config
I also tried setting:
let g:ale_dart_language_server_executable = 'dart ~/snap/flutter/common/flutter/bin/cache/dart-sdk/bin/snapshots/analysis_server.dart.snapshot --lsp'
But this was no good - ALE runs a file exists check and it fails.
Conclusions
Creating a new shell script works, but it would feel nicer if this could be handled through configuration. That way it would be consolidated with my Vim configuration and checked into source control rather than being a manual modification to my filesystem. Is there a way to do this through config?