Eglot stopped returning completions for dart-mode #1405
-
I have a small issue that I would greatly appreciate help with. I have been using Corfu, Eglot, and dart-mode to develop for about 6 weeks, and everything worked fine. However, last week while writing code, Corfu stopped showing autocompletion for dart/flutter regardless of what I tried. Here is my config relating to Flutter Corfu and Eglot. Corfu still shows auto-completion for all the other languages I develop in, so this points to me believing the issue might be with eglot interacting with the dart language server. Here is my config: (setq tab-always-indent 'complete)
(when (maybe-require-package 'orderless)
(with-eval-after-load 'vertico
(require 'orderless)
(setq completion-styles '(orderless basic))))
(setq completion-category-defaults nil
completion-category-overrides nil)
(setq completion-cycle-threshold 4)
(when (maybe-require-package 'corfu)
(setq-default corfu-auto t)
(with-eval-after-load 'eshell
(add-hook 'eshell-mode-hook (lambda () (setq-local corfu-auto nil))))
(setq-default corfu-quit-no-match 'separator)
(add-hook 'after-init-hook 'global-corfu-mode)
(with-eval-after-load 'corfu
(corfu-popupinfo-mode))
;; Make Corfu also work in terminals, without disturbing usual behaviour in GUI
(when (maybe-require-package 'corfu-terminal)
(with-eval-after-load 'corfu
(corfu-terminal-mode)))
)
(use-package svg-lib)
(use-package kind-icon
:ensure t
:after corfu
:custom
(kind-icon-blend-background t)
(kind-icon-default-face 'corfu-default) ; only needed with blend-background
:config
(add-to-list 'corfu-margin-formatters #'kind-icon-margin-formatter))
(when (maybe-require-package 'eglot)
(maybe-require-package 'consult-eglot))
(with-eval-after-load 'eglot
(add-to-list 'eglot-server-programs '((web-mode) . ("typescript-language-server")))
(add-to-list 'eglot-server-programs '((rust-mode rust-ts-mode) . ("rust-analyzer"))))
(dolist (mode '(bash-ts-mode-hook
c-mode-hook
css-mode-hook
css-ts-mode-hook
closure-ts-mode-hook
dart-mode-hook
dockerfile-mode-hook
js-mode-hook
js-ts-mode-hook
less-css-mode-hook
php-mode-hook
python-mode-hook
python-ts-mode-hook
prisma-ts-mode-hook
ruby-mode-hook
ruby-ts-mode-hook
rust-mode-hook
go-mode-hook
go-ts-mode-hook
rust-ts-mode-hook
sass-mode-hook
scss-mode-hook
terraform-mode-hook
typescript-mode-hook
tsx-ts-mode-hook
ts-mode-hook
yaml-mode-hook
c++-mode-hook))
(add-hook mode 'eglot-ensure))
;; Assuming usage with dart-mode
(use-package dart-mode
;; Optional
:hook (dart-mode . flutter-test-mode))
(use-package flutter
:after dart-mode
:bind (:map dart-mode-map
("C-M-x" . #'flutter-run-or-hot-reload))
:custom
(flutter-sdk-path "/opt/homebrew/bin/flutter"))
(reformatter-define dart-format
:program "dart"
:args '("format"))
(add-to-list 'eglot-server-programs '(dart-mode . ("dart" "language-server")))
(with-eval-after-load "dart-mode"
(define-key dart-mode-map (kbd "C-c C-o") 'dart-format-buffer))
(add-hook 'dart-mode-hook (lambda () (add-hook 'after-save-hook 'dart-format-buffer nil t)))
(add-hook 'flutter-test-mode-hook (lambda () (add-hook 'after-save-hook #'flutter-run-or-hot-reload nil t)))
(add-hook 'flutter-mode-hook (lambda () (add-hook 'after-save-hook #'flutter-run-or-hot-reload nil t))) Contents of Dart file:import 'package:flutter/material.dart';
import 'package:sqflite/sqflite.dart';
import 'state/app_state.dart';
import 'widgets/map.dart';
import 'package:provider/provider.dart';
import 'widgets/home_app_bar.dart';
import 'package:get/get.dart';
import 'package:flutter_background_geolocation/flutter_background_geolocation.dart'
as bg;
import 'dart:io';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
// This widget is the root of Loadaman.
@override
Widget build(BuildContext context) {
return GetMaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(seedColor: Colors.black),
useMaterial3: true,
),
home: const MyHomePage(title: 'Loadaman'),
);
}
}
class MyHomePage extends StatefulWidget {
const MyHomePage({super.key, required this.title});
final String title;
@override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
// Controls the bottom navigator
int _selectedIndex = 0;
void _onItemTapped(int index) {
setState(() {
_selectedIndex = index;
});
}
static const List<Widget> _pages = <Widget>[
MapWidget(),
Center(
child: Text('Services'),
),
Center(
child: Text('Activity'),
),
Center(
child: Text('Account'),
),
];
@override
void initState() {
super.initState();
var db = openDatabase('loadaman', version: 1, onOpen: (Database db) async {
print('Database version: ${await db.getVersion()}');
}, onCreate: (Database db, int version) async {
await db.execute(
'CREATE TABLE location(id INTEGER PRIMARY KEY, lattitude REAL, longitude REAL)');
});
}
@override
Widget build(BuildContext context) {
final ThemeData theme = Theme.of(context);
return ChangeNotifierProvider<AppState>(
create: (context) => AppState(),
child: SafeArea(
child: Scaffold(
appBar: HomeAppBar(
title: widget.title,
),
body: _pages.elementAt(_selectedIndex),
bottomNavigationBar: BottomNavigationBar(
items: <BottomNavigationBarItem>[
BottomNavigationBarItem(
backgroundColor: theme.iconTheme.color,
icon: const Icon(Icons.home),
label: 'Home',
),
BottomNavigationBarItem(
backgroundColor: theme.iconTheme.color,
icon: const Icon(Icons.apps),
label: 'Services',
),
BottomNavigationBarItem(
backgroundColor: theme.iconTheme.color,
icon: const Icon(Icons.newspaper),
label: 'Activities',
),
BottomNavigationBarItem(
backgroundColor: theme.iconTheme.color,
icon: const Icon(Icons.person),
label: 'Account',
),
],
backgroundColor: theme.iconTheme.color,
selectedItemColor: Colors.amberAccent,
selectedIconTheme: const IconThemeData(color: Colors.amberAccent),
currentIndex: _selectedIndex,
onTap: _onItemTapped,
enableFeedback: true,
),
),
),
);
}
}
Here's an error log I got once when trying to debug this issue:Debugger entered--Lisp error: (jsonrpc-error "request id=64 failed:" (jsonrpc-error-message . "Timed out"))
signal(jsonrpc-error ("request id=64 failed:" (jsonrpc-error-message . "Timed out")))
#<subr jsonrpc-request>(#<eglot-lsp-server eglot-lsp-server-4d0d2768> :textDocument/completion (:textDocument (:uri "file:///Users/randyburrell/Projects/Work/Randy/Loa...") :position (:line 10 :character 4) :context (:triggerKind 1)) :deferred :textDocument/completion :cancel-on-input t)
apply(#<subr jsonrpc-request> (#<eglot-lsp-server eglot-lsp-server-4d0d2768> :textDocument/completion (:textDocument (:uri "file:///Users/randyburrell/Projects/Work/Randy/Loa...") :position (:line 10 :character 4) :context (:triggerKind 1)) :deferred :textDocument/completion :cancel-on-input t))
jsonrpc-request(#<eglot-lsp-server eglot-lsp-server-4d0d2768> :textDocument/completion (:textDocument (:uri "file:///Users/randyburrell/Projects/Work/Randy/Loa...") :position (:line 10 :character 4) :context (:triggerKind 1)) :deferred :textDocument/completion :cancel-on-input t)
#f(compiled-function () #<bytecode 0x1d97b3477f652e0e>)()
#f(compiled-function (probe pred action) #<bytecode 0xb16bffce9dc675a>)("" nil t)
completion-pcm--all-completions("" (prefix "i" any "m" any "p" any "o") #f(compiled-function (probe pred action) #<bytecode 0xb16bffce9dc675a>) nil)
completion-substring--all-completions("impo" #f(compiled-function (probe pred action) #<bytecode 0xb16bffce9dc675a>) nil 4 completion-flex--make-flex-pattern)
#<subr completion-flex-all-completions>("impo" #f(compiled-function (probe pred action) #<bytecode 0xb16bffce9dc675a>) nil 4)
apply(#<subr completion-flex-all-completions> ("impo" #f(compiled-function (probe pred action) #<bytecode 0xb16bffce9dc675a>) nil 4))
completion-flex-all-completions("impo" #f(compiled-function (probe pred action) #<bytecode 0xb16bffce9dc675a>) nil 4)
#f(compiled-function (style) #<bytecode -0x18c96571742c93bf>)(flex)
completion--some(#f(compiled-function (style) #<bytecode -0x18c96571742c93bf>) (flex basic orderless))
completion--nth-completion(2 "impo" #f(compiled-function (probe pred action) #<bytecode 0xb16bffce9dc675a>) nil 4 (metadata (category . eglot) (display-sort-function . #<subr F616e6f6e796d6f75732d6c616d626461_anonymous_lambda_151>)))
#<subr completion-all-completions>("impo" #f(compiled-function (probe pred action) #<bytecode 0xb16bffce9dc675a>) nil 4 (metadata (category . eglot) (display-sort-function . #<subr F616e6f6e796d6f75732d6c616d626461_anonymous_lambda_151>)))
apply(#<subr completion-all-completions> ("impo" #f(compiled-function (probe pred action) #<bytecode 0xb16bffce9dc675a>) nil 4 (metadata (category . eglot) (display-sort-function . #<subr F616e6f6e796d6f75732d6c616d626461_anonymous_lambda_151>))))
completion-all-completions("impo" #f(compiled-function (probe pred action) #<bytecode 0xb16bffce9dc675a>) nil 4 (metadata (category . eglot) (display-sort-function . #<subr F616e6f6e796d6f75732d6c616d626461_anonymous_lambda_151>)))
corfu--filter-completions("impo" #f(compiled-function (probe pred action) #<bytecode 0xb16bffce9dc675a>) nil 4 (metadata (category . eglot) (display-sort-function . #<subr F616e6f6e796d6f75732d6c616d626461_anonymous_lambda_151>)))
corfu--recompute("impo" 4 #f(compiled-function (probe pred action) #<bytecode 0xb16bffce9dc675a>) nil)
corfu--update(interruptible)
#f(compiled-function (&optional auto) #<bytecode 0x1d4c8c548ab2ea4c>)(auto)
apply(#f(compiled-function (&optional auto) #<bytecode 0x1d4c8c548ab2ea4c>) auto)
#f(compiled-function (&rest args) #<bytecode -0x11808fa36a21efe5>)(auto)
apply(#f(compiled-function (&rest args) #<bytecode -0x11808fa36a21efe5>) auto)
corfu--exhibit(auto)
corfu--auto-complete-deferred((#<window 2073 on main.dart> #<buffer main.dart> 1734 363))
apply(corfu--auto-complete-deferred (#<window 2073 on main.dart> #<buffer main.dart> 1734 363))
timer-event-handler([t 26199 11817 483055 nil corfu--auto-complete-deferred ((#<window 2073 on main.dart> #<buffer main.dart> 1734 363)) nil 0 nil])
sit-for(3)
flyspell-check-word-p()
flyspell-post-command-hook() Eglot Events Buffer Prinnts
Could you point me in the right direction to solve this issue? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 22 replies
-
Could you try following the steps lined out here? Specifically, could you provide a recipe from |
Beta Was this translation helpful? Give feedback.
-
@joaotavora I found the issue: Based on the:
I was able to solve it by this quick change (I haven't experimented with different time values).
But I guess it is not the best solution. Can you suggest the optional one? |
Beta Was this translation helpful? Give feedback.
@joaotavora I found the issue:
dart-lang/sdk#56311
Based on the:
I was able to solve it by this quick change (I haven't experimented with different time values).